Core/SAI: Add an action_param3 to "summon gob" to control when the object will despawn
Port From (https://github.com/TrinityCore/TrinityCore/commit/4b6e76a5efe5e48ff20b4ef84e0f3dc0f9bc84a0)
This commit is contained in:
@@ -134,4 +134,10 @@ namespace Framework.Constants
|
|||||||
Destroyed = 2,
|
Destroyed = 2,
|
||||||
Rebuilding = 3
|
Rebuilding = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum GameObjectSummonType
|
||||||
|
{
|
||||||
|
TimedOrCorpseDespawn = 0, // despawns after a specified time OR when the summoner dies
|
||||||
|
TimedDespawn = 1 // despawns after a specified time
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2731,6 +2731,7 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
public uint entry;
|
public uint entry;
|
||||||
public uint despawnTime;
|
public uint despawnTime;
|
||||||
|
public uint summonType;
|
||||||
}
|
}
|
||||||
public struct Active
|
public struct Active
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1173,13 +1173,15 @@ namespace Game.AI
|
|||||||
foreach (var target in targets)
|
foreach (var target in targets)
|
||||||
{
|
{
|
||||||
Position pos = target.GetPositionWithOffset(new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o));
|
Position pos = target.GetPositionWithOffset(new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o));
|
||||||
summoner.SummonGameObject(e.Action.summonGO.entry, pos, Quaternion.fromEulerAnglesZYX(pos.GetOrientation(), 0.0f, 0.0f), e.Action.summonGO.despawnTime);
|
Quaternion rot = Quaternion.fromEulerAnglesZYX(pos.GetOrientation(), 0f, 0f);
|
||||||
|
summoner.SummonGameObject(e.Action.summonGO.entry, pos, rot, e.Action.summonGO.despawnTime, (GameObjectSummonType)e.Action.summonGO.summonType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.GetTargetType() != SmartTargets.Position)
|
if (e.GetTargetType() != SmartTargets.Position)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
summoner.SummonGameObject(e.Action.summonGO.entry, new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o), Quaternion.fromEulerAnglesZYX(e.Target.o, 0.0f, 0.0f), e.Action.summonGO.despawnTime);
|
Quaternion _rot = Quaternion.fromEulerAnglesZYX(e.Target.o, 0f, 0f);
|
||||||
|
summoner.SummonGameObject(e.Action.summonGO.entry, new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o), _rot, e.Action.summonGO.despawnTime, (GameObjectSummonType)e.Action.summonGO.summonType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SmartActions.KillUnit:
|
case SmartActions.KillUnit:
|
||||||
|
|||||||
@@ -1456,7 +1456,7 @@ namespace Game.Entities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject SummonGameObject(uint entry, float x, float y, float z, float ang, Quaternion rotation, uint respawnTime)
|
public GameObject SummonGameObject(uint entry, float x, float y, float z, float ang, Quaternion rotation, uint respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn)
|
||||||
{
|
{
|
||||||
if (x == 0 && y == 0 && z == 0)
|
if (x == 0 && y == 0 && z == 0)
|
||||||
{
|
{
|
||||||
@@ -1465,10 +1465,10 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
Position pos = new(x, y, z, ang);
|
Position pos = new(x, y, z, ang);
|
||||||
return SummonGameObject(entry, pos, rotation, respawnTime);
|
return SummonGameObject(entry, pos, rotation, respawnTime, summonType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject SummonGameObject(uint entry, Position pos, Quaternion rotation, uint respawnTime)
|
public GameObject SummonGameObject(uint entry, Position pos, Quaternion rotation, uint respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn)
|
||||||
{
|
{
|
||||||
if (!IsInWorld)
|
if (!IsInWorld)
|
||||||
return null;
|
return null;
|
||||||
@@ -1488,7 +1488,7 @@ namespace Game.Entities
|
|||||||
PhasingHandler.InheritPhaseShift(go, this);
|
PhasingHandler.InheritPhaseShift(go, this);
|
||||||
|
|
||||||
go.SetRespawnTime((int)respawnTime);
|
go.SetRespawnTime((int)respawnTime);
|
||||||
if (IsTypeId(TypeId.Player) || IsTypeId(TypeId.Unit)) //not sure how to handle this
|
if (IsPlayer() || (IsCreature() && summonType == GameObjectSummonType.TimedOrCorpseDespawn)) //not sure how to handle this
|
||||||
ToUnit().AddGameObject(go);
|
ToUnit().AddGameObject(go);
|
||||||
else
|
else
|
||||||
go.SetSpawnedByDefault(false);
|
go.SetSpawnedByDefault(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user