Jump to content

[Patch] SummonedMovementInform() in WaypointMovementGenerator


Guest kid 10

Recommended Posts

What features does the patch add?

Implements SummonedMovementInform() in WaypointMovementGenerator to script summoned creatures waypoints.

For which repository revision was the patch created?

11338

Is there a thread in the bug report section or at lighthouse?

I don't know.

Who has been writing this patch?

Me

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp
index c1c06e6..e1bb026 100644
--- a/src/game/WaypointMovementGenerator.cpp
+++ b/src/game/WaypointMovementGenerator.cpp
@@ -40,6 +40,7 @@ alter table creature_movement add `wpguid` int(11) default '0';
#include "WaypointManager.h"
#include "WorldPacket.h"
#include "ScriptMgr.h"
+#include "TemporarySummon.h"

#include 
@@ -300,6 +301,15 @@ void WaypointMovementGenerator::MovementInform(Creature &creature)
{
    if (creature.AI())
        creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
+
+    if (creature.IsTemporarySummon())
+    {
+        TemporarySummon* pSummon = (TemporarySummon*)(&creature);
+        if (pSummon->GetSummonerGuid().IsCreature())
+            if(Creature* pSummoner = creature.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
+                if (pSummoner->AI())
+                    pSummoner->AI()->SummonedMovementInform(&creature, WAYPOINT_MOTION_TYPE, i_currentNode);
+    }
}

bool WaypointMovementGenerator::GetResetPosition(Creature&, float& x, float& y, float& z)

Link to comment
Share on other sites

actually this shouldn't be used for scripting purposes (yet)

as currently waypoints are only assigned by the database-providers, scripting cannot use the waypoint-ids

But yes, in long term, or in short term for situation where it is only need to know when any waypoint is reached - this is really usefull

Link to comment
Share on other sites

  • 9 months later...

Here is an updated version.

I am just too lazy to do a proper test.

Would appreciate if somebody would test this. (both summoned-type cases if possible)

diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp
index fb3012a..23e5ffa 100644
--- a/src/game/WaypointMovementGenerator.cpp
+++ b/src/game/WaypointMovementGenerator.cpp
@@ -41,6 +41,7 @@ alter table creature_movement add `wpguid` int(11) default '0';
#include "ScriptMgr.h"
#include "movement/MoveSplineInit.h"
#include "movement/MoveSpline.h"
+#include "TemporarySummon.h"

#include <cassert>

@@ -224,10 +225,24 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
    return true;
}

-void WaypointMovementGenerator<Creature>::MovementInform(Creature &creature)
+void WaypointMovementGenerator<Creature>::MovementInform(Creature& creature)
{
    if (creature.AI())
        creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
+
+    if (creature.IsTemporarySummon())
+    {
+        TemporarySummon* pSummon = (TemporarySummon*)(&creature);
+        if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
+            if (Creature* pSummoner = creature.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
+                if (pSummoner->AI())
+                    pSummoner->AI()->SummonedMovementInform(&creature, WAYPOINT_MOTION_TYPE, i_currentNode);
+    }
+    else if (Unit* pOwner = creature.GetCharmerOrOwner())
+    {
+        if (pOwner->GetTypeId() == TYPEID_UNIT && ((Creature*)pOwner)->AI())
+            ((Creature*)pOwner)->AI()->SummonedMovementInform(&creature, WAYPOINT_MOTION_TYPE, i_currentNode);
+    }
}

bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x, float& y, float& z)

(fixed copy and paste typo, thx to reamer for pointing)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use