Exemple #1
0
        public static void CalculateEventDelays(WorldEvent worldEvent)
        {
            DateTime now = DateTime.Now;

            if (now < worldEvent.Until)
            {
                if (worldEvent.From > now)
                {
                    worldEvent.TimeUntilNextStart = new TimeSpan?(worldEvent.From - now);
                }
                else
                {
                    DateTime from = worldEvent.From;
                    while (from < now && (!(from + worldEvent.Duration > now) ||
                                          !(from + worldEvent.Duration < from + worldEvent.Occurence)))
                    {
                        from += worldEvent.Occurence;
                    }
                    worldEvent.TimeUntilNextStart = new TimeSpan?(from - now);
                }

                WorldEvent worldEvent1        = worldEvent;
                TimeSpan?  timeUntilNextStart = worldEvent.TimeUntilNextStart;
                TimeSpan   duration           = worldEvent.Duration;
                TimeSpan?  nullable           = timeUntilNextStart.HasValue
                    ? new TimeSpan?(timeUntilNextStart.GetValueOrDefault() + duration)
                    : new TimeSpan?();
                worldEvent1.TimeUntilEnd = nullable;
            }
            else
            {
                worldEvent.TimeUntilNextStart = new TimeSpan?();
                worldEvent.TimeUntilEnd       = new TimeSpan?();
            }
        }
Exemple #2
0
 public void FinalizeDataHolder()
 {
     this.Occurence = TimeSpan.FromMinutes((double)this._Occurence);
     this.Duration  = TimeSpan.FromMinutes((double)this._Length);
     WorldEvent.CalculateEventDelays(this);
     WorldEventMgr.AddEvent(this);
 }
Exemple #3
0
 public static void AddEvent(WorldEvent worldEvent)
 {
     if (WorldEventMgr.AllEvents.Get <WorldEvent>(worldEvent.Id) == null)
     {
         ++WorldEventMgr._eventCount;
     }
     ArrayUtil.Set <WorldEvent>(ref WorldEventMgr.AllEvents, worldEvent.Id, worldEvent);
 }
Exemple #4
0
 public static void AddEvent(WorldEvent worldEvent)
 {
     if (AllEvents.Get(worldEvent.Id) == null)
     {
         _eventCount++;
     }
     ArrayUtil.Set(ref AllEvents, worldEvent.Id, worldEvent);
 }
Exemple #5
0
        private static void ApplyEventNPCData(WorldEvent worldEvent)
        {
            foreach (var eventNpcData in worldEvent.ModelEquips)
            {
                var spawnEntry = NPCMgr.GetSpawnEntry(eventNpcData.Guid);
                if (spawnEntry == null)
                {
                    Log.Warn("Invalid Spawn Entry in World Event NPC Data, Entry: {0}", eventNpcData.Guid);
                    continue;
                }

                if (eventNpcData.EntryId != 0)
                {
                    eventNpcData.OriginalEntryId = spawnEntry.EntryId;
                    spawnEntry.EntryId           = eventNpcData.EntryId;

                    spawnEntry.Entry = NPCMgr.GetEntry(spawnEntry.EntryId);
                    if (spawnEntry.Entry == null)
                    {
                        Log.Warn("{0} had an invalid World Event EntryId.", spawnEntry);
                        spawnEntry.EntryId = eventNpcData.OriginalEntryId;
                        spawnEntry.Entry   = NPCMgr.GetEntry(spawnEntry.EntryId);
                    }
                }

                if (eventNpcData.ModelId != 0)
                {
                    spawnEntry.DisplayIdOverride = eventNpcData.ModelId;
                }

                if (eventNpcData.EquipmentId != 0)
                {
                    eventNpcData.OriginalEquipmentId = spawnEntry.EquipmentId;
                    spawnEntry.EquipmentId           = eventNpcData.EquipmentId;

                    spawnEntry.Equipment = NPCMgr.GetEquipment(spawnEntry.EquipmentId);
                }

                foreach (var point in spawnEntry.SpawnPoints.ToArray().Where(point => point.IsActive))
                {
                    point.Respawn();
                    if (eventNpcData.SpellIdToCastAtStart == 0)
                    {
                        continue;
                    }

                    Spell spell = SpellHandler.Get(eventNpcData.SpellIdToCastAtStart);
                    if (spell == null)
                    {
                        continue;
                    }

                    SpellCast cast = point.ActiveSpawnling.SpellCast;
                    cast.Start(spell);
                }
            }
        }
        public void FinalizeDataHolder()
        {
            WorldEvent worldEvent = WorldEventMgr.GetEvent(EventId);

            if (worldEvent == null)
            {
                return;
            }
            worldEvent.ModelEquips.Add(this);
        }
Exemple #7
0
        public static bool StopEvent(uint id)
        {
            WorldEvent worldEvent = WorldEventMgr.GetEvent(id);

            if (worldEvent == null)
            {
                return(false);
            }
            WorldEventMgr.StopEvent(worldEvent);
            return(true);
        }
Exemple #8
0
        public static bool StartEvent(uint id)
        {
            WorldEvent worldEvent = GetEvent(id);

            if (worldEvent == null)
            {
                return(false);
            }
            StartEvent(worldEvent);
            return(true);
        }
Exemple #9
0
        private static void DeSpawnEvent(WorldEvent worldEvent)
        {
            foreach (var worldEventNPC in worldEvent.NPCSpawns)
            {
                var spawnEntry = NPCMgr.GetSpawnEntry(worldEventNPC.Guid);
                var map        = spawnEntry.Map;

                //if the map is null then this saves us some work
                //since the map wont spawn any inactive events when
                //it is created
                if (map == null)
                {
                    continue;
                }

                if (worldEventNPC.Spawn)
                {
                    map.RemoveNPCSpawnPool(spawnEntry.PoolTemplate);
                }
                else
                {
                    foreach (var point in spawnEntry.SpawnPoints.ToArray())
                    {
                        point.Respawn();
                    }
                }
            }

            foreach (var worldEventGO in worldEvent.GOSpawns)
            {
                var spawnEntry = GOMgr.GetSpawnEntry(worldEventGO.Guid);
                var map        = spawnEntry.Map;

                //if the map is null then this saves us some work
                //since the map wont spawn any inactive events when
                //it is created
                if (map == null)
                {
                    continue;
                }

                if (worldEventGO.Spawn)
                {
                    map.RemoveGOSpawnPool(spawnEntry.PoolTemplate);
                }
                else
                {
                    foreach (var point in spawnEntry.SpawnPoints.ToArray())
                    {
                        point.Respawn();
                    }
                }
            }
        }
Exemple #10
0
        public void FinalizeDataHolder()
        {
            WorldEventMgr.WorldEventQuests.Add(this);
            WorldEvent worldEvent = WorldEventMgr.GetEvent(EventId);

            if (worldEvent == null)
            {
                return;
            }
            worldEvent.QuestIds.Add(QuestId);
        }
Exemple #11
0
        public void FinalizeDataHolder()
        {
            Spawn   = _eventId > 0;
            EventId = (uint)_eventId;
            WorldEvent worldEvent = WorldEventMgr.GetEvent(EventId);

            if (worldEvent == null)
            {
                return;
            }
            worldEvent.NPCSpawns.Add(this);
        }
Exemple #12
0
        public void FinalizeDataHolder()
        {
            this.Spawn   = this._eventId > 0;
            this.EventId = (uint)this._eventId;
            WorldEvent worldEvent = WorldEventMgr.GetEvent(this.EventId);

            if (worldEvent == null)
            {
                return;
            }
            worldEvent.GOSpawns.Add(this);
        }
Exemple #13
0
        private static void ApplyEventNPCData(WorldEvent worldEvent)
        {
            foreach (WorldEventNpcData modelEquip in worldEvent.ModelEquips)
            {
                NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(modelEquip.Guid);
                if (spawnEntry == null)
                {
                    WorldEventMgr.Log.Warn("Invalid Spawn Entry in World Event NPC Data, Entry: {0}", modelEquip.Guid);
                }
                else
                {
                    if (modelEquip.EntryId != (NPCId)0)
                    {
                        modelEquip.OriginalEntryId = spawnEntry.EntryId;
                        spawnEntry.EntryId         = modelEquip.EntryId;
                        spawnEntry.Entry           = NPCMgr.GetEntry(spawnEntry.EntryId);
                        if (spawnEntry.Entry == null)
                        {
                            WorldEventMgr.Log.Warn("{0} had an invalid World Event EntryId.", (object)spawnEntry);
                            spawnEntry.EntryId = modelEquip.OriginalEntryId;
                            spawnEntry.Entry   = NPCMgr.GetEntry(spawnEntry.EntryId);
                        }
                    }

                    if (modelEquip.ModelId != 0U)
                    {
                        spawnEntry.DisplayIdOverride = modelEquip.ModelId;
                    }
                    if (modelEquip.EquipmentId != 0U)
                    {
                        modelEquip.OriginalEquipmentId = spawnEntry.EquipmentId;
                        spawnEntry.EquipmentId         = modelEquip.EquipmentId;
                        spawnEntry.Equipment           = NPCMgr.GetEquipment(spawnEntry.EquipmentId);
                    }

                    foreach (NPCSpawnPoint npcSpawnPoint in
                             ((IEnumerable <NPCSpawnPoint>)spawnEntry.SpawnPoints.ToArray()).Where <NPCSpawnPoint>(
                                 (Func <NPCSpawnPoint, bool>)(point => point.IsActive)))
                    {
                        npcSpawnPoint.Respawn();
                        if (modelEquip.SpellIdToCastAtStart != SpellId.None)
                        {
                            Spell spell = SpellHandler.Get(modelEquip.SpellIdToCastAtStart);
                            if (spell != null)
                            {
                                int num = (int)npcSpawnPoint.ActiveSpawnling.SpellCast.Start(spell);
                            }
                        }
                    }
                }
            }
        }
Exemple #14
0
        public static void StartEvent(WorldEvent worldEvent)
        {
            //Log.Debug("Incrementing start event timer {0}: {1}", worldEvent.Id, worldEvent.Description);
            worldEvent.TimeUntilNextStart += worldEvent.Occurence;
            if (IsEventActive(worldEvent.Id))
            {
                return;
            }

            Log.Info("Starting event {0}: {1}", worldEvent.Id, worldEvent.Description);
            ArrayUtil.Set(ref ActiveEvents, worldEvent.Id, worldEvent);
            SpawnEvent(worldEvent);
            ApplyEventNPCData(worldEvent);
        }
Exemple #15
0
        public static void StartEvent(WorldEvent worldEvent)
        {
            WorldEvent worldEvent1        = worldEvent;
            TimeSpan?  timeUntilNextStart = worldEvent1.TimeUntilNextStart;
            TimeSpan   occurence          = worldEvent.Occurence;

            worldEvent1.TimeUntilNextStart = timeUntilNextStart.HasValue
                ? new TimeSpan?(timeUntilNextStart.GetValueOrDefault() + occurence)
                : new TimeSpan?();
            if (WorldEventMgr.IsEventActive(worldEvent.Id))
            {
                return;
            }
            WorldEventMgr.Log.Info("Starting event {0}: {1}", (object)worldEvent.Id, (object)worldEvent.Description);
            ArrayUtil.Set <WorldEvent>(ref WorldEventMgr.ActiveEvents, worldEvent.Id, worldEvent);
            WorldEventMgr.SpawnEvent(worldEvent);
            WorldEventMgr.ApplyEventNPCData(worldEvent);
        }
Exemple #16
0
        public static void Update()
        {
            if (!Loaded || !QuestMgr.Loaded || (!NPCMgr.Loaded || !GOMgr.Loaded))
            {
                return;
            }
            TimeSpan timeSpan1 = DateTime.Now - LastUpdateTime;

            LastUpdateTime = DateTime.Now;
            foreach (WorldEvent worldEvent1 in AllEvents
                     .Where(worldEvent => worldEvent != null)
                     .Where(worldEvent => worldEvent.TimeUntilNextStart.HasValue))
            {
                WorldEvent worldEvent2         = worldEvent1;
                TimeSpan?  timeUntilNextStart1 = worldEvent2.TimeUntilNextStart;
                TimeSpan   timeSpan2           = timeSpan1;
                worldEvent2.TimeUntilNextStart = timeUntilNextStart1.HasValue
          ? timeUntilNextStart1.GetValueOrDefault() - timeSpan2
          : new TimeSpan?();
                WorldEvent worldEvent3   = worldEvent1;
                TimeSpan?  timeUntilEnd1 = worldEvent3.TimeUntilEnd;
                TimeSpan   timeSpan3     = timeSpan1;
                worldEvent3.TimeUntilEnd = timeUntilEnd1.HasValue
          ? timeUntilEnd1.GetValueOrDefault() - timeSpan3
          : new TimeSpan?();
                TimeSpan?timeUntilEnd2 = worldEvent1.TimeUntilEnd;
                TimeSpan zero1         = TimeSpan.Zero;
                if ((timeUntilEnd2.HasValue ? (timeUntilEnd2.GetValueOrDefault() <= zero1 ? 1 : 0) : 0) != 0)
                {
                    StopEvent(worldEvent1);
                }
                else
                {
                    TimeSpan?timeUntilNextStart2 = worldEvent1.TimeUntilNextStart;
                    TimeSpan zero2 = TimeSpan.Zero;
                    if ((timeUntilNextStart2.HasValue
               ? (timeUntilNextStart2.GetValueOrDefault() <= zero2 ? 1 : 0)
               : 0) != 0)
                    {
                        StartEvent(worldEvent1);
                    }
                }
            }
        }
Exemple #17
0
        public static void Update()
        {
            if (!WorldEventMgr.Loaded || !QuestMgr.Loaded || (!NPCMgr.Loaded || !GOMgr.Loaded))
            {
                return;
            }
            TimeSpan timeSpan1 = DateTime.Now - WorldEventMgr.LastUpdateTime;

            WorldEventMgr.LastUpdateTime = DateTime.Now;
            foreach (WorldEvent worldEvent1 in ((IEnumerable <WorldEvent>)WorldEventMgr.AllEvents)
                     .Where <WorldEvent>((Func <WorldEvent, bool>)(worldEvent => worldEvent != null))
                     .Where <WorldEvent>((Func <WorldEvent, bool>)(worldEvent => worldEvent.TimeUntilNextStart.HasValue)))
            {
                WorldEvent worldEvent2         = worldEvent1;
                TimeSpan?  timeUntilNextStart1 = worldEvent2.TimeUntilNextStart;
                TimeSpan   timeSpan2           = timeSpan1;
                worldEvent2.TimeUntilNextStart = timeUntilNextStart1.HasValue
                    ? new TimeSpan?(timeUntilNextStart1.GetValueOrDefault() - timeSpan2)
                    : new TimeSpan?();
                WorldEvent worldEvent3   = worldEvent1;
                TimeSpan?  timeUntilEnd1 = worldEvent3.TimeUntilEnd;
                TimeSpan   timeSpan3     = timeSpan1;
                worldEvent3.TimeUntilEnd = timeUntilEnd1.HasValue
                    ? new TimeSpan?(timeUntilEnd1.GetValueOrDefault() - timeSpan3)
                    : new TimeSpan?();
                TimeSpan?timeUntilEnd2 = worldEvent1.TimeUntilEnd;
                TimeSpan zero1         = TimeSpan.Zero;
                if ((timeUntilEnd2.HasValue ? (timeUntilEnd2.GetValueOrDefault() <= zero1 ? 1 : 0) : 0) != 0)
                {
                    WorldEventMgr.StopEvent(worldEvent1);
                }
                else
                {
                    TimeSpan?timeUntilNextStart2 = worldEvent1.TimeUntilNextStart;
                    TimeSpan zero2 = TimeSpan.Zero;
                    if ((timeUntilNextStart2.HasValue
                            ? (timeUntilNextStart2.GetValueOrDefault() <= zero2 ? 1 : 0)
                            : 0) != 0)
                    {
                        WorldEventMgr.StartEvent(worldEvent1);
                    }
                }
            }
        }
Exemple #18
0
        private static void DeSpawnEvent(WorldEvent worldEvent)
        {
            foreach (WorldEventNPC npcSpawn in worldEvent.NPCSpawns)
            {
                NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(npcSpawn.Guid);
                Map           map        = spawnEntry.Map;
                if (map != null)
                {
                    if (npcSpawn.Spawn)
                    {
                        map.RemoveNPCSpawnPool(spawnEntry.PoolTemplate);
                    }
                    else
                    {
                        foreach (SpawnPoint <NPCSpawnPoolTemplate, NPCSpawnEntry, NPC, NPCSpawnPoint, NPCSpawnPool>
                                 spawnPoint in spawnEntry.SpawnPoints.ToArray())
                        {
                            spawnPoint.Respawn();
                        }
                    }
                }
            }

            foreach (WorldEventGameObject goSpawn in worldEvent.GOSpawns)
            {
                GOSpawnEntry spawnEntry = GOMgr.GetSpawnEntry(goSpawn.Guid);
                Map          map        = spawnEntry.Map;
                if (map != null)
                {
                    if (goSpawn.Spawn)
                    {
                        map.RemoveGOSpawnPool(spawnEntry.PoolTemplate);
                    }
                    else
                    {
                        foreach (SpawnPoint <GOSpawnPoolTemplate, GOSpawnEntry, GameObject, GOSpawnPoint, GOSpawnPool>
                                 spawnPoint in spawnEntry.SpawnPoints.ToArray())
                        {
                            spawnPoint.Respawn();
                        }
                    }
                }
            }
        }
Exemple #19
0
        private static void ResetEventNPCData(WorldEvent worldEvent)
        {
            foreach (WorldEventNpcData modelEquip in worldEvent.ModelEquips)
            {
                NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(modelEquip.Guid);
                if (spawnEntry == null)
                {
                    Log.Warn("Invalid Spawn Entry in World Event NPC Data, Entry: {0}", modelEquip.Guid);
                }
                else
                {
                    if (modelEquip.EntryId != 0)
                    {
                        spawnEntry.EntryId = modelEquip.OriginalEntryId;
                        spawnEntry.Entry   = NPCMgr.GetEntry(spawnEntry.EntryId);
                    }

                    if (modelEquip.ModelId != 0U)
                    {
                        spawnEntry.DisplayIdOverride = 0U;
                    }
                    if (modelEquip.EquipmentId != 0U)
                    {
                        spawnEntry.EquipmentId = modelEquip.OriginalEquipmentId;
                        spawnEntry.Equipment   = NPCMgr.GetEquipment(spawnEntry.EquipmentId);
                    }

                    foreach (NPCSpawnPoint npcSpawnPoint in
                             spawnEntry.SpawnPoints.ToArray().Where(
                                 point => point.IsActive))
                    {
                        npcSpawnPoint.Respawn();
                        if (modelEquip.SpellIdToCastAtEnd != SpellId.None)
                        {
                            Spell spell = SpellHandler.Get(modelEquip.SpellIdToCastAtEnd);
                            if (spell != null)
                            {
                                int num = (int)npcSpawnPoint.ActiveSpawnling.SpellCast.Start(spell);
                            }
                        }
                    }
                }
            }
        }
Exemple #20
0
        public static void StopEvent(WorldEvent worldEvent)
        {
            //Log.Debug("Incrementing end event timer {0}: {1}", worldEvent.Id, worldEvent.Description);
            worldEvent.TimeUntilEnd += worldEvent.Occurence + worldEvent.Duration;
            if (!IsEventActive(worldEvent.Id))
            {
                return;
            }

            Log.Info("Stopping event {0}: {1}", worldEvent.Id, worldEvent.Description);
            ActiveEvents[worldEvent.Id] = null;

            if (worldEvent.QuestIds.Count != 0)
            {
                ClearActiveQuests(worldEvent.QuestIds);
            }

            DeSpawnEvent(worldEvent);
            ResetEventNPCData(worldEvent);
        }
Exemple #21
0
        public static void CalculateEventDelays(WorldEvent worldEvent)
        {
            var time = DateTime.Now;

            //Only work out start times for events that will ever be able to start
            if (time < worldEvent.Until)
            {
                //If the first time this event can start is in the
                //future then this is easy
                if (worldEvent.From > time)
                {
                    worldEvent.TimeUntilNextStart = worldEvent.From - time;
                }
                else
                {
                    //If the first time this event started was in the
                    //past work out which cycle of the event we are up
                    //to
                    DateTime timeToCheck = worldEvent.From;
                    while (timeToCheck < time)
                    {
                        //if we are in the middle of a cycle
                        if ((timeToCheck + worldEvent.Duration) > time && (timeToCheck + worldEvent.Duration) < (timeToCheck + worldEvent.Occurence))
                        {
                            break;
                        }

                        timeToCheck += worldEvent.Occurence;
                    }
                    worldEvent.TimeUntilNextStart = timeToCheck - time;
                }

                worldEvent.TimeUntilEnd = worldEvent.TimeUntilNextStart + worldEvent.Duration;
            }
            else
            {
                worldEvent.TimeUntilNextStart = null;
                worldEvent.TimeUntilEnd       = null;
            }
        }
Exemple #22
0
        public static void StopEvent(WorldEvent worldEvent)
        {
            WorldEvent worldEvent1  = worldEvent;
            TimeSpan?  timeUntilEnd = worldEvent1.TimeUntilEnd;
            TimeSpan   timeSpan     = worldEvent.Occurence + worldEvent.Duration;

            worldEvent1.TimeUntilEnd = timeUntilEnd.HasValue
                ? new TimeSpan?(timeUntilEnd.GetValueOrDefault() + timeSpan)
                : new TimeSpan?();
            if (!WorldEventMgr.IsEventActive(worldEvent.Id))
            {
                return;
            }
            WorldEventMgr.Log.Info("Stopping event {0}: {1}", (object)worldEvent.Id, (object)worldEvent.Description);
            WorldEventMgr.ActiveEvents[worldEvent.Id] = (WorldEvent)null;
            if (worldEvent.QuestIds.Count != 0)
            {
                WorldEventMgr.ClearActiveQuests((IEnumerable <uint>)worldEvent.QuestIds);
            }
            WorldEventMgr.DeSpawnEvent(worldEvent);
            WorldEventMgr.ResetEventNPCData(worldEvent);
        }
Exemple #23
0
        public static void StopEvent(WorldEvent worldEvent)
        {
            WorldEvent worldEvent1  = worldEvent;
            TimeSpan?  timeUntilEnd = worldEvent1.TimeUntilEnd;
            TimeSpan   timeSpan     = worldEvent.Occurence + worldEvent.Duration;

            worldEvent1.TimeUntilEnd = timeUntilEnd.HasValue
        ? timeUntilEnd.GetValueOrDefault() + timeSpan
        : new TimeSpan?();
            if (!IsEventActive(worldEvent.Id))
            {
                return;
            }
            Log.Info("Stopping event {0}: {1}", worldEvent.Id, worldEvent.Description);
            ActiveEvents[worldEvent.Id] = null;
            if (worldEvent.QuestIds.Count != 0)
            {
                ClearActiveQuests(worldEvent.QuestIds);
            }
            DeSpawnEvent(worldEvent);
            ResetEventNPCData(worldEvent);
        }
Exemple #24
0
	    public static void CalculateEventDelays(WorldEvent worldEvent)
	    {
	        var time = DateTime.Now;

	        //Only work out start times for events that will ever be able to start
            if (time < worldEvent.Until)
	        {
	            //If the first time this event can start is in the
	            //future then this is easy
                if (worldEvent.From > time)
                    worldEvent.TimeUntilNextStart = worldEvent.From - time;
	            else
	            {
	                //If the first time this event started was in the
	                //past work out which cycle of the event we are up
	                //to
                    DateTime timeToCheck = worldEvent.From;
	                while (timeToCheck < time)
	                {
	                    //if we are in the middle of a cycle
                        if ((timeToCheck + worldEvent.Duration) > time && (timeToCheck + worldEvent.Duration) < (timeToCheck + worldEvent.Occurence))
	                        break;

                        timeToCheck += worldEvent.Occurence;
	                }
                    worldEvent.TimeUntilNextStart = timeToCheck - time;
	            }

                worldEvent.TimeUntilEnd = worldEvent.TimeUntilNextStart + worldEvent.Duration;
	        }
            else
            {
                worldEvent.TimeUntilNextStart = null;
                worldEvent.TimeUntilEnd = null;
            }
	    }
Exemple #25
0
        public static void StopEvent(WorldEvent worldEvent)
        {
            //Log.Debug("Incrementing end event timer {0}: {1}", worldEvent.Id, worldEvent.Description);
            worldEvent.TimeUntilEnd += worldEvent.Occurence + worldEvent.Duration;
            if (!IsEventActive(worldEvent.Id))
                return;

            Log.Info("Stopping event {0}: {1}", worldEvent.Id, worldEvent.Description);
            ActiveEvents[worldEvent.Id] = null;

            if (worldEvent.QuestIds.Count != 0)
                ClearActiveQuests(worldEvent.QuestIds);

            DeSpawnEvent(worldEvent);
            ResetEventNPCData(worldEvent);
        }
Exemple #26
0
        public static void StartEvent(WorldEvent worldEvent)
        {
            //Log.Debug("Incrementing start event timer {0}: {1}", worldEvent.Id, worldEvent.Description);
            worldEvent.TimeUntilNextStart += worldEvent.Occurence;
            if (IsEventActive(worldEvent.Id))
                return;

            Log.Info("Starting event {0}: {1}", worldEvent.Id, worldEvent.Description);
            ArrayUtil.Set(ref ActiveEvents, worldEvent.Id, worldEvent);
            SpawnEvent(worldEvent);
            ApplyEventNPCData(worldEvent);
        }
Exemple #27
0
 public static void StartEvent(WorldEvent worldEvent)
 {
     worldEvent.TimeUntilNextStart = worldEvent.Occurence;
     ActiveEvents[worldEvent.Id] = worldEvent;
 }
Exemple #28
0
 public static void StopEvent(WorldEvent worldEvent)
 {
     worldEvent.TimeUntilEnd = worldEvent.Occurence + worldEvent.Duration;
     ActiveEvents[worldEvent.Id] = null;
 }
Exemple #29
0
        private static void ResetEventNPCData(WorldEvent worldEvent)
        {
            foreach (var eventNpcData in worldEvent.ModelEquips)
            {
                var spawnEntry = NPCMgr.GetSpawnEntry(eventNpcData.Guid);
                if (spawnEntry == null)
                {
                    Log.Warn("Invalid Spawn Entry in World Event NPC Data, Entry: {0}", eventNpcData.Guid);
                    continue;
                }

                if (eventNpcData.EntryId != 0)
                {
                    spawnEntry.EntryId = eventNpcData.OriginalEntryId;
                    spawnEntry.Entry = NPCMgr.GetEntry(spawnEntry.EntryId);
                }

                if (eventNpcData.ModelId != 0)
                {
                    spawnEntry.DisplayIdOverride = 0;
                }

                if (eventNpcData.EquipmentId != 0)
                {
                    spawnEntry.EquipmentId = eventNpcData.OriginalEquipmentId;

                    spawnEntry.Equipment = NPCMgr.GetEquipment(spawnEntry.EquipmentId);
                }

                foreach (var point in spawnEntry.SpawnPoints.ToArray().Where(point => point.IsActive))
                {
                    point.Respawn();

                    if (eventNpcData.SpellIdToCastAtEnd == 0)
                        continue;

                    Spell spell = SpellHandler.Get(eventNpcData.SpellIdToCastAtEnd);
                    if (spell != null)
                    {
                        SpellCast cast = point.ActiveSpawnling.SpellCast;
                        cast.Start(spell);
                    }
                }
            }
        }
Exemple #30
0
 public static void AddEvent(WorldEvent worldEvent)
 {
     if (AllEvents.Get(worldEvent.Id) == null)
     {
         _eventCount++;
     }
     ArrayUtil.Set(ref AllEvents, worldEvent.Id, worldEvent);
 }
Exemple #31
0
        private static void DeSpawnEvent(WorldEvent worldEvent)
        {
            foreach (var worldEventNPC in worldEvent.NPCSpawns)
            {
                var spawnEntry = NPCMgr.GetSpawnEntry(worldEventNPC.Guid);
                var map = spawnEntry.Map;

                //if the map is null then this saves us some work
                //since the map wont spawn any inactive events when
                //it is created
                if (map == null)
                    continue;

                if (worldEventNPC.Spawn)
                {
                    map.RemoveNPCSpawnPool(spawnEntry.PoolTemplate);
                }
                else
                {
                    foreach (var point in spawnEntry.SpawnPoints.ToArray())
                    {
                        point.Respawn();
                    }
                }
            }

            foreach (var worldEventGO in worldEvent.GOSpawns)
            {
                var spawnEntry = GOMgr.GetSpawnEntry(worldEventGO.Guid);
                var map = spawnEntry.Map;

                //if the map is null then this saves us some work
                //since the map wont spawn any inactive events when
                //it is created
                if (map == null)
                    continue;

                if (worldEventGO.Spawn)
                {
                    map.RemoveGOSpawnPool(spawnEntry.PoolTemplate);
                }
                else
                {
                    foreach (var point in spawnEntry.SpawnPoints.ToArray())
                    {
                        point.Respawn();
                    }
                }
            }
        }