Item to replace Fly not working?

MagentaGiratina

Distortion World Enthusiast
Member
Joined
Jun 16, 2019
Posts
46
I've attempted to implement an item to replace Fly, and everything appears to be in order in the scripts, but whenever I try to use it, I get "Can't use that here." regardless of whether the map is outdoors or not. I've gone to maps where every condition to allow flying I can easily change is in order and I'm not having hidden moves count badges so I know that isn't the issue. Is there something in reference to the Fly temp data that I'm doing wrong? Here are my scripts in the hidden moves section:

Code:
# HiddenMoveHandlers::CanUseMove.add(:FLY,proc{|move,pkmn|
def CanUseFly?
   if !$DEBUG || $PokemonBag.pbQuantity(PBItems::SKYSCOOTER)>0
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLY : $Trainer.badges[BADGEFORFLY])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     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,MetadataOutdoor)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   return true
end
# })

# HiddenMoveHandlers::UseMove.add(:FLY,proc{|move,pokemon|
def UseFly
   if !$PokemonTemp.flydata
     Kernel.pbMessage(_INTL("Can't use that here."))
   end
   if !pbHiddenMoveAnimation(nil)
     Kernel.pbMessage(_INTL("Alli used the Sky Scooter!",pokemon.name,PBMoves.getName(move)))
   end
   pbFadeOutIn(99999){
      Kernel.pbCancelVehicles
      $game_temp.player_new_map_id=$PokemonTemp.flydata[0]
      $game_temp.player_new_x=$PokemonTemp.flydata[1]
      $game_temp.player_new_y=$PokemonTemp.flydata[2]
      $PokemonTemp.flydata=nil
      $game_temp.player_new_direction=2
      $scene.transfer_player
      $game_map.autoplay
      $game_map.refresh
   }
   pbEraseEscapePoint
   return true
end
 

leilou

A wild Minun appeared!
Member
Joined
May 17, 2017
Posts
223
so I looked for any occurence of useFly in base essentials and got no hits. How are you calling it?
if you just go UseFly to call it without anything else the following line of code might just cause this since you don't set $PokemonTemp.flydata:
Code:
if !$PokemonTemp.flydata
  Kernel.pbMessage(_INTL("Can't use that here."))
end

if you ever get into the if of the following code your game will just crash, because neither pokemon nor move are defined. If you just want to display the text delete ,pokemon.name,PBMoves.getName(move) since that's from the original text that would display the name of the Pokémon that used Fly and the move that was used.
Code:
if !pbHiddenMoveAnimation(nil)
  Kernel.pbMessage(_INTL("Alli used the Sky Scooter!",pokemon.name,PBMoves.getName(move)))
end

also if get into the the first if there is no error handling if $PokemonTemp.flydata is nil. Therefore you will just crash because of
Code:
$game_temp.player_new_map_id=$PokemonTemp.flydata[0]
$game_temp.player_new_x=$PokemonTemp.flydata[1]
$game_temp.player_new_y=$PokemonTemp.flydata[2]
 

MagentaGiratina

Distortion World Enthusiast
Member
Joined
Jun 16, 2019
Posts
46
Here's my code in PItem_ItemEffects for the Sky Scooter, following the same format as my other HM items, which are working properly.
Code:
ItemHandlers::UseFromBag.add(:SKYSCOOTER,proc{|item|  next canUseFly? ? 2:0 })

ItemHandlers::UseInField.add(:SKYSCOOTER,proc{|item|  useFly if canUseFly? })
 

leilou

A wild Minun appeared!
Member
Joined
May 17, 2017
Posts
223
I just looked at what essentials did and you'll need to put this code to call the destiny selection screen and set flydata:
Code:
scene = PokemonRegionMap_Scene.new(-1,false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartFlyScreen
if ret
  $PokemonTemp.flydata=ret
end
you need to do that either in the first line of UseFly (btw starting methods/funktions with kapital letters is considered bad style) or before you call UseFly
 

MagentaGiratina

Distortion World Enthusiast
Member
Joined
Jun 16, 2019
Posts
46
Okay, I'll try that. What version of Essentials is that for? I have version 16. As far as I know, it'll still work script-wise, just wanting to make sure.
 

MagentaGiratina

Distortion World Enthusiast
Member
Joined
Jun 16, 2019
Posts
46
Ok. And if I'm understanding correctly, I'm gonna put that in the definition for UseFly, right, not in the item where it's called? Sorry if these are stupid questions.
 

leilou

A wild Minun appeared!
Member
Joined
May 17, 2017
Posts
223
well that depends on how you want to do it ... it's more a question of style than a question of whether it works ...
you just have to make sure it is done before the stuff that you had in UseFly originally because that's where the player chooses the destination
 
Top