mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/SAI: added new action type SMART_ACTION_ADD_TO_STORED_TARGET_LIST (#27029)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -78,6 +78,7 @@ class TC_GAME_API SmartScript
|
||||
bool IsSmart(bool silent = false);
|
||||
|
||||
void StoreTargetList(ObjectVector const& targets, uint32 id);
|
||||
void AddToStoredTargetList(ObjectVector const& targets, uint32 id);
|
||||
ObjectVector const* GetStoredTargetVector(uint32 id, WorldObject const& ref) const;
|
||||
|
||||
void StoreCounter(uint32 id, uint32 value, uint32 reset);
|
||||
|
||||
@@ -1832,6 +1832,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_REMOVE_ALL_GAMEOBJECTS:
|
||||
case SMART_ACTION_SPAWN_SPAWNGROUP:
|
||||
case SMART_ACTION_DESPAWN_SPAWNGROUP:
|
||||
case SMART_ACTION_ADD_TO_STORED_TARGET_LIST:
|
||||
break;
|
||||
default:
|
||||
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry " SI64FMTD " SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);
|
||||
|
||||
@@ -606,7 +606,8 @@ enum SMART_ACTION
|
||||
SMART_ACTION_OVERRIDE_LIGHT = 138, // zoneId, overrideLightID, transitionMilliseconds
|
||||
SMART_ACTION_OVERRIDE_WEATHER = 139, // zoneId, weatherId, intensity
|
||||
SMART_ACTION_CREATE_CONVERSATION = 143, // conversation_template.id
|
||||
SMART_ACTION_END = 144
|
||||
SMART_ACTION_ADD_TO_STORED_TARGET_LIST = 148, // varID
|
||||
SMART_ACTION_END = 149
|
||||
};
|
||||
|
||||
enum class SmartActionSummonCreatureFlags
|
||||
@@ -1229,6 +1230,11 @@ struct SmartAction
|
||||
uint32 id;
|
||||
} conversation;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 id;
|
||||
} addToStoredTargets;
|
||||
|
||||
//! Note for any new future actions
|
||||
//! All parameters must have type uint32
|
||||
|
||||
@@ -1640,6 +1646,8 @@ class ObjectGuidVector
|
||||
return &_objectVector;
|
||||
}
|
||||
|
||||
void AddGuid(ObjectGuid const& guid) { _guidVector.push_back(guid); }
|
||||
|
||||
~ObjectGuidVector() { }
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user