- 3
- Posts
- 9
- Years
- Seen Dec 5, 2016
I'm new around here so I'm not sure if this is the right place to ask this but I'm trying to turn HMs into items. I'm changing surf to a raft now, and everything work except the use from bag. When I use it from the bag it uses the item, it changes to the surfing sprite, but the player doesn't jump forward into the water. He just remains on the land tile he was standing on unable to move and then it freezes, I can't move or open the pause menu or anything. I'm so confused because it works is you walk up and press the action button on the water but not from the bag. Can anyone help?
Here's my script:
Any help is very appreciated. Thank you.
Here's my script:
Code:
def Kernel.pbSurf
if $game_player.pbHasDependentEvents?
return false
end
if $DEBUG ||
(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
movefinder=Kernel.pbCheckMove(:SURF)
if $DEBUG || $PokemonBag.pbQuantity(PBItems::RAFT)>0
if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to use the raft?"))
speciesname=!movefinder ? $Trainer.name : movefinder.name
Kernel.pbMessage(_INTL("You started rafting!",speciesname))
surfbgm=pbGetMetadata(0,MetadataSurfBGM)
if surfbgm
pbCueBGM(surfbgm,0.5)
end
pbStartSurfing()
return true
end
end
end
return false
end
def pbStartSurfing()
Kernel.pbCancelVehicles
$PokemonEncounters.clearStepCount
$PokemonGlobal.surfing=true
Kernel.pbUpdateVehicle
Kernel.pbJumpToward
Kernel.pbUpdateVehicle
$game_player.check_event_trigger_here([1,2])
end
def pbEndSurf(xOffset,yOffset)
return false if !$PokemonGlobal.surfing
x=$game_player.x
y=$game_player.y
currentTag=$game_map.terrain_tag(x,y)
facingTag=Kernel.pbFacingTerrainTag
if PBTerrain.isSurfable?(currentTag) && !PBTerrain.isSurfable?(facingTag)
if Kernel.pbJumpToward
Kernel.pbCancelVehicles
$game_map.autoplayAsCue
$game_player.increase_steps
result=$game_player.check_event_trigger_here([1,2])
Kernel.pbOnStepTaken(result)
end
return true
end
return false
end
Events.onAction+=proc{|sender,e|
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if PBTerrain.isSurfable?(terrain) && !$PokemonGlobal.surfing &&
!pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
Kernel.pbSurf
return
end
}
def canUseMoveSurf?
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if !$DEBUG &&
!(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
return false
end
if $PokemonGlobal.surfing
Kernel.pbMessage(_INTL("You're already rafting."))
return false
end
if $game_player.pbHasDependentEvents?
Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
return false
end
if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
return false
end
if !PBTerrain.isSurfable?(terrain) || !notCliff
Kernel.pbMessage(_INTL("No rafting here!"))
return false
end
return true
end
def useMoveSurf
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("You started rafting!",$Trainer.name,"Surf"))
end
pbStartSurfing()
return true
end
HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
if !pbHiddenMoveAnimation(pokemon)
Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
end
pbStartSurfing()
return true
})
Code:
ItemHandlers::UseFromBag.add(:RAFT,proc{|item|
next canUseMoveSurf? ? 2 : 0
})
ItemHandlers::UseInField.add(:RAFT,proc{|item|
useMoveSurf if canUseMoveSurf?
})
Any help is very appreciated. Thank you.