Skip to content

Energy Burst (damage based on the total amount of Energy attached to both Active Pokemon)

Sha0den edited this page Oct 24, 2024 · 4 revisions

This tutorial will focus on creating both versions of the Energy Burst effect, as seen on Gardevoir (EX Ruby and Sapphire 7/109), which does damage to the Defending Pokémon equal to 10 times the total amount of Energy attached to both Active Pokémon, and also on Gardevoir (Platinum 8/127), which does 10 more damage for each Energy attached to both Active Pokémon.

  1. First, we need to add the following code to src/engine/duel/effect_commands.asm:
EnergyBurst10xDamageEffectCommands:
	dbw EFFECTCMDTYPE_BEFORE_DAMAGE, EnergyBurst_10xDamageEffect
	dbw EFFECTCMDTYPE_AI, EnergyBurst_10xDamageEffect

EnergyBurst10MoreDamageEffectCommands:
	dbw EFFECTCMDTYPE_BEFORE_DAMAGE, EnergyBurst_10MoreDamageEffect
	dbw EFFECTCMDTYPE_AI, EnergyBurst_10MoreDamageEffect
  1. Next, we need to create the actual attack effects in src/engine/duel/effect_functions.asm.
; sets the attack damage to 10 times the total amount of Energy
; attached to both Active Pokémon, up to a maximum of 250 damage.
; preserves bc and hl
EnergyBurst_10xDamageEffect:
	call CountEnergyAttachedToBothActivePkmn
	cp 25
	jr nc, .cap_damage ; set damage to 250 if there are at least 25 Energy
	; otherwise, multiply the amount of Energy by 10, and set damage to that.
	call ATimes10
	jp SetDefiniteDamage
.cap_damage
	ld a, 250
	jp SetDefiniteDamage


; counts the total amount of Energy attached to both Active Pokémon.
; each Double Colorless Energy counts as 2 Energy.
; preserves bc and hl
; output:
;	a = total amount of Energy attached to both Active Pokémon
CountEnergyAttachedToBothActivePkmn:
	ld e, PLAY_AREA_ARENA
	call GetPlayAreaCardAttachedEnergies
	ld d, a ; wTotalAttachedEnergies for the Attacking Pokémon
	call SwapTurn
	call GetPlayAreaCardAttachedEnergies
	add d
	jp SwapTurn


; does 10 more damage for each Energy attached to both Active Pokémon.
; total damage is capped at 250.
; preserves bc
EnergyBurst_10MoreDamageEffect:
	call CountEnergyAttachedToBothActivePkmn
	ld l, a
	ld h, 10
	call HtimesL ; added damage is 10 * total Energy
	ld a, [wDamage]
	ld e, a
	ld d, $00
	add hl, de
	ld a, h
	or a
	ld a, l
	jr z, .set_damage ; use the damage in hl if it can fit in 1 byte (0-255)
	; otherwise, cap the damage to 250
	ld a, 250
.set_damage
	jp SetDefiniteDamage
  1. In src/data/cards.asm, there is one last thing we have to do to get the AI to understand the attack. In the Flags section of the Energy Burst attack, you will need to change the flags 2 byte and the effect parameter byte, like so:
	db NONE ; flags 1
+	db ATTACHED_ENERGY_BOOST ; flags 2
	db NONE ; flags 3
+	db MAX_ENERGY_BOOST_IS_NOT_LIMITED

And that's all. Create the appropriate text and text offsets, give it an animation, and the attack is ready.