mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
Optimized Intimidate's code
This commit is contained in:
parent
e6ae0bd01e
commit
31a602f3b6
@ -1162,7 +1162,7 @@
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
.macro trygetintimidatetarget ptr:req
|
||||
.macro unused2 ptr:req
|
||||
.byte 0xe1
|
||||
.4byte \ptr
|
||||
.endm
|
||||
@ -1326,8 +1326,8 @@
|
||||
various \battler, VARIOUS_GET_BATTLER_FAINTED
|
||||
.endm
|
||||
|
||||
.macro resetintimidatetracebits battler:req
|
||||
various \battler, VARIOUS_RESET_INTIMIDATE_TRACE_BITS
|
||||
.macro resetswitchinabilitybits battler:req
|
||||
various \battler, VARIOUS_RESET_SWITCH_IN_ABILITY_BITS
|
||||
.endm
|
||||
|
||||
.macro updatechoicemoveonlvlup battler:req
|
||||
|
@ -6128,7 +6128,7 @@ BattleScript_FaintedMonTryChoose:
|
||||
jumpifbyte CMP_EQUAL, gBattleCommunication, PARTY_SIZE, BattleScript_FaintedMonSendOutNew
|
||||
@ Switch Pokémon before opponent
|
||||
atknameinbuff1
|
||||
resetintimidatetracebits BS_ATTACKER
|
||||
resetswitchinabilitybits BS_ATTACKER
|
||||
hpthresholds2 BS_ATTACKER
|
||||
printstring STRINGID_RETURNMON
|
||||
switchoutabilities BS_ATTACKER
|
||||
@ -8198,19 +8198,15 @@ BattleScript_TryAdrenalineOrb:
|
||||
BattleScript_TryAdrenalineOrbRet:
|
||||
return
|
||||
|
||||
BattleScript_IntimidateActivatesEnd3::
|
||||
call BattleScript_PauseIntimidateActivates
|
||||
end3
|
||||
|
||||
BattleScript_PauseIntimidateActivates:
|
||||
pause B_WAIT_TIME_SHORT
|
||||
BattleScript_IntimidateActivates::
|
||||
showabilitypopup BS_ATTACKER
|
||||
pause B_WAIT_TIME_LONG
|
||||
destroyabilitypopup
|
||||
setbyte gBattlerTarget, 0
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_IntimidateActivatesLoop:
|
||||
setstatchanger STAT_ATK, 1, TRUE
|
||||
trygetintimidatetarget BattleScript_IntimidateActivatesReturn
|
||||
jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_IntimidateActivatesLoopIncrement
|
||||
BattleScript_IntimidateLoop:
|
||||
jumpifbyteequal gBattlerTarget, gBattlerAttacker, BattleScript_IntimidateLoopIncrement
|
||||
jumpiftargetally BattleScript_IntimidateLoopIncrement
|
||||
jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_IntimidateLoopIncrement
|
||||
jumpifability BS_TARGET, ABILITY_CLEAR_BODY, BattleScript_IntimidatePrevented
|
||||
jumpifability BS_TARGET, ABILITY_HYPER_CUTTER, BattleScript_IntimidatePrevented
|
||||
jumpifability BS_TARGET, ABILITY_WHITE_SMOKE, BattleScript_IntimidatePrevented
|
||||
@ -8220,27 +8216,30 @@ BattleScript_IntimidateActivatesLoop:
|
||||
jumpifability BS_TARGET, ABILITY_OWN_TEMPO, BattleScript_IntimidatePrevented
|
||||
jumpifability BS_TARGET, ABILITY_OBLIVIOUS, BattleScript_IntimidatePrevented
|
||||
.endif
|
||||
statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED | STAT_CHANGE_ALLOW_PTR, BattleScript_IntimidateActivatesLoopIncrement
|
||||
jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, 1, BattleScript_IntimidateActivatesLoopIncrement
|
||||
BattleScript_IntimidateEffect:
|
||||
statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL
|
||||
setgraphicalstatchangevalues
|
||||
playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
|
||||
printstring STRINGID_PKMNCUTSATTACKWITH
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
call BattleScript_TryAdrenalineOrb
|
||||
BattleScript_IntimidateActivatesLoopIncrement:
|
||||
@ Perform stat nerf
|
||||
BattleScript_IntimidateLoopIncrement:
|
||||
addbyte gBattlerTarget, 1
|
||||
goto BattleScript_IntimidateActivatesLoop
|
||||
BattleScript_IntimidateActivatesReturn:
|
||||
return
|
||||
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_IntimidateLoop
|
||||
BattleScript_IntimidateEnd:
|
||||
destroyabilitypopup
|
||||
pause B_WAIT_TIME_MED
|
||||
end3
|
||||
|
||||
BattleScript_IntimidatePrevented:
|
||||
pause B_WAIT_TIME_SHORT
|
||||
call BattleScript_AbilityPopUp
|
||||
pause B_WAIT_TIME_LONG
|
||||
setbyte gBattleCommunication STAT_ATK
|
||||
stattextbuffer BS_ATTACKER
|
||||
stattextbuffer BS_TARGET
|
||||
printstring STRINGID_STATWASNOTLOWERED
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
call BattleScript_TryAdrenalineOrb
|
||||
goto BattleScript_IntimidateActivatesLoopIncrement
|
||||
goto BattleScript_IntimidateLoopIncrement
|
||||
|
||||
BattleScript_DroughtActivates::
|
||||
pause B_WAIT_TIME_SHORT
|
||||
|
@ -53,7 +53,7 @@ struct ResourceFlags
|
||||
#define RESOURCE_FLAG_FLASH_FIRE 0x1
|
||||
#define RESOURCE_FLAG_ROOST 0x2
|
||||
#define RESOURCE_FLAG_UNBURDEN 0x4
|
||||
#define RESOURCE_FLAG_INTIMIDATED 0x8
|
||||
#define RESOURCE_FLAG_UNUSED 0x8
|
||||
#define RESOURCE_FLAG_TRACED 0x10
|
||||
#define RESOURCE_FLAG_EMERGENCY_EXIT 0x20
|
||||
#define RESOURCE_FLAG_NEUTRALIZING_GAS 0x40
|
||||
@ -158,7 +158,6 @@ struct SpecialStatus
|
||||
u8 statLowered:1;
|
||||
u8 lightningRodRedirected:1;
|
||||
u8 restoredBattlerSprite: 1;
|
||||
u8 intimidatedMon:1;
|
||||
u8 traced:1;
|
||||
u8 ppNotAffectedByPressure:1;
|
||||
u8 faintedHasReplacement:1;
|
||||
@ -583,7 +582,6 @@ struct BattleStruct
|
||||
u8 AI_itemFlags[2];
|
||||
u16 choicedMove[MAX_BATTLERS_COUNT];
|
||||
u16 changedItems[MAX_BATTLERS_COUNT];
|
||||
u8 intimidateBattler;
|
||||
u8 switchInItemsCounter;
|
||||
u8 arenaTurnCounter;
|
||||
u8 turnSideTracker;
|
||||
|
@ -152,7 +152,6 @@ extern const u8 BattleScript_ShedSkinActivates[];
|
||||
extern const u8 BattleScript_WeatherFormChanges[];
|
||||
extern const u8 BattleScript_WeatherFormChangesLoop[];
|
||||
extern const u8 BattleScript_WeatherFormChange[];
|
||||
extern const u8 BattleScript_IntimidateActivatesEnd3[];
|
||||
extern const u8 BattleScript_IntimidateActivates[];
|
||||
extern const u8 BattleScript_DroughtActivates[];
|
||||
extern const u8 BattleScript_TookAttack[];
|
||||
|
@ -29,13 +29,11 @@
|
||||
#define ABILITYEFFECT_WEATHER_FORM 7
|
||||
#define ABILITYEFFECT_SYNCHRONIZE 8
|
||||
#define ABILITYEFFECT_ATK_SYNCHRONIZE 9
|
||||
#define ABILITYEFFECT_INTIMIDATE1 10
|
||||
#define ABILITYEFFECT_INTIMIDATE2 11
|
||||
#define ABILITYEFFECT_TRACE1 12
|
||||
#define ABILITYEFFECT_TRACE2 13
|
||||
#define ABILITYEFFECT_MOVE_END_OTHER 14
|
||||
#define ABILITYEFFECT_NEUTRALIZINGGAS 15
|
||||
#define ABILITYEFFECT_FIELD_SPORT 16 // Only used if B_SPORT_TURNS < GEN_6
|
||||
#define ABILITYEFFECT_TRACE1 10
|
||||
#define ABILITYEFFECT_TRACE2 11
|
||||
#define ABILITYEFFECT_MOVE_END_OTHER 12
|
||||
#define ABILITYEFFECT_NEUTRALIZINGGAS 13
|
||||
#define ABILITYEFFECT_FIELD_SPORT 14 // Only used if B_SPORT_TURNS < GEN_6
|
||||
// Special cases
|
||||
#define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS < GEN_6
|
||||
#define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS < GEN_6
|
||||
|
@ -93,7 +93,7 @@
|
||||
#define VARIOUS_IS_RUNNING_IMPOSSIBLE 2
|
||||
#define VARIOUS_GET_MOVE_TARGET 3
|
||||
#define VARIOUS_GET_BATTLER_FAINTED 4
|
||||
#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5
|
||||
#define VARIOUS_RESET_SWITCH_IN_ABILITY_BITS 5
|
||||
#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6
|
||||
#define VARIOUS_RESET_PLAYER_FAINTED 7
|
||||
#define VARIOUS_PALACE_FLAVOR_TEXT 8
|
||||
|
@ -3721,8 +3721,6 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gBattlerAttacker, 0, 0, 0) != 0)
|
||||
return;
|
||||
}
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE1, 0, 0, 0, 0) != 0)
|
||||
return;
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_TRACE1, 0, 0, 0, 0) != 0)
|
||||
return;
|
||||
// Check all switch in items having effect from the fastest mon to slowest.
|
||||
|
@ -545,7 +545,7 @@ static void Cmd_setuserstatus3(void);
|
||||
static void Cmd_assistattackselect(void);
|
||||
static void Cmd_trysetmagiccoat(void);
|
||||
static void Cmd_trysetsnatch(void);
|
||||
static void Cmd_trygetintimidatetarget(void);
|
||||
static void Cmd_unused2(void);
|
||||
static void Cmd_switchoutabilities(void);
|
||||
static void Cmd_jumpifhasnohp(void);
|
||||
static void Cmd_getsecretpowereffect(void);
|
||||
@ -804,7 +804,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
Cmd_assistattackselect, //0xDE
|
||||
Cmd_trysetmagiccoat, //0xDF
|
||||
Cmd_trysetsnatch, //0xE0
|
||||
Cmd_trygetintimidatetarget, //0xE1
|
||||
Cmd_unused2, //0xE1
|
||||
Cmd_switchoutabilities, //0xE2
|
||||
Cmd_jumpifhasnohp, //0xE3
|
||||
Cmd_getsecretpowereffect, //0xE4
|
||||
@ -6783,7 +6783,6 @@ static void Cmd_switchineffects(void)
|
||||
|
||||
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_WEATHER_FORM, 0, 0, 0, 0))
|
||||
return;
|
||||
@ -8469,8 +8468,7 @@ static void Cmd_various(void)
|
||||
else
|
||||
gBattleCommunication[0] = FALSE;
|
||||
break;
|
||||
case VARIOUS_RESET_INTIMIDATE_TRACE_BITS:
|
||||
gSpecialStatuses[gActiveBattler].intimidatedMon = FALSE;
|
||||
case VARIOUS_RESET_SWITCH_IN_ABILITY_BITS:
|
||||
gSpecialStatuses[gActiveBattler].traced = FALSE;
|
||||
gSpecialStatuses[gActiveBattler].switchInAbilityDone = FALSE;
|
||||
break;
|
||||
@ -8634,7 +8632,6 @@ static void Cmd_various(void)
|
||||
gBattlescriptCurrInstr += 3;
|
||||
AbilityBattleEffects(ABILITYEFFECT_NEUTRALIZINGGAS, gActiveBattler, 0, 0, 0);
|
||||
AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBattler, 0, 0, 0);
|
||||
AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE2, gActiveBattler, 0, 0, 0);
|
||||
AbilityBattleEffects(ABILITYEFFECT_TRACE2, gActiveBattler, 0, 0, 0);
|
||||
return;
|
||||
case VARIOUS_SAVE_TARGET:
|
||||
@ -13533,27 +13530,8 @@ static void Cmd_trysetsnatch(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void Cmd_trygetintimidatetarget(void)
|
||||
static void Cmd_unused2(void)
|
||||
{
|
||||
u8 side;
|
||||
|
||||
gBattleScripting.battler = gBattleStruct->intimidateBattler;
|
||||
side = GetBattlerSide(gBattleScripting.battler);
|
||||
|
||||
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.battler].ability)
|
||||
|
||||
for (;gBattlerTarget < gBattlersCount; gBattlerTarget++)
|
||||
{
|
||||
if (GetBattlerSide(gBattlerTarget) == side)
|
||||
continue;
|
||||
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (gBattlerTarget >= gBattlersCount)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
else
|
||||
gBattlescriptCurrInstr += 5;
|
||||
}
|
||||
|
||||
static void Cmd_switchoutabilities(void)
|
||||
|
@ -4780,10 +4780,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
}
|
||||
break;
|
||||
case ABILITY_INTIMIDATE:
|
||||
if (!(gSpecialStatuses[battler].intimidatedMon))
|
||||
if (!gSpecialStatuses[battler].switchInAbilityDone)
|
||||
{
|
||||
gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_INTIMIDATED;
|
||||
gSpecialStatuses[battler].intimidatedMon = TRUE;
|
||||
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
|
||||
SET_STATCHANGER(STAT_ATK, 1, TRUE);
|
||||
BattleScriptPushCursorAndCallback(BattleScript_IntimidateActivates);
|
||||
effect++;
|
||||
}
|
||||
break;
|
||||
case ABILITY_FORECAST:
|
||||
@ -5958,30 +5960,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_INTIMIDATE1:
|
||||
case ABILITYEFFECT_INTIMIDATE2:
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (GetBattlerAbility(i) == ABILITY_INTIMIDATE && gBattleResources->flags->flags[i] & RESOURCE_FLAG_INTIMIDATED
|
||||
&& (IsBattlerAlive(BATTLE_OPPOSITE(i)) || IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(i))))) // At least one opposing mon has to be alive.
|
||||
{
|
||||
gBattleResources->flags->flags[i] &= ~RESOURCE_FLAG_INTIMIDATED;
|
||||
gLastUsedAbility = ABILITY_INTIMIDATE;
|
||||
if (caseID == ABILITYEFFECT_INTIMIDATE1)
|
||||
{
|
||||
BattleScriptPushCursorAndCallback(BattleScript_IntimidateActivatesEnd3);
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_IntimidateActivates;
|
||||
}
|
||||
battler = gBattlerAbility = gBattleStruct->intimidateBattler = i;
|
||||
effect++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_TRACE1:
|
||||
case ABILITYEFFECT_TRACE2:
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user