Skip to content

Commit da9725f

Browse files
committed
Fit battle UI disp for max-damage
1 parent f43f1c8 commit da9725f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Kernel/Wizardry/Core/BattleSys/Source/BattleDamage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int CalcBattleRealDamage(struct BattleUnit *attacker, struct BattleUnit *defende
5555
return damage;
5656
}
5757

58-
STATIC_DECLAR int GetMaxDamage(struct BattleUnit *attacker, struct BattleUnit *defender)
58+
int GetMaxDamage(struct BattleUnit *attacker, struct BattleUnit *defender)
5959
{
6060
/* TODO: better to put this to designer config */
6161
return CONFIG_BATTLE_MAX_DAMAGE;

Kernel/Wizardry/Core/BattleSys/Source/BattleUI.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ STATIC_DECLAR void Local_ModifyBattleStatusExt(struct BattleUnit *attacker, stru
1515
struct BaseDmg *base_dmg = GetBaseDmg(attacker);
1616

1717
if (attacker->battleAttack > defender->battleDefense) {
18-
u32 simu_dmg, dividend, divisor, quotient;
18+
int simu_dmg, max_damage, dividend, quotient;
1919

20+
max_damage = GetMaxDamage(attacker, defender);
2021
simu_dmg = attacker->battleAttack - defender->battleDefense;
2122

22-
dividend = simu_dmg * base_dmg->increase * 0x100;
23-
divisor = 1 * 100 * base_dmg->decrease;
24-
quotient = k_udiv(dividend, divisor);
23+
dividend = k_udiv(simu_dmg * base_dmg->increase, 100);
24+
if (dividend > max_damage)
25+
dividend = max_damage;
26+
27+
quotient = k_udiv(dividend * 0x100, base_dmg->decrease);
2528

26-
LTRACEF("dividend=%ld, divisor=%ld, quotient=%ld", dividend, divisor, quotient);
2729
attacker->battleAttack = defender->battleDefense + quotient;
2830
}
2931

include/kernel/battle-system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ static inline struct BaseDmg *GetBaseDmg(struct BattleUnit *bu)
222222
}
223223

224224
void PreBattleCalcInit_BaseDamage(struct BattleUnit *attacker, struct BattleUnit *defender);
225+
int GetMaxDamage(struct BattleUnit *attacker, struct BattleUnit *defender);
225226

226227
/**
227228
* BattleUI

0 commit comments

Comments
 (0)