pokecrystal/engine/battle/ai/redundant.asm

199 lines
3.4 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
AI_Redundant:
2015-12-13 19:15:16 +00:00
; 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
2015-12-13 19:15:16 +00:00
2018-06-24 14:09:41 +00:00
.Moves:
2015-12-13 19:15:16 +00:00
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
2018-06-24 14:09:41 +00:00
.LightScreen:
2018-01-23 22:39:09 +00:00
ld a, [wEnemyScreens]
2015-12-13 19:15:16 +00:00
bit SCREENS_LIGHT_SCREEN, a
ret
2018-06-24 14:09:41 +00:00
.Mist:
2018-01-23 22:39:09 +00:00
ld a, [wEnemySubStatus4]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_MIST, a
ret
2018-06-24 14:09:41 +00:00
.FocusEnergy:
2018-01-23 22:39:09 +00:00
ld a, [wEnemySubStatus4]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_FOCUS_ENERGY, a
ret
2018-06-24 14:09:41 +00:00
.Confuse:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus3]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_CONFUSED, a
ret nz
2018-01-23 22:39:09 +00:00
ld a, [wPlayerScreens]
2015-12-13 19:15:16 +00:00
bit SCREENS_SAFEGUARD, a
ret
2018-06-24 14:09:41 +00:00
.Transform:
2018-01-23 22:39:09 +00:00
ld a, [wEnemySubStatus5]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_TRANSFORMED, a
ret
2018-06-24 14:09:41 +00:00
.Reflect:
2018-01-23 22:39:09 +00:00
ld a, [wEnemyScreens]
2015-12-13 19:15:16 +00:00
bit SCREENS_REFLECT, a
ret
2018-06-24 14:09:41 +00:00
.Substitute:
2018-01-23 22:39:09 +00:00
ld a, [wEnemySubStatus4]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_SUBSTITUTE, a
ret
2018-06-24 14:09:41 +00:00
.LeechSeed:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus4]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_LEECH_SEED, a
ret
2018-06-24 14:09:41 +00:00
.Disable:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerDisableCount]
2015-12-13 19:15:16 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
.Encore:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus5]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_ENCORED, a
ret
.Snore:
2018-06-24 14:09:41 +00:00
.SleepTalk:
2018-01-23 22:39:09 +00:00
ld a, [wEnemyMonStatus]
2015-12-13 19:15:16 +00:00
and SLP
jr z, .Redundant
jr .NotRedundant
2018-06-24 14:09:41 +00:00
.MeanLook:
2018-01-23 22:39:09 +00:00
ld a, [wEnemySubStatus5]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_CANT_RUN, a
ret
2018-06-24 14:09:41 +00:00
.Nightmare:
2018-01-23 22:39:09 +00:00
ld a, [wBattleMonStatus]
2015-12-13 19:15:16 +00:00
and a
jr z, .Redundant
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus1]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_NIGHTMARE, a
ret
2018-06-24 14:09:41 +00:00
.Spikes:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerScreens]
2015-12-13 19:15:16 +00:00
bit SCREENS_SPIKES, a
ret
2018-06-24 14:09:41 +00:00
.Foresight:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus1]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_IDENTIFIED, a
ret
2018-06-24 14:09:41 +00:00
.PerishSong:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus1]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_PERISH, a
ret
2018-06-24 14:09:41 +00:00
.Sandstorm:
ld a, [wBattleWeather]
2015-12-13 19:15:16 +00:00
cp WEATHER_SANDSTORM
jr z, .Redundant
jr .NotRedundant
2018-06-24 14:09:41 +00:00
.Attract:
2017-12-24 17:47:30 +00:00
farcall CheckOppositeGender
2015-12-13 19:15:16 +00:00
jr c, .Redundant
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus1]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_IN_LOVE, a
ret
2018-06-24 14:09:41 +00:00
.Safeguard:
2018-01-23 22:39:09 +00:00
ld a, [wEnemyScreens]
2015-12-13 19:15:16 +00:00
bit SCREENS_SAFEGUARD, a
ret
2018-06-24 14:09:41 +00:00
.RainDance:
ld a, [wBattleWeather]
2015-12-13 19:15:16 +00:00
cp WEATHER_RAIN
jr z, .Redundant
jr .NotRedundant
2018-06-24 14:09:41 +00:00
.SunnyDay:
ld a, [wBattleWeather]
2015-12-13 19:15:16 +00:00
cp WEATHER_SUN
jr z, .Redundant
jr .NotRedundant
2018-06-24 14:09:41 +00:00
.DreamEater:
2018-01-23 22:39:09 +00:00
ld a, [wBattleMonStatus]
2015-12-13 19:15:16 +00:00
and SLP
jr z, .Redundant
jr .NotRedundant
2018-06-24 14:09:41 +00:00
.Swagger:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerSubStatus3]
2015-12-13 19:15:16 +00:00
bit SUBSTATUS_CONFUSED, a
ret
2018-06-24 14:09:41 +00:00
.FutureSight:
2018-01-23 22:39:09 +00:00
ld a, [wEnemyScreens]
2015-12-13 19:15:16 +00:00
bit 5, a
ret
.Heal:
.MorningSun:
.Synthesis:
2018-06-24 14:09:41 +00:00
.Moonlight:
2017-12-24 17:47:30 +00:00
farcall AICheckEnemyMaxHP
2015-12-13 19:15:16 +00:00
jr nc, .NotRedundant
.Teleport:
2018-06-24 14:09:41 +00:00
.Redundant:
2015-12-13 19:15:16 +00:00
ld a, 1
and a
ret
2018-06-24 14:09:41 +00:00
.NotRedundant:
2015-12-13 19:15:16 +00:00
xor a
ret