#include "macros/btlcmd.inc"


_000:
    Call BATTLE_SUBSCRIPT_SHOW_PREPARED_MESSAGE
    PlayBattleAnimationFromVar BTLSCR_PLAYER, BTLVAR_SCRIPT_TEMP
    Wait 
    UpdateVar OPCODE_SET, BTLVAR_BATTLER_SPEED_TEMP, 0

_009:
    GetMonBySpeedOrder BTLVAR_MSG_BATTLER_TEMP
    EndOfTurnWeatherEffect BTLSCR_MSG_TEMP
    CompareVarToValue OPCODE_EQU, BTLVAR_SCRIPT_TEMP, 1, _098
    CompareVarToValue OPCODE_EQU, BTLVAR_HP_CALC_TEMP, 0, _090
    CompareVarToValue OPCODE_GT, BTLVAR_HP_CALC_TEMP, 0, _076
    CheckAbility CHECK_HAVE, BTLSCR_MSG_TEMP, ABILITY_MAGIC_GUARD, _090
    CompareVarToValue OPCODE_FLAG_SET, BTLVAR_FIELD_CONDITIONS, FIELD_CONDITION_SUNNY, _045
    // {1} is buffeted by the {0}!
    PrintMessage pl_msg_00000368_00285, TAG_MOVE_NICKNAME, BTLSCR_MSG_TEMP, BTLSCR_MSG_TEMP
    GoTo _062

_045:
    CompareVarToValue OPCODE_EQU, BTLVAR_SCRIPT_TEMP, 2, _057
    // {0} is hurt by its {1}!
    PrintMessage pl_msg_00000368_01090, TAG_NICKNAME_ABILITY, BTLSCR_MSG_TEMP, BTLSCR_MSG_BATTLER_TEMP
    GoTo _062

_057:
    // {0} lost some HP because of its {1}!
    PrintMessage pl_msg_00000368_01096, TAG_NICKNAME_ABILITY, BTLSCR_MSG_TEMP, BTLSCR_MSG_BATTLER_TEMP

_062:
    Wait 
    WaitButtonABTime 30
    Call BATTLE_SUBSCRIPT_UPDATE_HP
    CompareVarToValue OPCODE_FLAG_NOT, BTLVAR_BATTLE_CTX_STATUS, SYSCTL_MON_FAINTED, _090
    Call BATTLE_SUBSCRIPT_FAINT_MON
    GoTo _090

_076:
    UpdateVar OPCODE_FLAG_ON, BTLVAR_BATTLE_CTX_STATUS, SYSCTL_SKIP_SPRITE_BLINK
    Call BATTLE_SUBSCRIPT_UPDATE_HP
    // {0} restored HP using its {1}!
    PrintMessage pl_msg_00000368_00635, TAG_NICKNAME_ABILITY, BTLSCR_MSG_TEMP, BTLSCR_MSG_BATTLER_TEMP
    Wait 
    WaitButtonABTime 30

_090:
    UpdateVar OPCODE_ADD, BTLVAR_BATTLER_SPEED_TEMP, 1
    GoToIfValidMon BTLVAR_BATTLER_SPEED_TEMP, _009
    End 

_098:
    Call BATTLE_SUBSCRIPT_ABILITY_RESTORE_STATUS
    GoTo _090
