Skip to content

Commit 6b54860

Browse files
authored
Merge pull request #10046 from WinterSolstice8/ranged_tp_return_thing
[core] Use slot to determine delay for TP return
2 parents dcaaa65 + b598214 commit 6b54860

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/map/utils/battleutils.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,17 +1864,22 @@ auto GetBaseRangedDelay(CBattleEntity* PEntity) -> uint16
18641864
return baseDelay;
18651865
}
18661866

1867-
auto CalculateTPFromDamageDealt(CBattleEntity* PAttacker, bool isZanshin) -> int32
1867+
auto CalculateTPFromDamageDealt(CBattleEntity* PAttacker, const bool& isZanshin, const SLOTTYPE& slot) -> int32
18681868
{
18691869
if (PAttacker == nullptr)
18701870
{
18711871
ShowWarning("battleutils::CalculateTPFromDamageDealt() - PAttacker was null.");
18721872
return 0;
18731873
}
18741874

1875-
int32 tpReturn = luautils::callGlobal<int32>("xi.combat.tp.getSingleMeleeHitTPReturn", PAttacker, isZanshin);
1876-
1877-
return tpReturn;
1875+
if (slot == SLOT_RANGED || slot == SLOT_AMMO)
1876+
{
1877+
return luautils::callGlobal<int32>("xi.combat.tp.getSingleRangedHitTPReturn", PAttacker);
1878+
}
1879+
else
1880+
{
1881+
return luautils::callGlobal<int32>("xi.combat.tp.getSingleMeleeHitTPReturn", PAttacker, isZanshin);
1882+
}
18781883
}
18791884

18801885
auto CalculateTPFromDamageTaken(CBattleEntity* PAttacker, CBattleEntity* PDefender, int32 damage, uint16 delay) -> int32
@@ -2267,7 +2272,7 @@ int32 TakePhysicalDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, PHY
22672272
{
22682273
bool isZanshin = physicalAttackType == PHYSICAL_ATTACK_TYPE::ZANSHIN;
22692274

2270-
int16 attackerTPReturn = CalculateTPFromDamageDealt(PAttacker, isZanshin);
2275+
int16 attackerTPReturn = CalculateTPFromDamageDealt(PAttacker, isZanshin, static_cast<SLOTTYPE>(slot));
22712276

22722277
PAttacker->addTP((int16)(tpMultiplier * attackerTPReturn));
22732278
}
@@ -2396,7 +2401,7 @@ int32 TakeWeaponskillDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender,
23962401
if (primary)
23972402
// Calculate TP Return from WS
23982403
{
2399-
int16 baseTp = CalculateTPFromDamageDealt(PAttacker, false);
2404+
int16 baseTp = CalculateTPFromDamageDealt(PAttacker, false, static_cast<SLOTTYPE>(slot));
24002405

24012406
standbyTp = bonusTP + (int16)((tpMultiplier * baseTp));
24022407
}

src/map/utils/battleutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ bool CanUseWeaponskill(CCharEntity* PChar, CWeaponSkill* PSkill);
180180
int16 CalculateBaseTP(CBattleEntity* PEntity, int32 delay);
181181
auto GetBaseDelay(CBattleEntity* PEntity) -> uint16; // get base delay of entity, melee only
182182
auto GetBaseRangedDelay(CBattleEntity* PEntity) -> uint16; // get base delay of entity, ranged only
183-
auto CalculateTPFromDamageDealt(CBattleEntity* PAttacker, bool isZanshin) -> int32;
183+
auto CalculateTPFromDamageDealt(CBattleEntity* PAttacker, const bool& isZanshin, const SLOTTYPE& slot) -> int32;
184184
auto CalculateTPFromDamageTaken(CBattleEntity* PAttacker, CBattleEntity* PDefender, int32 damage, uint16 delay) -> int32;
185185
void GenerateCureEnmity(CBattleEntity* PSource, CBattleEntity* PTarget, int32 amount, int32 fixedCE = 0, int32 fixedVE = 0);
186186
void GenerateInRangeEnmity(CBattleEntity* PSource, int32 CE, int32 VE);

0 commit comments

Comments
 (0)