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:
hondacrx
2021-06-23 23:50:55 -04:00
parent eefb63647d
commit 515ae6ed12
4 changed files with 15 additions and 6 deletions
@@ -134,4 +134,10 @@ namespace Framework.Constants
Destroyed = 2,
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 despawnTime;
public uint summonType;
}
public struct Active
{
+4 -2
View File
@@ -1173,13 +1173,15 @@ namespace Game.AI
foreach (var target in targets)
{
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)
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;
}
case SmartActions.KillUnit:
+4 -4
View File
@@ -1456,7 +1456,7 @@ namespace Game.Entities
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)
{
@@ -1465,10 +1465,10 @@ namespace Game.Entities
}
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)
return null;
@@ -1488,7 +1488,7 @@ namespace Game.Entities
PhasingHandler.InheritPhaseShift(go, this);
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);
else
go.SetSpawnedByDefault(false);