You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-09-08 08:13:02 -07:00
Split battle/ into data/ and engine/ components
This commit is contained in:
1514
engine/anims/anim_commands.asm
Normal file
1514
engine/anims/anim_commands.asm
Normal file
File diff suppressed because it is too large
Load Diff
2958
engine/anims/bg_effects.asm
Normal file
2958
engine/anims/bg_effects.asm
Normal file
File diff suppressed because it is too large
Load Diff
314
engine/anims/engine.asm
Executable file
314
engine/anims/engine.asm
Executable file
@@ -0,0 +1,314 @@
|
||||
QueueBattleAnimation: ; cc9a1 (33:49a1)
|
||||
ld hl, ActiveAnimObjects
|
||||
ld e, 10
|
||||
.loop
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .done
|
||||
ld bc, BATTLEANIMSTRUCT_LENGTH
|
||||
add hl, bc
|
||||
dec e
|
||||
jr nz, .loop
|
||||
scf
|
||||
ret
|
||||
|
||||
.done
|
||||
ld c, l
|
||||
ld b, h
|
||||
ld hl, wNumActiveBattleAnims
|
||||
inc [hl]
|
||||
call InitBattleAnimation
|
||||
ret
|
||||
|
||||
DeinitBattleAnimation: ; cc9bd
|
||||
ld hl, BATTLEANIMSTRUCT_INDEX
|
||||
add hl, bc
|
||||
ld [hl], $0
|
||||
ret
|
||||
|
||||
; cc9c4
|
||||
|
||||
InitBattleAnimation: ; cc9c4 (33:49c4)
|
||||
ld a, [wBattleAnimTemp0]
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, BattleAnimObjects
|
||||
rept 6
|
||||
add hl, de
|
||||
endr
|
||||
ld e, l
|
||||
ld d, h
|
||||
ld hl, BATTLEANIMSTRUCT_INDEX
|
||||
add hl, bc
|
||||
ld a, [wNumActiveBattleAnims]
|
||||
ld [hli], a ; Index
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a ; 01
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a ; 02
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a ; Frameset ID
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a ; Function
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a ; 05
|
||||
ld a, [de]
|
||||
call GetBattleAnimTileOffset
|
||||
ld [hli], a ; Tile ID
|
||||
ld a, [wBattleAnimTemp1]
|
||||
ld [hli], a ; X Coord
|
||||
ld a, [wBattleAnimTemp2]
|
||||
ld [hli], a ; Y Coord
|
||||
xor a
|
||||
ld [hli], a ; X Offset
|
||||
ld [hli], a ; Y Offset
|
||||
ld a, [wBattleAnimTemp3]
|
||||
ld [hli], a ; 0b
|
||||
xor a
|
||||
ld [hli], a ; 0c
|
||||
dec a
|
||||
ld [hli], a ; 0d
|
||||
xor a
|
||||
ld [hli], a ; 0e
|
||||
ld [hli], a ; 0f
|
||||
ld [hl], a ; 10
|
||||
ret
|
||||
|
||||
BattleAnimOAMUpdate: ; cca09
|
||||
call InitBattleAnimBuffer
|
||||
call GetBattleAnimFrame
|
||||
cp -3
|
||||
jp z, .done
|
||||
cp -4
|
||||
jp z, .delete
|
||||
push af
|
||||
ld hl, wBattleAnimTempOAMFlags
|
||||
ld a, [wBattleAnimTemp7]
|
||||
xor [hl]
|
||||
and $e0
|
||||
ld [hl], a
|
||||
pop af
|
||||
push bc
|
||||
call GetBattleAnimOAMPointer
|
||||
ld a, [wBattleAnimTempTileID]
|
||||
add [hl]
|
||||
ld [wBattleAnimTempTileID], a
|
||||
inc hl
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
ld a, [wBattleAnimOAMPointerLo]
|
||||
ld e, a
|
||||
ld d, HIGH(Sprites)
|
||||
.loop
|
||||
ld a, [wBattleAnimTempYCoord]
|
||||
ld b, a
|
||||
ld a, [wBattleAnimTempYOffset]
|
||||
add b
|
||||
ld b, a
|
||||
push hl
|
||||
ld a, [hl]
|
||||
ld hl, wBattleAnimTempOAMFlags
|
||||
bit 6, [hl]
|
||||
jr z, .no_yflip
|
||||
add $8
|
||||
xor $ff
|
||||
inc a
|
||||
|
||||
.no_yflip
|
||||
pop hl
|
||||
add b
|
||||
ld [de], a
|
||||
inc hl
|
||||
inc de
|
||||
ld a, [wBattleAnimTempXCoord]
|
||||
ld b, a
|
||||
ld a, [wBattleAnimTempXOffset]
|
||||
add b
|
||||
ld b, a
|
||||
push hl
|
||||
ld a, [hl]
|
||||
ld hl, wBattleAnimTempOAMFlags
|
||||
bit 5, [hl]
|
||||
jr z, .no_xflip
|
||||
add $8
|
||||
xor $ff
|
||||
inc a
|
||||
|
||||
.no_xflip
|
||||
pop hl
|
||||
add b
|
||||
ld [de], a
|
||||
inc hl
|
||||
inc de
|
||||
ld a, [wBattleAnimTempTileID]
|
||||
add $31
|
||||
add [hl]
|
||||
ld [de], a
|
||||
inc hl
|
||||
inc de
|
||||
ld a, [wBattleAnimTempOAMFlags]
|
||||
ld b, a
|
||||
ld a, [hl]
|
||||
xor b
|
||||
and $e0
|
||||
ld b, a
|
||||
ld a, [hl]
|
||||
and $10
|
||||
or b
|
||||
ld b, a
|
||||
ld a, [wBattleAnimTempPalette]
|
||||
and $f
|
||||
or b
|
||||
ld [de], a
|
||||
inc hl
|
||||
inc de
|
||||
ld a, e
|
||||
ld [wBattleAnimOAMPointerLo], a
|
||||
cp $a0
|
||||
jr nc, .exit_set_carry
|
||||
dec c
|
||||
jr nz, .loop
|
||||
pop bc
|
||||
jr .done
|
||||
|
||||
.delete
|
||||
call DeinitBattleAnimation
|
||||
|
||||
.done
|
||||
and a
|
||||
ret
|
||||
|
||||
.exit_set_carry
|
||||
pop bc
|
||||
scf
|
||||
ret
|
||||
|
||||
; ccaaa
|
||||
|
||||
InitBattleAnimBuffer: ; ccaaa
|
||||
ld hl, BATTLEANIMSTRUCT_01
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
and %10000000
|
||||
ld [wBattleAnimTempOAMFlags], a
|
||||
xor a
|
||||
ld [wBattleAnimTemp7], a
|
||||
ld hl, BATTLEANIMSTRUCT_PALETTE
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wBattleAnimTempPalette], a
|
||||
ld hl, BATTLEANIMSTRUCT_02
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wBattleAnimTemp1], a
|
||||
ld hl, BATTLEANIMSTRUCT_TILEID
|
||||
add hl, bc
|
||||
ld a, [hli]
|
||||
ld [wBattleAnimTempTileID], a
|
||||
ld a, [hli]
|
||||
ld [wBattleAnimTempXCoord], a
|
||||
ld a, [hli]
|
||||
ld [wBattleAnimTempYCoord], a
|
||||
ld a, [hli]
|
||||
ld [wBattleAnimTempXOffset], a
|
||||
ld a, [hli]
|
||||
ld [wBattleAnimTempYOffset], a
|
||||
ld a, [hBattleTurn]
|
||||
and a
|
||||
ret z
|
||||
ld hl, BATTLEANIMSTRUCT_01
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wBattleAnimTempOAMFlags], a
|
||||
bit 0, [hl]
|
||||
ret z
|
||||
ld hl, BATTLEANIMSTRUCT_XCOORD
|
||||
add hl, bc
|
||||
ld a, [hli]
|
||||
ld d, a
|
||||
ld a, (-10 * 8) + 4
|
||||
sub d
|
||||
ld [wBattleAnimTempXCoord], a
|
||||
ld a, [hli]
|
||||
ld d, a
|
||||
ld a, [wBattleAnimTemp1]
|
||||
cp $ff
|
||||
jr nz, .check_kinesis_softboiled_milkdrink
|
||||
ld a, 5 * 8
|
||||
add d
|
||||
jr .done
|
||||
|
||||
.check_kinesis_softboiled_milkdrink
|
||||
sub d
|
||||
push af
|
||||
ld a, [FXAnimID + 1]
|
||||
or a
|
||||
jr nz, .no_sub
|
||||
ld a, [FXAnimID]
|
||||
cp KINESIS
|
||||
jr z, .kinesis
|
||||
cp SOFTBOILED
|
||||
jr z, .softboiled
|
||||
cp MILK_DRINK
|
||||
jr nz, .no_sub
|
||||
.kinesis
|
||||
.softboiled
|
||||
.milk_drink
|
||||
pop af
|
||||
sub 1 * 8
|
||||
jr .done
|
||||
|
||||
.no_sub
|
||||
pop af
|
||||
.done
|
||||
ld [wBattleAnimTempYCoord], a
|
||||
ld a, [hli]
|
||||
xor $ff
|
||||
inc a
|
||||
ld [wBattleAnimTempXOffset], a
|
||||
ret
|
||||
|
||||
; ccb31
|
||||
|
||||
GetBattleAnimTileOffset: ; ccb31 (33:4b31)
|
||||
push hl
|
||||
push bc
|
||||
ld hl, wBattleAnimTileDict
|
||||
ld b, a
|
||||
ld c, 10 / 2
|
||||
.loop
|
||||
ld a, [hli]
|
||||
cp b
|
||||
jr z, .load
|
||||
inc hl
|
||||
dec c
|
||||
jr nz, .loop
|
||||
xor a
|
||||
jr .done
|
||||
|
||||
.load
|
||||
ld a, [hl]
|
||||
.done
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
|
||||
_ExecuteBGEffects: ; ccb48
|
||||
callfar ExecuteBGEffects
|
||||
ret
|
||||
|
||||
; ccb4f
|
||||
|
||||
_QueueBGEffect: ; ccb4f (33:4b4f)
|
||||
callfar QueueBGEffect
|
||||
ret
|
||||
|
||||
; ccb56 (33:4b56)
|
||||
4157
engine/anims/functions.asm
Executable file
4157
engine/anims/functions.asm
Executable file
File diff suppressed because it is too large
Load Diff
130
engine/anims/helpers.asm
Executable file
130
engine/anims/helpers.asm
Executable file
@@ -0,0 +1,130 @@
|
||||
ReinitBattleAnimFrameset: ; ce7bf (33:67bf)
|
||||
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
ld hl, BATTLEANIMSTRUCT_DURATION
|
||||
add hl, bc
|
||||
ld [hl], 0
|
||||
ld hl, BATTLEANIMSTRUCT_FRAME
|
||||
add hl, bc
|
||||
ld [hl], -1
|
||||
ret
|
||||
|
||||
GetBattleAnimFrame: ; ce7d1
|
||||
.loop
|
||||
ld hl, BATTLEANIMSTRUCT_DURATION
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .next_frame
|
||||
dec [hl]
|
||||
call .GetPointer
|
||||
ld a, [hli]
|
||||
push af
|
||||
jr .okay
|
||||
|
||||
.next_frame
|
||||
ld hl, BATTLEANIMSTRUCT_FRAME
|
||||
add hl, bc
|
||||
inc [hl]
|
||||
call .GetPointer
|
||||
ld a, [hli]
|
||||
cp -2
|
||||
jr z, .restart
|
||||
cp -1
|
||||
jr z, .repeat_last
|
||||
push af
|
||||
ld a, [hl]
|
||||
push hl
|
||||
and $3f
|
||||
ld hl, BATTLEANIMSTRUCT_DURATION
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
pop hl
|
||||
|
||||
.okay
|
||||
ld a, [hl]
|
||||
and $c0
|
||||
srl a
|
||||
ld [wBattleAnimTemp7], a
|
||||
pop af
|
||||
ret
|
||||
|
||||
.repeat_last
|
||||
xor a
|
||||
ld hl, BATTLEANIMSTRUCT_DURATION
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
ld hl, BATTLEANIMSTRUCT_FRAME
|
||||
add hl, bc
|
||||
dec [hl]
|
||||
dec [hl]
|
||||
jr .loop
|
||||
|
||||
.restart
|
||||
xor a
|
||||
ld hl, BATTLEANIMSTRUCT_DURATION
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
dec a
|
||||
ld hl, BATTLEANIMSTRUCT_FRAME
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
jr .loop
|
||||
|
||||
; ce823
|
||||
|
||||
.GetPointer: ; ce823
|
||||
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
|
||||
add hl, bc
|
||||
ld e, [hl]
|
||||
ld d, 0
|
||||
ld hl, BattleAnimFrameData
|
||||
add hl, de
|
||||
add hl, de
|
||||
ld e, [hl]
|
||||
inc hl
|
||||
ld d, [hl]
|
||||
ld hl, BATTLEANIMSTRUCT_FRAME
|
||||
add hl, bc
|
||||
ld l, [hl]
|
||||
ld h, $0
|
||||
add hl, hl
|
||||
add hl, de
|
||||
ret
|
||||
|
||||
; ce83c
|
||||
|
||||
GetBattleAnimOAMPointer: ; ce83c
|
||||
ld l, a
|
||||
ld h, 0
|
||||
ld de, BattleAnimOAMData
|
||||
add hl, hl
|
||||
add hl, hl
|
||||
add hl, de
|
||||
ret
|
||||
|
||||
; ce846
|
||||
|
||||
LoadBattleAnimObj: ; ce846 (33:6846)
|
||||
push hl
|
||||
ld l, a
|
||||
ld h, 0
|
||||
add hl, hl
|
||||
add hl, hl
|
||||
ld de, AnimObjGFX
|
||||
add hl, de
|
||||
ld c, [hl]
|
||||
inc hl
|
||||
ld b, [hl]
|
||||
inc hl
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
pop de
|
||||
push bc
|
||||
call DecompressRequest2bpp
|
||||
pop bc
|
||||
ret
|
||||
|
||||
; ce85e (33:685e)
|
||||
882
engine/battle/ai/items.asm
Normal file
882
engine/battle/ai/items.asm
Normal file
File diff suppressed because it is too large
Load Diff
221
engine/battle/ai/move.asm
Executable file
221
engine/battle/ai/move.asm
Executable file
@@ -0,0 +1,221 @@
|
||||
AIChooseMove: ; 440ce
|
||||
; Score each move in EnemyMonMoves starting from Buffer1. Lower is better.
|
||||
; Pick the move with the lowest score.
|
||||
|
||||
; Wildmons attack at random.
|
||||
ld a, [wBattleMode]
|
||||
dec a
|
||||
ret z
|
||||
|
||||
ld a, [wLinkMode]
|
||||
and a
|
||||
ret nz
|
||||
|
||||
; No use picking a move if there's no choice.
|
||||
farcall CheckEnemyLockedIn
|
||||
ret nz
|
||||
|
||||
|
||||
; The default score is 20. Unusable moves are given a score of 80.
|
||||
ld a, 20
|
||||
ld hl, Buffer1
|
||||
ld [hli], a
|
||||
ld [hli], a
|
||||
ld [hli], a
|
||||
ld [hl], a
|
||||
|
||||
; Don't pick disabled moves.
|
||||
ld a, [EnemyDisabledMove]
|
||||
and a
|
||||
jr z, .CheckPP
|
||||
|
||||
ld hl, EnemyMonMoves
|
||||
ld c, 0
|
||||
.CheckDisabledMove:
|
||||
cp [hl]
|
||||
jr z, .ScoreDisabledMove
|
||||
inc c
|
||||
inc hl
|
||||
jr .CheckDisabledMove
|
||||
.ScoreDisabledMove:
|
||||
ld hl, Buffer1
|
||||
ld b, 0
|
||||
add hl, bc
|
||||
ld [hl], 80
|
||||
|
||||
; Don't pick moves with 0 PP.
|
||||
.CheckPP:
|
||||
ld hl, Buffer1 - 1
|
||||
ld de, EnemyMonPP
|
||||
ld b, 0
|
||||
.CheckMovePP:
|
||||
inc b
|
||||
ld a, b
|
||||
cp EnemyMonMovesEnd - EnemyMonMoves + 1
|
||||
jr z, .ApplyLayers
|
||||
inc hl
|
||||
ld a, [de]
|
||||
inc de
|
||||
and $3f
|
||||
jr nz, .CheckMovePP
|
||||
ld [hl], 80
|
||||
jr .CheckMovePP
|
||||
|
||||
|
||||
; Apply AI scoring layers depending on the trainer class.
|
||||
.ApplyLayers:
|
||||
ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS
|
||||
|
||||
; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner)
|
||||
; so we have always the same AI, regardless of the loaded class of trainer
|
||||
ld a, [InBattleTowerBattle]
|
||||
bit 0, a
|
||||
jr nz, .battle_tower_skip
|
||||
|
||||
ld a, [TrainerClass]
|
||||
dec a
|
||||
ld bc, 7 ; Trainer2AI - Trainer1AI
|
||||
call AddNTimes
|
||||
|
||||
.battle_tower_skip
|
||||
lb bc, CHECK_FLAG, 0
|
||||
push bc
|
||||
push hl
|
||||
|
||||
.CheckLayer:
|
||||
pop hl
|
||||
pop bc
|
||||
|
||||
ld a, c
|
||||
cp 16 ; up to 16 scoring layers
|
||||
jr z, .DecrementScores
|
||||
|
||||
push bc
|
||||
ld d, BANK(TrainerClassAttributes)
|
||||
predef FlagPredef
|
||||
ld d, c
|
||||
pop bc
|
||||
|
||||
inc c
|
||||
push bc
|
||||
push hl
|
||||
|
||||
ld a, d
|
||||
and a
|
||||
jr z, .CheckLayer
|
||||
|
||||
ld hl, AIScoringPointers
|
||||
dec c
|
||||
ld b, 0
|
||||
add hl, bc
|
||||
add hl, bc
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
ld a, BANK(AIScoring)
|
||||
call FarCall_hl
|
||||
|
||||
jr .CheckLayer
|
||||
|
||||
; Decrement the scores of all moves one by one until one reaches 0.
|
||||
.DecrementScores:
|
||||
ld hl, Buffer1
|
||||
ld de, EnemyMonMoves
|
||||
ld c, EnemyMonMovesEnd - EnemyMonMoves
|
||||
|
||||
.DecrementNextScore:
|
||||
; If the enemy has no moves, this will infinite.
|
||||
ld a, [de]
|
||||
inc de
|
||||
and a
|
||||
jr z, .DecrementScores
|
||||
|
||||
; We are done whenever a score reaches 0
|
||||
dec [hl]
|
||||
jr z, .PickLowestScoreMoves
|
||||
|
||||
; If we just decremented the fourth move's score, go back to the first move
|
||||
inc hl
|
||||
dec c
|
||||
jr z, .DecrementScores
|
||||
|
||||
jr .DecrementNextScore
|
||||
|
||||
; In order to avoid bias towards the moves located first in memory, increment the scores
|
||||
; that were decremented one more time than the rest (in case there was a tie).
|
||||
; This means that the minimum score will be 1.
|
||||
.PickLowestScoreMoves:
|
||||
ld a, c
|
||||
|
||||
.move_loop
|
||||
inc [hl]
|
||||
dec hl
|
||||
inc a
|
||||
cp NUM_MOVES + 1
|
||||
jr nz, .move_loop
|
||||
|
||||
ld hl, Buffer1
|
||||
ld de, EnemyMonMoves
|
||||
ld c, NUM_MOVES
|
||||
|
||||
; Give a score of 0 to a blank move
|
||||
.loop2
|
||||
ld a, [de]
|
||||
and a
|
||||
jr nz, .skip_load
|
||||
ld [hl], a
|
||||
|
||||
; Disregard the move if its score is not 1
|
||||
.skip_load
|
||||
ld a, [hl]
|
||||
dec a
|
||||
jr z, .keep
|
||||
xor a
|
||||
ld [hli], a
|
||||
jr .after_toss
|
||||
|
||||
.keep
|
||||
ld a, [de]
|
||||
ld [hli], a
|
||||
.after_toss
|
||||
inc de
|
||||
dec c
|
||||
jr nz, .loop2
|
||||
|
||||
; Randomly choose one of the moves with a score of 1
|
||||
.ChooseMove:
|
||||
ld hl, Buffer1
|
||||
call Random
|
||||
and 3
|
||||
ld c, a
|
||||
ld b, 0
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .ChooseMove
|
||||
|
||||
ld [CurEnemyMove], a
|
||||
ld a, c
|
||||
ld [CurEnemyMoveNum], a
|
||||
ret
|
||||
; 441af
|
||||
|
||||
|
||||
AIScoringPointers: ; 441af
|
||||
dw AI_Basic
|
||||
dw AI_Setup
|
||||
dw AI_Types
|
||||
dw AI_Offensive
|
||||
dw AI_Smart
|
||||
dw AI_Opportunist
|
||||
dw AI_Aggressive
|
||||
dw AI_Cautious
|
||||
dw AI_Status
|
||||
dw AI_Risky
|
||||
dw AI_None
|
||||
dw AI_None
|
||||
dw AI_None
|
||||
dw AI_None
|
||||
dw AI_None
|
||||
dw AI_None
|
||||
; 441cf
|
||||
198
engine/battle/ai/redundant.asm
Executable file
198
engine/battle/ai/redundant.asm
Executable file
@@ -0,0 +1,198 @@
|
||||
AI_Redundant: ; 2c41a
|
||||
; Check if move effect c will fail because it's already been used.
|
||||
; Return z if the move is a good choice.
|
||||
; Return nz if the move is a bad choice.
|
||||
ld a, c
|
||||
ld de, 3
|
||||
ld hl, .Moves
|
||||
call IsInArray
|
||||
jp nc, .NotRedundant
|
||||
inc hl
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
jp hl
|
||||
|
||||
.Moves: ; 2c42c
|
||||
dbw EFFECT_DREAM_EATER, .DreamEater
|
||||
dbw EFFECT_HEAL, .Heal
|
||||
dbw EFFECT_LIGHT_SCREEN, .LightScreen
|
||||
dbw EFFECT_MIST, .Mist
|
||||
dbw EFFECT_FOCUS_ENERGY, .FocusEnergy
|
||||
dbw EFFECT_CONFUSE, .Confuse
|
||||
dbw EFFECT_TRANSFORM, .Transform
|
||||
dbw EFFECT_REFLECT, .Reflect
|
||||
dbw EFFECT_SUBSTITUTE, .Substitute
|
||||
dbw EFFECT_LEECH_SEED, .LeechSeed
|
||||
dbw EFFECT_DISABLE, .Disable
|
||||
dbw EFFECT_ENCORE, .Encore
|
||||
dbw EFFECT_SNORE, .Snore
|
||||
dbw EFFECT_SLEEP_TALK, .SleepTalk
|
||||
dbw EFFECT_MEAN_LOOK, .MeanLook
|
||||
dbw EFFECT_NIGHTMARE, .Nightmare
|
||||
dbw EFFECT_SPIKES, .Spikes
|
||||
dbw EFFECT_FORESIGHT, .Foresight
|
||||
dbw EFFECT_PERISH_SONG, .PerishSong
|
||||
dbw EFFECT_SANDSTORM, .Sandstorm
|
||||
dbw EFFECT_ATTRACT, .Attract
|
||||
dbw EFFECT_SAFEGUARD, .Safeguard
|
||||
dbw EFFECT_RAIN_DANCE, .RainDance
|
||||
dbw EFFECT_SUNNY_DAY, .SunnyDay
|
||||
dbw EFFECT_TELEPORT, .Teleport
|
||||
dbw EFFECT_MORNING_SUN, .MorningSun
|
||||
dbw EFFECT_SYNTHESIS, .Synthesis
|
||||
dbw EFFECT_MOONLIGHT, .Moonlight
|
||||
dbw EFFECT_SWAGGER, .Swagger
|
||||
dbw EFFECT_FUTURE_SIGHT, .FutureSight
|
||||
db -1
|
||||
|
||||
.LightScreen: ; 2c487
|
||||
ld a, [EnemyScreens]
|
||||
bit SCREENS_LIGHT_SCREEN, a
|
||||
ret
|
||||
|
||||
.Mist: ; 2c48d
|
||||
ld a, [EnemySubStatus4]
|
||||
bit SUBSTATUS_MIST, a
|
||||
ret
|
||||
|
||||
.FocusEnergy: ; 2c493
|
||||
ld a, [EnemySubStatus4]
|
||||
bit SUBSTATUS_FOCUS_ENERGY, a
|
||||
ret
|
||||
|
||||
.Confuse: ; 2c499
|
||||
ld a, [PlayerSubStatus3]
|
||||
bit SUBSTATUS_CONFUSED, a
|
||||
ret nz
|
||||
ld a, [PlayerScreens]
|
||||
bit SCREENS_SAFEGUARD, a
|
||||
ret
|
||||
|
||||
.Transform: ; 2c4a5
|
||||
ld a, [EnemySubStatus5]
|
||||
bit SUBSTATUS_TRANSFORMED, a
|
||||
ret
|
||||
|
||||
.Reflect: ; 2c4ab
|
||||
ld a, [EnemyScreens]
|
||||
bit SCREENS_REFLECT, a
|
||||
ret
|
||||
|
||||
.Substitute: ; 2c4b1
|
||||
ld a, [EnemySubStatus4]
|
||||
bit SUBSTATUS_SUBSTITUTE, a
|
||||
ret
|
||||
|
||||
.LeechSeed: ; 2c4b7
|
||||
ld a, [PlayerSubStatus4]
|
||||
bit SUBSTATUS_LEECH_SEED, a
|
||||
ret
|
||||
|
||||
.Disable: ; 2c4bd
|
||||
ld a, [PlayerDisableCount]
|
||||
and a
|
||||
ret
|
||||
|
||||
.Encore: ; 2c4c2
|
||||
ld a, [PlayerSubStatus5]
|
||||
bit SUBSTATUS_ENCORED, a
|
||||
ret
|
||||
|
||||
.Snore:
|
||||
.SleepTalk: ; 2c4c8
|
||||
ld a, [EnemyMonStatus]
|
||||
and SLP
|
||||
jr z, .Redundant
|
||||
jr .NotRedundant
|
||||
|
||||
.MeanLook: ; 2c4d1
|
||||
ld a, [EnemySubStatus5]
|
||||
bit SUBSTATUS_CANT_RUN, a
|
||||
ret
|
||||
|
||||
.Nightmare: ; 2c4d7
|
||||
ld a, [BattleMonStatus]
|
||||
and a
|
||||
jr z, .Redundant
|
||||
ld a, [PlayerSubStatus1]
|
||||
bit SUBSTATUS_NIGHTMARE, a
|
||||
ret
|
||||
|
||||
.Spikes: ; 2c4e3
|
||||
ld a, [PlayerScreens]
|
||||
bit SCREENS_SPIKES, a
|
||||
ret
|
||||
|
||||
.Foresight: ; 2c4e9
|
||||
ld a, [PlayerSubStatus1]
|
||||
bit SUBSTATUS_IDENTIFIED, a
|
||||
ret
|
||||
|
||||
.PerishSong: ; 2c4ef
|
||||
ld a, [PlayerSubStatus1]
|
||||
bit SUBSTATUS_PERISH, a
|
||||
ret
|
||||
|
||||
.Sandstorm: ; 2c4f5
|
||||
ld a, [Weather]
|
||||
cp WEATHER_SANDSTORM
|
||||
jr z, .Redundant
|
||||
jr .NotRedundant
|
||||
|
||||
.Attract: ; 2c4fe
|
||||
farcall CheckOppositeGender
|
||||
jr c, .Redundant
|
||||
ld a, [PlayerSubStatus1]
|
||||
bit SUBSTATUS_IN_LOVE, a
|
||||
ret
|
||||
|
||||
.Safeguard: ; 2c50c
|
||||
ld a, [EnemyScreens]
|
||||
bit SCREENS_SAFEGUARD, a
|
||||
ret
|
||||
|
||||
.RainDance: ; 2c512
|
||||
ld a, [Weather]
|
||||
cp WEATHER_RAIN
|
||||
jr z, .Redundant
|
||||
jr .NotRedundant
|
||||
|
||||
.SunnyDay: ; 2c51b
|
||||
ld a, [Weather]
|
||||
cp WEATHER_SUN
|
||||
jr z, .Redundant
|
||||
jr .NotRedundant
|
||||
|
||||
.DreamEater: ; 2c524
|
||||
ld a, [BattleMonStatus]
|
||||
and SLP
|
||||
jr z, .Redundant
|
||||
jr .NotRedundant
|
||||
|
||||
.Swagger: ; 2c52d
|
||||
ld a, [PlayerSubStatus3]
|
||||
bit SUBSTATUS_CONFUSED, a
|
||||
ret
|
||||
|
||||
.FutureSight: ; 2c533
|
||||
ld a, [EnemyScreens]
|
||||
bit 5, a
|
||||
ret
|
||||
|
||||
.Heal:
|
||||
.MorningSun:
|
||||
.Synthesis:
|
||||
.Moonlight: ; 2c539
|
||||
farcall AICheckEnemyMaxHP
|
||||
jr nc, .NotRedundant
|
||||
|
||||
.Teleport:
|
||||
.Redundant: ; 2c541
|
||||
ld a, 1
|
||||
and a
|
||||
ret
|
||||
|
||||
.NotRedundant: ; 2c545
|
||||
xor a
|
||||
ret
|
||||
3598
engine/battle/ai/scoring.asm
Normal file
3598
engine/battle/ai/scoring.asm
Normal file
File diff suppressed because it is too large
Load Diff
672
engine/battle/ai/switch.asm
Executable file
672
engine/battle/ai/switch.asm
Executable file
File diff suppressed because it is too large
Load Diff
9511
engine/battle/core.asm
Normal file
9511
engine/battle/core.asm
Normal file
File diff suppressed because it is too large
Load Diff
10066
engine/battle/effect_commands.asm
Normal file
10066
engine/battle/effect_commands.asm
Normal file
File diff suppressed because it is too large
Load Diff
79
engine/battle/effect_commands/attract.asm
Executable file
79
engine/battle/effect_commands/attract.asm
Executable file
@@ -0,0 +1,79 @@
|
||||
BattleCommand_Attract: ; 377ce
|
||||
; attract
|
||||
ld a, [AttackMissed]
|
||||
and a
|
||||
jr nz, .failed
|
||||
call CheckOppositeGender
|
||||
jr c, .failed
|
||||
call CheckHiddenOpponent
|
||||
jr nz, .failed
|
||||
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
||||
call GetBattleVarAddr
|
||||
bit SUBSTATUS_IN_LOVE, [hl]
|
||||
jr nz, .failed
|
||||
|
||||
set SUBSTATUS_IN_LOVE, [hl]
|
||||
call AnimateCurrentMove
|
||||
|
||||
; 'fell in love!'
|
||||
ld hl, FellInLoveText
|
||||
jp StdBattleTextBox
|
||||
|
||||
.failed
|
||||
jp FailAttract
|
||||
; 377f5
|
||||
|
||||
|
||||
CheckOppositeGender: ; 377f5
|
||||
ld a, MON_SPECIES
|
||||
call BattlePartyAttr
|
||||
ld a, [hl]
|
||||
ld [CurPartySpecies], a
|
||||
|
||||
ld a, [CurBattleMon]
|
||||
ld [CurPartyMon], a
|
||||
xor a
|
||||
ld [MonType], a
|
||||
|
||||
farcall GetGender
|
||||
jr c, .genderless_samegender
|
||||
|
||||
ld b, 1
|
||||
jr nz, .got_gender
|
||||
dec b
|
||||
|
||||
.got_gender
|
||||
push bc
|
||||
ld a, [TempEnemyMonSpecies]
|
||||
ld [CurPartySpecies], a
|
||||
ld hl, EnemyMonDVs
|
||||
ld a, [EnemySubStatus5]
|
||||
bit SUBSTATUS_TRANSFORMED, a
|
||||
jr z, .not_transformed
|
||||
ld hl, wEnemyBackupDVs
|
||||
.not_transformed
|
||||
ld a, [hli]
|
||||
ld [TempMonDVs], a
|
||||
ld a, [hl]
|
||||
ld [TempMonDVs + 1], a
|
||||
ld a, 3
|
||||
ld [MonType], a
|
||||
farcall GetGender
|
||||
pop bc
|
||||
jr c, .genderless_samegender
|
||||
|
||||
ld a, 1
|
||||
jr nz, .got_enemy_gender
|
||||
dec a
|
||||
|
||||
.got_enemy_gender
|
||||
xor b
|
||||
jr z, .genderless_samegender
|
||||
|
||||
and a
|
||||
ret
|
||||
|
||||
.genderless_samegender
|
||||
scf
|
||||
ret
|
||||
; 3784b
|
||||
97
engine/battle/effect_commands/curse.asm
Normal file
97
engine/battle/effect_commands/curse.asm
Normal file
@@ -0,0 +1,97 @@
|
||||
BattleCommand_Curse: ; 37588
|
||||
; curse
|
||||
|
||||
ld de, BattleMonType1
|
||||
ld bc, PlayerStatLevels
|
||||
ld a, [hBattleTurn]
|
||||
and a
|
||||
jr z, .go
|
||||
ld de, EnemyMonType1
|
||||
ld bc, EnemyStatLevels
|
||||
|
||||
.go
|
||||
|
||||
; Curse is different for Ghost-types.
|
||||
|
||||
ld a, [de]
|
||||
cp GHOST
|
||||
jr z, .ghost
|
||||
inc de
|
||||
ld a, [de]
|
||||
cp GHOST
|
||||
jr z, .ghost
|
||||
|
||||
|
||||
; If no stats can be increased, don't.
|
||||
|
||||
; Attack
|
||||
ld a, [bc]
|
||||
cp MAX_STAT_LEVEL
|
||||
jr c, .raise
|
||||
|
||||
; Defense
|
||||
inc bc
|
||||
ld a, [bc]
|
||||
cp MAX_STAT_LEVEL
|
||||
jr nc, .cantraise
|
||||
|
||||
.raise
|
||||
|
||||
; Raise Attack and Defense, and lower Speed.
|
||||
|
||||
ld a, $1
|
||||
ld [wKickCounter], a
|
||||
call AnimateCurrentMove
|
||||
ld a, SPEED
|
||||
call LowerStat
|
||||
call BattleCommand_SwitchTurn
|
||||
call BattleCommand_StatDownMessage
|
||||
call ResetMiss
|
||||
call BattleCommand_SwitchTurn
|
||||
call BattleCommand_AttackUp
|
||||
call BattleCommand_StatUpMessage
|
||||
call ResetMiss
|
||||
call BattleCommand_DefenseUp
|
||||
jp BattleCommand_StatUpMessage
|
||||
|
||||
|
||||
.ghost
|
||||
|
||||
; Cut HP in half and put a curse on the opponent.
|
||||
|
||||
call CheckHiddenOpponent
|
||||
jr nz, .failed
|
||||
|
||||
call CheckSubstituteOpp
|
||||
jr nz, .failed
|
||||
|
||||
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
||||
call GetBattleVarAddr
|
||||
bit SUBSTATUS_CURSE, [hl]
|
||||
jr nz, .failed
|
||||
|
||||
set SUBSTATUS_CURSE, [hl]
|
||||
call AnimateCurrentMove
|
||||
ld hl, GetHalfMaxHP
|
||||
call CallBattleCore
|
||||
ld hl, SubtractHPFromUser
|
||||
call CallBattleCore
|
||||
call UpdateUserInParty
|
||||
ld hl, PutACurseText
|
||||
jp StdBattleTextBox
|
||||
|
||||
.failed
|
||||
call AnimateFailedMove
|
||||
jp PrintButItFailed
|
||||
|
||||
|
||||
.cantraise
|
||||
|
||||
; Can't raise either stat.
|
||||
|
||||
ld b, ABILITY + 1
|
||||
call GetStatName
|
||||
call AnimateFailedMove
|
||||
ld hl, WontRiseAnymoreText
|
||||
jp StdBattleTextBox
|
||||
; 37618
|
||||
17
engine/battle/effect_commands/endure.asm
Normal file
17
engine/battle/effect_commands/endure.asm
Normal file
@@ -0,0 +1,17 @@
|
||||
BattleCommand_Endure: ; 3766f
|
||||
; endure
|
||||
|
||||
; Endure shares code with Protect. See protect.asm.
|
||||
|
||||
call ProtectChance
|
||||
ret c
|
||||
|
||||
ld a, BATTLE_VARS_SUBSTATUS1
|
||||
call GetBattleVarAddr
|
||||
set SUBSTATUS_ENDURE, [hl]
|
||||
|
||||
call AnimateCurrentMove
|
||||
|
||||
ld hl, BracedItselfText
|
||||
jp StdBattleTextBox
|
||||
; 37683
|
||||
23
engine/battle/effect_commands/foresight.asm
Normal file
23
engine/battle/effect_commands/foresight.asm
Normal file
@@ -0,0 +1,23 @@
|
||||
BattleCommand_Foresight: ; 376a0
|
||||
; foresight
|
||||
|
||||
ld a, [AttackMissed]
|
||||
and a
|
||||
jr nz, .failed
|
||||
|
||||
call CheckHiddenOpponent
|
||||
jr nz, .failed
|
||||
|
||||
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
||||
call GetBattleVarAddr
|
||||
bit SUBSTATUS_IDENTIFIED, [hl]
|
||||
jr nz, .failed
|
||||
|
||||
set SUBSTATUS_IDENTIFIED, [hl]
|
||||
call AnimateCurrentMove
|
||||
ld hl, IdentifiedText
|
||||
jp StdBattleTextBox
|
||||
|
||||
.failed
|
||||
jp FailForesight
|
||||
; 376c2
|
||||
61
engine/battle/effect_commands/metronome.asm
Normal file
61
engine/battle/effect_commands/metronome.asm
Normal file
@@ -0,0 +1,61 @@
|
||||
BattleCommand_Metronome: ; 37418
|
||||
; metronome
|
||||
|
||||
call ClearLastMove
|
||||
call CheckUserIsCharging
|
||||
jr nz, .asm_3742b
|
||||
|
||||
ld a, [wKickCounter]
|
||||
push af
|
||||
call BattleCommand_LowerSub
|
||||
pop af
|
||||
ld [wKickCounter], a
|
||||
|
||||
.asm_3742b
|
||||
call LoadMoveAnim
|
||||
|
||||
.GetMove:
|
||||
call BattleRandom
|
||||
|
||||
; No invalid moves.
|
||||
cp NUM_ATTACKS + 1
|
||||
jr nc, .GetMove
|
||||
|
||||
; None of the moves in MetronomeExcepts.
|
||||
push af
|
||||
ld de, 1
|
||||
ld hl, MetronomeExcepts
|
||||
call IsInArray
|
||||
pop bc
|
||||
jr c, .GetMove
|
||||
|
||||
; No moves the user already has.
|
||||
ld a, b
|
||||
call CheckUserMove
|
||||
jr z, .GetMove
|
||||
|
||||
|
||||
ld a, BATTLE_VARS_MOVE
|
||||
call GetBattleVarAddr
|
||||
ld [hl], b
|
||||
call UpdateMoveData
|
||||
jp ResetTurn
|
||||
; 37454
|
||||
|
||||
|
||||
MetronomeExcepts: ; 37454
|
||||
db NO_MOVE
|
||||
db METRONOME
|
||||
db STRUGGLE
|
||||
db SKETCH
|
||||
db MIMIC
|
||||
db COUNTER
|
||||
db MIRROR_COAT
|
||||
db PROTECT
|
||||
db DETECT
|
||||
db ENDURE
|
||||
db DESTINY_BOND
|
||||
db SLEEP_TALK
|
||||
db THIEF
|
||||
db -1
|
||||
; 37462
|
||||
52
engine/battle/effect_commands/mirror_move.asm
Normal file
52
engine/battle/effect_commands/mirror_move.asm
Normal file
@@ -0,0 +1,52 @@
|
||||
BattleCommand_MirrorMove: ; 373c9
|
||||
; mirrormove
|
||||
|
||||
call ClearLastMove
|
||||
|
||||
ld a, BATTLE_VARS_MOVE
|
||||
call GetBattleVarAddr
|
||||
|
||||
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
||||
call GetBattleVar
|
||||
and a
|
||||
jr z, .failed
|
||||
|
||||
call CheckUserMove
|
||||
jr nz, .use
|
||||
|
||||
.failed
|
||||
call AnimateFailedMove
|
||||
|
||||
ld hl, MirrorMoveFailedText
|
||||
call StdBattleTextBox
|
||||
jp EndMoveEffect
|
||||
|
||||
.use
|
||||
ld a, b
|
||||
ld [hl], a
|
||||
ld [wd265], a
|
||||
|
||||
push af
|
||||
ld a, BATTLE_VARS_MOVE_ANIM
|
||||
call GetBattleVarAddr
|
||||
ld d, h
|
||||
ld e, l
|
||||
pop af
|
||||
|
||||
dec a
|
||||
call GetMoveData
|
||||
call GetMoveName
|
||||
call CopyName1
|
||||
call CheckUserIsCharging
|
||||
jr nz, .done
|
||||
|
||||
ld a, [wKickCounter]
|
||||
push af
|
||||
call BattleCommand_LowerSub
|
||||
pop af
|
||||
ld [wKickCounter], a
|
||||
|
||||
.done
|
||||
call BattleCommand_MoveDelay
|
||||
jp ResetTurn
|
||||
; 37418
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user