Merge remote-tracking branch 'xcrystal/master' into master
Conflicts: battle/ai/scoring.asm main.asm
This commit is contained in:
38
main.asm
38
main.asm
@@ -41695,6 +41695,8 @@ TrainerClassNames:: ; 2c1ef
|
||||
|
||||
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
|
||||
@@ -47162,7 +47164,7 @@ AIChooseMove: ; 440ce
|
||||
|
||||
ld a, c
|
||||
cp 16 ; up to 16 scoring layers
|
||||
jr z, .asm_4415e
|
||||
jr z, .DecrementScores
|
||||
|
||||
push bc
|
||||
ld d, BANK(TrainerClassAttributes)
|
||||
@@ -47191,28 +47193,36 @@ AIChooseMove: ; 440ce
|
||||
|
||||
jr .CheckLayer
|
||||
|
||||
.asm_4415e
|
||||
; Decrement the scores of all moves one by one until one reaches 0.
|
||||
.DecrementScores
|
||||
ld hl, Buffer1
|
||||
ld de, EnemyMonMoves
|
||||
ld c, EnemyMonMovesEnd - EnemyMonMoves
|
||||
.asm_44166
|
||||
|
||||
.DecrementNextScore
|
||||
; If the enemy has no moves, this will infinite.
|
||||
ld a, [de]
|
||||
inc de
|
||||
and a
|
||||
jr z, .asm_4415e
|
||||
jr z, .DecrementScores
|
||||
|
||||
; We are done whenever a score reaches 0
|
||||
dec [hl]
|
||||
jr z, .asm_44174
|
||||
jr z, .PickLowestScoreMoves
|
||||
|
||||
; If we just decremented the fourth move's score, go back to the first move
|
||||
inc hl
|
||||
dec c
|
||||
jr z, .asm_4415e
|
||||
jr z, .DecrementScores
|
||||
|
||||
jr .asm_44166
|
||||
jr .DecrementNextScore
|
||||
|
||||
.asm_44174
|
||||
; 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
|
||||
|
||||
.asm_44175
|
||||
inc [hl]
|
||||
dec hl
|
||||
@@ -47223,11 +47233,15 @@ AIChooseMove: ; 440ce
|
||||
ld hl, Buffer1
|
||||
ld de, EnemyMonMoves
|
||||
ld c, NUM_MOVES
|
||||
|
||||
; Give a score of 0 to a blank move
|
||||
.asm_44184
|
||||
ld a, [de]
|
||||
and a
|
||||
jr nz, .asm_44189
|
||||
ld [hl], a
|
||||
ld [hl], a
|
||||
|
||||
; Disregard the move if its score is not 1
|
||||
.asm_44189
|
||||
ld a, [hl]
|
||||
dec a
|
||||
@@ -47235,6 +47249,7 @@ AIChooseMove: ; 440ce
|
||||
xor a
|
||||
ld [hli], a
|
||||
jr .asm_44193
|
||||
|
||||
.asm_44191
|
||||
ld a, [de]
|
||||
ld [hli], a
|
||||
@@ -47243,7 +47258,8 @@ AIChooseMove: ; 440ce
|
||||
dec c
|
||||
jr nz, .asm_44184
|
||||
|
||||
.asm_44197
|
||||
; Randomly choose one of the moves with a score of 1
|
||||
.ChooseMove
|
||||
ld hl, Buffer1
|
||||
call Random
|
||||
and 3
|
||||
@@ -47252,7 +47268,7 @@ AIChooseMove: ; 440ce
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .asm_44197
|
||||
jr z, .ChooseMove
|
||||
|
||||
ld [CurEnemyMove], a
|
||||
ld a, c
|
||||
|
Reference in New Issue
Block a user