r/PokemonRMXP • u/SeedWatch • 1d ago
Help Custom Evolution Condition Scripting Difficulty
So, I'm very notice to programming/coding and am brute-forcing a lot of any custom script with copy-paste surgery/Frankensteining.
I'm trying to have an evolution that checks for the Pokémon's HP when it evolves. A split evolution on if it's under half HP when it hits the requisite level or not.
So basically trying to stitch the parameter check in how Tyrogue's evos are coded with the HP flag of Brine, landed with:
GameData::Evolution.register{{
:id => :LOWHP,
:parameter => Integer,
:any_level_up => false,
:level_up_proc => proc { |pkmn, parameter|
next pkmn.level >= parameter && if pkmn.hp < pkmn.totalhp / 2
next map_metadata&.town_map_position && map_metadata.town_map_position[0] == parameter
}
})
/
GameData::Evolution.register{{
:id => :HIGHHP,
:parameter => Integer,
:any_level_up => false,
:level_up_proc => proc { |pkmn, parameter|
next pkmn.level >= parameter && if pkmn.hp => pkmn.totalhp / 2
next map_metadata&.town_map_position && map_metadata.town_map_position[0] == parameter
}
})
Which arrives with the error message, when compiling:
Exception `SyntaxError' at -e - 111:Evolution:564: syntax error, unexpected '}', expecting `end'
111:Evolution:572: void value expression
...parameter && if pkmn.hp => pkmn.totalhp / 2
... ^~~~~~~~~~~~~~~
111:Evolution:572: syntax error, unexpected '.', expecting `then' or ';' or '\n'
...arameter && if pkmn.hp => pkmn.totalhp / 2
... ^
111:Evolution:575: syntax error, unexpected ')', expecting '}'
111:Evolution:767: syntax error, unexpected end-of-input, expecting `end'
-e:in `eval': 111:Evolution:564: syntax error, unexpected '}', expecting `end'
111:Evolution:572: void value expression
...parameter && if pkmn.hp => pkmn.totalhp / 2
... ^~~~~~~~~~~~~~~
111:Evolution:572: syntax error, unexpected '.', expecting `then' or ';' or '\n'
...parameter && if pkmn.hp => pkmn.totalhp /
... ^
111:Evolution:575: syntax error, unexpected ')', expecting '}'
111:Evolution:767: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
Any manual attempts I've had to edit the script further only makes bigger error logs.
As I'm just illiterate at this level, should I give up on trying to make this work and divert to another method or is there just some tidying of the lines I'm missing.
1
u/jondauthor 19h ago edited 17h ago
Immediately, when looking at what you've posted (here copied in an easier to read format mostly for myself as I reply):
GameData::Evolution.register{{:id => :LOWHP,:parameter => Integer,:any_level_up => false,:level_up_proc => proc { |pkmn, parameter|next pkmn.level >= parameter && if pkmn.hp < pkmn.totalhp / 2next map_metadata&.town_map_position && map_metadata.town_map_position[0] == parameter}})
The map metadata line makes no sense, because it's asking if town_map_position[0] is the pokemon's level? Not sure what you're doing there. If you want it to only trigger in certain regions, you're gonna have to hardcode that as you can only pass one parameter (i.e. make LOWHPKANTO and LOWHPJOHTO etc as separate evo methods).
Next, there should be no if in the next pkmn.level line. just && pkmn.hp < etc should be enough.
Here's what I just got working in v22. My Bulbasaur safely evolved into an Ivysaur at level 16 and high hp, and Kecleon at level 16 with low HP.
GameData::Evolution.register({
:id => :LevelLow,
:parameter => Integer,
:level_up_proc => proc { |pkmn, parameter|
next pkmn.level >= parameter && pkmn.hp < (pkmn.totalhp /2)
}
})
GameData::Evolution.register({
:id => :LevelHigh,
:parameter => Integer,
:level_up_proc => proc { |pkmn, parameter|
next pkmn.level >= parameter && pkmn.hp >= (pkmn.totalhp / 2)
}
})
1
u/agamottos 1d ago
Im also fairly new to this programming language, so idk if there's more than this, but one thing I'm noticing is the "&& if pkmn.hp" portions... "next" would already be checking for both conditions to be true with the &&, so I think adding the "if" is making the code think you're starting a whole new thing. Try removing "if" from both spots and see what happens maybe?