Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/move_effects/transform.asm
2019 views
1
TransformEffect_:
2
ld hl, wBattleMonSpecies
3
ld de, wEnemyMonSpecies
4
ld bc, wEnemyBattleStatus3
5
; bug: on enemy's turn, a is overloaded with hWhoseTurn,
6
; before the check for INVULNERABLE
7
ld a, [wEnemyBattleStatus1]
8
ldh a, [hWhoseTurn]
9
and a
10
jr nz, .hitTest
11
; player's turn
12
ld hl, wEnemyMonSpecies
13
ld de, wBattleMonSpecies
14
ld bc, wPlayerBattleStatus3
15
ld [wPlayerMoveListIndex], a
16
; bug: this should be target's BattleStatus1 (i.e. wEnemyBattleStatus1)
17
ld a, [wPlayerBattleStatus1]
18
.hitTest
19
bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig)
20
; this check doesn't work due to above bugs
21
jp nz, .failed
22
push hl
23
push de
24
push bc
25
ld hl, wPlayerBattleStatus2
26
ldh a, [hWhoseTurn]
27
and a
28
jr z, .transformEffect
29
ld hl, wEnemyBattleStatus2
30
.transformEffect
31
; animation(s) played are different if target has Substitute up
32
bit HAS_SUBSTITUTE_UP, [hl]
33
push af
34
ld hl, HideSubstituteShowMonAnim
35
ld b, BANK(HideSubstituteShowMonAnim)
36
call nz, Bankswitch
37
ld a, [wOptions]
38
add a
39
ld hl, PlayCurrentMoveAnimation
40
ld b, BANK(PlayCurrentMoveAnimation)
41
jr nc, .gotAnimToPlay
42
ld hl, AnimationTransformMon
43
ld b, BANK(AnimationTransformMon)
44
.gotAnimToPlay
45
call Bankswitch
46
ld hl, ReshowSubstituteAnim
47
ld b, BANK(ReshowSubstituteAnim)
48
pop af
49
call nz, Bankswitch
50
pop bc
51
ld a, [bc]
52
set TRANSFORMED, a ; mon is now transformed
53
ld [bc], a
54
pop de
55
pop hl
56
push hl
57
; transform user into opposing Pokemon
58
; species
59
ld a, [hl]
60
ld [de], a
61
; type 1, type 2, catch rate, and moves
62
ld bc, $5
63
add hl, bc
64
inc de
65
inc de
66
inc de
67
inc de
68
inc de
69
inc bc
70
inc bc
71
call CopyData
72
ldh a, [hWhoseTurn]
73
and a
74
jr z, .next
75
; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
76
ld a, [de]
77
ld [wTransformedEnemyMonOriginalDVs], a
78
inc de
79
ld a, [de]
80
ld [wTransformedEnemyMonOriginalDVs + 1], a
81
dec de
82
.next
83
; DVs
84
ld a, [hli]
85
ld [de], a
86
inc de
87
ld a, [hli]
88
ld [de], a
89
inc de
90
; Skip level and max HP
91
inc hl
92
inc hl
93
inc hl
94
inc de
95
inc de
96
inc de
97
; Attack, Defense, Speed, and Special stats
98
ld bc, (NUM_STATS - 1) * 2
99
call CopyData
100
ld bc, wBattleMonMoves - wBattleMonPP
101
add hl, bc ; ld hl, wBattleMonMoves
102
ld b, NUM_MOVES
103
.copyPPLoop
104
; 5 PP for all moves
105
ld a, [hli]
106
and a
107
jr z, .lessThanFourMoves
108
ld a, 5
109
ld [de], a
110
inc de
111
dec b
112
jr nz, .copyPPLoop
113
jr .copyStats
114
.lessThanFourMoves
115
; 0 PP for blank moves
116
xor a
117
ld [de], a
118
inc de
119
dec b
120
jr nz, .lessThanFourMoves
121
.copyStats
122
; original (unmodified) stats and stat mods
123
pop hl
124
ld a, [hl]
125
ld [wNamedObjectIndex], a
126
call GetMonName
127
ld hl, wEnemyMonUnmodifiedAttack
128
ld de, wPlayerMonUnmodifiedAttack
129
call .copyBasedOnTurn ; original (unmodified) stats
130
ld hl, wEnemyMonStatMods
131
ld de, wPlayerMonStatMods
132
call .copyBasedOnTurn ; stat mods
133
ld hl, TransformedText
134
jp PrintText
135
136
.copyBasedOnTurn
137
ldh a, [hWhoseTurn]
138
and a
139
jr z, .gotStatsOrModsToCopy
140
push hl
141
ld h, d
142
ld l, e
143
pop de
144
.gotStatsOrModsToCopy
145
ld bc, (NUM_STATS - 1) * 2
146
jp CopyData
147
148
.failed
149
ld hl, PrintButItFailedText_
150
jp EffectCallBattleCore
151
152
TransformedText:
153
text_far _TransformedText
154
text_end
155
156