Created
September 19, 2012 09:42
-
-
Save cyberium/3748733 to your computer and use it in GitHub Desktop.
With this patch speed preference of a creature can be restored after any movement (return to home, waypoint, ...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp | |
index 810d3d0..1b5e59b 100644 | |
--- a/src/game/Creature.cpp | |
+++ b/src/game/Creature.cpp | |
@@ -178,7 +178,7 @@ Creature::Creature(CreatureSubtype subtype) : Unit(), | |
m_CreatureSpellCooldowns.clear(); | |
m_CreatureCategoryCooldowns.clear(); | |
- SetWalk(true); | |
+ SetDefaultWalkMode(true); | |
} | |
Creature::~Creature() | |
@@ -1529,7 +1529,7 @@ void Creature::SetDeathState(DeathState s) | |
SetHealth(GetMaxHealth()); | |
SetLootRecipient(NULL); | |
- SetWalk(true); | |
+ ResetToDefaultWalkMode(); | |
if (GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_RESPAWN) | |
ClearTemporaryFaction(); | |
@@ -2523,6 +2523,7 @@ bool Creature::HasStaticDBSpawnData() const | |
return sObjectMgr.GetCreatureData(GetGUIDLow()) != NULL; | |
} | |
+// Set effective speed of creature (can be modified by movement generator) | |
void Creature::SetWalk(bool enable) | |
{ | |
if (enable) | |
@@ -2534,6 +2535,25 @@ void Creature::SetWalk(bool enable) | |
SendMessageToSet(&data, true); | |
} | |
+// Set desired normal speed for that creature | |
+void Creature::SetDefaultWalkMode(bool mode) | |
+{ | |
+ m_movementInfo.SetDefaultWalkMode(mode); | |
+ SetWalk(mode); | |
+} | |
+ | |
+// Get default desired speed for that creature (not actualy applied one) | |
+bool Creature::GetDefaultWalkMode() | |
+{ | |
+ return m_movementInfo.GetDefaultWalkMode(); | |
+} | |
+ | |
+// Reset to defautl desired speed | |
+void Creature::ResetToDefaultWalkMode() | |
+{ | |
+ SetWalk(m_movementInfo.GetDefaultWalkMode()); | |
+} | |
+ | |
void Creature::SetLevitate(bool enable) | |
{ | |
if (enable) | |
diff --git a/src/game/Creature.h b/src/game/Creature.h | |
index 18a9e75..9dafaf8 100644 | |
--- a/src/game/Creature.h | |
+++ b/src/game/Creature.h | |
@@ -533,6 +533,9 @@ class MANGOS_DLL_SPEC Creature : public Unit | |
CreatureAI* AI() { return i_AI; } | |
+ void SetDefaultWalkMode(bool mode); | |
+ bool GetDefaultWalkMode(); | |
+ void ResetToDefaultWalkMode(); | |
void SetWalk(bool enable); | |
void SetLevitate(bool enable); | |
void SetRoot(bool enable) override; | |
diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp | |
index 23d08f2..63e4b44 100644 | |
--- a/src/game/FleeingMovementGenerator.cpp | |
+++ b/src/game/FleeingMovementGenerator.cpp | |
@@ -133,6 +133,7 @@ template<> | |
void FleeingMovementGenerator<Creature>::Finalize(Creature& owner) | |
{ | |
owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_FLEEING_MOVE); | |
+ owner.ResetToDefaultWalkMode(); | |
} | |
template<class T> | |
diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp | |
index 54c3247..e198a64 100644 | |
--- a/src/game/HomeMovementGenerator.cpp | |
+++ b/src/game/HomeMovementGenerator.cpp | |
@@ -68,7 +68,7 @@ void HomeMovementGenerator<Creature>::Finalize(Creature& owner) | |
if (owner.GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_REACH_HOME) | |
owner.ClearTemporaryFaction(); | |
- owner.SetWalk(true); | |
+ owner.ResetToDefaultWalkMode(); | |
owner.LoadCreatureAddon(true); | |
owner.AI()->JustReachedHome(); | |
} | |
diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp | |
index e718fcc..e220f8e 100644 | |
--- a/src/game/RandomMovementGenerator.cpp | |
+++ b/src/game/RandomMovementGenerator.cpp | |
@@ -82,14 +82,14 @@ template<> | |
void RandomMovementGenerator<Creature>::Interrupt(Creature& creature) | |
{ | |
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); | |
- creature.SetWalk(false); | |
+ creature.ResetToDefaultWalkMode(); | |
} | |
template<> | |
void RandomMovementGenerator<Creature>::Finalize(Creature& creature) | |
{ | |
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); | |
- creature.SetWalk(false); | |
+ creature.ResetToDefaultWalkMode(); | |
} | |
template<> | |
diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp | |
index ceca305..8a737a6 100644 | |
--- a/src/game/ScriptMgr.cpp | |
+++ b/src/game/ScriptMgr.cpp | |
@@ -1563,7 +1563,7 @@ void ScriptAction::HandleScriptStep() | |
if (LogIfNotCreature(pSource)) | |
break; | |
- ((Creature*)pSource)->SetWalk(!m_script->run.run); | |
+ ((Creature*)pSource)->SetDefaultWalkMode(!m_script->run.run); | |
break; | |
} | |
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp | |
index 1dd97e9..b861c21 100644 | |
--- a/src/game/SpellEffects.cpp | |
+++ b/src/game/SpellEffects.cpp | |
@@ -5319,7 +5319,7 @@ bool Spell::DoSummonPossessed(CreatureSummonPositions& list, SummonPropertiesEnt | |
spawnCreature->SetLevel(level); | |
- spawnCreature->SetWalk(m_caster->IsWalking()); | |
+ spawnCreature->SetDefaultWalkMode(m_caster->IsWalking()); | |
// TODO: Set Fly (ie glyph dependend) | |
// Internal changes | |
diff --git a/src/game/Unit.h b/src/game/Unit.h | |
index 6e703cb..509fa70 100644 | |
--- a/src/game/Unit.h | |
+++ b/src/game/Unit.h | |
@@ -670,7 +670,7 @@ class MovementInfo | |
{ | |
public: | |
MovementInfo() : moveFlags(MOVEFLAG_NONE), moveFlags2(MOVEFLAG2_NONE), time(0), | |
- t_time(0), t_seat(-1), t_time2(0), s_pitch(0.0f), fallTime(0), u_unk1(0.0f) {} | |
+ t_time(0), t_seat(-1), t_time2(0), s_pitch(0.0f), fallTime(0), u_unk1(0.0f), defaultWalkMode(true) {} | |
// Read/Write methods | |
void Read(ByteBuffer& data); | |
@@ -680,6 +680,8 @@ class MovementInfo | |
void AddMovementFlag(MovementFlags f) { moveFlags |= f; } | |
void RemoveMovementFlag(MovementFlags f) { moveFlags &= ~f; } | |
bool HasMovementFlag(MovementFlags f) const { return moveFlags & f; } | |
+ bool GetDefaultWalkMode() { return defaultWalkMode; }; | |
+ void SetDefaultWalkMode(bool m) { defaultWalkMode = m; } | |
MovementFlags GetMovementFlags() const { return MovementFlags(moveFlags); } | |
void SetMovementFlags(MovementFlags f) { moveFlags = f; } | |
MovementFlags2 GetMovementFlags2() const { return MovementFlags2(moveFlags2); } | |
@@ -728,6 +730,7 @@ class MovementInfo | |
uint16 moveFlags2; // see enum MovementFlags2 | |
uint32 time; | |
Position pos; | |
+ bool defaultWalkMode; // set default run/walk choice | |
// transport | |
ObjectGuid t_guid; | |
Position t_pos; | |
diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp | |
index 6b44ffa..d774190 100644 | |
--- a/src/game/WaypointMovementGenerator.cpp | |
+++ b/src/game/WaypointMovementGenerator.cpp | |
@@ -88,13 +88,13 @@ void WaypointMovementGenerator<Creature>::Initialize(Creature& creature) | |
void WaypointMovementGenerator<Creature>::Finalize(Creature& creature) | |
{ | |
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); | |
- creature.SetWalk(false); | |
+ creature.ResetToDefaultWalkMode(); | |
} | |
void WaypointMovementGenerator<Creature>::Interrupt(Creature& creature) | |
{ | |
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); | |
- creature.SetWalk(false); | |
+ creature.ResetToDefaultWalkMode(); | |
} | |
void WaypointMovementGenerator<Creature>::Reset(Creature& creature) | |
@@ -185,7 +185,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature& creature) | |
if (node.orientation != 100 && node.delay != 0) | |
init.SetFacing(node.orientation); | |
- init.SetWalk(!creature.IsLevitating()); | |
+ init.SetWalk(creature.GetDefaultWalkMode()); | |
init.Launch(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment