Core/SAI: Implement new action to set movement speed

This commit is contained in:
Lopfest
2018-01-30 11:31:52 +01:00
committed by Shauren
parent 04ab611111
commit 5dd6d31c01
3 changed files with 43 additions and 2 deletions

View File

@@ -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;