Core/SmartAI: implement SMART_ACTION_OVERRIDE_LIGHT and SMART_ACTION_OVERRIDE_WEATHER (#24146)

* Core\SmartAI: implement SMART_ACTION_OVERRIDE_LIGHT and SMART_ACTION_OVERRIDE_WEATHER

* Change the invoker of action to any worldobject

* Revert "Change the invoker of action to any worldobject"

This reverts commit 2e15f7258553b7057c3e8f67c54efc77fb6d75b8.

* Add dbc-validations for new actions

* Use GetBaseObject() instead of Creature* for new actions. Add debug-logging

(cherry picked from commit c65ba35269)
This commit is contained in:
ForesterDev
2020-02-23 00:11:14 +04:00
committed by Shauren
parent f0f7cecc01
commit 1d08423725
4 changed files with 77 additions and 0 deletions

View File

@@ -1700,6 +1700,46 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
}
case SMART_ACTION_OVERRIDE_LIGHT:
{
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(e.action.overrideLight.zoneId);
if (!areaEntry)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent zoneId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.overrideLight.zoneId);
return false;
}
if (areaEntry->ParentAreaID != 0)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses subzone (ID: %u) instead of zone, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.overrideLight.zoneId);
return false;
}
if (!sLightStore.LookupEntry(e.action.overrideLight.lightId))
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent lightId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.overrideLight.lightId);
return false;
}
break;
}
case SMART_ACTION_OVERRIDE_WEATHER:
{
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(e.action.overrideWeather.zoneId);
if (!areaEntry)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent zoneId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.overrideWeather.zoneId);
return false;
}
if (areaEntry->ParentAreaID != 0)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses subzone (ID: %u) instead of zone, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.overrideWeather.zoneId);
return false;
}
break;
}
case SMART_ACTION_CREATE_CONVERSATION:
{
if (!sConversationDataStore->GetConversationTemplate(e.action.conversation.id))