mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/SAI: Support SMART_TARGET_POSITION in SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER
This commit is contained in:
@@ -2524,18 +2524,28 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER:
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
WorldObject* baseObject = GetBaseObject();
|
||||
|
||||
auto doCreatePersonalClone = [&](Position const& position, Unit* owner)
|
||||
{
|
||||
if (!IsPlayer(target))
|
||||
continue;
|
||||
|
||||
ObjectGuid privateObjectOwner = target->GetGUID();
|
||||
if (Creature* summon = GetBaseObject()->SummonPersonalClone((TempSummonType)e.action.becomePersonalClone.type, e.action.becomePersonalClone.duration, 0, 0, privateObjectOwner))
|
||||
{
|
||||
ObjectGuid privateObjectOwner = owner->GetGUID();
|
||||
if (Creature* summon = GetBaseObject()->SummonPersonalClone(position, TempSummonType(e.action.becomePersonalClone.type), e.action.becomePersonalClone.duration, 0, 0, privateObjectOwner))
|
||||
if (IsSmart(summon))
|
||||
ENSURE_AI(SmartAI, summon->AI())->SetTimedActionList(e, e.entryOrGuid, target->ToUnit(), e.event_id + 1);
|
||||
ENSURE_AI(SmartAI, summon->AI())->SetTimedActionList(e, e.entryOrGuid, owner, e.event_id + 1);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// if target is position then targets container was empty
|
||||
if (e.GetTargetType() != SMART_TARGET_POSITION)
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
if (Player* playerTarget = Object::ToPlayer(target))
|
||||
doCreatePersonalClone(baseObject->GetPosition(), playerTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Player* invoker = Object::ToPlayer(GetLastInvoker()))
|
||||
doCreatePersonalClone({ e.target.x, e.target.y, e.target.z, e.target.o }, invoker);
|
||||
}
|
||||
|
||||
// action list will continue on personal clones
|
||||
@@ -4222,7 +4232,7 @@ void SmartScript::SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* i
|
||||
}
|
||||
|
||||
// Do NOT allow to start a new actionlist if a previous one is already running, unless explicitly allowed. We need to always finish the current actionlist
|
||||
if (!e.action.timedActionList.allowOverride && !mTimedActionList.empty())
|
||||
if (e.GetActionType() == SMART_ACTION_CALL_TIMED_ACTIONLIST && !e.action.timedActionList.allowOverride && !mTimedActionList.empty())
|
||||
return;
|
||||
|
||||
mTimedActionList.clear();
|
||||
|
||||
@@ -1866,11 +1866,11 @@ TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, fl
|
||||
return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, 0, privateObjectOwner);
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonPersonalClone(TempSummonType despawnType, uint32 despawnTime, uint32 vehId, uint32 spellId, ObjectGuid privateObjectOwner)
|
||||
TempSummon* WorldObject::SummonPersonalClone(Position const& pos, TempSummonType despawnType, uint32 despawnTime, uint32 vehId, uint32 spellId, ObjectGuid privateObjectOwner)
|
||||
{
|
||||
if (Map* map = FindMap())
|
||||
{
|
||||
if (TempSummon* summon = map->SummonCreature(GetEntry(), GetPosition(), nullptr, despawnTime, this, spellId, vehId, privateObjectOwner))
|
||||
if (TempSummon* summon = map->SummonCreature(GetEntry(), pos, nullptr, despawnTime, this, spellId, vehId, privateObjectOwner))
|
||||
{
|
||||
summon->SetTempSummonType(despawnType);
|
||||
return summon;
|
||||
|
||||
@@ -571,7 +571,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds despawnTime, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty) { return SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId, spellId, privateObjectOwner); }
|
||||
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
|
||||
TempSummon* SummonPersonalClone(TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
|
||||
TempSummon* SummonPersonalClone(Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
|
||||
GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime /* s */, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, uint32 respawnTime /* s */, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
|
||||
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user