Skip to content

Commit 9fdd453

Browse files
committed
Compile Errors Fix for NPCBot Spells Broken From Spell Change Commit 2-18-26
1 parent 0513227 commit 9fdd453

File tree

5 files changed

+49
-26
lines changed

5 files changed

+49
-26
lines changed

src/server/game/AI/NpcBots/bot_ai.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16842,7 +16842,7 @@ void bot_ai::CastBotItemCombatSpell(DamageInfo const& damageInfo, Item* item, It
1684216842
//TODO: custom spell triggers maybe?
1684316843

1684416844
// Can do effect if any damage done to target
16845-
bool canTrigger = (damageInfo.GetHitMask() & (PROC_HIT_NORMAL | PROC_HIT_CRITICAL | PROC_HIT_ABSORB)) != 0;
16845+
bool canTrigger = (damageInfo.GetBotHitMask() & (PROC_HIT_NORMAL | PROC_HIT_CRITICAL | PROC_HIT_ABSORB)) != 0;
1684616846
if (canTrigger)
1684716847
{
1684816848
for (uint8 i = 0; i != MAX_ITEM_PROTO_SPELLS; ++i)
@@ -16896,7 +16896,7 @@ void bot_ai::CastBotItemCombatSpell(DamageInfo const& damageInfo, Item* item, It
1689616896
if (entry && entry->procEx)
1689716897
{
1689816898
// Check hit/crit/dodge/parry requirement
16899-
if ((entry->procEx & damageInfo.GetHitMask()) == 0)
16899+
if ((entry->procEx & damageInfo.GetBotHitMask()) == 0)
1690016900
continue;
1690116901
}
1690216902
else

src/server/game/AI/NpcBots/bot_bm_ai.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ class blademaster_bot : public CreatureScript
680680
SPELL_SCHOOL_MASK_NORMAL, dinfo.GetAbsorb(), dinfo.GetResist(), false, dinfo.GetBlock(), true);
681681
CleanDamage cl(0, 0, BASE_ATTACK, MELEE_HIT_CRIT);
682682
Unit::DealDamage(me, target, dinfo.GetDamage(), &cl);
683-
Unit::ProcDamageAndSpell(me, dinfo.GetVictim(), calcdinfo->procAttacker, calcdinfo->procVictim, calcdinfo->procEx, dinfo.GetDamage(), calcdinfo->attackType);
683+
Unit::ProcSkillsAndAuras(me, dinfo.GetVictim(), calcdinfo->procAttacker, calcdinfo->procVictim, calcdinfo->procEx, dinfo.GetDamage(), calcdinfo->attackType);
684684
me->CombatStart(target);
685685

686686
me->resetAttackTimer(BASE_ATTACK);

src/server/game/Entities/Unit/Unit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class DamageInfo
386386
[[nodiscard]] uint32 GetUnmitigatedDamage() const;
387387

388388
//npcbot
389-
[[nodiscard]] uint32 GetHitMask() const { return m_procEx; }
389+
[[nodiscard]] uint32 GetBotHitMask() const { return m_procEx; }
390390
//end npcbot
391391
};
392392

@@ -503,6 +503,7 @@ struct CalcDamageInfo
503503
WeaponAttackType attackType; //
504504
uint32 procAttacker;
505505
uint32 procVictim;
506+
uint32 procEx; //npcbot
506507
uint32 cleanDamage; // Used only for rage calculation
507508
MeleeHitOutcome hitOutCome; /// @todo: remove this field (need use TargetState)
508509
};

src/server/scripts/Spells/spell_item.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
#include "SpellScript.h"
2929
#include "SpellScriptLoader.h"
3030
#include "WorldSession.h"
31+
32+
//npcbot
33+
#include "botdatamgr.h"
34+
#include "botmgr.h"
35+
//end npcbot
36+
3137
/*
3238
* Scripts for spells with SPELLFAMILY_GENERIC spells used by items.
3339
* Ordered alphabetically using scriptname.

src/server/scripts/Spells/spell_shaman.cpp

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,12 +1600,16 @@ class spell_sha_flametongue_weapon : public AuraScript
16001600
//if (!item || !item->IsEquipped())
16011601
// return false;
16021602

1603-
Item* item = eventInfo.GetCastItem();
1604-
if (!item && actor->IsPlayer())
1605-
item = actor->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID());
1603+
ObjectGuid itemGuid = GetAura()->GetCastItemGUID();
1604+
Item* item = nullptr;
16061605

1607-
if (!item || (actor->IsPlayer() && !item->IsEquipped()))
1608-
return false;
1606+
if (actor->IsPlayer())
1607+
item = actor->ToPlayer()->GetItemByGuid(itemGuid);
1608+
else if (actor->IsNPCBot())
1609+
item = actor->ToCreature()->GetBotEquipsByGuid(itemGuid);
1610+
1611+
if (!item)
1612+
return false; // Use 'return false;' if this is inside CheckProc (a bool function)
16091613

16101614
//WeaponAttackType attType = Player::GetAttackBySlot(item->GetSlot());
16111615
//if (attType != BASE_ATTACK && attType != OFF_ATTACK)
@@ -1653,14 +1657,13 @@ class spell_sha_flametongue_weapon : public AuraScript
16531657
// return;
16541658

16551659
// npcbot: Item detection for both players and bots
1656-
Item* item = eventInfo.GetCastItem();
1657-
if (!item)
1658-
{
1659-
if (actor->IsPlayer())
1660-
item = actor->ToPlayer()->GetWeaponForAttack(attType);
1661-
else if (actor->IsNPCBot())
1662-
item = actor->ToCreature()->GetBotEquips(attType == BASE_ATTACK ? 0 : 1);
1663-
}
1660+
ObjectGuid itemGuid = GetAura()->GetCastItemGUID();
1661+
Item* item = nullptr;
1662+
1663+
if (actor->IsPlayer())
1664+
item = actor->ToPlayer()->GetWeaponForAttack(attType);
1665+
else if (actor->IsNPCBot())
1666+
item = actor->ToCreature()->GetBotEquipsByGuid(itemGuid);
16641667

16651668
if (!item) return;
16661669

@@ -2234,12 +2237,16 @@ class spell_sha_windfury_weapon : public AuraScript
22342237
// return false;
22352238

22362239
// Get the item responsible for the proc
2237-
Item* item = eventInfo.GetCastItem();
2238-
if (!item && actor->IsPlayer())
2239-
item = actor->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID());
2240+
ObjectGuid itemGuid = GetAura()->GetCastItemGUID();
2241+
Item* item = nullptr;
22402242

2241-
if (!item || (actor->IsPlayer() && !item->IsEquipped()))
2242-
return false;
2243+
if (actor->IsPlayer())
2244+
item = actor->ToPlayer()->GetItemByGuid(itemGuid);
2245+
else if (actor->IsNPCBot())
2246+
item = actor->ToCreature()->GetBotEquipsByGuid(itemGuid);
2247+
2248+
if (!item)
2249+
return false; // Use 'return false;' if this is inside CheckProc (a bool function)
22432250

22442251
//WeaponAttackType attType = Player::GetAttackBySlot(item->GetSlot());
22452252
//if (attType != BASE_ATTACK && attType != OFF_ATTACK)
@@ -2283,10 +2290,16 @@ class spell_sha_windfury_weapon : public AuraScript
22832290
//if (!item)
22842291
// return;
22852292

2286-
Item* item = eventInfo.GetCastItem();
2287-
if (!item && actor->IsPlayer())
2288-
item = actor->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID());
2289-
if (!item) return;
2293+
ObjectGuid itemGuid = GetAura()->GetCastItemGUID();
2294+
Item* item = nullptr;
2295+
2296+
if (actor->IsPlayer())
2297+
item = actor->ToPlayer()->GetItemByGuid(itemGuid);
2298+
else if (actor->IsNPCBot())
2299+
item = actor->ToCreature()->GetBotEquipsByGuid(itemGuid);
2300+
2301+
if (!item)
2302+
return;
22902303

22912304
//uint8 slot = item->GetSlot();
22922305
//bool mainHand = slot == EQUIPMENT_SLOT_MAINHAND;
@@ -2323,6 +2336,9 @@ class spell_sha_windfury_weapon : public AuraScript
23232336
//int32 bonus = windfurySpellInfo ? windfurySpellInfo->Effects[EFFECT_1].CalcValue(player) : 0;
23242337
//bonus = int32(bonus * player->GetAttackTime(mainHand ? BASE_ATTACK : OFF_ATTACK) / 1000.f);
23252338

2339+
// Calculation is now unified for both types
2340+
int32 bonus = spellInfo ? spellInfo->Effects[EFFECT_1].CalcValue(actor) : 0;
2341+
bonus = int32(bonus * actor->GetAttackTime(mainHand ? BASE_ATTACK : OFF_ATTACK) / 1000.f);
23262342

23272343
//player->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, bonus, target, true, item, aurEff);
23282344
//player->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, bonus, target, true, item, aurEff);

0 commit comments

Comments
 (0)