pokered/engine/battle/moveEffects/transform_effect.asm

149 lines
2.7 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
TransformEffect_:
ld hl, wBattleMonSpecies
ld de, wEnemyMonSpecies
2015-08-31 02:38:41 +00:00
ld bc, wEnemyBattleStatus3
ld a, [wEnemyBattleStatus1]
ld a, [H_WHOSETURN]
and a
jr nz, .hitTest
ld hl, wEnemyMonSpecies
ld de, wBattleMonSpecies
2015-08-31 02:38:41 +00:00
ld bc, wPlayerBattleStatus3
ld [wPlayerMoveListIndex], a
2015-08-31 02:38:41 +00:00
ld a, [wPlayerBattleStatus1]
.hitTest
bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig)
jp nz, .failed
push hl
push de
push bc
2015-08-31 02:38:41 +00:00
ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .transformEffect
2015-08-31 02:38:41 +00:00
ld hl, wEnemyBattleStatus2
.transformEffect
; animation(s) played are different if target has Substitute up
2015-06-11 22:41:33 +00:00
bit HasSubstituteUp, [hl]
push af
2015-07-12 22:51:04 +00:00
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
2015-08-31 02:38:41 +00:00
ld a, [wOptions]
add a
ld hl, PlayCurrentMoveAnimation
ld b, BANK(PlayCurrentMoveAnimation)
jr nc, .gotAnimToPlay
ld hl, AnimationTransformMon
ld b, BANK(AnimationTransformMon)
.gotAnimToPlay
call Bankswitch
2015-07-12 22:51:04 +00:00
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
pop bc
ld a, [bc]
set Transformed, a ; mon is now Transformed
ld [bc], a
pop de
pop hl
push hl
2015-06-11 22:41:33 +00:00
; transform user into opposing Pokemon
; species
2015-06-11 22:41:33 +00:00
ld a, [hl]
ld [de], a
2015-06-11 22:41:33 +00:00
; type 1, type 2, catch rate, and moves
ld bc, $5
2015-06-11 22:41:33 +00:00
add hl, bc
inc de
inc de
inc de
inc de
inc de
inc bc
inc bc
call CopyData
ld a, [H_WHOSETURN]
and a
jr z, .next
2015-08-14 07:36:06 +00:00
; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
ld a, [de]
2015-08-14 07:36:06 +00:00
ld [wTransformedEnemyMonOriginalDVs], a
inc de
ld a, [de]
2015-08-14 07:36:06 +00:00
ld [wTransformedEnemyMonOriginalDVs + 1], a
dec de
.next
; DVs
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
2015-06-11 22:41:33 +00:00
; Attack, Defense, Speed, and Special stats
inc hl
inc hl
inc hl
inc de
inc de
inc de
ld bc, $8
call CopyData
2015-06-11 22:41:33 +00:00
ld bc, wBattleMonMoves - wBattleMonPP
add hl, bc ; ld hl, wBattleMonMoves
ld b, NUM_MOVES
.copyPPLoop
; 5 PP for all moves
ld a, [hli]
and a
jr z, .lessThanFourMoves
ld a, $5
ld [de], a
inc de
dec b
jr nz, .copyPPLoop
jr .copyStats
.lessThanFourMoves
; 0 PP for blank moves
xor a
ld [de], a
inc de
dec b
jr nz, .lessThanFourMoves
.copyStats
; original (unmodified) stats and stat mods
pop hl
ld a, [hl]
ld [wd11e], a
call GetMonName
ld hl, wEnemyMonUnmodifiedAttack
ld de, wPlayerMonUnmodifiedAttack
call .copyBasedOnTurn ; original (unmodified) stats
ld hl, wEnemyMonStatMods
ld de, wPlayerMonStatMods
call .copyBasedOnTurn ; stat mods
ld hl, TransformedText
jp PrintText
.copyBasedOnTurn
ld a, [H_WHOSETURN]
and a
jr z, .gotStatsOrModsToCopy
push hl
ld h, d
ld l, e
pop de
.gotStatsOrModsToCopy
ld bc, $8
jp CopyData
.failed
ld hl, PrintButItFailedText_
jp BankswitchEtoF
2016-06-12 00:24:04 +00:00
TransformedText:
TX_FAR _TransformedText
db "@"