Beispiel #1
0
        public TOTVL(ushort zoneid, ushort id, byte realm, Instance_Lockouts lockouts) : base(zoneid, id, realm, lockouts)
        {
            _evtInterface = new EventInterface();
            ZoneID        = zoneid;
            createPenulums();

            StartFireTrap();
            StartDartTrap();
        }
Beispiel #2
0
 private ushort Create_new_instance(Player player, Zone_jump Jump)
 {
     lock (_instances)
     {
         for (ushort i = 1; i < ushort.MaxValue; i++)
         {
             if (!_instances.ContainsKey(i))
             {
                 if (Jump.ZoneID == 179)
                 {
                     TOTVL             ints       = null;
                     Instance_Lockouts deadbosses = null;
                     if (player._Value.GetLockout(Jump.InstanceID) != null)
                     {
                         if (player.PriorityGroup == null)                                 // solo player gets his own lockouts
                         {
                             InstanceService._InstanceLockouts.TryGetValue(player._Value.GetLockout(Jump.InstanceID), out deadbosses);
                         }
                         else                                 // group players gets the lockout of the leader
                         {
                             InstanceService._InstanceLockouts.TryGetValue(player.PriorityGroup.GetLeader()._Value.GetLockout(Jump.InstanceID), out deadbosses);
                         }
                     }
                     ints = new TOTVL(Jump.ZoneID, i, 0, deadbosses);
                     _instances.Add(i, ints);
                     return(i);
                 }
                 else
                 {
                     Instance          ints       = null;
                     Instance_Lockouts deadbosses = null;
                     if (player._Value.GetLockout(Jump.InstanceID) != null)
                     {
                         if (player.PriorityGroup == null)                                 // solo player gets his own lockouts
                         {
                             InstanceService._InstanceLockouts.TryGetValue(player._Value.GetLockout(Jump.InstanceID), out deadbosses);
                         }
                         else if (player.PriorityGroup.GetLeader()._Value.GetLockout(Jump.InstanceID) != null)                                 // group players gets the lockout of the leader
                         {
                             InstanceService._InstanceLockouts.TryGetValue(player.PriorityGroup.GetLeader()._Value.GetLockout(Jump.InstanceID), out deadbosses);
                         }
                     }
                     ints = new Instance(Jump.ZoneID, i, 0, deadbosses);
                     _instances.Add(i, ints);
                     return(i);
                 }
             }
         }
     }
     return(0);
 }
        public void OnBossDeath(uint GroupID)
        {
            List <InstanceBossSpawn> spawns;

            Boolean allbossesdead = true;

            InstanceBossSpawn boss = null;

            _BossSpawns.TryGetValue(GroupID, out spawns);
            for (int i = 0; i < spawns.Count; i++)
            {
                boss = spawns[i].GetInstanceBossSpawn();
                if (!spawns[i].IsDead)
                {
                    allbossesdead = false;
                }
            }
            if (allbossesdead)
            {
                if (Lockout == null)
                {
                    Lockout              = new Instance_Lockouts();
                    Lockout.InstanceID   = boss.InstanceID + ":" + (TCPManager.GetTimeStamp() + Info.LockoutTimer * 60);
                    Lockout.Bosseskilled = boss.ZoneId + ":" + boss.BossID;
                    InstanceService._InstanceLockouts.Add(Lockout.InstanceID, Lockout);
                    Lockout.Dirty = true;
                    WorldMgr.Database.AddObject(Lockout);
                }
                else
                {
                    Lockout.Bosseskilled += ";" + boss.ZoneId + ":" + boss.BossID;
                    //InstanceService._InstanceLockouts.Add(Lockout.InstanceID,Lockout);
                    Lockout.Dirty = true;
                    WorldMgr.Database.SaveObject(Lockout);
                }

                foreach (Player pl in Region.Players)
                {
                    pl._Value.AddLogout(Lockout.InstanceID);
                    pl.SendLockouts();
                }
                Encounterinprogress = false;
            }
        }
        public static void SaveLockoutInstanceID(string instanceID, Instance_Lockouts lockout)
        {
            if (lockout == null)
            {
                return;
            }

            // instanceID:      260:123456;

            if (!_InstanceStatistics.TryGetValue(instanceID, out Instances_Statistics stat))
            {
                stat = AddNewInstanceStatisticsEntry(instanceID);
            }

            stat.lockouts_InstanceID = lockout.InstanceID;

            stat.Dirty = true;
            Database.SaveObject(stat);
            Database.ForceSave();
        }
Beispiel #5
0
        public Instance(ushort zoneid, ushort id, byte realm, Instance_Lockouts lockouts)
        {
            Lockout = lockouts;
            ID      = id;
            ZoneID  = zoneid;
            Realm   = realm;
            Region  = new RegionMgr(zoneid, ZoneService.GetZoneRegion(zoneid), "", new ApocCommunications());
            InstanceService._InstanceInfo.TryGetValue(zoneid, out Info);
            LoadBossSpawns();
            LoadSpawns(); // todo get the saved progress from group
            _running      = true;
            _evtInterface = new EventInterface();
            closetime     = (TCPManager.GetTimeStamp() + 7200);

            // instancing stuff
            InstanceService.SaveLockoutInstanceID(ZoneID + ":" + ID, Lockout);

            new Thread(Update).Start();

            Log.Success("Opening Instance", "Instance ID " + ID + "  Map: " + Info.Name);
            // TOVL
            if (zoneid == 179)
            {
                foreach (var p in GameObjectService.GameObjectSpawns.Where(e => e.Value.ZoneId == 179))
                {
                    if (p.Value.Entry == 98908)
                    {
                        GameObject go = new GameObject(p.Value);

                        _Objects.Add(go);
                        Region.AddObject(go, zoneid, true);
                    }
                }

                if (Info != null && Info.Objects.Count > 0)
                {
                    LoadObjects();
                }
                _evtInterface.AddEvent(UpdatePendulums, 7000, 0);
            }
        }
Beispiel #6
0
        public void ApplyLockout(List <Player> subGroup)
        {
            if (Lockout == null) // instance hasn't got any lockouts
            {
                Lockout = new Instance_Lockouts
                {
                    InstanceID   = "~" + ZoneID + ":" + (TCPManager.GetTimeStamp() + Info.LockoutTimer * 60),
                    Bosseskilled = CurrentBossId.ToString()
                };
                InstanceService._InstanceLockouts.Add(Lockout.InstanceID, Lockout);
                Lockout.Dirty = true;
                WorldMgr.Database.AddObject(Lockout);
                InstanceService.SaveLockoutInstanceID(ZoneID + ":" + ID, Lockout);
            }
            else             // instance has got already lockouts
            {
                List <string> bossList = Lockout.Bosseskilled.Split(':').Distinct().ToList();
                if (!bossList.Contains(CurrentBossId.ToString()))
                {
                    bossList.Add(CurrentBossId.ToString());
                }
                Lockout.Bosseskilled = string.Empty;
                foreach (string boss in bossList)
                {
                    Lockout.Bosseskilled += ":" + boss;
                }
                if (Lockout.Bosseskilled.StartsWith(":"))
                {
                    Lockout.Bosseskilled = Lockout.Bosseskilled.Substring(1);
                }
                Lockout.Dirty = true;
                WorldMgr.Database.SaveObject(Lockout);
            }

            foreach (Player pl in subGroup)
            {
                pl._Value.AddLockout(Lockout);
                pl.SendLockouts();
            }
        }
Beispiel #7
0
 private ushort Create_new_instance(Player player, Zone_jump Jump)
 {
     lock (_instances)
     {
         for (ushort i = 1; i < ushort.MaxValue; i++)
         {
             if (!_instances.ContainsKey(i))
             {
                 if (Jump.ZoneID == 179)
                 {
                     TOTVL             ints       = null;
                     Instance_Lockouts deadbosses = null;
                     if (player._Value.GetLockout(Jump.InstanceID) != null)
                     {
                         InstanceService._InstanceLockouts.TryGetValue(player._Value.GetLockout(Jump.InstanceID), out deadbosses);
                     }
                     ints = new TOTVL(Jump.ZoneID, i, 0, deadbosses);
                     _instances.Add(i, ints);
                     return(i);
                 }
                 else
                 {
                     Instance          ints       = null;
                     Instance_Lockouts deadbosses = null;
                     if (player._Value.GetLockout(Jump.InstanceID) != null)
                     {
                         InstanceService._InstanceLockouts.TryGetValue(player._Value.GetLockout(Jump.InstanceID), out deadbosses);
                     }
                     ints = new Instance(Jump.ZoneID, i, 0, deadbosses);
                     _instances.Add(i, ints);
                     return(i);
                 }
             }
         }
     }
     return(0);
 }
Beispiel #8
0
        public void MyLockoutTest()
        {
            // test init
            Character_value charValue = new Character_value();

            // Test 1:
            // Player Lockouts empty, add new Lockout
            Instance_Lockouts Lockout = new Instance_Lockouts
            {
                InstanceID   = "~260:10000",
                Bosseskilled = "1:2:5"
            };

            charValue.AddLockout(Lockout);
            Assert.AreEqual(charValue.Lockouts, "~260:10000:1:2:5");

            // Test 2:
            // Player Lockouts filled, add new Lockout of same zoneID
            Lockout = new Instance_Lockouts
            {
                InstanceID   = "~260:10000",
                Bosseskilled = "3:4"
            };
            charValue.AddLockout(Lockout);
            Assert.AreEqual(charValue.Lockouts, "~260:10000:1:2:3:4:5");

            // Test 3:
            // Player Lockouts filled, add new Lockout of other zoneID
            Lockout = new Instance_Lockouts
            {
                InstanceID   = "~197:20000",
                Bosseskilled = "6:9"
            };
            charValue.AddLockout(Lockout);
            Assert.AreEqual(charValue.Lockouts, "~260:10000:1:2:3:4:5~197:20000:6:9");
            Lockout = new Instance_Lockouts
            {
                InstanceID   = "~100:30000",
                Bosseskilled = "331:789"
            };
            charValue.AddLockout(Lockout);
            Assert.AreEqual(charValue.Lockouts, "~260:10000:1:2:3:4:5~197:20000:6:9~100:30000:331:789");

            // Test 4:
            // Player get all Lockouts
            List <string> allLockouts = charValue.GetAllLockouts();
            string        allLo       = string.Empty;

            foreach (string lo in allLockouts)
            {
                allLo += lo;
            }
            Assert.AreEqual(allLo, "~260:10000:1:2:3:4:5~197:20000:6:9~100:30000:331:789");

            // Test 5:
            // Player Lockout filled, remove a Lockout of containing zoneID
            charValue.RemoveLockout("~100:30000:331:789");
            Assert.AreEqual(charValue.Lockouts, "~260:10000:1:2:3:4:5~197:20000:6:9");

            // Test 6:
            // Player Lockout filled, try to remove a Lockout of not-containing zoneID
            charValue.RemoveLockout("~42:9999:12:43");
            Assert.AreEqual(charValue.Lockouts, "~260:10000:1:2:3:4:5~197:20000:6:9");

            // Test 7:
            // Player get Lockout positive
            string validLo = charValue.GetLockout(260);

            Assert.AreEqual(validLo, "~260:10000:1:2:3:4:5");

            // Test 8:
            // Player get Lockout negative
            string invalidLo = charValue.GetLockout(42);

            Assert.IsNull(invalidLo);
        }