aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-01-19 19:20:56 +0100
committerShauren <shauren.trinity@gmail.com>2022-01-19 19:20:56 +0100
commita270005de1122d18ea4b4e01b114a87bc0e7c0eb (patch)
treebfd60fe2d30a9383af6a936f86b9e802bc9be232 /src/server/game/AI/SmartScripts
parent279744efcd48394edeab2b3ac03fd2dd9a4175ab (diff)
Core/SAI: Support SMART_TARGET_POSITION in SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 5968b4e8791..3657667408a 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -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)
- {
- if (!IsPlayer(target))
- continue;
+ WorldObject* baseObject = GetBaseObject();
- ObjectGuid privateObjectOwner = target->GetGUID();
- if (Creature* summon = GetBaseObject()->SummonPersonalClone((TempSummonType)e.action.becomePersonalClone.type, e.action.becomePersonalClone.duration, 0, 0, privateObjectOwner))
- {
+ auto doCreatePersonalClone = [&](Position const& position, Unit* owner)
+ {
+ 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();