aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp17
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp16
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h12
3 files changed, 43 insertions, 2 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index f058c59d434..3dd207261d9 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2873,6 +2873,23 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
delete targets;
break;
}
+ case SMART_ACTION_SET_MOVEMENT_SPEED:
+ {
+ ObjectList* targets = GetTargets(e, unit);
+ if (!targets)
+ break;
+
+ uint32 speedInteger = e.action.movementSpeed.speedInteger;
+ uint32 speedFraction = e.action.movementSpeed.speedFraction;
+ float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(float(speedFraction ? speedFraction : 1)) + 1));
+
+ for (WorldObject* target : *targets)
+ if (IsCreature(target))
+ me->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
+
+ delete targets;
+ break;
+ }
default:
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry " SI64FMTD " SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 5152cb8e707..123aa163f37 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -1492,6 +1492,22 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
}
+ case SMART_ACTION_SET_MOVEMENT_SPEED:
+ {
+ if (e.action.movementSpeed.movementType >= MAX_MOVE_TYPE)
+ {
+ TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid movementType %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.movementSpeed.movementType);
+ return false;
+ }
+
+ if (!e.action.movementSpeed.speedInteger && !e.action.movementSpeed.speedFraction)
+ {
+ TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses speed 0, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
+ return false;
+ }
+
+ break;
+ }
case SMART_ACTION_START_CLOSEST_WAYPOINT:
case SMART_ACTION_FOLLOW:
case SMART_ACTION_SET_ORIENTATION:
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index fe1eb7cf516..25d82698da4 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -598,9 +598,10 @@ enum SMART_ACTION
SMART_ACTION_PLAY_ANIMKIT = 128, // id, type (0 = oneShot, 1 = aiAnim, 2 = meleeAnim, 3 = movementAnim)
SMART_ACTION_SCENE_PLAY = 129, // sceneId
SMART_ACTION_SCENE_CANCEL = 130, // sceneId
- // 131 - 135 : 3.3.5 reserved
+ // 131 - 134 : 3.3.5 reserved
SMART_ACTION_PLAY_CINEMATIC = 135, // reserved for future uses
- SMART_ACTION_END = 136
+ SMART_ACTION_SET_MOVEMENT_SPEED = 136, // movementType, speedInteger, speedFraction
+ SMART_ACTION_END = 137
};
struct SmartAction
@@ -1172,6 +1173,13 @@ struct SmartAction
uint32 sceneId;
} scene;
+ struct
+ {
+ uint32 movementType;
+ uint32 speedInteger;
+ uint32 speedFraction;
+ } movementSpeed;
+
//! Note for any new future actions
//! All parameters must have type uint32