Prepare to merge

This commit is contained in:
PikalaxALT
2016-01-18 00:39:01 -05:00
parent 7cc2571529
commit 8bf255b9f8
14 changed files with 301 additions and 290 deletions

View File

@@ -1248,7 +1248,7 @@ HandlePerishSong: ; 3c801
res SUBSTATUS_PERISH, [hl]
ld a, [hBattleTurn]
and a
jr nz, .asm_3c85c
jr nz, .kill_enemy
ld hl, BattleMonHP
xor a
ld [hli], a
@@ -1261,7 +1261,7 @@ HandlePerishSong: ; 3c801
ld [hl], a
ret
.asm_3c85c
.kill_enemy
ld hl, EnemyMonHP
xor a
ld [hli], a
@@ -1334,12 +1334,12 @@ HandleWrap: ; 3c874
call GetSixteenthMaxHP
call SubtractHPFromUser
ld hl, BattleText_UsersHurtByStringBuffer1
jr .asm_3c8e1
jr .print_text
.release_from_bounds
ld hl, BattleText_UserWasReleasedFromStringBuffer1
.asm_3c8e1
.print_text
jp StdBattleTextBox
; 3c8e4
@@ -1396,7 +1396,7 @@ HandleLeftovers: ; 3c8eb
call GetSixteenthMaxHP
call SwitchTurnCore
call RestoreHP
ld hl, BattleText_0x80880
ld hl, BattleText_TargetRecoveredWithItem
jp StdBattleTextBox
; 3c93c
@@ -1569,7 +1569,7 @@ HandleFutureSight: ; 3ca26
cp $1
ret nz
ld hl, BattleText_0x808b6
ld hl, BattleText_TargetWasHitByFutureSight
call StdBattleTextBox
ld a, BATTLE_VARS_MOVE
@@ -1645,12 +1645,12 @@ HanleDefrost: ; 3ca8f
ld a, [wBattleMode]
dec a
jr z, .asm_3caef
jr z, .wild
ld a, [CurOTMon]
ld hl, OTPartyMon1Status
call GetPartyLocation
ld [hl], 0
.asm_3caef
.wild
call UpdateBattleHuds
call SetPlayerTurn
@@ -1661,13 +1661,13 @@ HanleDefrost: ; 3ca8f
HandleSafeguard: ; 3cafb
ld a, [hLinkPlayerNumber]
cp $1
jr z, .asm_3cb06
call .asm_3cb09
jr .asm_3cb1c
jr z, .player1
call .CheckPlayer
jr .CheckEnemy
.asm_3cb06
call .asm_3cb1c
.asm_3cb09
.player1
call .CheckEnemy
.CheckPlayer
ld a, [PlayerScreens]
bit SCREENS_SAFEGUARD, a
ret z
@@ -1677,9 +1677,9 @@ HandleSafeguard: ; 3cafb
res SCREENS_SAFEGUARD, a
ld [PlayerScreens], a
xor a
jr .asm_3cb2e
jr .print
.asm_3cb1c
.CheckEnemy
ld a, [EnemyScreens]
bit SCREENS_SAFEGUARD, a
ret z
@@ -1690,7 +1690,7 @@ HandleSafeguard: ; 3cafb
ld [EnemyScreens], a
ld a, $1
.asm_3cb2e
.print
ld [hBattleTurn], a
ld hl, BattleText_SafeguardFaded
jp StdBattleTextBox
@@ -1712,7 +1712,7 @@ HandleScreens: ; 3cb36
call .Copy
ld hl, PlayerScreens
ld de, PlayerLightScreenCount
jr .FadeScreens
jr .TickScreens
.CheckEnemy
call SetEnemyTurn
@@ -1721,11 +1721,11 @@ HandleScreens: ; 3cb36
ld hl, EnemyScreens
ld de, EnemyLightScreenCount
.FadeScreens
.TickScreens
bit SCREENS_LIGHT_SCREEN, [hl]
call nz, FadeLightScreen
call nz, .LightScreenTick
bit SCREENS_REFLECT, [hl]
call nz, FadeReflect
call nz, .ReflectTick
ret
.Copy
@@ -1740,7 +1740,7 @@ HandleScreens: ; 3cb36
; 3cb80
FadeLightScreen: ; 3cb80
.LightScreenTick: ; 3cb80
ld a, [de]
dec a
ld [de], a
@@ -1748,21 +1748,21 @@ FadeLightScreen: ; 3cb80
res SCREENS_LIGHT_SCREEN, [hl]
push hl
push de
ld hl, BattleText_PkmnnLightScreenFell
ld hl, BattleText_PkmnLightScreenFell
call StdBattleTextBox
pop de
pop hl
ret
; 3cb91
FadeReflect: ; 3cb91
.ReflectTick: ; 3cb91
inc de
ld a, [de]
dec a
ld [de], a
ret nz
res SCREENS_REFLECT, [hl]
ld hl, BattleText_0x80905
ld hl, BattleText_PkmnReflectFaded
jp StdBattleTextBox
; 3cb9e
@@ -3969,7 +3969,7 @@ TryToRunAwayFromBattle: ; 3d8b3
and a
jr z, .can_escape
ld [hDivisor], a
ld b, $2
ld b, 2
call Divide
ld a, [hQuotient + 1]
and a
@@ -4941,16 +4941,16 @@ PrintPlayerHUD: ; 3dfbf
ld [MonType], a
callab GetGender
ld a, " "
jr c, .asm_3e013
jr c, .got_gender_char
ld a, "♂"
jr nz, .asm_3e013
jr nz, .got_gender_char
ld a, "♀"
.asm_3e013
.got_gender_char
hlcoord 17, 8
ld [hl], a
hlcoord 14, 8
push af
push af ; back up gender
push hl
ld de, BattleMonStatus
predef PlaceNonFaintStatus
@@ -4959,10 +4959,10 @@ PrintPlayerHUD: ; 3dfbf
ret nz
ld a, b
cp " "
jr nz, .asm_3e02d
dec hl
jr nz, .copy_level ; male or female
dec hl ; genderless
.asm_3e02d
.copy_level
ld a, [BattleMonLevel]
ld [TempMonLevel], a
jp PrintLevel

View File

@@ -1928,6 +1928,7 @@ BattleCommand_CheckHit: ; 34d32
ld a, [hBattleTurn]
and a
; load the user's accuracy into b and the opponent's evasion into c.
ld hl, wPlayerMoveStruct + MOVE_ACC
ld a, [PlayerAccLevel]
ld b, a
@@ -1944,26 +1945,31 @@ BattleCommand_CheckHit: ; 34d32
.got_acc_eva
cp b
jr c, .eva_less_than_acc
jr c, .skip_foresight_check
; if the target's evasion is greater than the user's accuracy,
; check the target's foresight status
ld a, BATTLE_VARS_SUBSTATUS1_OPP
call GetBattleVar
bit SUBSTATUS_IDENTIFIED, a
ret nz
.eva_less_than_acc
.skip_foresight_check
; subtract evasion from 14
ld a, 14
sub c
ld c, a
; store the base move accuracy for math ops
xor a
ld [hMultiplicand + 0], a
ld [hMultiplicand + 1], a
ld a, [hl]
ld [hMultiplicand + 2], a
push hl
ld d, 2
ld d, 2 ; do this twice, once for the user's accuracy and once for the target's evasion
.accuracy_loop
; look up the multiplier from the table
push bc
ld hl, .AccProb
dec b
@@ -1972,27 +1978,32 @@ BattleCommand_CheckHit: ; 34d32
ld b, 0
add hl, bc
pop bc
; multiply by the first byte in that row...
ld a, [hli]
ld [hMultiplier], a
call Multiply
; ... and divide by the second byte
ld a, [hl]
ld [hDivisor], a
ld b, 4
call Divide
; minimum accuracy is $0001
ld a, [hQuotient + 2]
ld b, a
ld a, [hQuotient + 1]
or b
jr nz, .min_accuracy
ld [hQuotient + 1], a
ld a, $1
ld a, 1
ld [hQuotient + 2], a
.min_accuracy
; do the same thing to the target's evasion
ld b, c
dec d
jr nz, .accuracy_loop
; if the result is more than 2 bytes, max out at 100%
ld a, [hQuotient + 1]
and a
ld a, [hQuotient + 2]
@@ -8393,148 +8404,7 @@ BattleCommand_Heal: ; 3713e
; 371cd
BattleCommand_Transform: ; 371cd
; transform
call ClearLastMove
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVarAddr
bit SUBSTATUS_TRANSFORMED, [hl]
jp nz, BattleEffect_ButItFailed
call CheckHiddenOpponent
jp nz, BattleEffect_ButItFailed
xor a
ld [wNumHits], a
ld [FXAnimIDHi], a
ld a, $1
ld [wKickCounter], a
ld a, BATTLE_VARS_SUBSTATUS4
call GetBattleVarAddr
bit SUBSTATUS_SUBSTITUTE, [hl]
push af
jr z, .mimic_substitute
call CheckUserIsCharging
jr nz, .mimic_substitute
ld a, SUBSTITUTE
call LoadAnim
.mimic_substitute
ld a, BATTLE_VARS_SUBSTATUS5
call GetBattleVarAddr
set SUBSTATUS_TRANSFORMED, [hl]
call ResetActorDisable
ld hl, BattleMonSpecies
ld de, EnemyMonSpecies
ld a, [hBattleTurn]
and a
jr nz, .got_mon_species
ld hl, EnemyMonSpecies
ld de, BattleMonSpecies
xor a
ld [CurMoveNum], a
.got_mon_species
push hl
ld a, [hli]
ld [de], a
inc hl
inc de
inc de
ld bc, NUM_MOVES
call CopyBytes
ld a, [hBattleTurn]
and a
jr z, .mimic_enemy_backup
ld a, [de]
ld [wEnemyBackupDVs], a
inc de
ld a, [de]
ld [wEnemyBackupDVs + 1], a
dec de
.mimic_enemy_backup
; copy DVs
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
; move pointer to stats
ld bc, BattleMonStats - BattleMonPP
add hl, bc
push hl
ld h, d
ld l, e
add hl, bc
ld d, h
ld e, l
pop hl
ld bc, BattleMonStructEnd - BattleMonStats
call CopyBytes
; init the power points
ld bc, BattleMonMoves - BattleMonStructEnd
add hl, bc
push de
ld d, h
ld e, l
pop hl
ld bc, BattleMonPP - BattleMonStructEnd
add hl, bc
ld b, NUM_MOVES
.pp_loop
ld a, [de]
inc de
and a
jr z, .done_move
cp SKETCH
ld a, 1
jr z, .done_move
ld a, 5
.done_move
ld [hli], a
dec b
jr nz, .pp_loop
pop hl
ld a, [hl]
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, EnemyStats
ld de, PlayerStats
ld bc, 2 * 5
call BattleSideCopy
ld hl, EnemyStatLevels
ld de, PlayerStatLevels
ld bc, 8
call BattleSideCopy
call _CheckBattleScene
jr c, .mimic_anims
ld a, [hBattleTurn]
and a
ld a, [wPlayerMinimized]
jr z, .got_byte
ld a, [wEnemyMinimized]
.got_byte
and a
jr nz, .mimic_anims
call LoadMoveAnim
jr .after_anim
.mimic_anims
call BattleCommand_MoveDelay
call BattleCommand_RaiseSubNoAnim
.after_anim
xor a
ld [wNumHits], a
ld [FXAnimIDHi], a
ld a, $2
ld [wKickCounter], a
pop af
ld a, SUBSTITUTE
call nz, LoadAnim
ld hl, TransformedText
jp StdBattleTextBox
; 372c6
INCLUDE "battle/effects/transform.asm"
BattleSideCopy: ; 372c6
; Copy bc bytes from hl to de if it's the player's turn.

141
battle/effects/transform.asm Executable file
View File

@@ -0,0 +1,141 @@
BattleCommand_Transform: ; 371cd
; transform
call ClearLastMove
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVarAddr
bit SUBSTATUS_TRANSFORMED, [hl]
jp nz, BattleEffect_ButItFailed
call CheckHiddenOpponent
jp nz, BattleEffect_ButItFailed
xor a
ld [wNumHits], a
ld [FXAnimIDHi], a
ld a, $1
ld [wKickCounter], a
ld a, BATTLE_VARS_SUBSTATUS4
call GetBattleVarAddr
bit SUBSTATUS_SUBSTITUTE, [hl]
push af
jr z, .mimic_substitute
call CheckUserIsCharging
jr nz, .mimic_substitute
ld a, SUBSTITUTE
call LoadAnim
.mimic_substitute
ld a, BATTLE_VARS_SUBSTATUS5
call GetBattleVarAddr
set SUBSTATUS_TRANSFORMED, [hl]
call ResetActorDisable
ld hl, BattleMonSpecies
ld de, EnemyMonSpecies
ld a, [hBattleTurn]
and a
jr nz, .got_mon_species
ld hl, EnemyMonSpecies
ld de, BattleMonSpecies
xor a
ld [CurMoveNum], a
.got_mon_species
push hl
ld a, [hli]
ld [de], a
inc hl
inc de
inc de
ld bc, NUM_MOVES
call CopyBytes
ld a, [hBattleTurn]
and a
jr z, .mimic_enemy_backup
ld a, [de]
ld [wEnemyBackupDVs], a
inc de
ld a, [de]
ld [wEnemyBackupDVs + 1], a
dec de
.mimic_enemy_backup
; copy DVs
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
; move pointer to stats
ld bc, BattleMonStats - BattleMonPP
add hl, bc
push hl
ld h, d
ld l, e
add hl, bc
ld d, h
ld e, l
pop hl
ld bc, BattleMonStructEnd - BattleMonStats
call CopyBytes
; init the power points
ld bc, BattleMonMoves - BattleMonStructEnd
add hl, bc
push de
ld d, h
ld e, l
pop hl
ld bc, BattleMonPP - BattleMonStructEnd
add hl, bc
ld b, NUM_MOVES
.pp_loop
ld a, [de]
inc de
and a
jr z, .done_move
cp SKETCH
ld a, 1
jr z, .done_move
ld a, 5
.done_move
ld [hli], a
dec b
jr nz, .pp_loop
pop hl
ld a, [hl]
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, EnemyStats
ld de, PlayerStats
ld bc, 2 * 5
call BattleSideCopy
ld hl, EnemyStatLevels
ld de, PlayerStatLevels
ld bc, 8
call BattleSideCopy
call _CheckBattleScene
jr c, .mimic_anims
ld a, [hBattleTurn]
and a
ld a, [wPlayerMinimized]
jr z, .got_byte
ld a, [wEnemyMinimized]
.got_byte
and a
jr nz, .mimic_anims
call LoadMoveAnim
jr .after_anim
.mimic_anims
call BattleCommand_MoveDelay
call BattleCommand_RaiseSubNoAnim
.after_anim
xor a
ld [wNumHits], a
ld [FXAnimIDHi], a
ld a, $2
ld [wKickCounter], a
pop af
ld a, SUBSTITUTE
call nz, LoadAnim
ld hl, TransformedText
jp StdBattleTextBox
; 372c6