Path: blob/master/engine/battle/move_effects/transform.asm
2019 views
TransformEffect_:1ld hl, wBattleMonSpecies2ld de, wEnemyMonSpecies3ld bc, wEnemyBattleStatus34; bug: on enemy's turn, a is overloaded with hWhoseTurn,5; before the check for INVULNERABLE6ld a, [wEnemyBattleStatus1]7ldh a, [hWhoseTurn]8and a9jr nz, .hitTest10; player's turn11ld hl, wEnemyMonSpecies12ld de, wBattleMonSpecies13ld bc, wPlayerBattleStatus314ld [wPlayerMoveListIndex], a15; bug: this should be target's BattleStatus1 (i.e. wEnemyBattleStatus1)16ld a, [wPlayerBattleStatus1]17.hitTest18bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig)19; this check doesn't work due to above bugs20jp nz, .failed21push hl22push de23push bc24ld hl, wPlayerBattleStatus225ldh a, [hWhoseTurn]26and a27jr z, .transformEffect28ld hl, wEnemyBattleStatus229.transformEffect30; animation(s) played are different if target has Substitute up31bit HAS_SUBSTITUTE_UP, [hl]32push af33ld hl, HideSubstituteShowMonAnim34ld b, BANK(HideSubstituteShowMonAnim)35call nz, Bankswitch36ld a, [wOptions]37add a38ld hl, PlayCurrentMoveAnimation39ld b, BANK(PlayCurrentMoveAnimation)40jr nc, .gotAnimToPlay41ld hl, AnimationTransformMon42ld b, BANK(AnimationTransformMon)43.gotAnimToPlay44call Bankswitch45ld hl, ReshowSubstituteAnim46ld b, BANK(ReshowSubstituteAnim)47pop af48call nz, Bankswitch49pop bc50ld a, [bc]51set TRANSFORMED, a ; mon is now transformed52ld [bc], a53pop de54pop hl55push hl56; transform user into opposing Pokemon57; species58ld a, [hl]59ld [de], a60; type 1, type 2, catch rate, and moves61ld bc, $562add hl, bc63inc de64inc de65inc de66inc de67inc de68inc bc69inc bc70call CopyData71ldh a, [hWhoseTurn]72and a73jr z, .next74; save enemy mon DVs at wTransformedEnemyMonOriginalDVs75ld a, [de]76ld [wTransformedEnemyMonOriginalDVs], a77inc de78ld a, [de]79ld [wTransformedEnemyMonOriginalDVs + 1], a80dec de81.next82; DVs83ld a, [hli]84ld [de], a85inc de86ld a, [hli]87ld [de], a88inc de89; Skip level and max HP90inc hl91inc hl92inc hl93inc de94inc de95inc de96; Attack, Defense, Speed, and Special stats97ld bc, (NUM_STATS - 1) * 298call CopyData99ld bc, wBattleMonMoves - wBattleMonPP100add hl, bc ; ld hl, wBattleMonMoves101ld b, NUM_MOVES102.copyPPLoop103; 5 PP for all moves104ld a, [hli]105and a106jr z, .lessThanFourMoves107ld a, 5108ld [de], a109inc de110dec b111jr nz, .copyPPLoop112jr .copyStats113.lessThanFourMoves114; 0 PP for blank moves115xor a116ld [de], a117inc de118dec b119jr nz, .lessThanFourMoves120.copyStats121; original (unmodified) stats and stat mods122pop hl123ld a, [hl]124ld [wNamedObjectIndex], a125call GetMonName126ld hl, wEnemyMonUnmodifiedAttack127ld de, wPlayerMonUnmodifiedAttack128call .copyBasedOnTurn ; original (unmodified) stats129ld hl, wEnemyMonStatMods130ld de, wPlayerMonStatMods131call .copyBasedOnTurn ; stat mods132ld hl, TransformedText133jp PrintText134135.copyBasedOnTurn136ldh a, [hWhoseTurn]137and a138jr z, .gotStatsOrModsToCopy139push hl140ld h, d141ld l, e142pop de143.gotStatsOrModsToCopy144ld bc, (NUM_STATS - 1) * 2145jp CopyData146147.failed148ld hl, PrintButItFailedText_149jp EffectCallBattleCore150151TransformedText:152text_far _TransformedText153text_end154155156