Beispiel #1
0
        public void HandleSkills()
        {
            if (!IsSpawned)
            {
                return;
            }

            if (BossSkills.Count > 0 && Creatures.Count == 0)
            {
                ConcurrentArrayList <Entities.GameClient> PossibleTargets = GetPossibleTargets();
                if (PossibleTargets.Count > 0)
                {
                    if (DateTime.Now >= BossSkillTime)
                    {
                        BossSkillTime = DateTime.Now.AddMilliseconds(ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(BossSkillSpeed * 2));

                        ushort[] rSkills = BossSkills.Keys.ToArray();
                        if (rSkills.Length > 0)
                        {
                            ushort[] Skills = new ushort[rSkills.Length * 4];                             // fixing random index issue with .NET's random ...
                            Array.Copy(rSkills, 0, Skills, 0, rSkills.Length);
                            Array.Copy(rSkills, 0, Skills, rSkills.Length, rSkills.Length);
                            ushort Skill = Skills[ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(Skills.Length - 1)];

                            BossSkills[Skill].Use(this, PossibleTargets.ToDictionary().Values.ToArray());
                        }

                        foreach (Data.AdvancedSkill skill in BossAlwaysSkills.Values)
                        {
                            skill.Use(this, PossibleTargets.ToDictionary().Values.ToArray());
                        }
                    }
                }
            }
        }
        private static Entities.GameClient FindMatchUp(Entities.GameClient Player)
        {
            foreach (Entities.GameClient client in PlayerQueue.ToDictionary().Values)
            {
                if (client.EntityUID == Player.EntityUID)
                {
                    continue;
                }
                if (client.ArenaMatch != null)
                {
                    continue;
                }

                byte MAX_LEVEL = (byte)(client.Level + 25);
                byte MIN_LEVEL = (byte)(Player.Level - 25);
                if (client.Level >= MIN_LEVEL && Player.Level <= MAX_LEVEL)
                {
                    ushort PLUS_NUM = client.Equipments.GetNumberOfPlus();
                    PLUS_NUM = (ushort)(PLUS_NUM > 2 ? PLUS_NUM / 2 : PLUS_NUM);
                    if (PLUS_NUM <= client.Equipments.GetNumberOfPlus())
                    {
                        return(client);
                    }
                }
            }
            return(null);            // no match up ...
        }
Beispiel #3
0
 public void KickWatchers()
 {
     foreach (Entities.GameClient watcher in Watchers.ToDictionary().Values)
     {
         watcher.CanAttack = true;
         if (!watcher.LeaveDynamicMap())
         {
             watcher.NetworkClient.Disconnect("Could not leave dynamic map...");
         }
         else
         {
             watcher.Arena.Status = Enums.ArenaStatus.NotSignedUp;
             using (var wait = watcher.Arena.Build())
                 watcher.Send(wait);
         }
     }
     Watchers.Clear();
 }
        public static void JoinArena(Entities.GameClient Player)
        {
            if (Player.Battle != null)
            {
                return;
            }
            if (Player.DynamicMap != null)
            {
                return;
            }
            if (Player.ArenaMatch != null)
            {
                return;
            }

            if (PlayerQueue.Contains(Player))
            {
                Player.Arena.Status = Enums.ArenaStatus.NotSignedUp;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);

                Player.Arena.Status = Enums.ArenaStatus.WaitingForOpponent;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);
            }
            else
            {
                Player.Arena.Status = Enums.ArenaStatus.WaitingForOpponent;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);
            }
            if (MatchQueue.Count > 0)
            {
                using (var matches = new Packets.ArenaBattleInfoPacket(MatchQueue.ToDictionary().Values.ToArray()))
                {
                    matches.Page = 1;
                    matches.SetSize();
                    Player.Send(matches);
                }
            }
            PlayerQueue.Add(Player);
            uint DelayedID = 0;

            DelayedID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
            {
                if (HandleMatchUp(Player, FindMatchUp(Player)))
                {
                    ProjectX_V3_Lib.Threading.DelayedTask.Remove(DelayedID);
                }
            }, 10000, 0);
        }