- 112
- Posts
- 10
- Years
- Seen Nov 17, 2023
I'm trying to activate headbutt with a terrain tag instead of the usual event because copy/pasting the same headbutt event for more than 10 trees starts to lag my maps.
1. I set the tag for my headbutt trees in the tag editor as tag 20 and created a new terrain tag for HeadbuttTrees in PBTerrain here:
I also created a definition for isHeadbuttTree? near the bottom of PBTerrain with these lines here:
2. In PField_HiddenMoves, I copy pasted a few lines from the waterfall code and changed/simplified it to function with headbutt trees here:
It works fine up to the point where it prompts you to use headbutt. If you choose no, it's fine. But if you choose yes, it crashes with this error:
I know I'm very close but I'm not exactly sure how to call the highlighted headbutt event. I've tried pbHeadbutt, pbHeadbuttEffect, etc.
Any help would be appreciated.
1. I set the tag for my headbutt trees in the tag editor as tag 20 and created a new terrain tag for HeadbuttTrees in PBTerrain here:
Spoiler:
Code:
module PBTerrain
Ledge = 1
Grass = 2
Sand = 3
Rock = 4
DeepWater = 5
StillWater = 6
Water = 7
Waterfall = 8
WaterfallCrest = 9
TallGrass = 10
UnderwaterGrass = 11
Ice = 12
Neutral = 13
SootGrass = 14
Bridge = 15
EncounterFloor = 16
SandFootprints = 17
Shoreline = 18
Puddle = 19
HeadbuttTree = 20
Spoiler:
Code:
def PBTerrain.isHeadbuttTree?(tag)
return tag==PBTerrain::HeadbuttTree
end
2. In PField_HiddenMoves, I copy pasted a few lines from the waterfall code and changed/simplified it to function with headbutt trees here:
Spoiler:
Code:
Events.onAction+=proc{|sender,e|
terrain=Kernel.pbFacingTerrainTag
if PBTerrain.isHeadbuttTree?(terrain)
[S-HIGHLIGHT]Kernel.pbHeadbutt(terrain)[/S-HIGHLIGHT]
return
end
}
Spoiler:
![[PokeCommunity.com] Using terrain tags to activate the headbutt tree event [PokeCommunity.com] Using terrain tags to activate the headbutt tree event](https://i.imgur.com/mfzYPUC.png)
I know I'm very close but I'm not exactly sure how to call the highlighted headbutt event. I've tried pbHeadbutt, pbHeadbuttEffect, etc.
Any help would be appreciated.
Last edited: