PDA

View Full Version : [Essentials tutorial] Turn HM moves to items


FL
July 13th, 2013, 01:29 PM
In this tutorial I explain how to turn HMs and/or other moves that work outside of battle to items.

First, in PokemonHiddenMoves script section comment the 'HiddenMoveHandlers::CanUseMove' proc (all the code, inclusive the '})'). Change the line 'if $DEBUG || movefinder' (there's one for each move) to 'if $DEBUG || ($PokemonBag.pbQuantity(PBItems::YOURITEMINTERNALNAME)>0'. There's a item example for item.txt PBs:

601,SURFBOARD,Surfboard,8,0,"Insert description here.",0,0,6

Adding the move in the "Use" item command

In item PBS data change the '0,0,6' to '2,0,6'. Copy the content of 'HiddenMoveHandlers::CanUseMove' proc (the code between the first line and the '})') and put between a method who start in the first line like 'def canUseMoveSurf?' and ends with 'end'. Do the same with 'HiddenMoveHandlers::UseMove' and name the method something like 'def useMoveSurf'. For this last one remember to change pokemon.name to $Trainer.name, pbHiddenMoveAnimation(pokemon) to pbHiddenMoveAnimation(nil) and PBMoves.getName(move) to the move name (e. g. "Surf"). In PokemonItemEffects script section, add the two item handlers:

ItemHandlers::UseFromBag.add(:YOURITEMINTERNALNAME,proc{|item|
next canUseMoveSurf? ? 2 : 0
})

ItemHandlers::UseInField.add(:YOURITEMINTERNALNAME,proc{|item|
useMoveSurf if canUseMoveSurf?
})

I suggest to change the text like "used Surf" to "used Surfboard". Mark HIDDENMOVESCOUNTBADGES as true and all badges to 0 to remove the badge requirements.

Example

I will made an example of the adding in the "use" item command using a knife item for Cut. First, I changed the seventh value to 2.

602,KNIFE,Knife,8,0,"Cut down thin trees.",2,0,6

So I made the two methods before the two handlers:

def canUseMoveCut?
if !$DEBUG &&
!(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORCUT : $Trainer.badges[BADGEFORCUT])
Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
return false
end
facingEvent=$game_player.pbFacingEvent
if !facingEvent || facingEvent.name!="Tree"
Kernel.pbMessage(_INTL("Can't use that here."))
return false
end
return true
end

def useMoveCut
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Cut"))
end
facingEvent=$game_player.pbFacingEvent
if facingEvent
facingEvent.erase
$PokemonMap.addErasedEvent(facingEvent.id)
end
return true
end

And I added at PokemonItemEffects script section:

ItemHandlers::UseFromBag.add(:KNIFE,proc{|item|
next canUseMoveCut? ? 2 : 0
})

ItemHandlers::UseInField.add(:KNIFE,proc{|item|
useMoveCut if canUseMoveCut?
})

arktyz
December 22nd, 2013, 09:25 PM
i am confused as to what and where to comment, and change in the hiddenmovehandlers sections

Rayquaza.
December 23rd, 2013, 02:24 AM
I too am finding it difficult to understand what you've stated in the 'Adding the move in the "Use" item command'.

Is there no way that it could be better explained?

p.claydon
December 23rd, 2013, 08:37 AM
thank yu for this its pretty straight forward if you follow the steps

Rayquaza.
December 23rd, 2013, 09:34 AM
thank yu for this its pretty straight forward if you follow the steps

I am following the steps. But the middle section isn't very clear to me.

p.claydon
December 24th, 2013, 03:47 AM
well bit busy atm (sortting new laptop out) but when able (prob boxing day) i'll see if i can do a better tutorial

Rayquaza.
December 24th, 2013, 05:23 AM
Okay. Does that mean you and FL are the same person or something?

FL
December 26th, 2013, 06:34 AM
Topic updated with an example.

Okay. Does that mean you and FL are the same person or something?Yeah! And in this post (http://www.pokecommunity.com/showpost.php?p=7989315&postcount=35) I'm talking with myself!

Just joking. I'm not p.claydon.

Rayquaza.
December 27th, 2013, 03:51 AM
I'm still having trouble with the script. It keeps coming up with syntax errors and I'm unsure why.

FL
December 28th, 2013, 11:49 AM
I'm still having trouble with the script. It keeps coming up with syntax errors and I'm unsure why.Post the script parts here and I try to help you.

Your problem may be the same problem of other people that will uses this tutorial.

mej71
March 23rd, 2014, 12:01 AM
How does one alter this code for moves like Fly or Flash in which the if $DEBUG || movefinder lines do not exist? I am getting syntax errors.

Derxwna Kapsyla
March 24th, 2014, 08:37 PM
I'm actually curious about how to bind Fly to an item as well. My scripters and I have been unable to really figure out how to bind what fly does to an individual item, despite searching through the code for fly to find a clue, and I have it planned for a Fly item to appear in the next demo of my game, and I'd rather not delay the item or the game if it's unavoidable

FL
March 25th, 2014, 10:22 AM
How does one alter this code for moves like Fly or Flash in which the if $DEBUG || movefinder lines do not exist? I am getting syntax errors.For these moves that only can be triggered at menu screen just don't change HiddenMoveHandlers::CanUseMove code since it's can't be called when the player haven't a pokémon with this move.

mej71
March 25th, 2014, 01:48 PM
I can't get the item to be useable for fly. For the cut example, that line you said to initially change is not located in CanUseMove, it's in Kernel.pbCut, and returns sytnax errors if you change it.
Sorry if I'm just incompetent, but it's really confusing me.

FL
March 27th, 2014, 12:34 PM
Sorry! Fly is an exception since $PokemonTemp.flydata had some definitions at the summary screen, so the methods should be:

def canUseMoveFly?
if !$DEBUG &&
!(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

def useMoveFly
scene=PokemonRegionMapScene.new(-1,false)
screen=PokemonRegionMap.new(scene)
ret=screen.pbStartFlyScreen
return false if !ret
$PokemonTemp.flydata=ret
if !$PokemonTemp.flydata
Kernel.pbMessage(_INTL("Can't use that here."))
end
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Fly"))
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

Tested.

Mugendai
March 27th, 2014, 12:40 PM
This is my attempt at turning Fly into a key item, called the Mini Teleporter, but it doesn't work. HM Fly works normally, but if I press F5, it says "Can't use that here." and if I bypass that part of the code, the game has a scripting error.

I assume it's because specifically $PokemonTemp.flydata is missing; $PokemonTemp itself exists to the code. How would I fix this?


ItemHandlers::UseInField.add(:TELEPORTER,proc{|item|
if !$PokemonTemp.flydata || !pbGetMetadata($game_map.map_id,MetadataOutdoor)
Kernel.pbMessage(_INTL("Can't use that here."))
next false
end
if $game_player.pbHasDependentEvents?
Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
next false
end
Kernel.pbMessage(_INTL("{1} used the Mini Teleporter!",$Trainer.name))
pbFadeOutIn(99999){
$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
next true
})
Here's the error if I bypass the "Can't use that here." message:


---------------------------
Touhoumon Faith & Prayer Version 1.8
---------------------------
Exception: NoMethodError

Message: undefined method `[]' for nil:NilClass

PokemonItemEffects:996

PokemonItemEffects:995:in `pbFadeOutIn'

PokemonItemEffects:995

PokemonItemEffects:985:in `call'

PBEvent:150:in `trigger'

PokemonItems:186:in `triggerUseInField'

PokemonItems:379:in `pbUseKeyItemInField'

PokemonField:2276:in `pbUseKeyItem'

Scene_Map:170:in `update'

Scene_Map:68:in `main'



This exception was logged in

C:\Users\Mugendai\Saved Games/Touhoumon Faith _ Prayer Version 1_8/errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------


Edit: Sorry, didn't see new post above.

mej71
March 27th, 2014, 12:44 PM
Worked. Thank you so much!

Mugendai
March 28th, 2014, 05:27 AM
It worked for me as well, thanks.

C me
November 13th, 2014, 04:55 AM
What does this look like in a hex editor? I dont't understand what to do with these ASM commands.

Maruno
November 13th, 2014, 12:17 PM
This isn't the ROM Hacking section. We don't use hex editors here.