mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-28 12:44:18 +01:00
add some RecordItemEffect and RecordAbilityBattle situations, ai checks
This commit is contained in:
parent
bdb480765c
commit
5a26a69ccd
@ -2130,12 +2130,14 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||
break;
|
||||
case EFFECT_SKILL_SWAP:
|
||||
if (AI_DATA->abilities[battlerAtk] == ABILITY_NONE || AI_DATA->abilities[battlerDef] == ABILITY_NONE
|
||||
|| IsSkillSwapBannedAbility(AI_DATA->abilities[battlerAtk]) || IsSkillSwapBannedAbility(AI_DATA->abilities[battlerDef]))
|
||||
|| IsSkillSwapBannedAbility(AI_DATA->abilities[battlerAtk]) || IsSkillSwapBannedAbility(AI_DATA->abilities[battlerDef])
|
||||
|| AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
score -= 10;
|
||||
break;
|
||||
case EFFECT_WORRY_SEED:
|
||||
if (AI_DATA->abilities[battlerDef] == ABILITY_INSOMNIA
|
||||
|| IsWorrySeedBannedAbility(AI_DATA->abilities[battlerDef]))
|
||||
|| IsWorrySeedBannedAbility(AI_DATA->abilities[battlerDef])
|
||||
|| AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
score -= 10;
|
||||
break;
|
||||
case EFFECT_GASTRO_ACID:
|
||||
@ -2146,14 +2148,16 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||
case EFFECT_ENTRAINMENT:
|
||||
if (AI_DATA->abilities[battlerAtk] == ABILITY_NONE
|
||||
|| IsEntrainmentBannedAbilityAttacker(AI_DATA->abilities[battlerAtk])
|
||||
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(AI_DATA->abilities[battlerDef]))
|
||||
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(AI_DATA->abilities[battlerDef])
|
||||
|| AI_DATA->holdEffects[battlerAtk] == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
score -= 10;
|
||||
break;
|
||||
case EFFECT_CORE_ENFORCER:
|
||||
break;
|
||||
case EFFECT_SIMPLE_BEAM:
|
||||
if (AI_DATA->abilities[battlerDef] == ABILITY_SIMPLE
|
||||
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(AI_DATA->abilities[battlerDef]))
|
||||
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(AI_DATA->abilities[battlerDef])
|
||||
|| AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
score -= 10;
|
||||
break;
|
||||
case EFFECT_SNATCH:
|
||||
|
@ -2830,7 +2830,13 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
||||
&& !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
|
||||
&& !primary
|
||||
&& (gBattleScripting.moveEffect <= MOVE_EFFECT_TRI_ATTACK || gBattleScripting.moveEffect >= MOVE_EFFECT_SMACK_DOWN)) // Exclude stat lowering effects
|
||||
{
|
||||
if (battlerAbility == ABILITY_SHIELD_DUST)
|
||||
RecordAbilityBattle(gEffectBattler, battlerAbility)
|
||||
else
|
||||
RecordItemEffectBattle(gEffectBattler, HOLD_EFFECT_COVERT_CLOAK);
|
||||
INCREMENT_RESET_RETURN
|
||||
}
|
||||
|
||||
if (gSideStatuses[GET_BATTLER_SIDE(gEffectBattler)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
|
||||
&& !primary && gBattleScripting.moveEffect <= MOVE_EFFECT_CONFUSION)
|
||||
@ -8818,9 +8824,14 @@ static void Cmd_various(void)
|
||||
return;
|
||||
case VARIOUS_SET_SIMPLE_BEAM:
|
||||
if (IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability)
|
||||
|| gBattleMons[gBattlerTarget].ability == ABILITY_SIMPLE
|
||||
|| GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
|| gBattleMons[gBattlerTarget].ability == ABILITY_SIMPLE)
|
||||
{
|
||||
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
}
|
||||
else if (GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
{
|
||||
RecordItemEffectBattle(gBattlerTarget, HOLD_EFFECT_ABILITY_SHIELD);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
}
|
||||
else
|
||||
@ -8834,21 +8845,27 @@ static void Cmd_various(void)
|
||||
return;
|
||||
case VARIOUS_TRY_ENTRAINMENT:
|
||||
if (IsEntrainmentBannedAbilityAttacker(gBattleMons[gBattlerAttacker].ability)
|
||||
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability)
|
||||
|| GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability))
|
||||
{
|
||||
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gBattleMons[gBattlerTarget].ability == gBattleMons[gBattlerAttacker].ability)
|
||||
else if (GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
{
|
||||
RecordItemEffectBattle(gBattlerTarget, HOLD_EFFECT_ABILITY_SHIELD);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gBattleMons[gBattlerAttacker].ability;
|
||||
gBattlescriptCurrInstr += 7;
|
||||
if (gBattleMons[gBattlerTarget].ability == gBattleMons[gBattlerAttacker].ability)
|
||||
{
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gBattleMons[gBattlerAttacker].ability;
|
||||
gBattlescriptCurrInstr += 7;
|
||||
}
|
||||
}
|
||||
return;
|
||||
case VARIOUS_SET_LAST_USED_ABILITY:
|
||||
@ -10760,6 +10777,11 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
|| activeBattlerAbility == ABILITY_WHITE_SMOKE)
|
||||
&& !certain && gCurrentMove != MOVE_CURSE)
|
||||
{
|
||||
if (GetBattlerHoldEffect(gActiveBattler, TRUE) == HOLD_EFFECT_CLEAR_AMULET)
|
||||
{
|
||||
RecordItemEffectBattle(gActiveBattler, HOLD_EFFECT_CLEAR_AMULET);
|
||||
}
|
||||
|
||||
if (flags == STAT_CHANGE_ALLOW_PTR)
|
||||
{
|
||||
if (gSpecialStatuses[gActiveBattler].statLowered)
|
||||
@ -13369,24 +13391,30 @@ static void Cmd_setroom(void)
|
||||
static void Cmd_tryswapabilities(void)
|
||||
{
|
||||
if (IsSkillSwapBannedAbility(gBattleMons[gBattlerAttacker].ability)
|
||||
|| IsSkillSwapBannedAbility(gBattleMons[gBattlerTarget].ability)
|
||||
|| GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
|| IsSkillSwapBannedAbility(gBattleMons[gBattlerTarget].ability))
|
||||
{
|
||||
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
else if (GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
{
|
||||
RecordItemEffectBattle(gBattlerTarget, HOLD_EFFECT_ABILITY_SHIELD);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
u16 abilityAtk = gBattleMons[gBattlerAttacker].ability;
|
||||
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
|
||||
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = abilityAtk;
|
||||
if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
{
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
u16 abilityAtk = gBattleMons[gBattlerAttacker].ability;
|
||||
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
|
||||
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = abilityAtk;
|
||||
|
||||
gBattlescriptCurrInstr += 5;
|
||||
gBattlescriptCurrInstr += 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14742,9 +14770,14 @@ static void Cmd_unused(void)
|
||||
|
||||
static void Cmd_tryworryseed(void)
|
||||
{
|
||||
if (IsWorrySeedBannedAbility(gBattleMons[gBattlerTarget].ability)
|
||||
|| GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
if (IsWorrySeedBannedAbility(gBattleMons[gBattlerTarget].ability))
|
||||
{
|
||||
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
}
|
||||
else if (GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)
|
||||
{
|
||||
RecordItemEffectBattle(gBattlerTarget, HOLD_EFFECT_ABILITY_SHIELD);
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
}
|
||||
else
|
||||
@ -14810,6 +14843,7 @@ void BS_JumpIfHoldEffect(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
RecordItemEffectBattle(battler, holdEffect);
|
||||
gLastUsedItem = gBattleMons[battler].item; // For B_LAST_USED_ITEM
|
||||
gBattlescriptCurrInstr += 12;
|
||||
}
|
||||
|
@ -5363,8 +5363,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& (IsMoveMakingContact(move, gBattlerAttacker))
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_ABILITY_SHIELD)
|
||||
&& (IsMoveMakingContact(move, gBattlerAttacker)))
|
||||
{
|
||||
switch (gBattleMons[gBattlerAttacker].ability)
|
||||
{
|
||||
@ -5380,6 +5379,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
case ABILITY_STANCE_CHANGE:
|
||||
break;
|
||||
default:
|
||||
if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_ABILITY_SHIELD) {
|
||||
RecordItemEffectBattle(gBattlerAttacker, HOLD_EFFECT_ABILITY_SHIELD);
|
||||
break;
|
||||
}
|
||||
|
||||
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = ABILITY_MUMMY;
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_MummyActivates;
|
||||
@ -5392,8 +5396,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_ABILITY_SHIELD)
|
||||
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
|
||||
{
|
||||
switch (gBattleMons[gBattlerAttacker].ability)
|
||||
{
|
||||
@ -5412,6 +5415,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
case ABILITY_ZEN_MODE:
|
||||
break;
|
||||
default:
|
||||
if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_ABILITY_SHIELD) {
|
||||
RecordItemEffectBattle(gBattlerAttacker, HOLD_EFFECT_ABILITY_SHIELD);
|
||||
break;
|
||||
}
|
||||
|
||||
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability;
|
||||
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
|
||||
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gLastUsedAbility;
|
||||
|
Loading…
Reference in New Issue
Block a user