public virtual void Start() { if (this.Started) { return; } this.Started = true; Asda2EventMgr.SendMessageToWorld("Deffence town event started in {0}. [{1}-{2}]", (object)this.Town, (object)this.MinLevel, (object)this.MaxLevel); this._spawnTasks.IsRunning = true; this._map.DefenceTownEvent = this; foreach (NpcSpawnEntry npcEntry in this.NpcEntries) { NpcSpawnEntry entry = npcEntry; this._spawnTasks.CallDelayed(entry.TimeToSpawnMillis, (Action)(() => { NPC npc = entry.NpcEntry.SpawnAt(this._map, entry.MovingPoints[0], false); npc.Brain.State = BrainState.DefenceTownEventMove; npc.Brain.MovingPoints = entry.MovingPoints; npc.Brain.DefaultState = BrainState.DefenceTownEventMove; })); } this._spawnTasks.CallDelayed(1000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 1 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(180000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 2 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(360000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 3 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(540000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 4 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(720000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 5 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(940000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence FINAL BOSS WAVE!", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(1400000, (Action)(() => this.Stop(true))); }
protected void AddSpawnEntry(NpcCustomEntryId id, int timeToSpawnsecs, int amount, float amountMod, BrainState brainState = BrainState.DefenceTownEventMove) { var additionalTime = 0; var amountToSpawn = (int)(amount * amountMod); for (int i = 1; i <= amountToSpawn; i++) { var index = i % MovingPaths.Count; if (index == 0) { additionalTime += 2000; } var npcEntry = NPCMgr.GetEntry((uint)id); if (npcEntry.Rank >= CreatureRank.Boss) { index = Util.Utility.Random(0, MovingPaths.Count - 1); } var entry = new NpcSpawnEntry { BrainState = brainState, TimeToSpawnMillis = timeToSpawnsecs * 1000 + additionalTime, NpcEntry = npcEntry, MovingPoints = MovingPaths[index] }; NpcEntries.Add(entry); } }