aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRushor <Rushor@users.noreply.github.com>2020-09-11 21:16:35 +0200
committerGitHub <noreply@github.com>2020-09-11 21:16:35 +0200
commit02fca032e1d497be08681de0bfd7bca979f0dafd (patch)
tree5129d1313d4b97b1fab86af79d707047651d89db
parent9d96e4852a4a25fdc323f656e24034fa1a280826 (diff)
Game/AI: Implement option to move a creature back to Homeposition on Evade. (#24492)
* Game/AI: Implement option to move a creature back to Homeposition on Evade. * If ToHomePosition (action param 1) is 1 > Move to last stored position * If ToHomePosition (action param 1) is 0 > Move to homeposition * Ref: https://github.com/TrinityCore/TrinityCore/issues/24226 * Add parameter for walkmode * Game/AI: SAI SMART_ACTION_EVADE - Rename ToHomePosition to ToRespawnPosition and store point from GetRespawnPosition. * Game/AI: SAI SMART_ACTION_EVADE - Rename ToHomePosition to ToRespawnPosition * Remove broken bits, simplify the code * Update comments * Code cleanup Co-authored-by: jackpoz <giacomopoz@gmail.com>
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp8
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h7
2 files changed, 14 insertions, 1 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 582a53c8388..4a7d2afeb4d 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -822,6 +822,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!me)
break;
+ // Reset home position to respawn position if specified in the parameters
+ if (e.action.evade.toRespawnPosition == 0)
+ {
+ float homeX, homeY, homeZ, homeO;
+ me->GetRespawnPosition(homeX, homeY, homeZ, &homeO);
+ me->SetHomePosition(homeX, homeY, homeZ, homeO);
+ }
+
me->AI()->EnterEvadeMode();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_EVADE: Creature %s EnterEvadeMode", me->GetGUID().ToString().c_str());
break;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 1c8c5271e8e..11b15dc5210 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -480,7 +480,7 @@ enum SMART_ACTION
SMART_ACTION_ALLOW_COMBAT_MOVEMENT = 21, // AllowCombatMovement (0 = stop combat based movement, anything else continue attacking)
SMART_ACTION_SET_EVENT_PHASE = 22, // Phase
SMART_ACTION_INC_EVENT_PHASE = 23, // Value (may be negative to decrement phase, should not be 0)
- SMART_ACTION_EVADE = 24, // No Params
+ SMART_ACTION_EVADE = 24, // toRespawnPosition (0 = Move to RespawnPosition, 1 = Move to last stored home position)
SMART_ACTION_FLEE_FOR_ASSIST = 25, // With Emote
SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID
SMART_ACTION_COMBAT_STOP = 27, //
@@ -1177,6 +1177,11 @@ struct SmartAction
uint32 intensity;
} overrideWeather;
+ struct
+ {
+ uint32 toRespawnPosition;
+ } evade;
+
//! Note for any new future actions
//! All parameters must have type uint32