r/PokemonRMXP • u/SeedWatch • 7h 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/agamottos 4h 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?