Core/SAI: added new action type SMART_ACTION_ADD_TO_STORED_TARGET_LIST (#27029)

This commit is contained in:
ModoX
2021-12-25 16:00:34 +01:00
committed by GitHub
parent 924182f692
commit bc4e285c21
4 changed files with 31 additions and 1 deletions

View File

@@ -115,6 +115,14 @@ void SmartScript::StoreTargetList(ObjectVector const& targets, uint32 id)
_storedTargets.emplace(id, ObjectGuidVector(targets));
}
void SmartScript::AddToStoredTargetList(ObjectVector const& targets, uint32 id)
{
auto [itr, inserted] = _storedTargets.try_emplace(id, targets);
if (!inserted)
for (WorldObject* obj : targets)
itr->second.AddGuid(obj->GetGUID());
}
ObjectVector const* SmartScript::GetStoredTargetVector(uint32 id, WorldObject const& ref) const
{
auto itr = _storedTargets.find(id);
@@ -2494,6 +2502,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
break;
}
case SMART_ACTION_ADD_TO_STORED_TARGET_LIST:
{
if (!targets.empty())
AddToStoredTargetList(targets, e.action.addToStoredTargets.id);
else
{
WorldObject* baseObject = GetBaseObject();
TC_LOG_WARN("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_TO_STORED_TARGET_LIST: var %u, baseObject %s, event %u - tried to add no targets to stored target list",
e.action.addToStoredTargets.id, !baseObject ? "" : baseObject->GetName().c_str(), e.event_id);
}
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;