feat(Core/SAI): Implement SMART_ACTION_SET_GUID (#15978)

* feat(Core/SAI): Implement SMART_ACTION_SET_GUID

* Update SmartScript.cpp

* Update src/server/game/AI/SmartScripts/SmartScriptMgr.h

* Update SmartScript.cpp
This commit is contained in:
Skjalf
2023-04-16 21:00:44 -03:00
committed by GitHub
parent 8fa0953671
commit f3c63f9662
3 changed files with 35 additions and 1 deletions

View File

@@ -2688,6 +2688,31 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
} }
break; break;
} }
case SMART_ACTION_SET_GUID:
{
for (WorldObject* target : targets)
{
ObjectGuid guidToSend = me ? me->GetGUID() : go->GetGUID();
if (e.action.setGuid.invokerGUID)
{
if (Unit* invoker = GetLastInvoker())
{
guidToSend = invoker->GetGUID();
}
}
if (Creature* creature = target->ToCreature())
{
creature->AI()->SetGUID(guidToSend, e.action.setGuid.index);
}
else if (GameObject* object = target->ToGameObject())
{
object->AI()->SetGUID(guidToSend, e.action.setGuid.index);
}
}
break;
}
default: default:
LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break; break;

View File

@@ -762,6 +762,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
case SMART_ACTION_ZONE_UNDER_ATTACK: return NO_PARAMS; case SMART_ACTION_ZONE_UNDER_ATTACK: return NO_PARAMS;
case SMART_ACTION_LOAD_GRID: return NO_PARAMS; case SMART_ACTION_LOAD_GRID: return NO_PARAMS;
case SMART_ACTION_MUSIC: return sizeof(SmartAction::music); case SMART_ACTION_MUSIC: return sizeof(SmartAction::music);
case SMART_ACTION_SET_GUID: return sizeof(SmartAction::setGuid);
default: default:
LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.", LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.",
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
@@ -1914,6 +1915,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_SET_CORPSE_DELAY: case SMART_ACTION_SET_CORPSE_DELAY:
case SMART_ACTION_ATTACK_STOP: case SMART_ACTION_ATTACK_STOP:
case SMART_ACTION_PLAY_CINEMATIC: case SMART_ACTION_PLAY_CINEMATIC:
case SMART_ACTION_SET_GUID:
break; break;
default: default:
LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type({}), event_type({}), Entry {} SourceType {} Event {}, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id); LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type({}), event_type({}), Entry {} SourceType {} Event {}, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);

View File

@@ -692,8 +692,9 @@ enum SMART_ACTION
SMART_ACTION_CU_ENCOUNTER_START = 222, // Resets cooldowns on all targets and removes Heroism debuff(s) SMART_ACTION_CU_ENCOUNTER_START = 222, // Resets cooldowns on all targets and removes Heroism debuff(s)
SMART_ACTION_DO_ACTION = 223, // ActionId SMART_ACTION_DO_ACTION = 223, // ActionId
SMART_ACTION_ATTACK_STOP = 224, // SMART_ACTION_ATTACK_STOP = 224, //
SMART_ACTION_SET_GUID = 225, // Sends the invoker's or the base object's own ObjectGuid to target
SMART_ACTION_AC_END = 225, // placeholder SMART_ACTION_AC_END = 226, // placeholder
}; };
enum class SmartActionSummonCreatureFlags enum class SmartActionSummonCreatureFlags
@@ -1357,6 +1358,12 @@ struct SmartAction
{ {
uint32 entry; uint32 entry;
} cinematic; } cinematic;
struct
{
SAIBool invokerGUID;
uint32 index;
} setGuid;
//! Note for any new future actions //! Note for any new future actions
//! All parameters must have type uint32 //! All parameters must have type uint32