summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/battle/ai/scoring.asm61
-rw-r--r--engine/battle/core.asm2
-rw-r--r--engine/events/happiness_egg.asm2
-rw-r--r--engine/events/pokerus/pokerus.asm30
-rw-r--r--engine/games/slot_machine.asm42
-rw-r--r--engine/link/mystery_gift_2.asm2
6 files changed, 70 insertions, 69 deletions
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index 75efcf920..d0d17cc0d 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -1,5 +1,6 @@
AIScoring: ; used only for BANK(AIScoring)
+
AI_Basic:
; Don't do anything redundant:
; -Using status-only moves if the player can't be statused
@@ -458,15 +459,15 @@ AI_Smart_LockOn:
.asm_38834
ld a, [wPlayerEvaLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr nc, .asm_3887a
- cp $8
+ cp BASE_STAT_LEVEL + 1
jr nc, .asm_38875
ld a, [wEnemyAccLevel]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_3887a
- cp $7
+ cp BASE_STAT_LEVEL
jr c, .asm_38875
ld hl, wEnemyMonMoves
@@ -572,7 +573,7 @@ AI_Smart_Selfdestruct:
; If enemy's HP is between 25% and 50%,
; over 90% chance to greatly discourage this move.
call Random
- cp 9 percent - 2
+ cp 8 percent
ret c
.asm_388c6
@@ -596,7 +597,7 @@ AI_Smart_DreamEater:
AI_Smart_EvasionUp:
; Dismiss this move if enemy's evasion can't raise anymore.
ld a, [wEnemyEvaLevel]
- cp $d
+ cp MAX_STAT_LEVEL
jp nc, AIDiscourageMove
; If enemy's HP is full...
@@ -707,12 +708,12 @@ AI_Smart_AlwaysHit:
; ...enemy's accuracy level has been lowered three or more stages
ld a, [wEnemyAccLevel]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_38954
; ...or player's evasion level has been raised three or more stages.
ld a, [wPlayerEvaLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
ret c
.asm_38954
@@ -872,12 +873,12 @@ AI_Smart_ResetStats:
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
push hl
ld hl, wEnemyAtkLevel
- ld c, $8
+ ld c, NUM_LEVEL_STATS
.asm_389fb
dec c
jr z, .asm_38a05
ld a, [hli]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_38a12
jr .asm_389fb
@@ -889,7 +890,7 @@ AI_Smart_ResetStats:
dec c
jr z, .asm_38a1b
ld a, [hli]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr c, .asm_38a0a
.asm_38a12
@@ -1108,12 +1109,12 @@ AI_Smart_SpDefenseUp2:
; Discourage this move if enemy's special defense level is higher than +3.
ld a, [wEnemySDefLevel]
- cp $b
+ cp BASE_STAT_LEVEL + 4
jr nc, .asm_38b10
; 80% chance to greatly encourage this move if
; enemy's Special Defense level is lower than +2, and the player is of a special type.
- cp $9
+ cp BASE_STAT_LEVEL + 2
ret nc
ld a, [wBattleMonType1]
@@ -1252,11 +1253,11 @@ AI_Smart_Rage:
; Encourage this move based on Rage's counter.
.asm_38b8c
ld a, [wEnemyRageCounter]
- cp $2
+ cp 2
ret c
dec [hl]
ld a, [wEnemyRageCounter]
- cp $3
+ cp 3
ret c
dec [hl]
ret
@@ -1328,7 +1329,7 @@ AI_Smart_Mimic:
AI_Smart_Counter:
push hl
ld hl, wPlayerUsedMoves
- ld c, 4
+ ld c, NUM_MOVES
ld b, 0
.asm_38bf9
@@ -1467,8 +1468,8 @@ AI_Smart_SleepTalk:
; Greatly discourage this move otherwise.
ld a, [wEnemyMonStatus]
- and $7
- cp $1
+ and SLP
+ cp 1
jr z, .asm_38cc7
dec [hl]
@@ -1529,9 +1530,9 @@ AI_Smart_Spite:
.asm_38cfb
pop hl
ld a, [de]
- cp $6
+ cp 6
jr c, .asm_38d0d
- cp $f
+ cp 15
jr nc, .asm_38d0b
call Random
@@ -1828,9 +1829,9 @@ AI_Smart_Curse:
jr nc, .asm_38e93
ld a, [wEnemyAtkLevel]
- cp $b
+ cp BASE_STAT_LEVEL + 4
jr nc, .asm_38e93
- cp $9
+ cp BASE_STAT_LEVEL + 2
ret nc
ld a, [wBattleMonType1]
@@ -1954,10 +1955,10 @@ AI_Smart_Protect:
AI_Smart_Foresight:
ld a, [wEnemyAccLevel]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_38f41
ld a, [wPlayerEvaLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr nc, .asm_38f41
ld a, [wBattleMonType1]
@@ -2417,7 +2418,7 @@ AI_Smart_BellyDrum:
; Else, discourage this move if enemy's HP is not full.
ld a, [wEnemyAtkLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr nc, .asm_3914d
call AICheckEnemyMaxHP
@@ -2472,12 +2473,12 @@ AI_Smart_PsychUp:
; Else, 80% chance to encourage this move unless player's accuracy level is lower than -1...
ld a, [wPlayerAccLevel]
- cp $6
+ cp BASE_STAT_LEVEL - 1
ret c
; ...or enemy's evasion level is higher than +0.
ld a, [wEnemyEvaLevel]
- cp $8
+ cp BASE_STAT_LEVEL + 1
ret nc
call AI_80_20
@@ -2494,8 +2495,8 @@ AI_Smart_PsychUp:
AI_Smart_MirrorCoat:
push hl
ld hl, wPlayerUsedMoves
- ld c, $4
- ld b, $0
+ ld c, NUM_MOVES
+ ld b, 0
.asm_39193
ld a, [hli]
@@ -2828,7 +2829,7 @@ AIHasMoveInArray:
.next
ld a, [hli]
- cp $ff
+ cp -1
jr z, .done
ld b, a
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4d561c7ae..d51e4cdd5 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6200,7 +6200,7 @@ LoadEnemyMon:
jr z, .Happiness
; 40% chance of not flooring
call Random
- cp 40 percent - 2
+ cp 39 percent + 1
jr c, .Happiness
; Try again if length < 1024 mm (i.e. if HIGH(length) < 3 feet)
ld a, [wMagikarpLength]
diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm
index 1d33edb74..bb2e949cb 100644
--- a/engine/events/happiness_egg.asm
+++ b/engine/events/happiness_egg.asm
@@ -198,7 +198,7 @@ DayCareStep::
callfar CheckBreedmonCompatibility
ld a, [wBreedingCompatibility]
cp 230
- ld b, 32 percent - 1
+ ld b, 31 percent + 1
jr nc, .okay
ld a, [wBreedingCompatibility]
cp 170
diff --git a/engine/events/pokerus/pokerus.asm b/engine/events/pokerus/pokerus.asm
index 63eb7fe10..99a5652cd 100644
--- a/engine/events/pokerus/pokerus.asm
+++ b/engine/events/pokerus/pokerus.asm
@@ -26,8 +26,8 @@ GivePokerusAndConvertBerries:
and a
ret nz
ldh a, [hRandomSub]
- cp $3
- ret nc ; 3/65536 chance (00 00, 00 01 or 00 02)
+ cp 3
+ ret nc ; 3/65536 chance (00 00, 00 01 or 00 02)
ld a, [wPartyCount]
ld b, a
.randomMonSelectLoop
@@ -36,11 +36,11 @@ GivePokerusAndConvertBerries:
cp b
jr nc, .randomMonSelectLoop
ld hl, wPartyMon1PokerusStatus
- call GetPartyLocation ; get pokerus byte of random mon
+ call GetPartyLocation ; get pokerus byte of random mon
ld a, [hl]
and $f0
- ret nz ; if it already has pokerus, do nothing
-.randomPokerusLoop ; Simultaneously sample the strain and duration
+ ret nz ; if it already has pokerus, do nothing
+.randomPokerusLoop ; Simultaneously sample the strain and duration
call Random
and a
jr z, .randomPokerusLoop
@@ -62,20 +62,20 @@ GivePokerusAndConvertBerries:
.TrySpreadPokerus:
call Random
cp 33 percent + 1
- ret nc ; 1/3 chance
+ ret nc ; 1/3 chance
ld a, [wPartyCount]
cp 1
- ret z ; only one mon, nothing to do
+ ret z ; only one mon, nothing to do
ld c, [hl]
ld a, b
cp 2
- jr c, .checkPreviousMonsLoop ; no more mons after this one, go backwards
+ jr c, .checkPreviousMonsLoop ; no more mons after this one, go backwards
call Random
cp 50 percent + 1
- jr c, .checkPreviousMonsLoop ; 1/2 chance, go backwards
+ jr c, .checkPreviousMonsLoop ; 1/2 chance, go backwards
.checkFollowingMonsLoop
add hl, de
ld a, [hl]
@@ -83,8 +83,8 @@ GivePokerusAndConvertBerries:
jr z, .infectMon
ld c, a
and $3
- ret z ; if mon has cured pokerus, stop searching
- dec b ; go on to next mon
+ ret z ; if mon has cured pokerus, stop searching
+ dec b ; go on to next mon
ld a, b
cp 1
jr nz, .checkFollowingMonsLoop ; no more mons left
@@ -93,7 +93,7 @@ GivePokerusAndConvertBerries:
.checkPreviousMonsLoop
ld a, [wPartyCount]
cp b
- ret z ; no more mons
+ ret z ; no more mons
ld a, l
sub e
ld l, a
@@ -105,8 +105,8 @@ GivePokerusAndConvertBerries:
jr z, .infectMon
ld c, a
and $3
- ret z ; if mon has cured pokerus, stop searching
- inc b ; go on to next mon
+ ret z ; if mon has cured pokerus, stop searching
+ inc b ; go on to next mon
jr .checkPreviousMonsLoop
.infectMon
@@ -128,7 +128,7 @@ ConvertBerriesToBerryJuice:
bit STATUSFLAGS2_REACHED_GOLDENROD_F, [hl]
ret z
call Random
- cp 6 percent + 1 ; 1/16 chance
+ cp 1 out_of 16 ; 6.25% chance
ret nc
ld hl, wPartyMons
ld a, [wPartyCount]
diff --git a/engine/games/slot_machine.asm b/engine/games/slot_machine.asm
index eaf7999bd..30f6c45af 100644
--- a/engine/games/slot_machine.asm
+++ b/engine/games/slot_machine.asm
@@ -586,7 +586,7 @@ Slots_StopReel2:
call .CheckReel1ForASeven
jr nz, .dont_jump
call Random
- cp $50 ; 32%
+ cp 31 percent + 1
jr nc, .dont_jump
ld a, REEL_ACTION_SET_UP_REEL2_SKIP_TO_7
ret
@@ -632,20 +632,20 @@ Slots_StopReel3:
and a
jr nz, .biased
call Random
- cp 180
+ cp 71 percent - 1
jr nc, .stop
- cp 120
+ cp 47 percent + 1
jr nc, .slow_advance
- cp 60
+ cp 24 percent - 1
jr nc, .golem
ld a, REEL_ACTION_INIT_CHANSEY
ret
.biased
call Random
- cp 160
+ cp 63 percent
jr nc, .stop
- cp 80
+ cp 31 percent + 1
jr nc, .slow_advance
.golem
ld a, REEL_ACTION_INIT_GOLEM
@@ -1608,7 +1608,7 @@ Slots_GetNumberOfGolems:
.not_biased_to_seven
call Random
and $7
- cp $4 ; ((50 percent) & 7) + 1
+ cp $8 / 2 ; 50%
jr c, .not_biased_to_seven
ld e, a
.loop2
@@ -1649,22 +1649,22 @@ Slots_InitBias:
ret
.Normal:
- db $01, SLOTS_SEVEN ; 1/256
- db $03, SLOTS_POKEBALL ; 1/128
- db $0a, SLOTS_STARYU ; 7/256
- db $14, SLOTS_SQUIRTLE ; 5/128
- db $28, SLOTS_PIKACHU ; 5/64
- db $30, SLOTS_CHERRY ; 1/32
- db $ff, SLOTS_NO_BIAS ; everything else
+ db 1 percent - 1, SLOTS_SEVEN
+ db 1 percent + 1, SLOTS_POKEBALL
+ db 4 percent, SLOTS_STARYU
+ db 8 percent, SLOTS_SQUIRTLE
+ db 16 percent, SLOTS_PIKACHU
+ db 19 percent, SLOTS_CHERRY
+ db 100 percent, SLOTS_NO_BIAS
.Lucky:
- db $02, SLOTS_SEVEN ; 1/128
- db $03, SLOTS_POKEBALL ; 1/256
- db $08, SLOTS_STARYU ; 5/256
- db $10, SLOTS_SQUIRTLE ; 1/32
- db $1e, SLOTS_PIKACHU ; 7/128
- db $50, SLOTS_CHERRY ; 25/128
- db $ff, SLOTS_NO_BIAS ; everything else
+ db 1 percent, SLOTS_SEVEN
+ db 1 percent + 1, SLOTS_POKEBALL
+ db 3 percent + 1, SLOTS_STARYU
+ db 6 percent + 1, SLOTS_SQUIRTLE
+ db 12 percent, SLOTS_PIKACHU
+ db 31 percent + 1, SLOTS_CHERRY
+ db 100 percent, SLOTS_NO_BIAS
Slots_IlluminateBetLights:
ld b, $14 ; turned on
diff --git a/engine/link/mystery_gift_2.asm b/engine/link/mystery_gift_2.asm
index b9c7eccb4..9712c665d 100644
--- a/engine/link/mystery_gift_2.asm
+++ b/engine/link/mystery_gift_2.asm
@@ -80,7 +80,7 @@ PrepMysteryGiftDataToSend:
.tenpercent
call Random
- cp 20 percent - 1
+ cp 20 percent - 1 ; 50
jr c, .twopercent
call Random
and %011