- 6
- Posts
- 3
- Years
- The Netherlands
- Seen May 22, 2021
Hello! I am quite new to making fan games, however I have some experience coding. Therefore I thought I would make an item as practice.
The item in question warps the player to a pre-determined location (for instance, back home or to a secret base kind of thing) and when used again it warps the player back to the location it was originally used. (Think something along the lines of the Explorer Kit from DPP).
It is not fleshed out much, no fancy animations or anything but it works well. For this item to function, 3 variables and 1 switch are used, of which the IDs can be edited to serve your need. The code can be found below and needs to be inserted into the PItem_ItemEffects script section.
Any suggestions or improvements to the code are welcome!
The item in question warps the player to a pre-determined location (for instance, back home or to a secret base kind of thing) and when used again it warps the player back to the location it was originally used. (Think something along the lines of the Explorer Kit from DPP).
It is not fleshed out much, no fancy animations or anything but it works well. For this item to function, 3 variables and 1 switch are used, of which the IDs can be edited to serve your need. The code can be found below and needs to be inserted into the PItem_ItemEffects script section.
Any suggestions or improvements to the code are welcome!
Spoiler:
Code:
ItemHandlers::UseInField.add(:WARPER,proc{|item|
# Names of variables used to store mapID and x,y pos before transport
mapvar=29
xvar=30
yvar=31
# Switch number whether on destination or overworld
onOff=60
# mapID and x,y pos of transport destination
pocketmapID=33
pocketmapX=10
pocketmapY=10
if pbBikeCheck
if $game_switches[onOff]==true
$game_temp.player_new_map_id = $game_variables[mapvar]
$game_temp.player_new_x = $game_variables[xvar]
$game_temp.player_new_y = $game_variables[yvar]
Kernel.pbCancelVehicles
$scene.transfer_player
$game_map.autoplay
$game_map.refresh
$game_switches[onOff]=false
else
$game_variables[mapvar]=$game_map.map_id
$game_variables[xvar]=$game_player.x
$game_variables[yvar]=$game_player.y
$game_temp.player_new_map_id = pocketmapID
$game_temp.player_new_x = pocketmapX
$game_temp.player_new_y = pocketmapY
Kernel.pbCancelVehicles
$scene.transfer_player
$game_map.autoplay
$game_map.refresh
$game_switches[onOff]=true
end
next 1
end
next 0
})