Skip to content

More Damage Based on Retreat Cost

Sha0den edited this page Oct 23, 2024 · 5 revisions

This tutorial will focus on the simple, yet fun, effect of dealing damage based on the Defending Pokémon's Retreat Cost. This one is quite simple to understand. In this first section, we will define the effect commands for an attack that does 10 times the Defending Pokémon's Retreat Cost and another attack that will add 10 more damage for each Colorless Energy symbol in the Defending Pokémon's Retreat Cost.

  1. First, we need to add the following code to src/engine/duel/effect_commands.asm:
; sets attack's damage to 10 times the Defending Pokémon's adjusted Retreat Cost
Do10PerOppRCEffectCommands:
	dbw EFFECTCMDTYPE_BEFORE_DAMAGE, LowKickEffect
	dbw EFFECTCMDTYPE_AI, LowKickEffect
	db  $00

; increases attack's damage by 10 times the Defending Pokémon's adjusted Retreat Cost 
Do10MorePerOppRCEffectCommands:
	dbw EFFECTCMDTYPE_BEFORE_DAMAGE, GrassKnotEffect
	dbw EFFECTCMDTYPE_AI, GrassKnot_AIEffect
	db  $00

Since this effect is very simple, we only have two commands for each attack: one for the player, and another for the AI to understand it. As always, name these effects however you like.

  1. Next, we need to create the actual attack effects in src/engine/duel/effect_functions.asm
; output:
;	a = 10 * Defending Pokémon's adjusted Retreat Cost (accounting for things like Retreat Aid)
RCPlusDamageCalc:
        call SwapTurn
	ld e, PLAY_AREA_ARENA
	call GetPlayAreaCardRetreatCost
	call SwapTurn
	jp ATimes10 ; multiplies result by 10

LowKickEffect: 
	call RCPlusDamageCalc ; calls the calculation by the above function
	jp SetDefiniteDamage  ; and sets the attack's damage to the result

GrassKnotEffect:
        call RCPlusDamageCalc ; calls the calculation by the above function
	jp AddToDamage        ; and adds the result to the attack's base damage

GrassKnot_AIEffect:
        call GrassKnotEffect
	jp SetDefiniteAIDamage

And that's all it takes to program this simple, yet potent effect.