Question is related to turn based combat. I am creating sorta pokemon clone. Moves and pokemons work fine. Now I wanna imply abilities. And thats where my script must be fully reworked. For example, ability that reduces half of fire damage. I can activate the ability when the moves are selected, move.Damage will be *= 0.5. First issue, damage is gonna be halved every time the function is called (every turn). Second issue, how do I set damage value to default? Third issue, some abilities change weather or do something right away, but I still need to select moves, if I put it first I will get an error if move == null. This is a major issue, a function interfering with several mechanics. I would like to get some advice on how to make such structure work. Abilities, moves, pokemons are resources.
As far as I understand the question, the first thing I would do is NOT to change the value of the “Damage” variable itself upon acquiring a powerup. In the function where you are applying the damage, I would do something like:
I made 1000 lines of code already. General structure is messy, I have main turn_logic() which controls who goes first/second based on speed or priority of the move, after calculating who goes first exec_move is called, which has calculation of damage based on move. Just like I explained, exec_move grabs move resource, multiplies move.Damage to whatever is stat-related. In theory, I could make variable just like you stated, but exec_move() does not know which pokemon’s move is used, it just does damage or stat change, meaning I have no way of setting move.Damage outside the resource, I cannot call the ability function inside turn_logic() or exec_move(), because some abilities are not move-related. One more ability boosts damage by 30% (move.Damage *= 1.3), but removes its effect (move.effect = null).
It’s what I used when I ran into a similar issue, I don’t know if it’s “the right way to do things”, but then you can modify everything you want of the duplicated resource, and the original one will stay the same for next time you duplicate it.
thx I’ll try it. Just discovered moves resource acutally reduces PP of every instance of the move, so I must duplicate it. Not sure if I can do the same with multiplication of the damage, since PP of the move must be reduced, cannot just clone it every time ability function is used.