feat(Core/SmartScripts): SMART_ACTION_SET_MOVEMENT_SPEED (#10018)
This commit is contained in:
committed by
GitHub
parent
5f9235a62d
commit
2bc373b4f6
@@ -3330,6 +3330,29 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete targets;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMART_ACTION_SET_MOVEMENT_SPEED:
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
|
||||||
|
ObjectList* targets = GetTargets(e, unit);
|
||||||
|
if (!targets)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const& target : *targets)
|
||||||
|
{
|
||||||
|
if (IsCreature(target))
|
||||||
|
{
|
||||||
|
me->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete targets;
|
delete targets;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1182,6 +1182,21 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SMART_ACTION_SET_MOVEMENT_SPEED:
|
||||||
|
{
|
||||||
|
if (e.action.movementSpeed.movementType >= MAX_MOVE_TYPE)
|
||||||
|
{
|
||||||
|
LOG_ERROR("sql.sql", "SmartAIMgr: Entry %u 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)
|
||||||
|
{
|
||||||
|
LOG_ERROR("sql.sql", "SmartAIMgr: Entry %u 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_START_CLOSEST_WAYPOINT:
|
||||||
case SMART_ACTION_FOLLOW:
|
case SMART_ACTION_FOLLOW:
|
||||||
case SMART_ACTION_SET_ORIENTATION:
|
case SMART_ACTION_SET_ORIENTATION:
|
||||||
|
|||||||
@@ -607,6 +607,7 @@ enum SMART_ACTION
|
|||||||
// SMART_ACTION_INVOKER_CAST = 134, // TODO: solve name conflicts
|
// SMART_ACTION_INVOKER_CAST = 134, // TODO: solve name conflicts
|
||||||
|
|
||||||
SMART_ACTION_TC_END = 135, // placeholder
|
SMART_ACTION_TC_END = 135, // placeholder
|
||||||
|
SMART_ACTION_SET_MOVEMENT_SPEED = 136, // movementType, speedInteger, speedFraction
|
||||||
|
|
||||||
SMART_ACTION_SET_HEALTH_PCT = 142, // percent
|
SMART_ACTION_SET_HEALTH_PCT = 142, // percent
|
||||||
|
|
||||||
@@ -1289,6 +1290,13 @@ struct SmartAction
|
|||||||
uint32 timer;
|
uint32 timer;
|
||||||
} corpseDelay;
|
} corpseDelay;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32 movementType;
|
||||||
|
uint32 speedInteger;
|
||||||
|
uint32 speedFraction;
|
||||||
|
} movementSpeed;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 percent;
|
uint32 percent;
|
||||||
|
|||||||
Reference in New Issue
Block a user