Core/SAI: Support SMART_TARGET_POSITION in SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER
Port From (https://github.com/TrinityCore/TrinityCore/commit/a270005de1122d18ea4b4e01b114a87bc0e7c0eb)
This commit is contained in:
@@ -2468,20 +2468,33 @@ namespace Game.AI
|
|||||||
}
|
}
|
||||||
case SmartActions.BecomePersonalCloneForPlayer:
|
case SmartActions.BecomePersonalCloneForPlayer:
|
||||||
{
|
{
|
||||||
foreach (WorldObject target in targets)
|
WorldObject baseObject = GetBaseObject();
|
||||||
|
|
||||||
|
void doCreatePersonalClone(Position position, Unit owner)
|
||||||
{
|
{
|
||||||
if (!IsPlayer(target))
|
ObjectGuid privateObjectOwner = owner.GetGUID();
|
||||||
continue;
|
Creature summon = GetBaseObject().SummonPersonalClone(position, (TempSummonType)e.Action.becomePersonalClone.type, e.Action.becomePersonalClone.duration, 0, 0, privateObjectOwner);
|
||||||
|
|
||||||
ObjectGuid privateObjectOwner = target.GetGUID();
|
|
||||||
Creature summon = GetBaseObject().SummonPersonalClone((TempSummonType)e.Action.becomePersonalClone.type, e.Action.becomePersonalClone.duration, 0, 0, privateObjectOwner);
|
|
||||||
if (summon != null)
|
if (summon != null)
|
||||||
{
|
|
||||||
if (IsSmart(summon))
|
if (IsSmart(summon))
|
||||||
((SmartAI)summon.GetAI()).SetTimedActionList(e, (uint)e.EntryOrGuid, target.ToUnit(), e.EventId + 1);
|
((SmartAI)summon.GetAI()).SetTimedActionList(e, (uint)e.EntryOrGuid, owner, e.EventId + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if target is position then targets container was empty
|
||||||
|
if (e.GetTargetType() != SmartTargets.Position)
|
||||||
|
{
|
||||||
|
foreach (WorldObject target in targets)
|
||||||
|
{
|
||||||
|
Player playerTarget = target?.ToPlayer();
|
||||||
|
if (playerTarget != null)
|
||||||
|
doCreatePersonalClone(baseObject.GetPosition(), playerTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Player invoker = GetLastInvoker()?.ToPlayer();
|
||||||
|
if (invoker != null)
|
||||||
|
doCreatePersonalClone(new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o), invoker);
|
||||||
|
}
|
||||||
|
|
||||||
// action list will continue on personal clones
|
// action list will continue on personal clones
|
||||||
_timedActionList.RemoveAll(script => { return script.EventId > e.EventId; });
|
_timedActionList.RemoveAll(script => { return script.EventId > e.EventId; });
|
||||||
@@ -4155,7 +4168,7 @@ namespace Game.AI
|
|||||||
public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker, uint startFromEventId = 0)
|
public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker, uint startFromEventId = 0)
|
||||||
{
|
{
|
||||||
// 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
|
// 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 == 0 && !_timedActionList.Empty())
|
if (e.GetActionType() == SmartActions.CallTimedActionlist && e.Action.timedActionList.allowOverride == 0 && !_timedActionList.Empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_timedActionList.Clear();
|
_timedActionList.Clear();
|
||||||
|
|||||||
@@ -1442,12 +1442,12 @@ namespace Game.Entities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TempSummon SummonPersonalClone(TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default)
|
public TempSummon SummonPersonalClone(Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default)
|
||||||
{
|
{
|
||||||
Map map = GetMap();
|
Map map = GetMap();
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
TempSummon summon = map.SummonCreature(GetEntry(), GetPosition(), null, despawnTime, this, spellId, vehId, privateObjectOwner);
|
TempSummon summon = map.SummonCreature(GetEntry(), pos, null, despawnTime, this, spellId, vehId, privateObjectOwner);
|
||||||
if (summon != null)
|
if (summon != null)
|
||||||
{
|
{
|
||||||
summon.SetTempSummonType(despawnType);
|
summon.SetTempSummonType(despawnType);
|
||||||
|
|||||||
Reference in New Issue
Block a user