diff --git a/Source/Framework/Dynamic/EventMap.cs b/Source/Framework/Dynamic/EventMap.cs index b2a3a01ed..1d68d2b7e 100644 --- a/Source/Framework/Dynamic/EventMap.cs +++ b/Source/Framework/Dynamic/EventMap.cs @@ -203,12 +203,24 @@ namespace Framework.Dynamic } /// - /// Delays all events. If delay is greater than or equal internal timer, delay will be 0. + /// Delays all events. /// /// Amount of delay as TimeSpan type. public void DelayEvents(TimeSpan delay) { - _time = (uint)(delay.TotalMilliseconds < _time ? _time - delay.TotalMilliseconds : 0); + if (Empty()) + return; + + MultiMap delayed = new(); + + foreach (var pair in _eventMap.KeyValueList) + { + delayed.Add(pair.Key + (uint)delay.TotalMilliseconds, pair.Value); + _eventMap.Remove(pair.Key, pair.Value); + } + + foreach (var del in delayed) + _eventMap.Add(del); } /// @@ -269,17 +281,17 @@ namespace Framework.Dynamic } /// - /// Returns time in milliseconds until next event. + /// Returns time as TimeSpan type until next event. /// /// Id of the event. - /// Time of next event. - public uint GetTimeUntilEvent(uint eventId) + /// Time of next event. If event is not scheduled returns + public TimeSpan GetTimeUntilEvent(uint eventId) { foreach (var pair in _eventMap) if (eventId == (pair.Value & 0x0000FFFF)) - return pair.Key - _time; + return TimeSpan.FromMilliseconds(pair.Key - _time); - return uint.MaxValue; + return TimeSpan.MaxValue; } /// diff --git a/Source/Framework/Dynamic/EventSystem.cs b/Source/Framework/Dynamic/EventSystem.cs index 813f7204e..0d35c9fb2 100644 --- a/Source/Framework/Dynamic/EventSystem.cs +++ b/Source/Framework/Dynamic/EventSystem.cs @@ -58,7 +58,7 @@ namespace Framework.Dynamic // Reschedule non deletable events to be checked at // the next update tick - AddEvent(Event, CalculateTime(1), false); + AddEvent(Event, CalculateTime(TimeSpan.FromMilliseconds(1)), false); } } @@ -87,38 +87,40 @@ namespace Framework.Dynamic m_events.Clear(); } - public void AddEvent(BasicEvent Event, ulong e_time, bool set_addtime = true) + public void AddEvent(BasicEvent Event, TimeSpan e_time, bool set_addtime = true) { if (set_addtime) Event.m_addTime = m_time; - Event.m_execTime = e_time; - m_events.Add(e_time, Event); + Event.m_execTime = (ulong)e_time.TotalMilliseconds; + m_events.Add((ulong)e_time.TotalMilliseconds, Event); } - public void AddEvent(Action action, ulong e_time, bool set_addtime = true) { AddEvent(new LambdaBasicEvent(action), e_time, set_addtime); } + public void AddEvent(Action action, TimeSpan e_time, bool set_addtime = true) { AddEvent(new LambdaBasicEvent(action), e_time, set_addtime); } + + public void AddEventAtOffset(BasicEvent Event, TimeSpan offset) { AddEvent(Event, CalculateTime(offset)); } - public void AddEventAtOffset(BasicEvent Event, TimeSpan offset) { AddEvent(Event, CalculateTime((ulong)offset.TotalMilliseconds)); } + public void AddEventAtOffset(BasicEvent Event, TimeSpan offset, TimeSpan offset2) { AddEvent(Event, CalculateTime(RandomHelper.RandTime(offset, offset2))); } public void AddEventAtOffset(Action action, TimeSpan offset) { AddEventAtOffset(new LambdaBasicEvent(action), offset); } - public void ModifyEventTime(BasicEvent Event, ulong newTime) + public void ModifyEventTime(BasicEvent Event, TimeSpan newTime) { foreach (var pair in m_events) { if (pair.Value != Event) continue; - Event.m_execTime = newTime; + Event.m_execTime = (ulong)newTime.TotalMilliseconds; m_events.Remove(pair); - m_events.Add(newTime, Event); + m_events.Add((ulong)newTime.TotalMilliseconds, Event); break; } } - public ulong CalculateTime(ulong t_offset) + public TimeSpan CalculateTime(TimeSpan t_offset) { - return (m_time + t_offset); + return TimeSpan.FromMilliseconds(m_time) + t_offset; } public SortedMultiMap GetEvents() { return m_events; } diff --git a/Source/Game/AI/CoreAI/CreatureAI.cs b/Source/Game/AI/CoreAI/CreatureAI.cs index 60d7d1d82..0016984a0 100644 --- a/Source/Game/AI/CoreAI/CreatureAI.cs +++ b/Source/Game/AI/CoreAI/CreatureAI.cs @@ -322,7 +322,7 @@ namespace Game.AI return true; } - public CypherStrings VisualizeBoundary(int duration, Unit owner = null, bool fill = false) + public CypherStrings VisualizeBoundary(TimeSpan duration, Unit owner = null, bool fill = false) { if (!owner) return 0; @@ -380,7 +380,7 @@ namespace Game.AI if (fill || hasOutOfBoundsNeighbor) { var pos = new Position(startPosition.GetPositionX() + front.Key * SharedConst.BoundaryVisualizeStepSize, startPosition.GetPositionY() + front.Value * SharedConst.BoundaryVisualizeStepSize, spawnZ); - TempSummon point = owner.SummonCreature(SharedConst.BoundaryVisualizeCreature, pos, TempSummonType.TimedDespawn, (uint)(duration * Time.InMilliseconds)); + TempSummon point = owner.SummonCreature(SharedConst.BoundaryVisualizeCreature, pos, TempSummonType.TimedDespawn, duration); if (point) { point.SetObjectScale(SharedConst.BoundaryVisualizeCreatureScale); @@ -417,18 +417,18 @@ namespace Game.AI } } - public Creature DoSummon(uint entry, Position pos, uint despawnTime = 30000, TempSummonType summonType = TempSummonType.CorpseTimedDespawn) + public Creature DoSummon(uint entry, Position pos, TimeSpan despawnTime, TempSummonType summonType = TempSummonType.CorpseTimedDespawn) { return me.SummonCreature(entry, pos, summonType, despawnTime); } - public Creature DoSummon(uint entry, WorldObject obj, float radius = 5.0f, uint despawnTime = 30000, TempSummonType summonType = TempSummonType.CorpseTimedDespawn) + public Creature DoSummon(uint entry, WorldObject obj, float radius = 5.0f, TimeSpan despawnTime = default, TempSummonType summonType = TempSummonType.CorpseTimedDespawn) { Position pos = obj.GetRandomNearPosition(radius); return me.SummonCreature(entry, pos, summonType, despawnTime); } - public Creature DoSummonFlyer(uint entry, WorldObject obj, float flightZ, float radius = 5.0f, uint despawnTime = 30000, TempSummonType summonType = TempSummonType.CorpseTimedDespawn) + public Creature DoSummonFlyer(uint entry, WorldObject obj, float flightZ, float radius = 5.0f, TimeSpan despawnTime = default, TempSummonType summonType = TempSummonType.CorpseTimedDespawn) { Position pos = obj.GetRandomNearPosition(radius); pos.posZ += flightZ; diff --git a/Source/Game/AI/ScriptedAI/ScriptedAI.cs b/Source/Game/AI/ScriptedAI/ScriptedAI.cs index 980e37b12..550d2af32 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedAI.cs @@ -259,7 +259,7 @@ namespace Game.AI } //Spawns a creature relative to me - public Creature DoSpawnCreature(uint entry, float offsetX, float offsetY, float offsetZ, float angle, TempSummonType type, uint despawntime) + public Creature DoSpawnCreature(uint entry, float offsetX, float offsetY, float offsetZ, float angle, TempSummonType type, TimeSpan despawntime) { return me.SummonCreature(entry, me.GetPositionX() + offsetX, me.GetPositionY() + offsetY, me.GetPositionZ() + offsetZ, angle, type, despawntime); } @@ -639,8 +639,6 @@ namespace Game.AI DoMeleeAttackIfReady(); } - public void _DespawnAtEvade(uint delayToRespawn = 30, Creature who = null) { _DespawnAtEvade(TimeSpan.FromSeconds(delayToRespawn), who); } - public void _DespawnAtEvade(TimeSpan delayToRespawn, Creature who = null) { if (delayToRespawn < TimeSpan.FromSeconds(2)) @@ -660,7 +658,7 @@ namespace Game.AI return; } - who.DespawnOrUnsummon(0, delayToRespawn); + who.DespawnOrUnsummon(TimeSpan.Zero, delayToRespawn); if (instance != null && who == me) instance.SetBossState(_bossId, EncounterState.Fail); diff --git a/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs b/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs index acac8c12a..bebe2e1b5 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs @@ -29,7 +29,7 @@ namespace Game.AI { public EscortAI(Creature creature) : base(creature) { - _pauseTimer = 2500; + _pauseTimer = TimeSpan.FromSeconds(2.5); _playerCheckTimer = 1000; _maxPlayerDistance = 100; _activeAttacker = true; @@ -118,7 +118,7 @@ namespace Game.AI SetCombatMovement(true); //add a small delay before going to first waypoint, normal in near all cases - _pauseTimer = 2000; + _pauseTimer = TimeSpan.FromSeconds(2); if (me.GetFaction() != me.GetCreatureTemplate().Faction) me.RestoreFaction(); @@ -182,11 +182,11 @@ namespace Game.AI //Waypoint Updating if (HasEscortState(EscortState.Escorting) && !me.IsEngaged() && !HasEscortState(EscortState.Returning)) { - if (_pauseTimer <= diff) + if (_pauseTimer.TotalMilliseconds <= diff) { if (!HasEscortState(EscortState.Paused)) { - _pauseTimer = 0; + _pauseTimer = TimeSpan.Zero; if (_ended) { @@ -231,7 +231,7 @@ namespace Game.AI } } else - _pauseTimer -= diff; + _pauseTimer -= TimeSpan.FromMilliseconds(diff); } @@ -252,7 +252,7 @@ namespace Game.AI if (_instantRespawn) { if (!isEscort) - me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(1)); + me.DespawnOrUnsummon(TimeSpan.Zero, TimeSpan.FromSeconds(1)); else me.GetMap().Respawn(SpawnObjectType.Creature, me.GetSpawnId()); } @@ -288,8 +288,8 @@ namespace Game.AI //Combat start position reached, continue waypoint movement if (moveType == MovementGeneratorType.Point) { - if (_pauseTimer == 0) - _pauseTimer = 2000; + if (_pauseTimer == TimeSpan.Zero) + _pauseTimer = TimeSpan.FromSeconds(2); if (Id == EscortPointIds.LastPoint) { @@ -317,12 +317,12 @@ namespace Game.AI { _started = false; _ended = true; - _pauseTimer = 1000; + _pauseTimer = TimeSpan.FromSeconds(1); } } } - public void AddWaypoint(uint id, float x, float y, float z, float orientation = 0, uint waitTime = 0) + public void AddWaypoint(uint id, float x, float y, float z, float orientation, TimeSpan waitTime) { GridDefines.NormalizeMapCoord(ref x); GridDefines.NormalizeMapCoord(ref y); @@ -334,7 +334,7 @@ namespace Game.AI waypoint.z = z; waypoint.orientation = orientation; waypoint.moveType = _running ? WaypointMoveType.Run : WaypointMoveType.Walk; - waypoint.delay = waitTime; + waypoint.delay = (uint)waitTime.TotalMilliseconds; waypoint.eventId = 0; waypoint.eventChance = 100; _path.nodes.Add(waypoint); @@ -456,7 +456,7 @@ namespace Game.AI } } - void SetPauseTimer(uint Timer) { _pauseTimer = Timer; } + public void SetPauseTimer(TimeSpan timer) { _pauseTimer = timer; } public bool HasEscortState(EscortState escortState) { return (_escortState & escortState) != 0; } public override bool IsEscorted() { return !_playerGUID.IsEmpty(); } @@ -476,7 +476,7 @@ namespace Game.AI void RemoveEscortState(EscortState escortState) { _escortState &= ~escortState; } ObjectGuid _playerGUID; - uint _pauseTimer; + TimeSpan _pauseTimer; uint _playerCheckTimer; EscortState _escortState; float _maxPlayerDistance; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index a6b6f29d7..f32f88f45 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1185,7 +1185,7 @@ namespace Game.AI y += e.Target.y; z += e.Target.z; o += e.Target.o; - Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, privateObjectOwner); + Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner); if (summon != null) if (e.Action.summonCreature.attackInvoker != 0) summon.GetAI().AttackStart(target.ToUnit()); @@ -1194,7 +1194,7 @@ namespace Game.AI if (e.GetTargetType() != SmartTargets.Position) break; - Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, privateObjectOwner); + Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner); if (summon1 != null) if (unit != null && e.Action.summonCreature.attackInvoker != 0) summon1.GetAI().AttackStart(unit); @@ -1210,14 +1210,14 @@ namespace Game.AI { Position pos = target.GetPositionWithOffset(new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o)); Quaternion rot = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(pos.GetOrientation(), 0f, 0f)); - summoner.SummonGameObject(e.Action.summonGO.entry, pos, rot, e.Action.summonGO.despawnTime, (GameObjectSummonType)e.Action.summonGO.summonType); + summoner.SummonGameObject(e.Action.summonGO.entry, pos, rot, TimeSpan.FromSeconds(e.Action.summonGO.despawnTime), (GameObjectSummonType)e.Action.summonGO.summonType); } if (e.GetTargetType() != SmartTargets.Position) break; Quaternion _rot = Quaternion.CreateFromRotationMatrix(Extensions.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); + summoner.SummonGameObject(e.Action.summonGO.entry, new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o), _rot, TimeSpan.FromSeconds(e.Action.summonGO.despawnTime), (GameObjectSummonType)e.Action.summonGO.summonType); break; } case SmartActions.KillUnit: @@ -2473,7 +2473,7 @@ namespace Game.AI void doCreatePersonalClone(Position position, Unit owner) { ObjectGuid privateObjectOwner = owner.GetGUID(); - Creature summon = GetBaseObject().SummonPersonalClone(position, (TempSummonType)e.Action.becomePersonalClone.type, e.Action.becomePersonalClone.duration, 0, 0, privateObjectOwner); + Creature summon = GetBaseObject().SummonPersonalClone(position, (TempSummonType)e.Action.becomePersonalClone.type, TimeSpan.FromMilliseconds(e.Action.becomePersonalClone.duration), 0, 0, privateObjectOwner); if (summon != null) if (IsSmart(summon)) ((SmartAI)summon.GetAI()).SetTimedActionList(e, (uint)e.EntryOrGuid, owner, e.EventId + 1); diff --git a/Source/Game/BattleGrounds/BattleGroundQueue.cs b/Source/Game/BattleGrounds/BattleGroundQueue.cs index 57c557522..1bcfe35a5 100644 --- a/Source/Game/BattleGrounds/BattleGroundQueue.cs +++ b/Source/Game/BattleGrounds/BattleGroundQueue.cs @@ -407,10 +407,10 @@ namespace Game.BattleGrounds // create remind invite events BGQueueInviteEvent inviteEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgTypeId, (ArenaTypes)m_queueId.TeamSize, ginfo.RemoveInviteTime); - m_events.AddEvent(inviteEvent, m_events.CalculateTime(BattlegroundConst.InvitationRemindTime)); + m_events.AddEvent(inviteEvent, m_events.CalculateTime(TimeSpan.FromMilliseconds(BattlegroundConst.InvitationRemindTime))); // create automatic remove events BGQueueRemoveEvent removeEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgQueueTypeId, ginfo.RemoveInviteTime); - m_events.AddEvent(removeEvent, m_events.CalculateTime(BattlegroundConst.InviteAcceptWaitTime)); + m_events.AddEvent(removeEvent, m_events.CalculateTime(TimeSpan.FromMilliseconds(BattlegroundConst.InviteAcceptWaitTime))); uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId); diff --git a/Source/Game/Chat/Commands/DebugCommands.cs b/Source/Game/Chat/Commands/DebugCommands.cs index 6c72a6d5f..37e864a14 100644 --- a/Source/Game/Chat/Commands/DebugCommands.cs +++ b/Source/Game/Chat/Commands/DebugCommands.cs @@ -93,10 +93,12 @@ namespace Game.Chat string fill_str = args.NextString(); string duration_str = args.NextString(); - if (!int.TryParse(duration_str, out int duration)) - duration = -1; - if (duration <= 0 || duration >= 30 * Time.Minute) // arbitary upper limit - duration = 3 * Time.Minute; + if (!int.TryParse(duration_str, out int tempDuration)) + tempDuration = 0; + + TimeSpan duration = TimeSpan.FromSeconds(tempDuration); + if (duration <= TimeSpan.Zero || duration >= TimeSpan.FromMinutes(30)) // arbitary upper limit + duration = TimeSpan.FromMinutes(3); bool doFill = fill_str.ToLower().Equals("fill"); diff --git a/Source/Game/Chat/Commands/GameObjectCommands.cs b/Source/Game/Chat/Commands/GameObjectCommands.cs index 6e93d91e9..71e631b8a 100644 --- a/Source/Game/Chat/Commands/GameObjectCommands.cs +++ b/Source/Game/Chat/Commands/GameObjectCommands.cs @@ -645,10 +645,10 @@ namespace Game.Chat Player player = handler.GetPlayer(); uint spawntime = args.NextUInt32(); - uint spawntm = 300; + TimeSpan spawntm = TimeSpan.FromSeconds(300); if (spawntime != 0) - spawntm = spawntime; + spawntm = TimeSpan.FromSeconds(spawntime); Quaternion rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f)); if (Global.ObjectMgr.GetGameObjectTemplate(id) == null) diff --git a/Source/Game/Chat/Commands/MMapsCommands.cs b/Source/Game/Chat/Commands/MMapsCommands.cs index d1eef56fb..ec35abf56 100644 --- a/Source/Game/Chat/Commands/MMapsCommands.cs +++ b/Source/Game/Chat/Commands/MMapsCommands.cs @@ -20,6 +20,7 @@ using Framework.IO; using Game.Entities; using Game.Maps; using Game.Movement; +using System; using System.Collections.Generic; namespace Game.Chat @@ -84,7 +85,7 @@ namespace Game.Chat handler.SendSysMessage("Enable GM mode to see the path points."); for (uint i = 0; i < pointPath.Length; ++i) - player.SummonCreature(1, pointPath[i].X, pointPath[i].Y, pointPath[i].Z, 0, TempSummonType.TimedDespawn, 9000); + player.SummonCreature(1, pointPath[i].X, pointPath[i].Y, pointPath[i].Z, 0, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(9)); return true; } diff --git a/Source/Game/Chat/Commands/NPCCommands.cs b/Source/Game/Chat/Commands/NPCCommands.cs index cdb686487..1c5ece315 100644 --- a/Source/Game/Chat/Commands/NPCCommands.cs +++ b/Source/Game/Chat/Commands/NPCCommands.cs @@ -858,7 +858,7 @@ namespace Game.Chat return false; Player chr = handler.GetSession().GetPlayer(); - chr.SummonCreature(id, chr, loot ? TempSummonType.CorpseTimedDespawn : TempSummonType.CorpseDespawn, 30 * Time.InMilliseconds); + chr.SummonCreature(id, chr, loot ? TempSummonType.CorpseTimedDespawn : TempSummonType.CorpseDespawn, TimeSpan.FromSeconds(30)); return true; } diff --git a/Source/Game/Combat/CombatManager.cs b/Source/Game/Combat/CombatManager.cs index acf27cfca..b36bbc6d5 100644 --- a/Source/Game/Combat/CombatManager.cs +++ b/Source/Game/Combat/CombatManager.cs @@ -58,10 +58,10 @@ namespace Game.Combat if (a.HasUnitState(UnitState.InFlight) || b.HasUnitState(UnitState.InFlight)) return false; Creature aCreature = a.ToCreature(); - if (aCreature?.IsCombatDisallowed()) + if (aCreature != null && aCreature.IsCombatDisallowed()) return false; Creature bCreature = b.ToCreature(); - if (bCreature?.IsCombatDisallowed()) + if (bCreature != null && bCreature.IsCombatDisallowed()) return false; if (a.IsFriendlyTo(b) || b.IsFriendlyTo(a)) return false; diff --git a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs index ec660f71b..b6c8de5f7 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs @@ -1035,7 +1035,7 @@ namespace Game.Entities Player player = caster.ToPlayer(); if (player) if (player.IsDebugAreaTriggers) - player.SummonCreature(1, this, TempSummonType.TimedDespawn, GetTimeToTarget()); + player.SummonCreature(1, this, TempSummonType.TimedDespawn, TimeSpan.FromMilliseconds(GetTimeToTarget())); } } diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 8ea460c72..f8d5b2f4c 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -1959,7 +1959,7 @@ namespace Game.Entities { if (timeMSToDespawn != 0) { - m_Events.AddEvent(new ForcedDespawnDelayEvent(this, forceRespawnTimer), m_Events.CalculateTime(timeMSToDespawn)); + m_Events.AddEvent(new ForcedDespawnDelayEvent(this, forceRespawnTimer), m_Events.CalculateTime(TimeSpan.FromMilliseconds(timeMSToDespawn))); return; } @@ -2008,15 +2008,13 @@ namespace Game.Entities } } - public void DespawnOrUnsummon(TimeSpan time, TimeSpan forceRespawnTimer = default) { DespawnOrUnsummon((uint)time.TotalMilliseconds, forceRespawnTimer); } - - public void DespawnOrUnsummon(uint msTimeToDespawn = 0, TimeSpan forceRespawnTimer = default) + public void DespawnOrUnsummon(TimeSpan msTimeToDespawn = default, TimeSpan forceRespawnTimer = default) { TempSummon summon = ToTempSummon(); if (summon != null) - summon.UnSummon(msTimeToDespawn); + summon.UnSummon((uint)msTimeToDespawn.TotalMilliseconds); else - ForcedDespawn(msTimeToDespawn, forceRespawnTimer); + ForcedDespawn((uint)msTimeToDespawn.TotalMilliseconds, forceRespawnTimer); } public void LoadTemplateImmunities() @@ -2167,7 +2165,7 @@ namespace Game.Entities e.AddAssistant(assistList.First().GetGUID()); assistList.Remove(assistList.First()); } - m_Events.AddEvent(e, m_Events.CalculateTime(WorldConfig.GetUIntValue(WorldCfg.CreatureFamilyAssistanceDelay))); + m_Events.AddEvent(e, m_Events.CalculateTime(TimeSpan.FromMilliseconds(WorldConfig.GetUIntValue(WorldCfg.CreatureFamilyAssistanceDelay)))); } } } @@ -3098,7 +3096,7 @@ namespace Game.Entities { return GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Guard); } - bool IsCombatDisallowed() + public bool IsCombatDisallowed() { return GetCreatureTemplate().FlagsExtra.HasFlag(CreatureFlagsExtra.NoCombat); } @@ -3404,7 +3402,7 @@ namespace Game.Entities } public override bool Execute(ulong e_time, uint p_time) { - m_owner.DespawnOrUnsummon(0, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime + m_owner.DespawnOrUnsummon(TimeSpan.Zero, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime return true; } diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index eb56ecf3c..28b511441 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -1415,7 +1415,7 @@ namespace Game.Entities return null; } - public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, ObjectGuid privateObjectOwner = default) + public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, ObjectGuid privateObjectOwner = default) { if (x == 0.0f && y == 0.0f && z == 0.0f) GetClosePoint(out x, out y, out z, GetCombatReach()); @@ -1426,12 +1426,12 @@ namespace Game.Entities return SummonCreature(entry, new Position(x, y, z, o), despawnType, despawnTime, 0, 0, privateObjectOwner); } - public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default) + public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default) { Map map = GetMap(); if (map != null) { - TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, this, spellId, vehId, privateObjectOwner); + TempSummon summon = map.SummonCreature(entry, pos, null, (uint)despawnTime.TotalMilliseconds, this, spellId, vehId, privateObjectOwner); if (summon != null) { summon.SetTempSummonType(despawnType); @@ -1442,12 +1442,12 @@ namespace Game.Entities return null; } - public TempSummon SummonPersonalClone(Position pos, 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, TimeSpan despawnTime = default, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default) { Map map = GetMap(); if (map != null) { - TempSummon summon = map.SummonCreature(GetEntry(), pos, null, despawnTime, this, spellId, vehId, privateObjectOwner); + TempSummon summon = map.SummonCreature(GetEntry(), pos, null, (uint)despawnTime.TotalMilliseconds, this, spellId, vehId, privateObjectOwner); if (summon != null) { summon.SetTempSummonType(despawnType); @@ -1458,7 +1458,7 @@ namespace Game.Entities return null; } - public GameObject SummonGameObject(uint entry, float x, float y, float z, float ang, Quaternion rotation, uint respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn) + public GameObject SummonGameObject(uint entry, float x, float y, float z, float ang, Quaternion rotation, TimeSpan respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn) { if (x == 0 && y == 0 && z == 0) { @@ -1470,7 +1470,7 @@ namespace Game.Entities return SummonGameObject(entry, pos, rotation, respawnTime, summonType); } - public GameObject SummonGameObject(uint entry, Position pos, Quaternion rotation, uint respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn) + public GameObject SummonGameObject(uint entry, Position pos, Quaternion rotation, TimeSpan respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn) { if (!IsInWorld) return null; @@ -1489,7 +1489,7 @@ namespace Game.Entities PhasingHandler.InheritPhaseShift(go, this); - go.SetRespawnTime((int)respawnTime); + go.SetRespawnTime((int)respawnTime.TotalSeconds); if (IsPlayer() || (IsCreature() && summonType == GameObjectSummonType.TimedOrCorpseDespawn)) //not sure how to handle this ToUnit().AddGameObject(go); else @@ -1499,10 +1499,10 @@ namespace Game.Entities return go; } - public Creature SummonTrigger(float x, float y, float z, float ang, uint duration, CreatureAI AI = null) + public Creature SummonTrigger(float x, float y, float z, float ang, TimeSpan despawnTime, CreatureAI AI = null) { - TempSummonType summonType = (duration == 0) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn; - Creature summon = SummonCreature(SharedConst.WorldTrigger, x, y, z, ang, summonType, duration); + TempSummonType summonType = (despawnTime == TimeSpan.Zero) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn; + Creature summon = SummonCreature(SharedConst.WorldTrigger, x, y, z, ang, summonType, despawnTime); if (summon == null) return null; @@ -1535,7 +1535,7 @@ namespace Game.Entities foreach (var tempSummonData in data) { - TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, tempSummonData.time); + TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, TimeSpan.FromMilliseconds(tempSummonData.time)); if (summon) list.Add(summon); } diff --git a/Source/Game/Entities/Player/CinematicManager.cs b/Source/Game/Entities/Player/CinematicManager.cs index 882f3d7bb..88bf4a0f4 100644 --- a/Source/Game/Entities/Player/CinematicManager.cs +++ b/Source/Game/Entities/Player/CinematicManager.cs @@ -81,7 +81,7 @@ namespace Game.Entities return; player.GetMap().LoadGridForActiveObject(pos.GetPositionX(), pos.GetPositionY(), player); - m_CinematicObject = player.SummonCreature(1, pos.posX, pos.posY, pos.posZ, 0.0f, TempSummonType.TimedDespawn, 5 * Time.Minute * Time.InMilliseconds); + m_CinematicObject = player.SummonCreature(1, pos.posX, pos.posY, pos.posZ, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(5)); if (m_CinematicObject) { m_CinematicObject.SetActive(true); diff --git a/Source/Game/Entities/TemporarySummon.cs b/Source/Game/Entities/TemporarySummon.cs index 9b57ad789..06df0ab3d 100644 --- a/Source/Game/Entities/TemporarySummon.cs +++ b/Source/Game/Entities/TemporarySummon.cs @@ -18,6 +18,7 @@ using Framework.Constants; using Framework.Dynamic; using Game.DataStorage; +using System; using System.Collections.Generic; namespace Game.Entities @@ -254,7 +255,7 @@ namespace Game.Entities { ForcedUnsummonDelayEvent pEvent = new(this); - m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime)); + m_Events.AddEvent(pEvent, m_Events.CalculateTime(TimeSpan.FromMilliseconds(msTime))); return; } diff --git a/Source/Game/Entities/Totem.cs b/Source/Game/Entities/Totem.cs index c9cff3b54..a749af8d0 100644 --- a/Source/Game/Entities/Totem.cs +++ b/Source/Game/Entities/Totem.cs @@ -20,6 +20,7 @@ using Game.DataStorage; using Game.Groups; using Game.Networking.Packets; using Game.Spells; +using System; namespace Game.Entities { @@ -99,7 +100,7 @@ namespace Game.Entities { if (msTime != 0) { - m_Events.AddEvent(new ForcedUnsummonDelayEvent(this), m_Events.CalculateTime(msTime)); + m_Events.AddEvent(new ForcedUnsummonDelayEvent(this), m_Events.CalculateTime(TimeSpan.FromMilliseconds(msTime))); return; } diff --git a/Source/Game/Entities/Vehicle.cs b/Source/Game/Entities/Vehicle.cs index 8c84b432d..427a8734f 100644 --- a/Source/Game/Entities/Vehicle.cs +++ b/Source/Game/Entities/Vehicle.cs @@ -279,7 +279,7 @@ namespace Game.Entities Log.outDebug(LogFilter.Vehicle, "Vehicle ({0}, Entry {1}): installing accessory (Entry: {2}) on seat: {3}", _me.GetGUID().ToString(), GetCreatureEntry(), entry, seatId); - TempSummon accessory = _me.SummonCreature(entry, _me, (TempSummonType)type, summonTime); + TempSummon accessory = _me.SummonCreature(entry, _me, (TempSummonType)type, TimeSpan.FromMilliseconds(summonTime)); Cypher.Assert(accessory); if (minion) @@ -310,7 +310,7 @@ namespace Game.Entities // exits the vehicle will dismiss. That's why the actual adding the passenger to the vehicle is scheduled // asynchronously, so it can be cancelled easily in case the vehicle is uninstalled meanwhile. VehicleJoinEvent e = new(this, unit); - unit.m_Events.AddEvent(e, unit.m_Events.CalculateTime(0)); + unit.m_Events.AddEvent(e, unit.m_Events.CalculateTime(TimeSpan.Zero)); KeyValuePair seat = new(); if (seatId < 0) // no specific seat requirement diff --git a/Source/Game/Maps/Instances/InstanceScript.cs b/Source/Game/Maps/Instances/InstanceScript.cs index a2acc3c05..393bff3ba 100644 --- a/Source/Game/Maps/Instances/InstanceScript.cs +++ b/Source/Game/Maps/Instances/InstanceScript.cs @@ -548,7 +548,7 @@ namespace Game.Maps Log.outDebug(LogFilter.Scripts, "InstanceScript: DoCloseDoorOrButton failed"); } - public void DoRespawnGameObject(ObjectGuid guid, uint timeToDespawn) + public void DoRespawnGameObject(ObjectGuid guid, TimeSpan timeToDespawn) { GameObject go = instance.GetGameObject(guid); if (go) @@ -569,7 +569,7 @@ namespace Game.Maps if (go.IsSpawned()) return; - go.SetRespawnTime((int)timeToDespawn); + go.SetRespawnTime((int)timeToDespawn.TotalSeconds); } else Log.outDebug(LogFilter.Scripts, "InstanceScript: DoRespawnGameObject failed"); diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index fe1411ecf..96fbdb2ec 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -4738,7 +4738,7 @@ namespace Game.Maps float z = step.script.TempSummonCreature.PosZ; float o = step.script.TempSummonCreature.Orientation; - if (pSummoner.SummonCreature(step.script.TempSummonCreature.CreatureEntry, x, y, z, o, TempSummonType.TimedOrDeadDespawn, step.script.TempSummonCreature.DespawnDelay) == null) + if (pSummoner.SummonCreature(step.script.TempSummonCreature.CreatureEntry, x, y, z, o, TempSummonType.TimedOrDeadDespawn, TimeSpan.FromMilliseconds(step.script.TempSummonCreature.DespawnDelay)) == null) Log.outError(LogFilter.Scripts, "{0} creature was not spawned (entry: {1}).", step.script.GetDebugInfo(), step.script.TempSummonCreature.CreatureEntry); } } @@ -4884,7 +4884,7 @@ namespace Game.Maps // First try with target or source creature, then with target or source gameobject Creature cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true); if (cSource != null) - cSource.DespawnOrUnsummon(step.script.DespawnSelf.DespawnDelay); + cSource.DespawnOrUnsummon(TimeSpan.FromMilliseconds(step.script.DespawnSelf.DespawnDelay)); else { GameObject goSource = _GetScriptGameObjectSourceOrTarget(source, target, step.script, true); diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 7d866b03a..5805147a7 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -896,7 +896,7 @@ namespace Game.Spells return; m_dropEvent = new ChargeDropEvent(this, removeMode); - owner.m_Events.AddEvent(m_dropEvent, owner.m_Events.CalculateTime(delay)); + owner.m_Events.AddEvent(m_dropEvent, owner.m_Events.CalculateTime(TimeSpan.FromMilliseconds(delay))); } public void SetStackAmount(byte stackAmount) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 4d69820d0..6e517e8cf 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -324,7 +324,7 @@ namespace Game.Spells public void RecalculateDelayMomentForDst() { m_delayMoment = CalculateDelayMomentForDst(0.0f); - m_caster.m_Events.ModifyEventTime(_spellEvent, GetDelayStart() + m_delayMoment); + m_caster.m_Events.ModifyEventTime(_spellEvent, TimeSpan.FromMilliseconds(GetDelayStart() + m_delayMoment)); } void SelectEffectImplicitTargets(SpellEffectInfo spellEffectInfo, SpellImplicitTargetInfo targetType, ref uint processedEffectMask) @@ -1830,7 +1830,7 @@ namespace Game.Spells targetInfo.ReflectResult = unitCaster.SpellHitResult(unitCaster, m_spellInfo, false); // can't reflect twice // Proc spell reflect aura when missile hits the original target - target.m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target.m_Events.CalculateTime(targetInfo.TimeDelay)); + target.m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target.m_Events.CalculateTime(TimeSpan.FromMilliseconds(targetInfo.TimeDelay))); // Increase time interval for reflected spells by 1.5 targetInfo.TimeDelay += targetInfo.TimeDelay >> 1; @@ -2374,7 +2374,7 @@ namespace Game.Spells // create and add update event for this spell _spellEvent = new SpellEvent(this); - m_caster.m_Events.AddEvent(_spellEvent, m_caster.m_Events.CalculateTime(1)); + m_caster.m_Events.AddEvent(_spellEvent, m_caster.m_Events.CalculateTime(TimeSpan.FromMilliseconds(1))); // check disables if (Global.DisableMgr.IsDisabledFor(DisableType.Spell, m_spellInfo.Id, m_caster)) @@ -8797,7 +8797,7 @@ namespace Game.Spells if (n_offset != 0) { // re-add us to the queue - m_Spell.GetCaster().m_Events.AddEvent(this, m_Spell.GetDelayStart() + n_offset, false); + m_Spell.GetCaster().m_Events.AddEvent(this, TimeSpan.FromMilliseconds(m_Spell.GetDelayStart() + n_offset), false); return false; // event not complete } // event complete @@ -8815,7 +8815,7 @@ namespace Game.Spells Cypher.Assert(n_offset == m_Spell.GetDelayMoment()); // re-plan the event for the delay moment - m_Spell.GetCaster().m_Events.AddEvent(this, e_time + m_Spell.GetDelayMoment(), false); + m_Spell.GetCaster().m_Events.AddEvent(this, TimeSpan.FromMilliseconds(e_time + m_Spell.GetDelayMoment()), false); return false; // event not complete } break; @@ -8829,7 +8829,7 @@ namespace Game.Spells } // spell processing not complete, plan event on the next update interval - m_Spell.GetCaster().m_Events.AddEvent(this, e_time + 1, false); + m_Spell.GetCaster().m_Events.AddEvent(this, TimeSpan.FromMilliseconds(e_time + 1), false); return false; // event not complete } diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 3ccf067eb..347cc07ca 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -1621,7 +1621,7 @@ namespace Game.Spells // randomize position for multiple summons pos = caster.GetRandomPoint(destTarget, radius); - summon = caster.SummonCreature(entry, pos, summonType, (uint)duration, 0, m_spellInfo.Id, privateObjectOwner); + summon = caster.SummonCreature(entry, pos, summonType, TimeSpan.FromMilliseconds(duration), 0, m_spellInfo.Id, privateObjectOwner); if (summon == null) continue; diff --git a/Source/Scripts/Pets/DeathKnight.cs b/Source/Scripts/Pets/DeathKnight.cs index 45c559de1..e95681998 100644 --- a/Source/Scripts/Pets/DeathKnight.cs +++ b/Source/Scripts/Pets/DeathKnight.cs @@ -100,7 +100,7 @@ namespace Scripts.Pets me.GetMotionMaster().MovePoint(0, x, y, z); // Despawn as soon as possible - me.DespawnOrUnsummon(4 * Time.InMilliseconds); + me.DespawnOrUnsummon(TimeSpan.FromSeconds(4)); } diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Items.cs index 1ea971a12..68e459aa8 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Items.cs @@ -2573,7 +2573,7 @@ namespace Scripts.Spells.Items { if (target.IsDead() && !target.IsPet()) { - GetCaster().SummonGameObject(ObjectIds.ImprisonedDoomguard, target, Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f)), (uint)(target.GetRespawnTime() - GameTime.GetGameTime())); + GetCaster().SummonGameObject(ObjectIds.ImprisonedDoomguard, target, Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f)), TimeSpan.FromSeconds(target.GetRespawnTime() - GameTime.GetGameTime())); target.DespawnOrUnsummon(); } } diff --git a/Source/Scripts/Spells/Quest.cs b/Source/Scripts/Spells/Quest.cs index b7fb5c9b1..0ce67c9ad 100644 --- a/Source/Scripts/Spells/Quest.cs +++ b/Source/Scripts/Spells/Quest.cs @@ -285,7 +285,7 @@ namespace Scripts.Spells.Quest struct Misc { //Quests6124 6129 - public const uint DespawnTime = 30000; + public static TimeSpan DespawnTime = TimeSpan.FromSeconds(30); //HodirsHelm public const byte Say1 = 1; @@ -341,7 +341,7 @@ namespace Scripts.Spells.Quest creatureTarget.EngageWithTarget(GetCaster()); if (_despawnTime != 0) - creatureTarget.DespawnOrUnsummon(_despawnTime); + creatureTarget.DespawnOrUnsummon(TimeSpan.FromMilliseconds(_despawnTime)); } } } @@ -903,7 +903,7 @@ namespace Scripts.Spells.Quest { caster.KilledMonsterCredit(CreatureIds.VillagerKillCredit); target.CastSpell(target, SpellIds.Flames, true); - target.DespawnOrUnsummon(60000); + target.DespawnOrUnsummon(TimeSpan.FromSeconds(60)); } } } @@ -931,7 +931,7 @@ namespace Scripts.Spells.Quest { caster.KilledMonsterCredit(CreatureIds.ShardKillCredit); target.CastSpell(target, (uint)GetEffectValue(), true); - target.DespawnOrUnsummon(2000); + target.DespawnOrUnsummon(TimeSpan.FromSeconds(2)); } } @@ -1729,7 +1729,7 @@ namespace Scripts.Spells.Quest void HandleScript(uint effIndex) { - GetCaster().ToCreature().DespawnOrUnsummon(2 * Time.InMilliseconds); + GetCaster().ToCreature().DespawnOrUnsummon(TimeSpan.FromSeconds(2)); } public override void Register() diff --git a/Source/Scripts/World/AreaTrigger.cs b/Source/Scripts/World/AreaTrigger.cs index c91cb6713..5642b355b 100644 --- a/Source/Scripts/World/AreaTrigger.cs +++ b/Source/Scripts/World/AreaTrigger.cs @@ -21,6 +21,7 @@ using Game.Entities; using Game.Scripting; using System.Collections.Generic; using Game.AI; +using System; namespace Scripts.World.Areatriggers { @@ -210,7 +211,7 @@ namespace Scripts.World.Areatriggers if (!player.IsDead() && player.GetQuestStatus(QuestIds.ScentOfLarkorwi) == QuestStatus.Incomplete) { if (!player.FindNearestCreature(CreatureIds.LarkorwiMate, 15)) - player.SummonCreature(CreatureIds.LarkorwiMate, player.GetPositionX() + 5, player.GetPositionY(), player.GetPositionZ(), 3.3f, TempSummonType.TimedDespawnOutOfCombat, 100000); + player.SummonCreature(CreatureIds.LarkorwiMate, player.GetPositionX() + 5, player.GetPositionY(), player.GetPositionZ(), 3.3f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(100)); } return false; @@ -257,7 +258,7 @@ namespace Scripts.World.Areatriggers { if (!player.FindNearestCreature(CreatureIds.LurkingShark, 20.0f)) { - Creature shark = player.SummonCreature(CreatureIds.LurkingShark, -4246.243f, -3922.356f, -7.488f, 5.0f, TempSummonType.TimedDespawnOutOfCombat, 100000); + Creature shark = player.SummonCreature(CreatureIds.LurkingShark, -4246.243f, -3922.356f, -7.488f, 5.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(100)); if (shark) shark.GetAI().AttackStart(player); @@ -361,7 +362,7 @@ namespace Scripts.World.Areatriggers break; } - player.SummonCreature(CreatureIds.Spotlight, x, y, z, 0.0f, TempSummonType.TimedDespawn, 5000); + player.SummonCreature(CreatureIds.Spotlight, x, y, z, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(5)); player.AddAura(SpellIds.A52Neuralyzer, player); _triggerTimes[areaTrigger.Id] = GameTime.GetGameTime(); return false; @@ -393,7 +394,7 @@ namespace Scripts.World.Areatriggers if (stormforgedEradictor) return false; - stormforgedMonitor = player.SummonCreature(CreatureIds.StormforgedMonitor, Misc.StormforgedMonitorPosition, TempSummonType.TimedDespawnOutOfCombat, 60000); + stormforgedMonitor = player.SummonCreature(CreatureIds.StormforgedMonitor, Misc.StormforgedMonitorPosition, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(60)); if (stormforgedMonitor) { stormforgedMonitorGUID = stormforgedMonitor.GetGUID(); @@ -403,7 +404,7 @@ namespace Scripts.World.Areatriggers stormforgedMonitor.GetMotionMaster().MovePath(CreatureIds.StormforgedMonitor * 100, false); } - stormforgedEradictor = player.SummonCreature(CreatureIds.StormforgedEradictor, Misc.StormforgedEradictorPosition, TempSummonType.TimedDespawnOutOfCombat, 60000); + stormforgedEradictor = player.SummonCreature(CreatureIds.StormforgedEradictor, Misc.StormforgedEradictorPosition, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(60)); if (stormforgedEradictor) { stormforgedEradictorGUID = stormforgedEradictor.GetGUID(); diff --git a/Source/Scripts/World/EmeraldDragons.cs b/Source/Scripts/World/EmeraldDragons.cs index 02cf8ccac..882b30b6a 100644 --- a/Source/Scripts/World/EmeraldDragons.cs +++ b/Source/Scripts/World/EmeraldDragons.cs @@ -299,7 +299,7 @@ namespace Scripts.World.EmeraldDragons if (spellInfo.Id == SpellIds.DrawSpirit && target.IsPlayer()) { Position targetPos = target.GetPosition(); - me.SummonCreature(CreatureIds.SpiritShade, targetPos, TempSummonType.TimedDespawnOutOfCombat, 50000); + me.SummonCreature(CreatureIds.SpiritShade, targetPos, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(50)); } } } @@ -326,7 +326,7 @@ namespace Scripts.World.EmeraldDragons if (moveType == MovementGeneratorType.Follow && data == _summonerGuid.GetCounter()) { me.CastSpell((Unit)null, SpellIds.DarkOffering, false); - me.DespawnOrUnsummon(1000); + me.DespawnOrUnsummon(TimeSpan.FromSeconds(1)); } } } diff --git a/Source/Scripts/World/GameObject.cs b/Source/Scripts/World/GameObject.cs index 82029a23a..84fc94466 100644 --- a/Source/Scripts/World/GameObject.cs +++ b/Source/Scripts/World/GameObject.cs @@ -313,7 +313,7 @@ namespace Scripts.World.GameObjects { if (player.GetQuestStatus(QuestIds.TheFirstTrial) == QuestStatus.Incomplete) { - Creature Stillblade = player.SummonCreature(CreatureIds.Stillblade, 8106.11f, -7542.06f, 151.775f, 3.02598f, TempSummonType.DeadDespawn, 60000); + Creature Stillblade = player.SummonCreature(CreatureIds.Stillblade, 8106.11f, -7542.06f, 151.775f, 3.02598f, TempSummonType.DeadDespawn, TimeSpan.FromMinutes(1)); if (Stillblade) Stillblade.GetAI().AttackStart(player); } @@ -350,7 +350,7 @@ namespace Scripts.World.GameObjects me.UseDoorOrButton(); int Random = (int)(RandomHelper.Rand32() % (CreatureIds.PrisonEntry.Length / sizeof(uint))); - Creature creature = player.SummonCreature(CreatureIds.PrisonEntry[Random], me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedDespawnOutOfCombat, 30000); + Creature creature = player.SummonCreature(CreatureIds.PrisonEntry[Random], me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(30)); if (creature) { if (!creature.IsHostileTo(player)) @@ -404,7 +404,7 @@ namespace Scripts.World.GameObjects me.UseDoorOrButton(); int Random = (int)(RandomHelper.Rand32() % CreatureIds.StasisEntry.Length / sizeof(uint)); - player.SummonCreature(CreatureIds.StasisEntry[Random], me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedDespawnOutOfCombat, 30000); + player.SummonCreature(CreatureIds.StasisEntry[Random], me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(30)); return false; } @@ -418,7 +418,7 @@ namespace Scripts.World.GameObjects public override bool GossipHello(Player player) { if (me.GetGoType() == GameObjectTypes.Goober) - me.SummonCreature(CreatureIds.Goggeroc, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, 300000); + me.SummonCreature(CreatureIds.Goggeroc, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromMinutes(5)); return false; } @@ -434,7 +434,7 @@ namespace Scripts.World.GameObjects //implicitTarget=48 not implemented as of writing this code, and manual summon may be just ok for our purpose //player.CastSpell(player, SpellSummonRizzle, false); - Creature creature = player.SummonCreature(CreatureIds.Rizzle, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.DeadDespawn, 0); + Creature creature = player.SummonCreature(CreatureIds.Rizzle, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.DeadDespawn); if (creature) creature.CastSpell(player, SpellIds.Blackjack, false); @@ -543,7 +543,7 @@ namespace Scripts.World.GameObjects { if (player.GetQuestStatus(QuestIds.PrisonBreak) == QuestStatus.Incomplete) { - me.SummonCreature(25318, 3485.089844f, 6115.7422188f, 70.966812f, 0, TempSummonType.TimedDespawn, 60000); + me.SummonCreature(25318, 3485.089844f, 6115.7422188f, 70.966812f, 0, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(1)); player.CastSpell(player, SpellIds.ArcanePrisonerKillCredit, true); return true; } @@ -559,7 +559,7 @@ namespace Scripts.World.GameObjects public override bool GossipHello(Player player) { if (me.GetGoType() == GameObjectTypes.Goober) - player.SummonCreature(CreatureIds.Zelemar, -369.746f, 166.759f, -21.50f, 5.235f, TempSummonType.TimedDespawnOutOfCombat, 30000); + player.SummonCreature(CreatureIds.Zelemar, -369.746f, 166.759f, -21.50f, 5.235f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(30)); return true; } @@ -691,8 +691,8 @@ namespace Scripts.World.GameObjects public override bool GossipHello(Player player) { player.SendLoot(me.GetGUID(), LootType.Corpse); - me.SummonCreature(CreatureIds.HiveAmbusher, me.GetPositionX() + 1, me.GetPositionY(), me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedOrDeadDespawn, 60000); - me.SummonCreature(CreatureIds.HiveAmbusher, me.GetPositionX(), me.GetPositionY() + 1, me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedOrDeadDespawn, 60000); + me.SummonCreature(CreatureIds.HiveAmbusher, me.GetPositionX() + 1, me.GetPositionY(), me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedOrDeadDespawn, TimeSpan.FromMinutes(1)); + me.SummonCreature(CreatureIds.HiveAmbusher, me.GetPositionX(), me.GetPositionY() + 1, me.GetPositionZ(), me.GetAbsoluteAngle(player), TempSummonType.TimedOrDeadDespawn, TimeSpan.FromMinutes(1)); return true; } } @@ -724,7 +724,7 @@ namespace Scripts.World.GameObjects foreach (Creature creature in childrenList) { player.KilledMonsterCredit(CreatureIds.CaptiveChild, creature.GetGUID()); - creature.DespawnOrUnsummon(5000); + creature.DespawnOrUnsummon(TimeSpan.FromSeconds(5)); creature.GetMotionMaster().MovePoint(1, me.GetPositionX() + 5, me.GetPositionY(), me.GetPositionZ()); creature.GetAI().Talk(TextIds.SayFree0); creature.GetMotionMaster().Clear(); diff --git a/Source/Scripts/World/NpcSpecial.cs b/Source/Scripts/World/NpcSpecial.cs index f3cc73b73..739b72efb 100644 --- a/Source/Scripts/World/NpcSpecial.cs +++ b/Source/Scripts/World/NpcSpecial.cs @@ -464,7 +464,7 @@ namespace Scripts.World.NpcSpecial { Creature guard = ObjectAccessor.GetCreature(me, _myGuard); - if (guard == null && (guard = me.SummonCreature(_spawn.otherEntry, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, 300000))) + if (guard == null && (guard = me.SummonCreature(_spawn.otherEntry, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromMinutes(5)))) _myGuard = guard.GetGUID(); return guard; @@ -951,7 +951,7 @@ namespace Scripts.World.NpcSpecial var index = RandomHelper.IRand(0, Coordinates.Count - 1); - Creature Patient = me.SummonCreature(patientEntry, Coordinates[index], TempSummonType.TimedDespawnOutOfCombat, 5000); + Creature Patient = me.SummonCreature(patientEntry, Coordinates[index], TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(5)); if (Patient) { //303, this flag appear to be required for client side item.spell to work (TARGET_SINGLE_FRIEND) @@ -1727,7 +1727,7 @@ namespace Scripts.World.NpcSpecial case 1: case 2: case 3: - Creature minion = me.SummonCreature(CreatureIds.MinionOfOmen, me.GetPositionX() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionY() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionZ(), 0.0f, TempSummonType.CorpseTimedDespawn, 20000); + Creature minion = me.SummonCreature(CreatureIds.MinionOfOmen, me.GetPositionX() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionY() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionZ(), 0.0f, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(20)); if (minion) minion.GetAI().AttackStart(me.SelectNearestPlayer(20.0f)); break; @@ -1742,7 +1742,7 @@ namespace Scripts.World.NpcSpecial float displacement = 0.7f; for (byte i = 0; i < 4; i++) - me.SummonGameObject(GetFireworkGameObjectId(), me.GetPositionX() + (i % 2 == 0 ? displacement : -displacement), me.GetPositionY() + (i > 1 ? displacement : -displacement), me.GetPositionZ() + 4.0f, me.GetOrientation(), Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(me.GetOrientation(), 0.0f, 0.0f)), 1); + me.SummonGameObject(GetFireworkGameObjectId(), me.GetPositionX() + (i % 2 == 0 ? displacement : -displacement), me.GetPositionY() + (i > 1 ? displacement : -displacement), me.GetPositionZ() + 4.0f, me.GetOrientation(), Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(me.GetOrientation(), 0.0f, 0.0f)), TimeSpan.FromSeconds(1)); } else //me.CastSpell(me, GetFireworkSpell(me.GetEntry()), true); @@ -1894,7 +1894,7 @@ namespace Scripts.World.NpcSpecial return target; me.HandleEmoteCommand(Emote.OneshotRude); - me.DespawnOrUnsummon(3 * Time.InMilliseconds); + me.DespawnOrUnsummon(TimeSpan.FromSeconds(3)); return null; } @@ -1972,7 +1972,7 @@ namespace Scripts.World.NpcSpecial } me.UpdateEntry(CreatureIds.ExultingWindUpTrainWrecker); me.SetEmoteState(Emote.OneshotDance); - me.DespawnOrUnsummon(5 * Time.InMilliseconds); + me.DespawnOrUnsummon(TimeSpan.FromSeconds(5)); _nextAction = 0; break; default: @@ -2137,7 +2137,7 @@ namespace Scripts.World.NpcSpecial init.MoveTo(x, y, z, false); init.SetFacing(o); who.GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleBoard, MovementGeneratorPriority.Highest); - who.m_Events.AddEvent(new CastFoodSpell(who, SpellIds.ChairSpells[who.GetEntry()]), who.m_Events.CalculateTime(1000)); + who.m_Events.AddEvent(new CastFoodSpell(who, SpellIds.ChairSpells[who.GetEntry()]), who.m_Events.CalculateTime(TimeSpan.FromSeconds(1))); Creature creature = who.ToCreature(); if (creature) creature.SetDisplayFromModel(0);