Skip to content

Commit 327338a

Browse files
committed
Improve effect commands documentation, misc improvements
1 parent d5f3b33 commit 327338a

18 files changed

+268
-242
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ CopyLine::
139139
; e = attack index (0 or 1)
140140
; wAttachedEnergies and wTotalAttachedEnergies
141141
; returns: carry if not enough energy, nc if enough energy.
142-
_CheckIfEnoughEnergiesToAttack:
142+
CheckIfEnoughEnergiesForGivenAttack:
143143
```
144144

145145
```asm
@@ -258,7 +258,7 @@ wTextHeader4:: ; ce3a
258258
; such as PrintPlayAreaCardLocation, PrintPlayAreaCardInformation and PrintPlayAreaCardHeader
259259
wCurPlayAreaSlot:: ; cbc9
260260
261-
; X position to display the attached energies, HP bar, and Pluspower/Defender icons
261+
; X position to display the attached energies, HP bar, and PlusPower/Defender icons
262262
; obviously different for player and opponent side. used by DrawDuelHUD.
263263
wHUDEnergyAndHPBarsX:: ; cbc9
264264
ds $1

bugs_and_glitches.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ AIDecide_FullHeal:
412412

413413
### AI might use a Pkmn Power as an attack
414414

415-
Under very specific conditions, the AI might attempt to use its Arena card's Pkmn Power as an attack. This is because when the AI plays Pluspower, it is hardcoding which attack to use when it finally decides to attack. This does not account for the case where afterwards, for example, the AI plays a Professor Oak and obtains an evolution of that card, and then evolves that card. If the new evolved Pokémon has Pkmn Power on the first "attack slot", and the AI hardcoded to use that attack, then it will be used. This specific combination can be seen when playing with John, since his deck contains Professor Oak, Pluspower, and Doduo and its evolution Dodrio (which has the Pkmn Power Retreat Aid).
415+
Under very specific conditions, the AI might attempt to use its Arena card's Pkmn Power as an attack. This is because when the AI plays PlusPower, it is hardcoding which attack to use when it finally decides to attack. This does not account for the case where afterwards, for example, the AI plays a Professor Oak and obtains an evolution of that card, and then evolves that card. If the new evolved Pokémon has Pkmn Power on the first "attack slot", and the AI hardcoded to use that attack, then it will be used. This specific combination can be seen when playing with John, since his deck contains Professor Oak, PlusPower, and Doduo and its evolution Dodrio (which has the Pkmn Power Retreat Aid).
416416

417417
**Fix:** Edit `AIDecideEvolution` in [src/engine/duel/ai/hand_pokemon.asm](https://github.com/pret/poketcg/blob/master/src/engine/duel/ai/hand_pokemon.asm):
418418
```diff

src/constants/deck_ai_constants.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ DEF AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in
8080

8181
const AI_TRAINER_CARD_PHASE_13 ; $d
8282
; Defender
83-
; Pluspower
83+
; PlusPower
8484
; Lass
8585
; Pokémon Flute
8686

8787
const AI_TRAINER_CARD_PHASE_14 ; $e
8888
; Defender
89-
; Pluspower
89+
; PlusPower
9090

9191
const AI_TRAINER_CARD_PHASE_15 ; $f
9292
; Professor Oak

src/constants/duel_constants.asm

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ DEF DUELVARS_BENCH2_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench2CardAttache
5757
DEF DUELVARS_BENCH3_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench3CardAttachedDefender)" ; dd
5858
DEF DUELVARS_BENCH4_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench4CardAttachedDefender)" ; de
5959
DEF DUELVARS_BENCH5_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench5CardAttachedDefender)" ; df
60-
DEF DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerArenaCardAttachedPluspower)" ; e0
61-
DEF DUELVARS_BENCH1_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench1CardAttachedPluspower)" ; e1
62-
DEF DUELVARS_BENCH2_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench2CardAttachedPluspower)" ; e2
63-
DEF DUELVARS_BENCH3_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench3CardAttachedPluspower)" ; e3
64-
DEF DUELVARS_BENCH4_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench4CardAttachedPluspower)" ; e4
65-
DEF DUELVARS_BENCH5_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench5CardAttachedPluspower)" ; e5
60+
DEF DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerArenaCardAttachedPlusPower)" ; e0
61+
DEF DUELVARS_BENCH1_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench1CardAttachedPlusPower)" ; e1
62+
DEF DUELVARS_BENCH2_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench2CardAttachedPlusPower)" ; e2
63+
DEF DUELVARS_BENCH3_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench3CardAttachedPlusPower)" ; e3
64+
DEF DUELVARS_BENCH4_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench4CardAttachedPlusPower)" ; e4
65+
DEF DUELVARS_BENCH5_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench5CardAttachedPlusPower)" ; e5
6666
DEF DUELVARS_ARENA_CARD_SUBSTATUS1 EQUS "LOW(wPlayerArenaCardSubstatus1)" ; e7
6767
DEF DUELVARS_ARENA_CARD_SUBSTATUS2 EQUS "LOW(wPlayerArenaCardSubstatus2)" ; e8
6868
DEF DUELVARS_ARENA_CARD_CHANGED_WEAKNESS EQUS "LOW(wPlayerArenaCardChangedWeakness)" ; e9
@@ -134,19 +134,19 @@ DEF DBLPSN_DAMAGE EQU 20
134134
; substatus conditions (DUELVARS_ARENA_CARD_SUBSTATUS*)
135135

136136
; SUBSTATUS1 are checked on a defending Pokemon
137-
DEF SUBSTATUS1_AGILITY EQU $0c
138-
DEF SUBSTATUS1_FLY EQU $0d
139-
DEF SUBSTATUS1_HARDEN EQU $0e
140-
DEF SUBSTATUS1_NO_DAMAGE_STIFFEN EQU $0f
141-
DEF SUBSTATUS1_NO_DAMAGE_10 EQU $10
142-
DEF SUBSTATUS1_NO_DAMAGE_11 EQU $11
143-
DEF SUBSTATUS1_REDUCE_BY_20 EQU $13
144-
DEF SUBSTATUS1_BARRIER EQU $14
145-
DEF SUBSTATUS1_HALVE_DAMAGE EQU $15
146-
DEF SUBSTATUS1_DESTINY_BOND EQU $16
147-
DEF SUBSTATUS1_NO_DAMAGE_17 EQU $17
137+
DEF SUBSTATUS1_AGILITY EQU $0c
138+
DEF SUBSTATUS1_FLY EQU $0d
139+
DEF SUBSTATUS1_PREVENT_LESS_THAN_40 EQU $0e
140+
DEF SUBSTATUS1_NO_DAMAGE_STIFFEN EQU $0f
141+
DEF SUBSTATUS1_NO_DAMAGE_WITHDRAW EQU $10
142+
DEF SUBSTATUS1_NO_DAMAGE_HIDE_IN_SHELL EQU $11
143+
DEF SUBSTATUS1_REDUCE_BY_20 EQU $13
144+
DEF SUBSTATUS1_BARRIER EQU $14
145+
DEF SUBSTATUS1_HALVE_DAMAGE EQU $15
146+
DEF SUBSTATUS1_DESTINY_BOND EQU $16
147+
DEF SUBSTATUS1_NO_DAMAGE_SCRUNCH EQU $17
148148
DEF SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE EQU $19
149-
DEF SUBSTATUS1_REDUCE_BY_10 EQU $1e
149+
DEF SUBSTATUS1_REDUCE_BY_10 EQU $1e
150150

151151
; SUBSTATUS2 are checked on an attacking Pokemon
152152
DEF SUBSTATUS2_SMOKESCREEN EQU $01
@@ -157,7 +157,7 @@ DEF SUBSTATUS2_TAIL_WAG EQU $05
157157
DEF SUBSTATUS2_LEER EQU $06
158158
DEF SUBSTATUS2_POUNCE EQU $07
159159
DEF SUBSTATUS2_CONVERSION2 EQU $08
160-
DEF SUBSTATUS2_UNABLE_RETREAT EQU $09
160+
DEF SUBSTATUS2_ACID EQU $09
161161
DEF SUBSTATUS2_BONE_ATTACK EQU $0b
162162
DEF SUBSTATUS2_GROWL EQU $12
163163

src/data/cards.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7903,7 +7903,7 @@ MewtwoLv60Card:
79037903
dw NONE ; description (cont)
79047904
db 0 ; damage
79057905
db RESIDUAL ; category
7906-
dw MewtwoLv60EnergyAbsorptionEffectCommands ; effect commands
7906+
dw MewtwoEnergyAbsorptionEffectCommands ; effect commands
79077907
db NONE ; flags 1
79087908
db NONE ; flags 2
79097909
db SPECIAL_AI_HANDLING ; flags 3
@@ -7954,7 +7954,7 @@ MewtwoAltLV60Card:
79547954
dw NONE ; description (cont)
79557955
db 0 ; damage
79567956
db RESIDUAL ; category
7957-
dw MewtwoAltLV60EnergyAbsorptionEffectCommands ; effect commands
7957+
dw MewtwoAltEnergyAbsorptionEffectCommands ; effect commands
79587958
db NONE ; flags 1
79597959
db NONE ; flags 2
79607960
db SPECIAL_AI_HANDLING ; flags 3

src/data/duel/ai_trainer_card_logic.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ AITrainerCardLogic:
1212
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_11, SUPER_POTION, AIDecide_SuperPotion2, AIPlay_SuperPotion
1313
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, DEFENDER, AIDecide_Defender1, AIPlay_Defender
1414
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_14, DEFENDER, AIDecide_Defender2, AIPlay_Defender
15-
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, PLUSPOWER, AIDecide_Pluspower1, AIPlay_Pluspower
16-
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_14, PLUSPOWER, AIDecide_Pluspower2, AIPlay_Pluspower
15+
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, PLUSPOWER, AIDecide_PlusPower1, AIPlay_PlusPower
16+
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_14, PLUSPOWER, AIDecide_PlusPower2, AIPlay_PlusPower
1717
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_09, SWITCH, AIDecide_Switch, AIPlay_Switch
1818
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_07, GUST_OF_WIND, AIDecide_GustOfWind, AIPlay_GustOfWind
1919
ai_trainer_card_logic AI_TRAINER_CARD_PHASE_10, GUST_OF_WIND, AIDecide_GustOfWind, AIPlay_GustOfWind

src/engine/duel/ai/attacks.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ AIProcessAndTryToUseAttack:
5252
; AI will use it if wAIExecuteProcessedAttack is 0.
5353
; in either case, return carry if an attack is chosen to be used.
5454
AIProcessAttacks:
55-
; if AI used Pluspower, load its attack index
55+
; if AI used PlusPower, load its attack index
5656
ld a, [wPreviousAIFlags]
5757
and AI_FLAG_USED_PLUSPOWER
5858
jr z, .no_pluspower
59-
ld a, [wAIPluspowerAttack]
59+
ld a, [wAIPlusPowerAttack]
6060
ld [wSelectedAttack], a
6161
jr .attack_chosen
6262

src/engine/duel/ai/damage_calculation.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ CalculateDamage_VersusDefendingPokemon:
167167
ldh a, [hTempPlayAreaLocation_ff9d]
168168
add CARD_LOCATION_ARENA
169169
ld b, a
170-
call ApplyAttachedPluspower
170+
call ApplyAttachedPlusPower
171171
call SwapTurn
172172
ld b, CARD_LOCATION_ARENA
173173
call ApplyAttachedDefender
@@ -404,7 +404,7 @@ CalculateDamage_FromDefendingPokemon:
404404
; apply pluspower and defender boosts
405405
call SwapTurn
406406
ld b, CARD_LOCATION_ARENA
407-
call ApplyAttachedPluspower
407+
call ApplyAttachedPlusPower
408408
call SwapTurn
409409
ldh a, [hTempPlayAreaLocation_ff9d]
410410
add CARD_LOCATION_ARENA

src/engine/duel/ai/trainer_cards.asm

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -755,22 +755,22 @@ AIDecide_Defender2:
755755
or a
756756
ret
757757

758-
AIPlay_Pluspower:
758+
AIPlay_PlusPower:
759759
ld a, [wCurrentAIFlags]
760760
or AI_FLAG_USED_PLUSPOWER
761761
ld [wCurrentAIFlags], a
762762
ld a, [wAITrainerCardParameter]
763-
ld [wAIPluspowerAttack], a
763+
ld [wAIPlusPowerAttack], a
764764
ld a, [wAITrainerCardToPlay]
765765
ldh [hTempCardIndex_ff9f], a
766766
ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS
767767
bank1call AIMakeDecision
768768
ret
769769

770-
; returns carry if using a Pluspower can KO defending Pokémon
770+
; returns carry if using a PlusPower can KO defending Pokémon
771771
; if active card cannot KO without the boost.
772772
; outputs in a the attack to use.
773-
AIDecide_Pluspower1:
773+
AIDecide_PlusPower1:
774774
; this is mistakenly duplicated
775775
xor a ; PLAY_AREA_ARENA
776776
ldh [hTempPlayAreaLocation_ff9d], a
@@ -811,7 +811,7 @@ AIDecide_Pluspower1:
811811
jr c, .no_carry
812812

813813
; check both attacks and decide which one
814-
; can KO with Pluspower boost.
814+
; can KO with PlusPower boost.
815815
; if neither can KO, return no carry.
816816
xor a ; FIRST_ATTACK_OR_PKMN_POWER
817817
ld [wSelectedAttack], a
@@ -826,14 +826,14 @@ AIDecide_Pluspower1:
826826
or a
827827
ret
828828

829-
; first attack can KO with Pluspower.
829+
; first attack can KO with PlusPower.
830830
.kos_with_pluspower_1
831831
call .check_mr_mime
832832
jr nc, .no_carry
833833
xor a ; FIRST_ATTACK_OR_PKMN_POWER
834834
scf
835835
ret
836-
; second attack can KO with Pluspower.
836+
; second attack can KO with PlusPower.
837837
.kos_with_pluspower_2
838838
call .check_mr_mime
839839
jr nc, .no_carry
@@ -842,7 +842,7 @@ AIDecide_Pluspower1:
842842
ret
843843

844844
; return carry if attack is useable and KOs
845-
; defending Pokémon with Pluspower boost.
845+
; defending Pokémon with PlusPower boost.
846846
.check_ko_with_pluspower
847847
farcall CheckIfSelectedAttackIsUnusable
848848
jr c, .unusable
@@ -856,23 +856,23 @@ AIDecide_Pluspower1:
856856
jr c, .no_carry
857857
jr z, .no_carry
858858
ld a, [hl]
859-
add 10 ; add Pluspower boost
859+
add 10 ; add PlusPower boost
860860
ld c, a
861861
ld a, b
862862
sub c
863863
ret c ; return carry if damage > HP left
864864
ret nz ; does not KO
865865
scf
866-
ret ; KOs with Pluspower boost
866+
ret ; KOs with PlusPower boost
867867
.unusable
868868
or a
869869
ret
870870

871-
; returns carry if Pluspower boost does
871+
; returns carry if PlusPower boost does
872872
; not exceed 30 damage when facing Mr. Mime.
873873
.check_mr_mime
874874
ld a, [wDamage]
875-
add 10 ; add Pluspower boost
875+
add 10 ; add PlusPower boost
876876
cp 30 ; no danger in preventing damage
877877
ret c
878878
call SwapTurn
@@ -888,11 +888,11 @@ AIDecide_Pluspower1:
888888
ret
889889

890890
; returns carry 7/10 of the time
891-
; if selected attack is useable, can't KO without Pluspower boost
892-
; can damage Mr. Mime even with Pluspower boost
891+
; if selected attack is useable, can't KO without PlusPower boost
892+
; can damage Mr. Mime even with PlusPower boost
893893
; and has a minimum damage > 0.
894894
; outputs in a the attack to use.
895-
AIDecide_Pluspower2:
895+
AIDecide_PlusPower2:
896896
xor a ; PLAY_AREA_ARENA
897897
ldh [hTempPlayAreaLocation_ff9d], a
898898
call .check_can_ko
@@ -907,11 +907,11 @@ AIDecide_Pluspower2:
907907
or a
908908
ret
909909

910-
; returns carry if Pluspower boost does
910+
; returns carry if PlusPower boost does
911911
; not exceed 30 damage when facing Mr. Mime.
912912
.check_mr_mime
913913
ld a, [wDamage]
914-
add 10 ; add Pluspower boost
914+
add 10 ; add PlusPower boost
915915
cp 30 ; no danger in preventing damage
916916
ret c
917917
call SwapTurn

src/engine/duel/core.asm

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,18 +1268,18 @@ CheckIfEnoughEnergiesToAttack:
12681268
ld d, [hl] ; card's deck index (0 to 59)
12691269
inc hl
12701270
ld e, [hl] ; attack index (0 or 1)
1271-
call _CheckIfEnoughEnergiesToAttack
1271+
call CheckIfEnoughEnergiesForGivenAttack
12721272
pop bc
12731273
pop hl
12741274
ret
12751275

12761276
; check if a pokemon card has enough energy attached to it in order to use an attack
12771277
; input:
12781278
; d = deck index of card (0 to 59)
1279-
; e = attack index (0 or 1)
1279+
; e = attack index (SECOND_ATTACK or FIRST_ATTACK_OR_PKMN_POWER)
12801280
; wAttachedEnergies and wTotalAttachedEnergies
12811281
; returns: carry if not enough energy, nc if enough energy.
1282-
_CheckIfEnoughEnergiesToAttack:
1282+
CheckIfEnoughEnergiesForGivenAttack:
12831283
push de
12841284
ld a, d
12851285
call LoadCardDataToBuffer1_FromDeckIndex
@@ -2290,12 +2290,10 @@ PlayDeckShuffleAnimation:
22902290
ld e, DUEL_ANIM_OPP_SHUFFLE
22912291
.load_anim
22922292
; play animation 3 times
2293+
REPT 3
22932294
ld a, e
22942295
call PlayDuelAnimation
2295-
ld a, e
2296-
call PlayDuelAnimation
2297-
ld a, e
2298-
call PlayDuelAnimation
2296+
ENDR
22992297

23002298
.loop_anim
23012299
call DoFrame
@@ -2543,7 +2541,7 @@ DrawDuelHUD:
25432541
ld b, HP_BAR_LENGTH / 2 ; second row of the HP bar
25442542
call SafeCopyDataHLtoDE
25452543

2546-
; print number of attached Pluspower and Defender with respective icon, if any
2544+
; print number of attached PlusPower and Defender with respective icon, if any
25472545
ld hl, wHUDEnergyAndHPBarsX
25482546
ld a, [hli]
25492547
add 6
@@ -2557,7 +2555,7 @@ DrawDuelHUD:
25572555
ld a, SYM_PLUSPOWER
25582556
call WriteByteToBGMap0
25592557
inc b
2560-
ld a, [hl] ; number of attached Pluspower
2558+
ld a, [hl] ; number of attached PlusPower
25612559
add SYM_0
25622560
call WriteByteToBGMap0
25632561
dec b
@@ -3256,7 +3254,7 @@ DisplayCardList:
32563254
ld hl, wSelectedDuelSubMenuItem
32573255
ld [hli], a
32583256
ld [hl], a
3259-
ld a, 1
3257+
ld a, TRUE
32603258
ld [wSortCardListByID], a
32613259
call EraseCursor
32623260
jr .reload_list
@@ -3423,7 +3421,7 @@ PrintSortNumberInCardList_SetPointer:
34233421
ld [hl], e
34243422
inc hl
34253423
ld [hl], d
3426-
ld a, 1
3424+
ld a, TRUE
34273425
ld [wSortCardListByID], a
34283426
ret
34293427

@@ -5474,7 +5472,7 @@ PrintPlayAreaCardHeader:
54745472
call CheckPrintDoublePoisoned
54755473

54765474
.skip_status
5477-
; finally check whether to print the Pluspower and/or Defender symbols
5475+
; finally check whether to print the PlusPower and/or Defender symbols
54785476
ld a, [wCurPlayAreaSlot]
54795477
add DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER
54805478
call GetTurnDuelistVariable
@@ -6830,7 +6828,7 @@ HandleBetweenTurnsEvents:
68306828
call IsArenaPokemonAsleepOrPoisoned
68316829
call SwapTurn
68326830
jr c, .something_to_handle
6833-
call DiscardAttachedPluspowers
6831+
call DiscardAttachedPlusPowers
68346832
call SwapTurn
68356833
call DiscardAttachedDefenders
68366834
call SwapTurn
@@ -6877,7 +6875,7 @@ HandleBetweenTurnsEvents:
68776875
call WaitForWideTextBoxInput
68786876

68796877
.discard_pluspower
6880-
call DiscardAttachedPluspowers
6878+
call DiscardAttachedPlusPowers
68816879
call SwapTurn
68826880
ld a, DUELVARS_ARENA_CARD
68836881
call GetTurnDuelistVariable
@@ -6898,7 +6896,7 @@ HandleBetweenTurnsEvents:
68986896
ret
68996897

69006898
; discard any PLUSPOWER attached to the turn holder's arena and/or bench Pokemon
6901-
DiscardAttachedPluspowers:
6899+
DiscardAttachedPlusPowers:
69026900
ld a, DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER
69036901
call GetTurnDuelistVariable
69046902
ld e, MAX_PLAY_AREA_POKEMON

0 commit comments

Comments
 (0)