mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-03-19 12:08:34 +01:00
Made AI_CheckBadMove take the primal weathers into account
Credits to Syreldar. Also took the chance and removed trailing spaces from the file.
This commit is contained in:
parent
216d8f0608
commit
c0c6821f62
@ -510,9 +510,9 @@ static void BattleAI_DoAIProcessing(void)
|
|||||||
static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||||
{
|
{
|
||||||
// move data
|
// move data
|
||||||
|
s32 moveType;
|
||||||
u8 atkPriority = GetMovePriority(battlerAtk, move);
|
u8 atkPriority = GetMovePriority(battlerAtk, move);
|
||||||
u16 moveEffect = gBattleMoves[move].effect;
|
u16 moveEffect = gBattleMoves[move].effect;
|
||||||
u8 moveType = gBattleMoves[move].type;
|
|
||||||
u8 moveTarget = gBattleMoves[move].target;
|
u8 moveTarget = gBattleMoves[move].target;
|
||||||
u16 accuracy = AI_GetMoveAccuracy(battlerAtk, battlerDef, AI_DATA->atkAbility, AI_DATA->defAbility, AI_DATA->atkHoldEffect, AI_DATA->defHoldEffect, move);
|
u16 accuracy = AI_GetMoveAccuracy(battlerAtk, battlerDef, AI_DATA->atkAbility, AI_DATA->defAbility, AI_DATA->atkHoldEffect, AI_DATA->defHoldEffect, move);
|
||||||
u8 effectiveness = AI_GetMoveEffectiveness(move, battlerAtk, battlerDef);
|
u8 effectiveness = AI_GetMoveEffectiveness(move, battlerAtk, battlerDef);
|
||||||
@ -523,6 +523,8 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
|||||||
if (IsTargetingPartner(battlerAtk, battlerDef))
|
if (IsTargetingPartner(battlerAtk, battlerDef))
|
||||||
return score;
|
return score;
|
||||||
|
|
||||||
|
GET_MOVE_TYPE(move, move);
|
||||||
|
|
||||||
// check non-user target
|
// check non-user target
|
||||||
if (!(gBattleMoves[move].target & MOVE_TARGET_USER))
|
if (!(gBattleMoves[move].target & MOVE_TARGET_USER))
|
||||||
{
|
{
|
||||||
@ -748,7 +750,34 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
|||||||
if (gStatuses3[battlerAtk] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(battlerAtk, move))
|
if (gStatuses3[battlerAtk] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(battlerAtk, move))
|
||||||
return 0; // Can't even select heal blocked move
|
return 0; // Can't even select heal blocked move
|
||||||
// primal weather check
|
// primal weather check
|
||||||
//TODO
|
if (WEATHER_HAS_EFFECT)
|
||||||
|
{
|
||||||
|
if (gBattleWeather & WEATHER_PRIMAL_ANY)
|
||||||
|
{
|
||||||
|
switch (move)
|
||||||
|
{
|
||||||
|
case MOVE_SUNNY_DAY:
|
||||||
|
case MOVE_RAIN_DANCE:
|
||||||
|
case MOVE_HAIL:
|
||||||
|
case MOVE_SANDSTORM:
|
||||||
|
RETURN_SCORE_MINUS(30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IS_MOVE_STATUS(move))
|
||||||
|
{
|
||||||
|
if (gBattleWeather & WEATHER_SUN_PRIMAL)
|
||||||
|
{
|
||||||
|
if (moveType == TYPE_WATER)
|
||||||
|
RETURN_SCORE_MINUS(30);
|
||||||
|
}
|
||||||
|
else if (gBattleWeather & WEATHER_RAIN_PRIMAL)
|
||||||
|
{
|
||||||
|
if (moveType == TYPE_FIRE)
|
||||||
|
RETURN_SCORE_MINUS(30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check move effects
|
// check move effects
|
||||||
switch (moveEffect)
|
switch (moveEffect)
|
||||||
@ -2434,13 +2463,32 @@ static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
|||||||
switch (AI_GetMoveEffectiveness(move, battlerAtk, battlerDef))
|
switch (AI_GetMoveEffectiveness(move, battlerAtk, battlerDef))
|
||||||
{
|
{
|
||||||
case AI_EFFECTIVENESS_x4:
|
case AI_EFFECTIVENESS_x4:
|
||||||
|
if (WEATHER_HAS_EFFECT
|
||||||
|
&& gBattleWeather & WEATHER_STRONG_WINDS
|
||||||
|
&& IS_BATTLER_OF_TYPE(battlerDef, TYPE_FLYING))
|
||||||
|
{
|
||||||
|
if (AI_RandLessThan(176)) //Consider it supereffective instead of hypereffective.
|
||||||
|
score += 2;
|
||||||
|
else
|
||||||
|
score++;
|
||||||
|
}
|
||||||
|
else
|
||||||
score += 4;
|
score += 4;
|
||||||
break;
|
break;
|
||||||
case AI_EFFECTIVENESS_x2:
|
case AI_EFFECTIVENESS_x2:
|
||||||
|
if (WEATHER_HAS_EFFECT
|
||||||
|
&& gBattleWeather & WEATHER_STRONG_WINDS
|
||||||
|
&& IS_BATTLER_OF_TYPE(battlerDef, TYPE_FLYING))
|
||||||
|
{
|
||||||
|
break; // Don't increase score, consider it neutral.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (AI_RandLessThan(176))
|
if (AI_RandLessThan(176))
|
||||||
score += 2;
|
score += 2;
|
||||||
else
|
else
|
||||||
score++;
|
score++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user