public static PlayerInvasionProfile EnsureProfile(PlayerMobile pm)
        {
            PlayerInvasionProfile p;

            if (!PlayerProfiles.TryGetValue(pm, out p))
            {
                PlayerProfiles.Add(pm, p = new PlayerInvasionProfile(pm));
            }
            else if (p == null)
            {
                PlayerProfiles[pm] = p = new PlayerInvasionProfile(pm);
            }

            return p;
        }
Example #2
0
        public static PlayerInvasionProfile EnsureProfile(PlayerMobile pm)
        {
            PlayerInvasionProfile p;

            if (!PlayerProfiles.TryGetValue(pm, out p))
            {
                PlayerProfiles.Add(pm, p = new PlayerInvasionProfile(pm));
            }
            else if (p == null)
            {
                PlayerProfiles[pm] = p = new PlayerInvasionProfile(pm);
            }

            return(p);
        }
Example #3
0
        private static bool DeserializePlayerProfiles(GenericReader reader)
        {
            reader.GetVersion();

            reader.ReadBlockDictionary(
                () =>
            {
                var e = reader.ReadMobile <PlayerMobile>();

                var p = new PlayerInvasionProfile(reader);

                return(new KeyValuePair <PlayerMobile, PlayerInvasionProfile>(e, p));
            },
                PlayerProfiles);

            return(true);
        }
Example #4
0
        private static void CSInvoke()
        {
            CommandUtility.Register(
                "Invade",
                AccessLevel.Player,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }
                new InvasionUI(e.Mobile as PlayerMobile).Send();
            });
            CommandUtility.Register(
                "InvadeScore",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                PlayerInvasionProfile p = EnsureProfile(e.Mobile as PlayerMobile);
                if (p != null)
                {
                    e.Mobile.SendMessage("Overall Score: " + p.OverallScore);
                    foreach (var kvp in p.SpecificInvasionScores)
                    {
                        var invasion = GetInvasion(kvp.Key);
                        if (invasion != null)
                        {
                            e.Mobile.SendMessage(54, invasion.RegionName + ": " + kvp.Value);
                        }
                    }
                }
            });
            foreach (var invasion in Invasions.Values.Where(invasion => invasion.Status == InvasionStatus.Running))
            {
                invasion.init();
            }
        }
Example #5
0
        public void AddScore(Mobile damager, int amount)
        {
            Mobile creditMob = null;

            var oneHandedWeapon = damager.FindItemOnLayer(Layer.OneHanded) as BaseWeapon;
            var twoHandedWeapon = damager.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
            var equipRanged     = twoHandedWeapon as BaseRanged;

            if (damager is BaseCreature)
            {
                var bc = (BaseCreature)damager;

                if (bc.ControlMaster is PlayerMobile)
                {
                    creditMob = bc.ControlMaster;
                    amount    = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.TamerMod));
                }
                else if (bc.SummonMaster is PlayerMobile)
                {
                    creditMob = bc.SummonMaster;
                    amount    = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.SummonMod));
                }
                else if (bc.BardMaster is PlayerMobile)
                {
                    creditMob = bc.BardMaster;
                    amount    = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.BardMod));
                }
            }
            else if (damager is PlayerMobile)
            {
                creditMob = damager;
                if (equipRanged != null)
                {
                    if (twoHandedWeapon.Slayer != SlayerName.None)
                    {
                        amount = (int)(Math.Ceiling(amount * 0.5));
                    }

                    amount = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.ArcherMod));
                }
                else if (oneHandedWeapon != null || twoHandedWeapon != null)
                {
                    if (oneHandedWeapon != null && oneHandedWeapon.Slayer != SlayerName.None ||
                        twoHandedWeapon != null && twoHandedWeapon.Slayer != SlayerName.None)
                    {
                        amount = (int)(Math.Ceiling(amount * 0.5));
                    }

                    amount = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.MeleeMod));
                }
            }

            if (creditMob != null)
            {
                PlayerInvasionProfile profile = EventInvasions.EnsureProfile(creditMob as PlayerMobile);
                profile.AddScore(amount, this);
                if (ParticipantsScores.ContainsKey(creditMob as PlayerMobile))
                {
                    ParticipantsScores[creditMob as PlayerMobile] += amount;
                }
                else
                {
                    ParticipantsScores.Add(creditMob as PlayerMobile, amount);
                }
            }
        }
        private static bool DeserializePlayerProfiles(GenericReader reader)
        {
            reader.GetVersion();

            reader.ReadBlockDictionary(
                () =>
                {
                    var e = reader.ReadMobile<PlayerMobile>();

                    var p = new PlayerInvasionProfile(reader);

                    return new KeyValuePair<PlayerMobile, PlayerInvasionProfile>(e, p);
                },
                PlayerProfiles);

            return true;
        }