Path: blob/master/engine/battle/move_effects/transform.asm
1271 views
TransformEffect_:1ld hl, wBattleMonSpecies2ld de, wEnemyMonSpecies3ld bc, wEnemyBattleStatus34ld a, [wEnemyBattleStatus1]5ldh a, [hWhoseTurn]6and a7jr nz, .hitTest8ld hl, wEnemyMonSpecies9ld de, wBattleMonSpecies10ld bc, wPlayerBattleStatus311ld [wPlayerMoveListIndex], a12ld a, [wPlayerBattleStatus1]13.hitTest14bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig)15jp nz, .failed16push hl17push de18push bc19ld hl, wPlayerBattleStatus220ldh a, [hWhoseTurn]21and a22jr z, .transformEffect23ld hl, wEnemyBattleStatus224.transformEffect25; animation(s) played are different if target has Substitute up26bit HAS_SUBSTITUTE_UP, [hl]27push af28ld hl, HideSubstituteShowMonAnim29ld b, BANK(HideSubstituteShowMonAnim)30call nz, Bankswitch31ld a, [wOptions]32add a33ld hl, PlayCurrentMoveAnimation34ld b, BANK(PlayCurrentMoveAnimation)35jr nc, .gotAnimToPlay36ld hl, AnimationTransformMon37ld b, BANK(AnimationTransformMon)38.gotAnimToPlay39call Bankswitch40ld hl, ReshowSubstituteAnim41ld b, BANK(ReshowSubstituteAnim)42pop af43call nz, Bankswitch44pop bc45ld a, [bc]46set TRANSFORMED, a ; mon is now transformed47ld [bc], a48pop de49pop hl50push hl51; transform user into opposing Pokemon52; species53ld a, [hl]54ld [de], a55; type 1, type 2, catch rate, and moves56ld bc, $557add hl, bc58inc de59inc de60inc de61inc de62inc de63inc bc64inc bc65call CopyData66ldh a, [hWhoseTurn]67and a68jr z, .next69; save enemy mon DVs at wTransformedEnemyMonOriginalDVs70ld a, [de]71ld [wTransformedEnemyMonOriginalDVs], a72inc de73ld a, [de]74ld [wTransformedEnemyMonOriginalDVs + 1], a75dec de76.next77; DVs78ld a, [hli]79ld [de], a80inc de81ld a, [hli]82ld [de], a83inc de84; Attack, Defense, Speed, and Special stats85inc hl86inc hl87inc hl88inc de89inc de90inc de91ld bc, $892call CopyData93ld bc, wBattleMonMoves - wBattleMonPP94add hl, bc ; ld hl, wBattleMonMoves95ld b, NUM_MOVES96.copyPPLoop97; 5 PP for all moves98ld a, [hli]99and a100jr z, .lessThanFourMoves101ld a, $5102ld [de], a103inc de104dec b105jr nz, .copyPPLoop106jr .copyStats107.lessThanFourMoves108; 0 PP for blank moves109xor a110ld [de], a111inc de112dec b113jr nz, .lessThanFourMoves114.copyStats115; original (unmodified) stats and stat mods116pop hl117ld a, [hl]118ld [wNamedObjectIndex], a119call GetMonName120ld hl, wEnemyMonUnmodifiedAttack121ld de, wPlayerMonUnmodifiedAttack122call .copyBasedOnTurn ; original (unmodified) stats123ld hl, wEnemyMonStatMods124ld de, wPlayerMonStatMods125call .copyBasedOnTurn ; stat mods126ld hl, TransformedText127jp PrintText128129.copyBasedOnTurn130ldh a, [hWhoseTurn]131and a132jr z, .gotStatsOrModsToCopy133push hl134ld h, d135ld l, e136pop de137.gotStatsOrModsToCopy138ld bc, $8139jp CopyData140141.failed142ld hl, PrintButItFailedText_143jp EffectCallBattleCore144145TransformedText:146text_far _TransformedText147text_end148149150