Skip to content

Commit

Permalink
NPCBots: Fix a crash happening if Death Knight bot casts Dancing Rune…
Browse files Browse the repository at this point in the history
… Weapon. Make non-pet summons created by bots ignore faction hostility rules and attack whatever bot can
  • Loading branch information
trickerer committed Nov 10, 2024
1 parent d347fc2 commit 196070d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
17 changes: 5 additions & 12 deletions src/server/game/AI/NpcBots/bot_death_knight_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1694,18 +1694,6 @@ class death_knight_bot : public CreatureScript
botPet = myPet;
}

void UnsummonAll(bool savePets = true) override
{
UnsummonPet(savePets);
}

void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override
{
//BOT_LOG_ERROR("entities.unit", "SummonedCreatureDies: {}'s {}", me->GetName(), summon->GetName());
//if (summon == botPet)
// botPet = nullptr;
}

void SummonedCreatureDespawn(Creature* summon) override
{
//all hunter bot pets despawn at death or manually (gossip, teleport, etc.)
Expand All @@ -1717,6 +1705,11 @@ class death_knight_bot : public CreatureScript
}
}

void UnsummonAll(bool savePets = true) override
{
UnsummonPet(savePets);
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
6 changes: 5 additions & 1 deletion src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3120,9 +3120,13 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
}
//end npcbot

//npcbot
//npcbot: allow bots and their summons to ignore this rule
if (unit && unitTarget && (unit->IsNPCBotOrPet() || unitTarget->IsNPCBotOrPet()))
{}
else if (unit && unit->GetOwnerGUID() && unit->GetOwnerGUID().IsCreature() && sObjectMgr->GetCreatureTemplate(unit->GetOwnerGUID().GetEntry())->IsNPCBotOrPet())
{}
else if (unitTarget && unitTarget->GetOwnerGUID() && unitTarget->GetOwnerGUID().IsCreature() && sObjectMgr->GetCreatureTemplate(unitTarget->GetOwnerGUID().GetEntry())->IsNPCBotOrPet())
{}
else
//end npcbot
// CvC case - can attack each other only when one of them is hostile
Expand Down
13 changes: 13 additions & 0 deletions src/server/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5479,6 +5479,19 @@ void Spell::SummonGuardian(SpellEffectInfo const& spellEffectInfo, uint32 entry,

if (summon->GetEntry() == 27893)
{
//npcbot
if (unitCaster->IsCreature())
{
if (uint32 weapon = unitCaster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID))
{
summon->SetDisplayId(11686); // modelid2
summon->SetVirtualItem(0, weapon);
}
else
summon->SetDisplayId(1126); // modelid1
}
else
//end npcbot
if (uint32 weapon = unitCaster->GetUInt32Value(PLAYER_VISIBLE_ITEM_16_ENTRYID))
{
summon->SetDisplayId(11686); // modelid2
Expand Down

0 comments on commit 196070d

Please sign in to comment.