-
Notifications
You must be signed in to change notification settings - Fork 100
Cap Damage of Attacks
This tutorial will give a simple way to add a damage cap to any attack. By capping damage to a certain number or below, it becomes possible to make sure numbers don't get out of hand when attacking. The base game's ApplyExtraWaterEnergyDamageBonus
has this function, so we will modify it to create a generic cap function that can be tacked on to any attack.
- First, go to src/engine/duel/effect_functions.asm
Select a function that you'd like to cap damage for. In this example, I will be using the Energy Burst function, which does 10 damage times the number of energy attached to both active pokemon. The relevant portion of what we need to edit is found here:
EnergyBurst_10xDamageEffect:
call CountEnergyAttachedToBothActivePkmn
call ATimes10
jp SetDefiniteDamage ; This is where the game sets damage found in the above code
This attack's damage has no ceiling. So now, let's add a code to cap the damage, we'll say the cap is 250 damage in this example.
EnergyBurst_10xDamageEffect:
call CountEnergyAttachedToBothActivePkmn
cp 25 ; Check amount of energy against the number 25
jr nc, .cap_damage ; if there is 25 or more energy, go to .cap_damage. Otherwise, continue.
call ATimes10 ; multiply the amount of Energy by 10, and set damage to that.
jp SetDefiniteDamage
.cap_damage
ld a, 250 ; load 250 to a (= damage)
jp SetDefiniteDamage
And that's it! The damage cap has been added! You can alternatively use this code to cap damage before ATimes10, which would look like this:
EnergyBurst_10xDamageEffect:
call CountEnergyAttachedToBothActivePkmn
call ATimes10
cp 250 ; check amount of damage against the number 250
jr nc, .cap_damage ; If it is higher than 250, go to .cap_damage. Otherwise, continue.
jp SetDefiniteDamage ; This is where the game sets damage found in the above code
.cap_damage
ld a, 250 ; load 250 to a (= damage)
jp SetDefiniteDamage
Either way will get you the result you want.