diff options
author | yenatch <yenatch@gmail.com> | 2014-12-11 23:25:30 -0800 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2014-12-11 23:25:30 -0800 |
commit | e325210a6108dad76551264d01f811e722d7d1bc (patch) | |
tree | c75f9b9478964c89524192feb2e8b0d8692cabd4 /main.asm | |
parent | 3755584ac4f620566facd9e72c4ae0b9807caf69 (diff) | |
parent | 63afd6dacd4425483a71cf4e6302a2d71829ca2a (diff) |
Merge remote-tracking branch 'kanzure/master'
Diffstat (limited to 'main.asm')
-rw-r--r-- | main.asm | 48 |
1 files changed, 33 insertions, 15 deletions
@@ -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 @@ -59426,11 +59442,13 @@ String_50bb5: ; 50bb5 GetGender: ; 50bdd -; Return the gender of a given monster in a. +; Return the gender of a given monster (CurPartyMon/CurOTMon/CurWildMon). +; When calling this function, a should be set to an appropriate MonType value. -; 1: male -; 0: female -; c: genderless +; return values: +; a = 1: f = nc|nz; male +; a = 0: f = nc|z; female +; f = c: genderless ; This is determined by comparing the Attack and Speed DVs ; with the species' gender ratio. |