Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/decrement_pp.asm
1271 views
1
DecrementPP:
2
; after using a move, decrement pp in battle and (if not transformed?) in party
3
ld a, [de]
4
cp STRUGGLE
5
ret z ; if the pokemon is using "struggle", there's nothing to do
6
; we don't decrement PP for "struggle"
7
ld hl, wPlayerBattleStatus1
8
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
9
; wPlayerBattleStatus2 status flags later
10
and (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
11
ret nz ; if any of these statuses are true, don't decrement PP
12
bit USING_RAGE, [hl]
13
ret nz ; don't decrement PP either if Pokemon is using Rage
14
ld hl, wBattleMonPP ; PP of first move (in battle)
15
16
; decrement PP in the battle struct
17
call .DecrementPP
18
19
; decrement PP in the party struct
20
ld a, [wPlayerBattleStatus3]
21
bit TRANSFORMED, a
22
ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP
23
; separately from the "Pokemon in your party's" PP. This is
24
; duplication -- in all cases *other* than Pokemon with Transform.
25
; Normally, this means we have to go on and make the same
26
; modification to the "party's pokemon" PP that we made to the
27
; "current pokemon's" PP. But, if we're dealing with a Transformed
28
; Pokemon, it has separate PP for the move set that it copied from
29
; its opponent, which is *not* the same as its real PP as part of your
30
; party. So we return, and don't do that part.
31
32
ld hl, wPartyMon1PP ; PP of first move (in party)
33
ld a, [wPlayerMonNumber] ; which mon in party is active
34
ld bc, wPartyMon2 - wPartyMon1
35
call AddNTimes ; calculate address of the mon to modify
36
.DecrementPP:
37
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
38
ld c, a
39
ld b, 0
40
add hl, bc ; calculate the address in memory of the PP we need to decrement
41
; based on the move chosen.
42
dec [hl] ; Decrement PP
43
ret
44
45