summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2015-08-14 00:36:06 -0700
committerYamaArashi <shadow962@live.com>2015-08-14 00:36:06 -0700
commit599a6aeaaf81e7174577c782f3b3ba113a4a4c39 (patch)
treed3f31cf0c4df4187d937d44f61c3ae81dce29d48
parentf6d618090aa689540056a13fb74125d83879347f (diff)
named battle and learn move variables
-rwxr-xr-xengine/battle/core.asm42
-rw-r--r--engine/battle/moveEffects/transform_effect.asm6
-rwxr-xr-xengine/items/items.asm8
-rwxr-xr-xengine/learn_move.asm22
-rw-r--r--text.asm10
-rwxr-xr-xwram.asm25
6 files changed, 67 insertions, 46 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 97ca5ab1..0b534dda 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -788,7 +788,7 @@ CheckNumAttacksLeft: ; 3c50f (f:450f)
HandleEnemyMonFainted: ; 3c525 (f:4525)
xor a
- ld [wccf0], a
+ ld [wInHandlePlayerMonFainted], a
call FaintEnemyPokemon
call AnyPartyAlive
ld a, d
@@ -888,9 +888,9 @@ FaintEnemyPokemon: ; 0x3c567
ld a, [hli]
or [hl]
jr nz, .playermonnotfaint
- ld a, [wccf0]
- and a
- jr nz, .playermonnotfaint
+ ld a, [wInHandlePlayerMonFainted]
+ and a ; was this called by HandlePlayerMonFainted?
+ jr nz, .playermonnotfaint ; if so, don't call RemoveFaintedPlayerMon twice
call RemoveFaintedPlayerMon
.playermonnotfaint
call AnyPartyAlive
@@ -950,11 +950,13 @@ EnemyMonFaintedText: ; 0x3c63e
db "@"
EndLowHealthAlarm: ; 3c643 (f:4643)
+; This function is called when the player has the won the battle. It turns off
+; the low health alarm and prevents it from reactivating until the next battle.
xor a
- ld [wLowHealthAlarm], a ;disable low health alarm
+ ld [wLowHealthAlarm], a ; turn off low health alarm
ld [wChannelSoundIDs + CH4], a
inc a
- ld [wccf6], a
+ ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret
AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f)
@@ -1053,8 +1055,8 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee)
jp Delay3
HandlePlayerMonFainted: ; 3c700 (f:4700)
- ld a, $1
- ld [wccf0], a
+ ld a, 1
+ ld [wInHandlePlayerMonFainted], a
call RemoveFaintedPlayerMon
call AnyPartyAlive ; test if any more mons are alive
ld a, d
@@ -1115,9 +1117,15 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
call SlideDownFaintedMonPic
ld a, $1
ld [wBattleResult], a
- ld a, [wccf0]
- and a
- ret z
+
+; When the player mon and enemy mon faint at the same time and the fact that the
+; enemy mon has fainted is detected first (e.g. when the player mon knocks out
+; the enemy mon using a move with recoil and faints due to the recoil), don't
+; play the player mon's cry or show the "[player mon] fainted!" message.
+ ld a, [wInHandlePlayerMonFainted]
+ and a ; was this called by HandleEnemyMonFainted?
+ ret z ; if so, return
+
ld a, [wBattleMonSpecies]
call PlayCry
ld hl, PlayerMonFaintedText
@@ -1932,9 +1940,9 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
ld a, [hli]
or [hl]
jr z, .asm_3cdd9
- ld a, [wccf6]
- and a
- ret nz
+ ld a, [wLowHealthAlarmDisabled]
+ and a ; has the alarm been disabled because the player has already won?
+ ret nz ; if so, return
ld a, [wPlayerHPBarColor]
cp HP_BAR_RED
jr z, .asm_3cde6
@@ -6201,7 +6209,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
call GetMonHeader
ld a, [W_ENEMYBATTSTATUS3]
bit Transformed, a ; is enemy mon transformed?
- ld hl, wcceb ; copied DVs from when it used Transform
+ ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming
ld a, [hli]
ld b, [hl]
jr nz, .storeDVs
@@ -6879,7 +6887,7 @@ InitBattleCommon: ; 3ef3d (f:6f3d)
ld [wEnemyMonPartyPos], a
ld a, $2
ld [W_ISINBATTLE], a
- jp InitBattle_Common
+ jp _InitBattleCommon
InitWildBattle: ; 3ef8b (f:6f8b)
ld a, $1
@@ -6931,7 +6939,7 @@ InitWildBattle: ; 3ef8b (f:6f8b)
predef CopyUncompressedPicToTilemap
; common code that executes after init battle code specific to trainer or wild battles
-InitBattle_Common: ; 3efeb (f:6feb)
+_InitBattleCommon: ; 3efeb (f:6feb)
ld b, SET_PAL_BATTLE_BLACK
call RunPaletteCommand
call SlidePlayerAndEnemySilhouettesOnScreen
diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm
index 185d47af..6a40eda2 100644
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -67,12 +67,12 @@ TransformEffect_: ; 3bab1 (e:7ab1)
ld a, [H_WHOSETURN]
and a
jr z, .next
-; save enemy mon DVs in wcceb/wccec (enemy turn only)
+; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
ld a, [de]
- ld [wcceb], a
+ ld [wTransformedEnemyMonOriginalDVs], a
inc de
ld a, [de]
- ld [wccec], a
+ ld [wTransformedEnemyMonOriginalDVs + 1], a
dec de
.next
; DVs
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 1a342d97..f0666587 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -364,7 +364,7 @@ ItemUseBall: ; d687 (3:5687)
jr .next16
.next15
set Transformed,[hl]
- ld hl,wcceb
+ ld hl,wTransformedEnemyMonOriginalDVs
ld a,[wEnemyMonDVs]
ld [hli],a
ld a,[wEnemyMonDVs + 1]
@@ -2105,16 +2105,16 @@ ItemUseTMHM: ; e479 (3:6479)
push af
.chooseMon
ld hl,wcf4b
- ld de,wd036
+ ld de,wTempMoveNameBuffer
ld bc,14
- call CopyData
+ call CopyData ; save the move name because DisplayPartyMenu will overwrite it
ld a,$ff
ld [wUpdateSpritesEnabled],a
ld a,TMHM_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
push af
- ld hl,wd036
+ ld hl,wTempMoveNameBuffer
ld de,wcf4b
ld bc,14
call CopyData
diff --git a/engine/learn_move.asm b/engine/learn_move.asm
index 46d30bd9..c0ced4a0 100755
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -4,7 +4,7 @@ LearnMove: ; 6e43 (1:6e43)
ld hl, wPartyMonNicks
call GetPartyMonName
ld hl, wcd6d
- ld de, wd036
+ ld de, wLearnMoveMonName
ld bc, NAME_LENGTH
call CopyData
@@ -16,13 +16,13 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
ld d, h
ld e, l
ld b, NUM_MOVES
-.asm_6e6b
+.findEmptyMoveSlotLoop
ld a, [hl]
and a
- jr z, .asm_6e8b
+ jr z, .next
inc hl
dec b
- jr nz, .asm_6e6b
+ jr nz, .findEmptyMoveSlotLoop
push de
call TryingToLearn
pop de
@@ -35,7 +35,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
call PrintText
pop de
pop hl
-.asm_6e8b
+.next
ld a, [wMoveNum]
ld [hl], a
ld bc, wPartyMon1PP - wPartyMon1Moves
@@ -86,13 +86,13 @@ AbandonLearning: ; 6eda (1:6eda)
jp nz, DontAbandonLearning
ld hl, DidNotLearnText
call PrintText
- ld b, $0
+ ld b, 0
ret
PrintLearnedMove: ; 6efe (1:6efe)
ld hl, LearnedMove1Text
call PrintText
- ld b, $1
+ ld b, 1
ret
TryingToLearn: ; 6f07 (1:6f07)
@@ -108,7 +108,7 @@ TryingToLearn: ; 6f07 (1:6f07)
ld a, [wCurrentMenuItem]
rra
ret c
- ld bc, - NUM_MOVES
+ ld bc, -NUM_MOVES
add hl, bc
push hl
ld de, wMoves
@@ -121,8 +121,8 @@ TryingToLearn: ; 6f07 (1:6f07)
ld hl, WhichMoveToForgetText
call PrintText
coord hl, 4, 7
- ld b, $4
- ld c, $e
+ ld b, 4
+ ld c, 14
call TextBoxBorder
coord hl, 6, 8
ld de, wMovesString
@@ -160,7 +160,7 @@ TryingToLearn: ; 6f07 (1:6f07)
push hl
ld a, [wCurrentMenuItem]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
push af
diff --git a/text.asm b/text.asm
index 9bbbb819..2ed5758f 100644
--- a/text.asm
+++ b/text.asm
@@ -2686,7 +2686,7 @@ _PokemartAnythingElseText:: ; a2719 (28:6719)
done
_LearnedMove1Text:: ; a273b (28:673b)
- TX_RAM wd036
+ TX_RAM wLearnMoveMonName
text " learned"
line "@"
TX_RAM wcf4b
@@ -2705,7 +2705,7 @@ _AbandonLearningText:: ; a2771 (28:6771)
done
_DidNotLearnText:: ; a278a (28:678a)
- TX_RAM wd036
+ TX_RAM wLearnMoveMonName
db $0
line "did not learn"
cont "@"
@@ -2714,7 +2714,7 @@ _DidNotLearnText:: ; a278a (28:678a)
prompt
_TryingToLearnText:: ; a27a4 (28:67a4)
- TX_RAM wd036
+ TX_RAM wLearnMoveMonName
text " is"
line "trying to learn"
cont "@"
@@ -2722,7 +2722,7 @@ _TryingToLearnText:: ; a27a4 (28:67a4)
text "!"
para "But, @"
- TX_RAM wd036
+ TX_RAM wLearnMoveMonName
db $0
line "can't learn more"
cont "than 4 moves!"
@@ -2743,7 +2743,7 @@ _PoofText:: ; a2827 (28:6827)
_ForgotAndText:: ; a2830 (28:6830)
db $0
para "@"
- TX_RAM wd036
+ TX_RAM wLearnMoveMonName
text " forgot"
line "@"
TX_RAM wcd6d
diff --git a/wram.asm b/wram.asm
index 303e9505..44ad46a5 100755
--- a/wram.asm
+++ b/wram.asm
@@ -622,15 +622,18 @@ wSafariBaitFactor:: ; cce9
ds 1
-wcceb:: ds 1 ; used to save the dvs of a mon when it uses transform
-wccec:: ds 1 ; also used with above case
+wTransformedEnemyMonOriginalDVs:: ; cceb
+ ds 2
wMonIsDisobedient:: ds 1 ; cced
wPlayerDisabledMoveNumber:: ds 1 ; ccee
wEnemyDisabledMoveNumber:: ds 1 ; ccef
-wccf0:: ds 1 ; used as a check if a mon fainted
+wInHandlePlayerMonFainted:: ; ccf0
+; When running in the scope of HandlePlayerMonFainted, it equals 1.
+; When running in the scope of HandleEnemyMonFainted, it equals 0.
+ ds 1
wPlayerUsedMove:: ds 1 ; ccf1
wEnemyUsedMove:: ds 1 ; ccf2
@@ -643,8 +646,13 @@ wPartyFoughtCurrentEnemyFlags:: ; ccf5
; flags that indicate which party members have fought the current enemy mon
flag_array 6
-wccf6:: ds 1 ; used in some hp bar thing
-wPlayerMonMinimized:: ds 1 ; ccf7
+wLowHealthAlarmDisabled:: ; ccf6
+; Whether the low health alarm has been disabled due to the player winning the
+; battle.
+ ds 1
+
+wPlayerMonMinimized:: ; ccf7
+ ds 1
ds 13
@@ -1556,7 +1564,12 @@ W_TRAINERCLASS:: ; d031
wTrainerPicPointer:: ; d033
ds 2
ds 1
-wd036:: ds 16 ; used as a temporary buffer to print "XXX learned YYY"
+
+wTempMoveNameBuffer:: ; d036
+
+wLearnMoveMonName:: ; d036
+; The name of the mon that is learning a move.
+ ds 16
wTrainerBaseMoney:: ; d046
; 2-byte BCD number