mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
handle battler being affected by terrain
This commit is contained in:
parent
4a5a3ea6af
commit
10b1d33d13
@ -1765,6 +1765,12 @@
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
.macro jumpifterrainaffected battler:req, terrainFlags:req, ptr:req
|
||||
various \battler, VARIOUS_JUMP_IF_TERRAIN_AFFECTED
|
||||
.4byte \terrainFlags
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
@ helpful macros
|
||||
.macro setstatchanger stat:req, stages:req, down:req
|
||||
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7
|
||||
|
@ -2134,8 +2134,8 @@ BattleScript_EffectSleep::
|
||||
jumpifleafguard BattleScript_LeafGuardProtects
|
||||
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
|
||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_ELECTRIC_TERRAIN, BattleScript_ElectricTerrainPrevents
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
jumpifterrainaffected BS_TARGET, STATUS_FIELD_ELECTRIC_TERRAIN, BattleScript_ElectricTerrainPrevents
|
||||
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||
jumpifsafeguard BattleScript_SafeguardProtected
|
||||
attackanimation
|
||||
@ -2670,7 +2670,7 @@ BattleScript_EffectToxic::
|
||||
jumpifsubstituteblocks BattleScript_ButItFailed
|
||||
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
|
||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
|
||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||
jumpifsafeguard BattleScript_SafeguardProtected
|
||||
@ -2721,7 +2721,7 @@ BattleScript_EffectRest::
|
||||
attackcanceler
|
||||
attackstring
|
||||
ppreduce
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, (STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_MISTY_TERRAIN), BattleScript_ButItFailed
|
||||
jumpifterrainaffected BS_ATTACKER, (STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_MISTY_TERRAIN), BattleScript_ButItFailed
|
||||
jumpifstatus BS_ATTACKER, STATUS1_SLEEP, BattleScript_RestIsAlreadyAsleep
|
||||
jumpifability BS_ATTACKER, ABILITY_COMATOSE, BattleScript_RestIsAlreadyAsleep
|
||||
jumpifcantmakeasleep BattleScript_RestCantSleep
|
||||
@ -3012,7 +3012,7 @@ BattleScript_EffectPoison::
|
||||
jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
|
||||
trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
|
||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||
jumpifsafeguard BattleScript_SafeguardProtected
|
||||
attackanimation
|
||||
@ -3038,7 +3038,7 @@ BattleScript_EffectParalyze:
|
||||
jumpifstatus BS_TARGET, STATUS1_PARALYSIS, BattleScript_AlreadyParalyzed
|
||||
tryparalyzetype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
|
||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||
jumpifsafeguard BattleScript_SafeguardProtected
|
||||
bichalfword gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
|
||||
@ -4337,7 +4337,7 @@ BattleScript_EffectWillOWisp::
|
||||
jumpifleafguard BattleScript_LeafGuardProtects
|
||||
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
|
||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
|
||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||
jumpifsafeguard BattleScript_SafeguardProtected
|
||||
attackanimation
|
||||
|
@ -135,5 +135,6 @@ bool32 CanBePoisoned(u8 battlerId);
|
||||
bool32 CanBeBurned(u8 battlerId);
|
||||
bool32 CanBeParalyzed(u8 battlerId);
|
||||
bool32 CanBeFrozen(u8 battlerId);
|
||||
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
|
||||
|
||||
#endif // GUARD_BATTLE_UTIL_H
|
||||
|
@ -168,6 +168,7 @@
|
||||
#define VARIOUS_JUMP_IF_ABSENT 101
|
||||
#define VARIOUS_DESTROY_ABILITY_POPUP 102
|
||||
#define VARIOUS_TOTEM_BOOST 103
|
||||
#define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 104
|
||||
|
||||
// Cmd_manipulatedamage
|
||||
#define DMG_CHANGE_SIGN 0
|
||||
|
@ -8301,6 +8301,15 @@ static void Cmd_various(void)
|
||||
gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe)
|
||||
}
|
||||
return;
|
||||
case VARIOUS_JUMP_IF_TERRAIN_AFFECTED:
|
||||
{
|
||||
u32 flags = T1_READ_32(gBattlescriptCurrInstr + 3);
|
||||
if (IsBattlerTerrainAffected(gActiveBattler, flags))
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 7);
|
||||
else
|
||||
gBattlescriptCurrInstr += 11;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gBattlescriptCurrInstr += 3;
|
||||
|
@ -5059,6 +5059,16 @@ enum
|
||||
ITEM_STATS_CHANGE, // 5
|
||||
};
|
||||
|
||||
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag)
|
||||
{
|
||||
if (!(gFieldStatuses & terrainFlag))
|
||||
return FALSE;
|
||||
else if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE)
|
||||
return FALSE;
|
||||
|
||||
return IsBattlerGrounded(battlerId);
|
||||
}
|
||||
|
||||
bool32 CanSleep(u8 battlerId)
|
||||
{
|
||||
u16 ability = GetBattlerAbility(battlerId);
|
||||
@ -5069,7 +5079,7 @@ bool32 CanSleep(u8 battlerId)
|
||||
|| gBattleMons[battlerId].status1 & STATUS1_ANY
|
||||
|| IsAbilityOnSide(battlerId, ABILITY_SWEET_VEIL)
|
||||
|| IsAbilityStatusProtected(battlerId)
|
||||
|| gFieldStatuses & (STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_MISTY_TERRAIN))
|
||||
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_MISTY_TERRAIN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
@ -5085,7 +5095,7 @@ bool32 CanBePoisoned(u8 battlerId)
|
||||
|| ability == ABILITY_COMATOSE
|
||||
|| gBattleMons[battlerId].status1 & STATUS1_ANY
|
||||
|| IsAbilityStatusProtected(battlerId)
|
||||
|| gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
|
||||
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
@ -5099,7 +5109,7 @@ bool32 CanBeBurned(u8 battlerId)
|
||||
|| ability == ABILITY_WATER_VEIL
|
||||
|| ability == ABILITY_COMATOSE
|
||||
|| IsAbilityStatusProtected(battlerId)
|
||||
|| gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
|
||||
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
@ -5113,7 +5123,7 @@ bool32 CanBeParalyzed(u8 battlerId)
|
||||
|| ability == ABILITY_COMATOSE
|
||||
|| gBattleMons[battlerId].status1 & STATUS1_ANY
|
||||
|| IsAbilityStatusProtected(battlerId)
|
||||
|| gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
|
||||
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
@ -5128,7 +5138,7 @@ bool32 CanBeFrozen(u8 battlerId)
|
||||
|| ability == ABILITY_COMATOSE
|
||||
|| gBattleMons[battlerId].status1 & STATUS1_ANY
|
||||
|| IsAbilityStatusProtected(battlerId)
|
||||
|| gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
|
||||
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user