Skip to content

Commit 0513227

Browse files
author
Lanny Ellis
committed
Attempt to fix NPCBot Spells Broken From Spell Change Commit 2-18-26
1 parent b4a7fe6 commit 0513227

File tree

5 files changed

+379
-84
lines changed

5 files changed

+379
-84
lines changed

src/server/scripts/Spells/spell_druid.cpp

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,23 @@ class spell_dru_leader_of_the_pack : public AuraScript
14931493
int32 manaAmount = CalculatePct(target->GetMaxPower(POWER_MANA), healAmount * 2);
14941494
target->CastCustomSpell(SPELL_DRUID_LEADER_OF_THE_PACK_MANA, SPELLVALUE_BASE_POINT0, manaAmount, target, true, nullptr, aurEff);
14951495
}
1496+
1497+
// npcbot - proc for bot
1498+
Unit* caster = GetCaster();
1499+
if (caster && caster->IsNPCBot())
1500+
{
1501+
// Check cooldown on the caster (the bot)
1502+
if (caster->ToCreature() && !caster->ToCreature()->HasSpellCooldown(34299))
1503+
{
1504+
// In the old Unit.cpp, basepoints1 was usually 4% of max health for this spell
1505+
int32 bp0 = int32(caster->GetMaxHealth() * 0.04f);
1506+
1507+
// Call CastCustomSpell ON the caster.
1508+
// We use 'aurEff' as the 'triggeredByAura' equivalent.
1509+
caster->CastCustomSpell(caster, 68285, &bp0, nullptr, nullptr, true, nullptr, aurEff);
1510+
}
1511+
}
1512+
// end npcbot
14961513
}
14971514

14981515
void Register() override
@@ -1552,7 +1569,9 @@ class spell_dru_eclipse : public AuraScript
15521569
return false;
15531570

15541571
Unit* target = GetTarget();
1555-
if (!target->IsPlayer())
1572+
// npcbot: Allow NPCBots to proc this (original code blocked non-players)
1573+
//if (!target->IsPlayer())
1574+
if (!target->IsPlayer() && !target->IsNPCBot())
15561575
return false;
15571576

15581577
bool isWrathSpell = (spellInfo->SpellFamilyFlags[0] & 1);
@@ -1562,12 +1581,28 @@ class spell_dru_eclipse : public AuraScript
15621581
if (!isWrathSpell && !isStarfireSpell)
15631582
return false;
15641583

1584+
//npcbot: Handle Cooldowns for Bots
1585+
if (target->IsNPCBot())
1586+
{
1587+
uint32 triggeredSpell = isWrathSpell ? SPELL_DRUID_ECLIPSE_LUNAR : SPELL_DRUID_ECLIPSE_SOLAR;
1588+
if (target->ToCreature() && target->ToCreature()->HasSpellCooldown(triggeredSpell))
1589+
return false;
1590+
}
1591+
else // Standard Player Cooldown handling
15651592
// Check 30 second internal cooldown
1566-
uint32 now = GameTime::GetGameTimeMS().count();
1567-
if (isWrathSpell && _lunarProcCooldownEnd > now)
1568-
return false;
1569-
if (isStarfireSpell && _solarProcCooldownEnd > now)
1570-
return false;
1593+
//uint32 now = GameTime::GetGameTimeMS().count();
1594+
//if (isWrathSpell && _lunarProcCooldownEnd > now)
1595+
// return false;
1596+
//if (isStarfireSpell && _solarProcCooldownEnd > now)
1597+
// return false;
1598+
{
1599+
uint32 now = GameTime::GetGameTimeMS().count();
1600+
if (isWrathSpell && _lunarProcCooldownEnd > now)
1601+
return false;
1602+
if (isStarfireSpell && _solarProcCooldownEnd > now)
1603+
return false;
1604+
}
1605+
//end npcbot
15711606

15721607
// Don't proc if already have any eclipse aura
15731608
if (target->HasAura(SPELL_DRUID_ECLIPSE_LUNAR) || target->HasAura(SPELL_DRUID_ECLIPSE_SOLAR))
@@ -1587,14 +1622,32 @@ class spell_dru_eclipse : public AuraScript
15871622
bool isWrathSpell = (spellInfo->SpellFamilyFlags[0] & 1);
15881623
uint32 triggeredSpell = isWrathSpell ? SPELL_DRUID_ECLIPSE_LUNAR : SPELL_DRUID_ECLIPSE_SOLAR;
15891624

1625+
//npcbot
1626+
Unit* target = GetTarget();
1627+
1628+
// npcbot: Set internal creature cooldown for bots
1629+
if (target->IsNPCBot() && target->ToCreature())
1630+
{
1631+
target->ToCreature()->AddSpellCooldown(triggeredSpell, 0, 30 * IN_MILLISECONDS);
1632+
}
1633+
else // Set player-specific cooldown timestamps
1634+
{
15901635
// Set 30 second internal cooldown
1591-
uint32 now = GameTime::GetGameTimeMS().count();
1592-
if (isWrathSpell)
1593-
_lunarProcCooldownEnd = now + 30000;
1594-
else
1595-
_solarProcCooldownEnd = now + 30000;
1636+
//uint32 now = GameTime::GetGameTimeMS().count();
1637+
//if (isWrathSpell)
1638+
// _lunarProcCooldownEnd = now + 30000;
1639+
//else
1640+
// _solarProcCooldownEnd = now + 30000;
1641+
uint32 now = GameTime::GetGameTimeMS().count();
1642+
if (isWrathSpell)
1643+
_lunarProcCooldownEnd = now + 30000;
1644+
else
1645+
_solarProcCooldownEnd = now + 30000;
1646+
}
15961647

1597-
GetTarget()->CastSpell(GetTarget(), triggeredSpell, true, nullptr, aurEff);
1648+
//GetTarget()->CastSpell(GetTarget(), triggeredSpell, true, nullptr, aurEff);
1649+
target->CastSpell(target, triggeredSpell, true, nullptr, aurEff);
1650+
//end npcbot
15981651
}
15991652

16001653
void Register() override
@@ -1925,6 +1978,14 @@ class spell_dru_t10_restoration_4p_bonus_dummy : public AuraScript
19251978
if (!healInfo || !healInfo->GetHeal())
19261979
return false;
19271980

1981+
//npcbot
1982+
Unit* actor = eventInfo.GetActor();
1983+
if (actor->IsNPCBot())
1984+
{
1985+
return actor != eventInfo.GetActionTarget();
1986+
}
1987+
//end npcbot
1988+
19281989
Player* caster = eventInfo.GetActor()->ToPlayer();
19291990
if (!caster)
19301991
return false;

src/server/scripts/Spells/spell_hunter.cpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,35 +1343,51 @@ class spell_hun_thrill_of_the_hunt : public AuraScript
13431343
return;
13441344

13451345
Unit* caster = GetTarget();
1346-
if (!caster->IsPlayer())
1346+
//npcbot: Allow NPCBots to proc this
1347+
//if (!caster->IsPlayer())
1348+
if (!caster->IsPlayer() && !caster->IsNPCBot())
13471349
return;
13481350

13491351
int32 mana = 0;
1350-
1351-
Spell* spell = caster->ToPlayer()->m_spellModTakingSpell;
1352-
1353-
// Disable charge drop because of Lock and Load
1354-
if (spell)
1355-
caster->ToPlayer()->SetSpellModTakingSpell(spell, false);
1352+
Player* player = caster->ToPlayer();
1353+
//npcbot
1354+
//Spell* spell = caster->ToPlayer()->m_spellModTakingSpell;
1355+
Spell* spell = player ? player->m_spellModTakingSpell : nullptr;
1356+
1357+
// Disable charge drop because of Lock and Load (Players only)
1358+
//if (spell)
1359+
// caster->ToPlayer()->SetSpellModTakingSpell(spell, false);
1360+
if (spell && player)
1361+
player->SetSpellModTakingSpell(spell, false);
1362+
//end npcbot
13561363

13571364
// Explosive Shot
13581365
if (procSpell->SpellFamilyFlags[2] & 0x200)
13591366
{
13601367
Unit* victim = eventInfo.GetActionTarget();
13611368
if (!victim)
13621369
{
1363-
if (spell)
1364-
caster->ToPlayer()->SetSpellModTakingSpell(spell, true);
1370+
//npcbot
1371+
//if (spell)
1372+
// caster->ToPlayer()->SetSpellModTakingSpell(spell, true);
1373+
if (spell && player)
1374+
player->SetSpellModTakingSpell(spell, true);
13651375
return;
13661376
}
1377+
// This aura check and math matches your original bot logic
13671378
if (AuraEffect const* pEff = victim->GetAuraEffect(SPELL_AURA_PERIODIC_DUMMY, SPELLFAMILY_HUNTER, 0x0, 0x80000000, 0x0, caster->GetGUID()))
13681379
mana = pEff->GetSpellInfo()->CalcPowerCost(caster, SpellSchoolMask(pEff->GetSpellInfo()->SchoolMask)) * 4 / 10 / 3;
1380+
//end npcbot
13691381
}
13701382
else
13711383
mana = procSpell->CalcPowerCost(caster, SpellSchoolMask(procSpell->SchoolMask)) * 4 / 10;
13721384

1373-
if (spell)
1374-
caster->ToPlayer()->SetSpellModTakingSpell(spell, true);
1385+
//npcbot Re-enable spell mod (Players only)
1386+
//if (spell)
1387+
// caster->ToPlayer()->SetSpellModTakingSpell(spell, true);
1388+
if (spell && player)
1389+
player->SetSpellModTakingSpell(spell, true);
1390+
//end npcbot
13751391

13761392
if (mana <= 0)
13771393
return;

src/server/scripts/Spells/spell_item.cpp

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,10 +4597,30 @@ class spell_item_darkmoon_card_greatness : public AuraScript
45974597
PreventDefaultAction();
45984598

45994599
Unit* caster = eventInfo.GetActor();
4600-
float str = caster->GetStat(STAT_STRENGTH);
4601-
float agi = caster->GetStat(STAT_AGILITY);
4602-
float intl = caster->GetStat(STAT_INTELLECT);
4603-
float spi = caster->GetStat(STAT_SPIRIT);
4600+
//npcbot
4601+
//float str = caster->GetStat(STAT_STRENGTH);
4602+
//float agi = caster->GetStat(STAT_AGILITY);
4603+
//float intl = caster->GetStat(STAT_INTELLECT);
4604+
//float spi = caster->GetStat(STAT_SPIRIT);
4605+
float str, agi, intl, spi;
4606+
4607+
// npcbot: Fetch stats using BotMgr for bots, otherwise use standard Unit stats
4608+
if (caster->IsNPCBot())
4609+
{
4610+
str = (float)BotMgr::GetBotStat(caster->ToCreature(), BOT_STAT_MOD_STRENGTH);
4611+
agi = (float)BotMgr::GetBotStat(caster->ToCreature(), BOT_STAT_MOD_AGILITY);
4612+
intl = (float)BotMgr::GetBotStat(caster->ToCreature(), BOT_STAT_MOD_INTELLECT);
4613+
spi = (float)BotMgr::GetBotStat(caster->ToCreature(), BOT_STAT_MOD_SPIRIT);
4614+
}
4615+
else
4616+
{
4617+
str = caster->GetStat(STAT_STRENGTH);
4618+
agi = caster->GetStat(STAT_AGILITY);
4619+
intl = caster->GetStat(STAT_INTELLECT);
4620+
spi = caster->GetStat(STAT_SPIRIT);
4621+
}
4622+
//end npcbot
4623+
46044624
float stat = 0.0f;
46054625

46064626
uint32 spellTrigger = SPELL_DARKMOON_CARD_STRENGTH;
@@ -4629,6 +4649,14 @@ class spell_item_darkmoon_card_greatness : public AuraScript
46294649
}
46304650

46314651
caster->CastSpell(caster, spellTrigger, true, nullptr, aurEff);
4652+
4653+
// npcbot: Add the 45-second cooldown to the bot's internal tracker
4654+
if (caster->IsNPCBot())
4655+
{
4656+
// 45000ms = 45 seconds
4657+
caster->ToCreature()->AddBotSpellCooldown(spellTrigger, 45000);
4658+
}
4659+
//end npcbot
46324660
}
46334661

46344662
void Register() override
@@ -4657,26 +4685,59 @@ class spell_item_death_choice : public AuraScript
46574685
PreventDefaultAction();
46584686

46594687
Unit* caster = eventInfo.GetActor();
4660-
float str = caster->GetStat(STAT_STRENGTH);
4661-
float agi = caster->GetStat(STAT_AGILITY);
4688+
//npcbot
4689+
//float str = caster->GetStat(STAT_STRENGTH);
4690+
//float agi = caster->GetStat(STAT_AGILITY);
4691+
float str, agi;
4692+
4693+
// npcbot: Fetch stats using BotMgr for bots, otherwise use standard Unit stats
4694+
if (caster->IsNPCBot())
4695+
{
4696+
str = (float)BotMgr::GetBotStat(caster->ToCreature(), BOT_STAT_MOD_STRENGTH);
4697+
agi = (float)BotMgr::GetBotStat(caster->ToCreature(), BOT_STAT_MOD_AGILITY);
4698+
}
4699+
else
4700+
{
4701+
str = caster->GetStat(STAT_STRENGTH);
4702+
agi = caster->GetStat(STAT_AGILITY);
4703+
}
4704+
4705+
uint32 spellId = 0;
46624706

46634707
switch (aurEff->GetId())
46644708
{
46654709
case SPELL_DEATH_CHOICE_NORMAL_AURA:
4666-
if (str > agi)
4667-
caster->CastSpell(caster, SPELL_DEATH_CHOICE_NORMAL_STRENGTH, true, nullptr, aurEff);
4668-
else
4669-
caster->CastSpell(caster, SPELL_DEATH_CHOICE_NORMAL_AGILITY, true, nullptr, aurEff);
4710+
//if (str > agi)
4711+
// caster->CastSpell(caster, SPELL_DEATH_CHOICE_NORMAL_STRENGTH, true, nullptr, aurEff);
4712+
//else
4713+
// caster->CastSpell(caster, SPELL_DEATH_CHOICE_NORMAL_AGILITY, true, nullptr, aurEff);
4714+
spellId = (str >= agi) ? SPELL_DEATH_CHOICE_NORMAL_STRENGTH : SPELL_DEATH_CHOICE_NORMAL_AGILITY;
46704715
break;
46714716
case SPELL_DEATH_CHOICE_HEROIC_AURA:
4672-
if (str > agi)
4673-
caster->CastSpell(caster, SPELL_DEATH_CHOICE_HEROIC_STRENGTH, true, nullptr, aurEff);
4674-
else
4675-
caster->CastSpell(caster, SPELL_DEATH_CHOICE_HEROIC_AGILITY, true, nullptr, aurEff);
4717+
//if (str > agi)
4718+
// caster->CastSpell(caster, SPELL_DEATH_CHOICE_HEROIC_STRENGTH, true, nullptr, aurEff);
4719+
//else
4720+
// caster->CastSpell(caster, SPELL_DEATH_CHOICE_HEROIC_AGILITY, true, nullptr, aurEff);
4721+
spellId = (str >= agi) ? SPELL_DEATH_CHOICE_HEROIC_STRENGTH : SPELL_DEATH_CHOICE_HEROIC_AGILITY;
46764722
break;
46774723
default:
4678-
break;
4724+
//break;
4725+
return;
46794726
}
4727+
4728+
// npcbot: Add the 45-second cooldown to the bot's internal tracker
4729+
if (spellId)
4730+
{
4731+
caster->CastSpell(caster, spellId, true, nullptr, aurEff);
4732+
4733+
// npcbot: Synchronize the 45-second internal cooldown (ICD) with the bot's AI
4734+
if (caster->IsNPCBot())
4735+
{
4736+
// 45000ms = 45 seconds
4737+
caster->ToCreature()->AddBotSpellCooldown(spellId, 45000);
4738+
}
4739+
}
4740+
//end npcbot
46804741
}
46814742

46824743
void Register() override

0 commit comments

Comments
 (0)