ai understands constant-damage effects

This commit is contained in:
Evan 2021-02-07 12:39:23 -07:00
parent b9e425252d
commit 1405f04e1e
2 changed files with 30 additions and 1 deletions

View File

@ -188,7 +188,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
move = gBattleMons[sBattler_AI].moves[i];
if (gBattleMoves[move].power != 0 && !(moveLimitations & gBitTable[i]))
{
dmg = AI_CalcDamage(move, sBattler_AI, gBattlerTarget) * (100 - (Random() % 10)) / 100;
dmg = AI_CalcDamage(move, sBattler_AI, gBattlerTarget);
if (dmg == 0)
dmg = 1;
}

View File

@ -721,6 +721,35 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
GET_MOVE_TYPE(move, moveType);
dmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, AI_GetIfCrit(move, battlerAtk, battlerDef), FALSE, FALSE);
// handle dynamic move damage
switch (gBattleMoves[move].effect)
{
case EFFECT_LEVEL_DAMAGE:
dmg = gBattleMons[battlerAtk].level;
break;
case EFFECT_DRAGON_RAGE:
dmg = 40;
break;
case EFFECT_SONICBOOM:
dmg = 20;
break;
case EFFECT_PSYWAVE:
{
u32 randDamage;
if (B_PSYWAVE_DMG >= GEN_6)
randDamage = (Random() % 101);
else
randDamage = (Random() % 11) * 10;
dmg = gBattleMons[battlerAtk].level * (randDamage + 50) / 100;
}
break;
//case EFFECT_METAL_BURST:
//case EFFECT_COUNTER:
default:
dmg *= (100 - (Random() % 10)) / 100; // add random factor
break;
}
RestoreBattlerData(battlerAtk);
RestoreBattlerData(battlerDef);