mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Merge branch 'battle_engine' of https://github.com/rh-hideout/pokeemerald-expansion into gen8_move_effects
This commit is contained in:
commit
6ec1a74948
@ -7786,6 +7786,7 @@ BattleScript_BerryReduceDmg::
|
||||
BattleScript_PrintBerryReduceString::
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
printstring STRINGID_BERRYDMGREDUCES
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
return
|
||||
|
||||
BattleScript_BerryCureConfusionEnd2::
|
||||
|
@ -13,6 +13,7 @@ struct StatFractions
|
||||
};
|
||||
|
||||
s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbility);
|
||||
s8 GetInverseCritChance(u8 battlerAtk, u8 battlerDef, u32 move);
|
||||
u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move);
|
||||
u8 GetBattlerTurnOrderNum(u8 battlerId);
|
||||
bool32 NoAliveMonsForEitherParty(void);
|
||||
|
@ -711,7 +711,8 @@ static bool32 AI_GetIfCrit(u32 move, u8 battlerAtk, u8 battlerDef)
|
||||
|
||||
s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
|
||||
{
|
||||
s32 dmg, moveType;
|
||||
s32 dmg, moveType, critDmg, normalDmg;
|
||||
s8 critChance;
|
||||
|
||||
SaveBattlerData(battlerAtk);
|
||||
SaveBattlerData(battlerDef);
|
||||
@ -722,12 +723,22 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
|
||||
gBattleStruct->dynamicMoveType = 0;
|
||||
SetTypeBeforeUsingMove(move, battlerAtk);
|
||||
GET_MOVE_TYPE(move, moveType);
|
||||
dmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, AI_GetIfCrit(move, battlerAtk, battlerDef), FALSE, FALSE);
|
||||
|
||||
critChance = GetInverseCritChance(battlerAtk, battlerDef, move);
|
||||
normalDmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, FALSE, FALSE, FALSE);
|
||||
critDmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, TRUE, FALSE, FALSE);
|
||||
|
||||
if(critChance == -1)
|
||||
dmg = normalDmg;
|
||||
else
|
||||
dmg = (critDmg + normalDmg * (critChance - 1)) / critChance;
|
||||
|
||||
// handle dynamic move damage
|
||||
switch (gBattleMoves[move].effect)
|
||||
{
|
||||
case EFFECT_LEVEL_DAMAGE:
|
||||
case EFFECT_PSYWAVE:
|
||||
//psywave's expected damage is equal to the user's level
|
||||
dmg = gBattleMons[battlerAtk].level;
|
||||
break;
|
||||
case EFFECT_DRAGON_RAGE:
|
||||
@ -736,20 +747,11 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
|
||||
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
|
||||
//do not add the random factor, it's an average case analysis
|
||||
//dmg *= (100 - (Random() % 10)) / 100; // add random factor
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1834,6 +1834,15 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi
|
||||
return critChance;
|
||||
}
|
||||
|
||||
s8 GetInverseCritChance(u8 battlerAtk, u8 battlerDef, u32 move)
|
||||
{
|
||||
s32 critChanceIndex = CalcCritChanceStage(battlerAtk, battlerDef, move, FALSE);
|
||||
if(critChanceIndex < 0)
|
||||
return -1;
|
||||
else
|
||||
return sCriticalHitChance[critChanceIndex];
|
||||
}
|
||||
|
||||
static void Cmd_critcalc(void)
|
||||
{
|
||||
s32 critChance = CalcCritChanceStage(gBattlerAttacker, gBattlerTarget, gCurrentMove, TRUE);
|
||||
@ -1982,6 +1991,15 @@ static void Cmd_multihitresultmessage(void)
|
||||
}
|
||||
}
|
||||
gBattlescriptCurrInstr++;
|
||||
|
||||
// Print berry reducing message after result message.
|
||||
if (gSpecialStatuses[gBattlerTarget].berryReduced
|
||||
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
|
||||
{
|
||||
gSpecialStatuses[gBattlerTarget].berryReduced = 0;
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
|
||||
}
|
||||
}
|
||||
|
||||
static void Cmd_attackanimation(void)
|
||||
|
@ -4047,7 +4047,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
u32 opposingDef = 0, opposingSpDef = 0;
|
||||
|
||||
opposingBattler = BATTLE_OPPOSITE(battler);
|
||||
for (i = 0; i < 2; opposingBattler ^= BIT_SIDE, i++)
|
||||
for (i = 0; i < 2; opposingBattler ^= BIT_FLANK, i++)
|
||||
{
|
||||
if (IsBattlerAlive(opposingBattler))
|
||||
{
|
||||
@ -4071,6 +4071,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||
{
|
||||
gBattleMons[battler].statStages[statId]++;
|
||||
SET_STATCHANGER(statId, 1, FALSE);
|
||||
gBattlerAttacker = battler;
|
||||
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
|
||||
BattleScriptPushCursorAndCallback(BattleScript_AttackerAbilityStatRaiseEnd3);
|
||||
effect++;
|
||||
@ -7808,7 +7809,7 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b
|
||||
atkStage = gBattleMons[battlerDef].statStages[STAT_SPATK];
|
||||
}
|
||||
}
|
||||
if (gBattleMoves[move].effect == EFFECT_BODY_PRESS)
|
||||
else if (gBattleMoves[move].effect == EFFECT_BODY_PRESS)
|
||||
{
|
||||
atkStat = gBattleMons[battlerAtk].defense;
|
||||
atkStage = gBattleMons[battlerAtk].statStages[STAT_DEF];
|
||||
@ -8763,6 +8764,7 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId)
|
||||
id = i;
|
||||
if (GetMonData(&party[id], MON_DATA_SANITY_HAS_SPECIES)
|
||||
&& GetMonData(&party[id], MON_DATA_HP)
|
||||
&& !GetMonData(&party[id], MON_DATA_IS_EGG)
|
||||
&& &party[id] != mon
|
||||
&& &party[id] != partnerMon)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user