mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 23:23:43 +01:00
Fix Intimidate and Trace on new switch in system
This commit is contained in:
parent
f19a51eea6
commit
f979987c2f
@ -6234,8 +6234,12 @@ BattleScript_TraceActivates::
|
||||
call BattleScript_AbilityPopUp
|
||||
printstring STRINGID_PKMNTRACED
|
||||
waitmessage 0x40
|
||||
settracedability BS_ATTACKER
|
||||
switchinabilities BS_ATTACKER
|
||||
settracedability BS_SCRIPTING
|
||||
switchinabilities BS_SCRIPTING
|
||||
return
|
||||
|
||||
BattleScript_TraceActivatesEnd3::
|
||||
call BattleScript_TraceActivates
|
||||
end3
|
||||
|
||||
BattleScript_RainDishActivates::
|
||||
|
@ -140,6 +140,7 @@ extern const u8 BattleScript_ItemSteal[];
|
||||
extern const u8 BattleScript_DrizzleActivates[];
|
||||
extern const u8 BattleScript_SpeedBoostActivates[];
|
||||
extern const u8 BattleScript_TraceActivates[];
|
||||
extern const u8 BattleScript_TraceActivatesEnd3[];
|
||||
extern const u8 BattleScript_RainDishActivates[];
|
||||
extern const u8 BattleScript_SandstreamActivates[];
|
||||
extern const u8 BattleScript_ShedSkinActivates[];
|
||||
|
@ -19,7 +19,8 @@
|
||||
#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8
|
||||
#define ABILITYEFFECT_INTIMIDATE1 0x9
|
||||
#define ABILITYEFFECT_INTIMIDATE2 0xA
|
||||
#define ABILITYEFFECT_TRACE 0xB
|
||||
#define ABILITYEFFECT_TRACE1 0xB
|
||||
#define ABILITYEFFECT_TRACE2 0xC
|
||||
#define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF
|
||||
|
||||
#define ITEMEFFECT_ON_SWITCH_IN 0x0
|
||||
|
@ -3512,7 +3512,7 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
}
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE1, 0, 0, 0, 0) != 0)
|
||||
return;
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_TRACE, 0, 0, 0, 0) != 0)
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_TRACE1, 0, 0, 0, 0) != 0)
|
||||
return;
|
||||
// Check all switch in items having effect from the fastest mon to slowest.
|
||||
while (gBattleStruct->switchInItemsCounter < gBattlersCount)
|
||||
|
@ -5443,39 +5443,38 @@ static void atk52_switchineffects(void)
|
||||
|
||||
gDisableStructs[gActiveBattler].truantSwitchInHack = 0;
|
||||
|
||||
if (!AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBattler, 0, 0, 0)
|
||||
&& !ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gActiveBattler, FALSE))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBattler, 0, 0, 0)
|
||||
|| ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gActiveBattler, FALSE)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE2, 0, 0, 0, 0)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_TRACE2, 0, 0, 0, 0)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_FORECAST, 0, 0, 0, 0))
|
||||
return;
|
||||
|
||||
gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED | SIDE_STATUS_TOXIC_SPIKES_DAMAGED | SIDE_STATUS_STEALTH_ROCK_DAMAGED | SIDE_STATUS_STICKY_WEB_DAMAGED);
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED | SIDE_STATUS_TOXIC_SPIKES_DAMAGED | SIDE_STATUS_STEALTH_ROCK_DAMAGED | SIDE_STATUS_STICKY_WEB_DAMAGED);
|
||||
if (gBattlerByTurnOrder[i] == gActiveBattler)
|
||||
gActionsByTurnOrder[i] = B_ACTION_CANCEL_PARTNER;
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (gBattlerByTurnOrder[i] == gActiveBattler)
|
||||
gActionsByTurnOrder[i] = B_ACTION_CANCEL_PARTNER;
|
||||
}
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
u16* hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(i)];
|
||||
*hpOnSwitchout = gBattleMons[i].hp;
|
||||
}
|
||||
|
||||
if (gBattlescriptCurrInstr[1] == 5)
|
||||
{
|
||||
u32 hitmarkerFaintBits = gHitMarker >> 0x1C;
|
||||
|
||||
gBattlerFainted++;
|
||||
while (1)
|
||||
{
|
||||
if (hitmarkerFaintBits & gBitTable[gBattlerFainted] && !(gAbsentBattlerFlags & gBitTable[gBattlerFainted]))
|
||||
break;
|
||||
if (gBattlerFainted >= gBattlersCount)
|
||||
break;
|
||||
gBattlerFainted++;
|
||||
}
|
||||
}
|
||||
gBattlescriptCurrInstr += 2;
|
||||
gBattleStruct->hpOnSwitchout[GetBattlerSide(i)] = gBattleMons[i].hp;
|
||||
}
|
||||
|
||||
if (gBattlescriptCurrInstr[1] == 5)
|
||||
{
|
||||
u32 hitmarkerFaintBits = gHitMarker >> 0x1C;
|
||||
|
||||
gBattlerFainted++;
|
||||
while (1)
|
||||
{
|
||||
if (hitmarkerFaintBits & gBitTable[gBattlerFainted] && !(gAbsentBattlerFlags & gBitTable[gBattlerFainted]))
|
||||
break;
|
||||
if (gBattlerFainted >= gBattlersCount)
|
||||
break;
|
||||
gBattlerFainted++;
|
||||
}
|
||||
}
|
||||
gBattlescriptCurrInstr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2021,7 +2021,7 @@ bool8 HandleFaintedMonActions(void)
|
||||
gBattleStruct->faintedActionsState = 4;
|
||||
break;
|
||||
case 6:
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE1, 0, 0, 0, 0) || AbilityBattleEffects(ABILITYEFFECT_TRACE, 0, 0, 0, 0) || ItemBattleEffects(1, 0, TRUE) || AbilityBattleEffects(ABILITYEFFECT_FORECAST, 0, 0, 0, 0))
|
||||
if (ItemBattleEffects(1, 0, TRUE))
|
||||
return TRUE;
|
||||
gBattleStruct->faintedActionsState++;
|
||||
break;
|
||||
@ -2704,11 +2704,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
||||
u8 effect = 0;
|
||||
u32 speciesAtk, speciesDef;
|
||||
u32 pidAtk, pidDef;
|
||||
u32 moveType;
|
||||
u32 moveType, move;
|
||||
u32 i;
|
||||
u32 move;
|
||||
u8 side;
|
||||
u8 target1;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
|
||||
return 0;
|
||||
@ -2960,15 +2957,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
||||
break;
|
||||
case ABILITY_CLOUD_NINE:
|
||||
case ABILITY_AIR_LOCK:
|
||||
// that's a weird choice for a variable, why not use i or battler?
|
||||
for (target1 = 0; target1 < gBattlersCount; target1++)
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
effect = TryWeatherFormChange(target1);
|
||||
effect = TryWeatherFormChange(i);
|
||||
if (effect != 0)
|
||||
{
|
||||
BattleScriptPushCursorAndCallback(BattleScript_CastformChange);
|
||||
gBattleScripting.battler = target1;
|
||||
*(&gBattleStruct->formToChangeInto) = effect - 1;
|
||||
gBattleScripting.battler = i;
|
||||
gBattleStruct->formToChangeInto = effect - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3543,13 +3539,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
||||
{
|
||||
BattleScriptPushCursorAndCallback(BattleScript_CastformChange);
|
||||
gBattleScripting.battler = battler;
|
||||
*(&gBattleStruct->formToChangeInto) = effect - 1;
|
||||
gBattleStruct->formToChangeInto = effect - 1;
|
||||
return effect;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_SYNCHRONIZE: // 7
|
||||
case ABILITYEFFECT_SYNCHRONIZE:
|
||||
if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT))
|
||||
{
|
||||
gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT);
|
||||
@ -3591,64 +3587,68 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_INTIMIDATE1: // 9
|
||||
case ABILITYEFFECT_INTIMIDATE1:
|
||||
case ABILITYEFFECT_INTIMIDATE2:
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gBattleResources->flags->flags[i] & RESOURCE_FLAG_INTIMIDATED)
|
||||
{
|
||||
gLastUsedAbility = ABILITY_INTIMIDATE;
|
||||
gBattleResources->flags->flags[i] &= ~(RESOURCE_FLAG_INTIMIDATED);
|
||||
BattleScriptPushCursorAndCallback(BattleScript_IntimidateActivatesEnd3);
|
||||
if (caseID == ABILITYEFFECT_INTIMIDATE1)
|
||||
{
|
||||
BattleScriptPushCursorAndCallback(BattleScript_IntimidateActivatesEnd3);
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_IntimidateActivates;
|
||||
}
|
||||
gBattlerAbility = gBattleStruct->intimidateBattler = i;
|
||||
effect++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_TRACE: // 11
|
||||
case ABILITYEFFECT_TRACE1:
|
||||
case ABILITYEFFECT_TRACE2:
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (gBattleMons[i].ability == ABILITY_TRACE && (gBattleResources->flags->flags[i] & RESOURCE_FLAG_TRACED))
|
||||
{
|
||||
u8 target2;
|
||||
side = (GetBattlerPosition(i) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon
|
||||
target1 = GetBattlerAtPosition(side);
|
||||
target2 = GetBattlerAtPosition(side + BIT_FLANK);
|
||||
u8 side = (GetBattlerPosition(i) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon
|
||||
u8 target1 = GetBattlerAtPosition(side);
|
||||
u8 target2 = GetBattlerAtPosition(side + BIT_FLANK);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0
|
||||
&& gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0)
|
||||
{
|
||||
gActiveBattler = GetBattlerAtPosition(((Random() & 1) * 2) | side);
|
||||
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[gActiveBattler].ability;
|
||||
effect++;
|
||||
}
|
||||
gActiveBattler = GetBattlerAtPosition(((Random() & 1) * 2) | side), effect++;
|
||||
else if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0)
|
||||
{
|
||||
gActiveBattler = target1;
|
||||
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[gActiveBattler].ability;
|
||||
effect++;
|
||||
}
|
||||
gActiveBattler = target1, effect++;
|
||||
else if (gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0)
|
||||
{
|
||||
gActiveBattler = target2;
|
||||
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[gActiveBattler].ability;
|
||||
effect++;
|
||||
}
|
||||
gActiveBattler = target2, effect++;
|
||||
}
|
||||
else
|
||||
{
|
||||
gActiveBattler = target1;
|
||||
if (gBattleMons[target1].ability && gBattleMons[target1].hp)
|
||||
{
|
||||
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[target1].ability;
|
||||
effect++;
|
||||
}
|
||||
gActiveBattler = target1, effect++;
|
||||
}
|
||||
|
||||
if (effect)
|
||||
{
|
||||
BattleScriptPushCursorAndCallback(BattleScript_TraceActivates);
|
||||
if (caseID == ABILITYEFFECT_TRACE1)
|
||||
{
|
||||
BattleScriptPushCursorAndCallback(BattleScript_TraceActivatesEnd3);
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_TraceActivates;
|
||||
}
|
||||
gBattleResources->flags->flags[i] &= ~(RESOURCE_FLAG_TRACED);
|
||||
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[gActiveBattler].ability;
|
||||
gBattlerAbility = gBattleScripting.battler = i;
|
||||
|
||||
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
|
||||
@ -3658,21 +3658,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_INTIMIDATE2: // 10
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (gBattleMons[i].ability == ABILITY_INTIMIDATE && (gBattleResources->flags->flags[i] & RESOURCE_FLAG_INTIMIDATED))
|
||||
{
|
||||
gLastUsedAbility = ABILITY_INTIMIDATE;
|
||||
gBattleResources->flags->flags[i] &= ~(RESOURCE_FLAG_INTIMIDATED);
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_IntimidateActivates;
|
||||
gBattlerAbility = gBattleStruct->intimidateBattler = i;
|
||||
effect++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (effect && gLastUsedAbility != 0xFF)
|
||||
|
Loading…
x
Reference in New Issue
Block a user