Advertisement
IdainTV

AI_Status, Substitute check

May 16th, 2021 (edited)
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AI_Status:
  2. ; Dismiss status moves that don't affect the player.
  3.  
  4.     ld hl, wEnemyAIMoveScores - 1
  5.     ld de, wEnemyMonMoves
  6.     ld b, NUM_MOVES + 1
  7. .checkmove
  8.     dec b
  9.     ret z
  10.  
  11.     ld c, 0 ; Cleaning register c.
  12.     inc hl
  13.     ld a, [de]
  14.     and a
  15.     ret z
  16.  
  17.     inc de
  18.     call AIGetEnemyMove
  19.  
  20.     ld a, [wEnemyMoveStruct + MOVE_EFFECT]
  21.     cp EFFECT_TOXIC
  22.     jr z, .poisonimmunity
  23.     cp EFFECT_POISON
  24.     jr z, .poisonimmunity
  25.     cp EFFECT_SLEEP
  26.     jr z, .typeimmunity
  27.     cp EFFECT_PARALYZE
  28.     jr z, .typeimmunity
  29.  
  30. ; Discourage moves that inflict status ailments, confuse or lower stats
  31. ; against a subtitute.
  32. ; This check also applies for both Leech Seed and Swagger.
  33.     cp EFFECT_LEECH_SEED
  34.     jr z, .subs_check  
  35.     cp EFFECT_SWAGGER
  36.     jr z, .subs_check
  37.     cp EFFECT_CONFUSE
  38.     jr z, .subs_check
  39.  
  40. ; Stat-lowering moves
  41.     cp EFFECT_ATTACK_DOWN
  42.     jr c, .powercheck
  43.     cp EFFECT_EVASION_DOWN + 1
  44.     jr c, .subs_check
  45.  
  46.     cp EFFECT_ATTACK_DOWN_2
  47.     jr c, .powercheck
  48.     cp EFFECT_EVASION_DOWN_2 + 1
  49.     jr c, .subs_check
  50.  
  51. .powercheck
  52.     ld a, [wEnemyMoveStruct + MOVE_POWER]
  53.     and a
  54.     ld c, a ; Store Move's Power in c.
  55.     jr z, .checkmove
  56.  
  57.     jr .typeimmunity
  58.  
  59. .poisonimmunity
  60.     ld a, [wBattleMonType1]
  61.     cp POISON
  62.     jr z, .immune
  63.     ld a, [wBattleMonType2]
  64.     cp POISON
  65.     jr z, .immune
  66.  
  67. .typeimmunity
  68.     push hl
  69.     push bc
  70.     push de
  71.     ld a, 1
  72.     ldh [hBattleTurn], a
  73.     callfar BattleCheckTypeMatchup
  74.     pop de
  75.     pop bc
  76.     pop hl
  77.  
  78.     ld a, [wTypeMatchup]
  79.     and a
  80.     jr z, .immune
  81.  
  82.     ; fallthrough
  83.  
  84. ; ** Substitute check goes here **
  85. .subs_check
  86.     ld a, BATTLE_VARS_SUBSTATUS4_OPP
  87.     call GetBattleVar
  88.     bit SUBSTATUS_SUBSTITUTE, a
  89.     jp z, .checkmove
  90.  
  91.     ld a, c ; Load Move's Power back into a.
  92.     and a
  93.     jp nz, .checkmove
  94.  
  95. .immune
  96.     call AIDiscourageMove
  97.     jp .checkmove
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement