mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/SAI: Added new Flags argument for SMART_ACTION_SUMMON_CREATURE (#26055)
* Added personalSpawn for SMART_ACTION_SUMMON_CREATURE
* Added flags for smart action summon creature, including prefer unit and personal spawn. When preferUnit flag is chosen only the unit will be chosen, even if nullptr
(cherry picked from commit e0278f0537)
# Conflicts:
# src/server/game/AI/SmartScripts/SmartScript.cpp
# src/server/game/AI/SmartScripts/SmartScriptMgr.h
This commit is contained in:
@@ -864,10 +864,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
// If invoker was pet or charm
|
||||
Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
if (player && GetBaseObject())
|
||||
Player* playerCharmed = unit->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
if (playerCharmed && GetBaseObject())
|
||||
{
|
||||
player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
|
||||
playerCharmed->GroupEventHappens(e.action.quest.quest, GetBaseObject());
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player %s, group credit for quest %u",
|
||||
unit->GetGUID().ToString().c_str(), e.action.quest.quest);
|
||||
}
|
||||
@@ -1259,10 +1259,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_SUMMON_CREATURE:
|
||||
{
|
||||
WorldObject* baseObj = GetBaseObjectOrPlayerTrigger();
|
||||
if (!baseObj)
|
||||
EnumFlag<SmartActionSummonCreatureFlags> flags(static_cast<SmartActionSummonCreatureFlags>(e.action.summonCreature.flags));
|
||||
bool preferUnit = flags.HasFlag(SmartActionSummonCreatureFlags::PreferUnit);
|
||||
WorldObject* summoner = preferUnit ? unit : Coalesce<WorldObject>(GetBaseObjectOrPlayerTrigger(), unit);
|
||||
if (!summoner)
|
||||
break;
|
||||
|
||||
bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
|
||||
|
||||
float x, y, z, o;
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
@@ -1271,7 +1275,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
y += e.target.y;
|
||||
z += e.target.z;
|
||||
o += e.target.o;
|
||||
if (Creature* summon = baseObj->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, Milliseconds(e.action.summonCreature.duration)))
|
||||
if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, Milliseconds(e.action.summonCreature.duration), personalSpawn))
|
||||
if (e.action.summonCreature.attackInvoker)
|
||||
summon->AI()->AttackStart(target->ToUnit());
|
||||
}
|
||||
@@ -1279,7 +1283,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (e.GetTargetType() != SMART_TARGET_POSITION)
|
||||
break;
|
||||
|
||||
if (Creature* summon = baseObj->SummonCreature(e.action.summonCreature.creature, e.target.x, e.target.y, e.target.z, e.target.o, (TempSummonType)e.action.summonCreature.type, Milliseconds(e.action.summonCreature.duration)))
|
||||
if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, e.target.x, e.target.y, e.target.z, e.target.o, (TempSummonType)e.action.summonCreature.type, Milliseconds(e.action.summonCreature.duration), personalSpawn))
|
||||
if (unit && e.action.summonCreature.attackInvoker)
|
||||
summon->AI()->AttackStart(unit);
|
||||
break;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define TRINITY_SMARTSCRIPTMGR_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "EnumFlag.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "WaypointDefines.h"
|
||||
#include <map>
|
||||
@@ -468,7 +469,7 @@ enum SMART_ACTION
|
||||
SMART_ACTION_ACTIVATE_GOBJECT = 9, //
|
||||
SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3...
|
||||
SMART_ACTION_CAST = 11, // SpellId, CastFlags, TriggeredFlags
|
||||
SMART_ACTION_SUMMON_CREATURE = 12, // CreatureID, summonType, duration in ms, attackInvoker
|
||||
SMART_ACTION_SUMMON_CREATURE = 12, // CreatureID, summonType, duration in ms, attackInvoker, flags(SmartActionSummonCreatureFlags)
|
||||
SMART_ACTION_THREAT_SINGLE_PCT = 13, // Threat%
|
||||
SMART_ACTION_THREAT_ALL_PCT = 14, // Threat%
|
||||
SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS = 15, // QuestID
|
||||
@@ -604,6 +605,17 @@ enum SMART_ACTION
|
||||
SMART_ACTION_END = 144
|
||||
};
|
||||
|
||||
enum class SmartActionSummonCreatureFlags
|
||||
{
|
||||
None = 0,
|
||||
PersonalSpawn = 1,
|
||||
PreferUnit = 2,
|
||||
|
||||
All = PersonalSpawn | PreferUnit,
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(SmartActionSummonCreatureFlags);
|
||||
|
||||
struct SmartAction
|
||||
{
|
||||
SMART_ACTION type;
|
||||
@@ -686,7 +698,7 @@ struct SmartAction
|
||||
uint32 type;
|
||||
uint32 duration;
|
||||
uint32 attackInvoker;
|
||||
uint32 flags; // SmartActionSummonCreatureFlags // reserved, pending cherry-pick
|
||||
uint32 flags; // SmartActionSummonCreatureFlags
|
||||
} summonCreature;
|
||||
|
||||
struct
|
||||
|
||||
Reference in New Issue
Block a user