aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2016-08-19 23:54:44 +0200
committertreeston <treeston.mmoc@gmail.com>2016-08-19 23:54:44 +0200
commitaeeae8d09c81e48d68ee3ff5a9588f8f94f5ad4d (patch)
treeaac108cdf1496ddad893fadc8c0b12e5376c2f6e
parentba4d6f63936fe3269e6c8b75358bc00a78fd49df (diff)
parent8c690f9edc3e4e7edd4cf4886ff616c8e6ac4e7e (diff)
Merge remote-tracking branch 'Treeston/3.3.5-petaggro' into 3.3.5 (PR #17800)
-rw-r--r--sql/updates/world/3.3.5/2016_08_19_03_world.sql2
-rw-r--r--src/server/scripts/Pet/pet_dk.cpp55
2 files changed, 29 insertions, 28 deletions
diff --git a/sql/updates/world/3.3.5/2016_08_19_03_world.sql b/sql/updates/world/3.3.5/2016_08_19_03_world.sql
new file mode 100644
index 00000000000..b10a117e6e9
--- /dev/null
+++ b/sql/updates/world/3.3.5/2016_08_19_03_world.sql
@@ -0,0 +1,2 @@
+-- add AI to bloodworms to make them not stupid and suicidal
+UPDATE `creature_template` SET `ScriptName`='npc_pet_dk_guardian', `AIName`='' WHERE `entry` IN (26125,28017);
diff --git a/src/server/scripts/Pet/pet_dk.cpp b/src/server/scripts/Pet/pet_dk.cpp
index 113b14a0d54..ceb400bf4a3 100644
--- a/src/server/scripts/Pet/pet_dk.cpp
+++ b/src/server/scripts/Pet/pet_dk.cpp
@@ -43,21 +43,10 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
struct npc_pet_dk_ebon_gargoyleAI : CasterAI
{
- npc_pet_dk_ebon_gargoyleAI(Creature* creature) : CasterAI(creature)
- {
- Initialize();
- }
-
- void Initialize()
- {
- // Not needed to be despawned now
- _despawnTimer = 0;
- }
+ npc_pet_dk_ebon_gargoyleAI(Creature* creature) : CasterAI(creature) { }
void InitializeAI() override
{
- Initialize();
-
CasterAI::InitializeAI();
ObjectGuid ownerGuid = me->GetOwnerGUID();
if (!ownerGuid)
@@ -112,34 +101,44 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
me->GetMotionMaster()->MovePoint(0, x, y, z);
// Despawn as soon as possible
- _despawnTimer = 4 * IN_MILLISECONDS;
+ me->DespawnOrUnsummon(Seconds(4));
}
+ };
- void UpdateAI(uint32 diff) override
- {
- if (_despawnTimer > 0)
- {
- if (_despawnTimer > diff)
- _despawnTimer -= diff;
- else
- me->DespawnOrUnsummon();
- return;
- }
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return new npc_pet_dk_ebon_gargoyleAI(creature);
+ }
+};
- CasterAI::UpdateAI(diff);
- }
+class npc_pet_dk_guardian : public CreatureScript
+{
+ public:
+ npc_pet_dk_guardian() : CreatureScript("npc_pet_dk_guardian") { }
- private:
- uint32 _despawnTimer;
+ struct npc_pet_dk_guardianAI : public AggressorAI
+ {
+ npc_pet_dk_guardianAI(Creature* creature) : AggressorAI(creature) { }
+
+ bool CanAIAttack(Unit const* target) const override
+ {
+ if (!target)
+ return false;
+ Unit* owner = me->GetOwner();
+ if (owner && !target->IsInCombatWith(owner))
+ return false;
+ return AggressorAI::CanAIAttack(target);
+ }
};
CreatureAI* GetAI(Creature* creature) const override
{
- return new npc_pet_dk_ebon_gargoyleAI(creature);
+ return new npc_pet_dk_guardianAI(creature);
}
};
void AddSC_deathknight_pet_scripts()
{
new npc_pet_dk_ebon_gargoyle();
+ new npc_pet_dk_guardian();
}