#include "macros/btlcmd.inc"


_000:
    PrintBufferedMessage 
    Wait 
    WaitButtonABTime 30
    CheckMoveHit BTLSCR_MSG_ATTACKER, BTLSCR_MSG_TEMP, BTLSCR_MSG_TEMP, _117
    UpdateVar OPCODE_SET, BTLVAR_MOVE_EFFECT_CHANCE, 1
    PlayMoveAnimationOnMons BTLSCR_MSG_TEMP, BTLSCR_MSG_ATTACKER, BTLSCR_MSG_TEMP
    Wait 
    UpdateVar OPCODE_FLAG_OFF, BTLVAR_BATTLE_CTX_STATUS, SYSCTL_PLAYED_MOVE_ANIMATION
    CompareMonDataToValue OPCODE_FLAG_NOT, BTLSCR_MSG_TEMP, BATTLEMON_VOLATILE_STATUS, VOLATILE_CONDITION_SUBSTITUTE, _058
    UpdateVar OPCODE_MUL, BTLVAR_HP_CALC_TEMP, -1
    CompareMonDataToVar OPCODE_LTE, BTLSCR_MSG_TEMP, BATTLEMON_SUBSTITUTE_HP, BTLVAR_HP_CALC_TEMP, _044
    UpdateMonDataFromVar OPCODE_SUB, BTLSCR_MSG_TEMP, BATTLEMON_SUBSTITUTE_HP, BTLVAR_HP_CALC_TEMP
    GoTo _054

_044:
    UpdateMonData OPCODE_SET, BTLSCR_MSG_TEMP, BATTLEMON_SUBSTITUTE_HP, 0
    UpdateMonData OPCODE_FLAG_OFF, BTLSCR_MSG_TEMP, BATTLEMON_VOLATILE_STATUS, VOLATILE_CONDITION_SUBSTITUTE

_054:
    Call BATTLE_SUBSCRIPT_HIT_SUBSTITUTE
    GoTo _092

_058:
    CheckHoldOnWith1HP BTLSCR_MSG_TEMP
    Call BATTLE_SUBSCRIPT_UPDATE_HP
    CompareMonDataToValue OPCODE_FLAG_NOT, BTLSCR_MSG_TEMP, BATTLEMON_VOLATILE_STATUS, VOLATILE_CONDITION_RAGE, _092
    CompareMonDataToValue OPCODE_EQU, BTLSCR_MSG_TEMP, BATTLEMON_CUR_HP, 0, _092
    CompareMonDataToValue OPCODE_EQU, BTLSCR_MSG_TEMP, BATTLEMON_ATTACK_STAGE, 12, _092
    UpdateMonData OPCODE_ADD, BTLSCR_MSG_TEMP, BATTLEMON_ATTACK_STAGE, 1
    // {0}’s rage is building!
    PrintMessage pl_msg_00000368_00363, TAG_NICKNAME, BTLSCR_MSG_TEMP
    Wait 
    WaitButtonABTime 30

_092:
    CompareVarToValue OPCODE_FLAG_NOT, BTLVAR_MOVE_STATUS_FLAGS, MOVE_STATUS_ENDURED_ITEM, _116
    PlayBattleAnimation BTLSCR_MSG_TEMP, BATTLE_ANIMATION_HELD_ITEM
    Wait 
    // {0} hung on using its {1}!
    PrintMessage pl_msg_00000368_00912, TAG_NICKNAME_ITEM, BTLSCR_MSG_TEMP, BTLSCR_MSG_BATTLER_TEMP
    Wait 
    WaitButtonABTime 30
    CheckItemHoldEffect CHECK_NOT_HAVE, BTLSCR_MSG_TEMP, HOLD_EFFECT_ENDURE, _116
    RemoveItem BTLSCR_MSG_TEMP

_116:
    End 

_117:
    WaitButtonABTime 30
    // But it failed!
    PrintMessage pl_msg_00000368_00796, TAG_NONE
    Wait 
    WaitButtonABTime 30
    End 
