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