Core/SAI: ported set speed, weather and override light smart actions from 335

This commit is contained in:
Ovahlord committed 2020-08-22 18:16:03 +02:00
1 parent 0e61055ac3
commit 52287e1f07
8 files changed
+177 -36

No files matched your search

@@ -2385,6 +2385,38 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
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));
for (WorldObject* target : targets)
if (IsCreature(target))
target->ToCreature()->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
break;
}
case SMART_ACTION_OVERRIDE_LIGHT:
{
if (WorldObject* obj = GetBaseObject())
{
obj->GetMap()->SetZoneOverrideLight(e.action.overrideLight.zoneId, e.action.overrideLight.overrideLightId, e.action.overrideLight.transitionMilliseconds);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_LIGHT: %s sets zone override light (zoneId: %u, overrideLightId: %u, transitionMilliseconds: %u)",
obj->GetGUID().ToString().c_str(), e.action.overrideLight.zoneId, e.action.overrideLight.overrideLightId, e.action.overrideLight.transitionMilliseconds);
}
break;
}
case SMART_ACTION_OVERRIDE_WEATHER:
{
if (WorldObject* obj = GetBaseObject())
{
obj->GetMap()->SetZoneWeather(e.action.overrideWeather.zoneId, (WeatherState)e.action.overrideWeather.weatherId, float(e.action.overrideWeather.intensity));
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_WEATHER: %s sets zone weather (zoneId: %u, weatherId: %u, intensity: %u)",
obj->GetGUID().ToString().c_str(), e.action.overrideWeather.zoneId, e.action.overrideWeather.weatherId, e.action.overrideWeather.intensity);
}
break;
}
default:
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break;