From 196070de249cd6179ceedca5afcd1219da763681 Mon Sep 17 00:00:00 2001 From: trickerer Date: Sun, 10 Nov 2024 19:14:00 +0700 Subject: [PATCH] NPCBots: Fix a crash happening if Death Knight bot casts Dancing Rune Weapon. Make non-pet summons created by bots ignore faction hostility rules and attack whatever bot can --- .../game/AI/NpcBots/bot_death_knight_ai.cpp | 17 +++++------------ src/server/game/Entities/Object/Object.cpp | 6 +++++- src/server/game/Spells/SpellEffects.cpp | 13 +++++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/server/game/AI/NpcBots/bot_death_knight_ai.cpp b/src/server/game/AI/NpcBots/bot_death_knight_ai.cpp index 1a808979b6abe..25a2d9e2eb01c 100644 --- a/src/server/game/AI/NpcBots/bot_death_knight_ai.cpp +++ b/src/server/game/AI/NpcBots/bot_death_knight_ai.cpp @@ -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.) @@ -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) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index a981a29d52ff0..5ebaf99d041bb 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -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 diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 89c924dbaf348..8f1a7efc4ade1 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -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