Пример #1
0
        public static int GetLuckChanceForKiller(Mobile dead)
        {
            if (dead == null)
            {
                return(240);
            }

            var list = BaseCreature.GetLootingRights(dead.DamageEntries, dead.HitsMax);

            DamageStore highest = null;

            for (int i = 0; i < list.Count; ++i)
            {
                DamageStore ds = list[i];

                if (ds.m_HasRight && (highest == null || ds.m_Damage > highest.m_Damage))
                {
                    highest = ds;
                }
            }

            if (highest == null)
            {
                return(0);
            }

            return(GetLuckChance(highest.m_Mobile, dead));
        }
Пример #2
0
		public static int GetLuckChanceForKiller(Mobile m)
		{
            BaseCreature dead = m as BaseCreature;

            if (dead == null)
                return 240;

			var list = dead.GetLootingRights();

			DamageStore highest = null;

			for (int i = 0; i < list.Count; ++i)
			{
				DamageStore ds = list[i];

				if (ds.m_HasRight && (highest == null || ds.m_Damage > highest.m_Damage))
				{
					highest = ds;
				}
			}

			if (highest == null)
			{
				return 0;
			}

			return GetLuckChance(highest.m_Mobile, dead);
		}
Пример #3
0
        public override void OnDeath(Container c)
        {
            if (Map == Map.Felucca)
            {
                //TODO: Confirm SE change or AoS one too?
                List <DamageStore> rights = BaseCreature.GetLootingRights(this.DamageEntries, this.HitsMax);
                List <Mobile>      toGive = new List <Mobile>();

                for (int i = rights.Count - 1; i >= 0; --i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        toGive.Add(ds.m_Mobile);
                    }
                }

                if (toGive.Count > 0)
                {
                    toGive[Utility.Random(toGive.Count)].AddToBackpack(new ChampionSkull(SkullType));
                }
                else
                {
                    c.DropItem(new ChampionSkull(SkullType));
                }
            }

            base.OnDeath(c);
        }
Пример #4
0
        public static int GetLuckChanceForKiller(Mobile m)
        {
            BaseCreature dead = m as BaseCreature;

            if (dead == null)
            {
                return(240);
            }

            System.Collections.Generic.List <DamageStore> list = dead.GetLootingRights();

            DamageStore highest = null;

            for (int i = 0; i < list.Count; ++i)
            {
                DamageStore ds = list[i];

                if (ds.m_HasRight && (highest == null || ds.m_Damage > highest.m_Damage))
                {
                    highest = ds;
                }
            }

            if (highest == null)
            {
                return(0);
            }

            return(GetLuckChance(highest.m_Mobile, dead));
        }
Пример #5
0
        public static void CheckArtifactGiving(BaseCreature boss)
        {
            int basePoints = (boss is DemonKnight) ? 500 : 100;

            List <DamageStore> rights = BaseCreature.GetLootingRights(boss.DamageEntries, boss.HitsMax);

            for (int i = 0; i < rights.Count; i++)
            {
                DamageStore store = rights[i];

                if (!store.HasRight)
                {
                    continue;
                }

                PlayerMobile pm = store.Mobile as PlayerMobile;

                if (pm != null)
                {
                    int awardPoints = (int)(basePoints * (1.0 - Math.Ceiling(i / 2.0) * 0.02));

                    pm.DoomCredits += awardPoints;

                    int chance = (int)(pm.DoomCredits * (1.0 + LootPack.GetLuckChance(pm, boss) / 10000.0));

                    if (chance > Utility.Random(1000000))
                    {
                        GiveArtifactTo(pm);
                    }
                }
            }
        }
        private void CalculateWeaponDps(UniqueBase unique, Dictionary <BonusType, StatBonus> maxStatBonuses)
        {
            Dictionary <ElementType, DamageStore> weaponDamage = new Dictionary <ElementType, DamageStore>();

            foreach (ElementType element in Enum.GetValues(typeof(ElementType)))
            {
                weaponDamage[element] = new DamageStore(0, 0);
            }
            weaponDamage[0].Min = CalculateStat(unique.MinDamage, maxStatBonuses, BonusType.LOCAL_PHYSICAL_DAMAGE_MIN);
            weaponDamage[0].Max = CalculateStat(unique.MaxDamage, maxStatBonuses, BonusType.LOCAL_PHYSICAL_DAMAGE_MAX);
            weaponDamage[0].Min = CalculateStat(weaponDamage[0].Min, maxStatBonuses, BonusType.LOCAL_PHYSICAL_DAMAGE);
            weaponDamage[0].Max = CalculateStat(weaponDamage[0].Max, maxStatBonuses, BonusType.LOCAL_PHYSICAL_DAMAGE);

            weaponDamage[ElementType.FIRE].Min = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_FIRE_DAMAGE_MIN);
            weaponDamage[ElementType.FIRE].Max = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_FIRE_DAMAGE_MAX);
            weaponDamage[ElementType.FIRE].Min = CalculateStat(weaponDamage[ElementType.FIRE].Min, maxStatBonuses, BonusType.LOCAL_FIRE_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);
            weaponDamage[ElementType.FIRE].Max = CalculateStat(weaponDamage[ElementType.FIRE].Max, maxStatBonuses, BonusType.LOCAL_FIRE_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);

            weaponDamage[ElementType.COLD].Min = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_COLD_DAMAGE_MIN);
            weaponDamage[ElementType.COLD].Max = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_COLD_DAMAGE_MAX);
            weaponDamage[ElementType.COLD].Min = CalculateStat(weaponDamage[ElementType.COLD].Min, maxStatBonuses, BonusType.LOCAL_COLD_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);
            weaponDamage[ElementType.COLD].Max = CalculateStat(weaponDamage[ElementType.COLD].Max, maxStatBonuses, BonusType.LOCAL_COLD_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);

            weaponDamage[ElementType.LIGHTNING].Min = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_LIGHTNING_DAMAGE_MIN);
            weaponDamage[ElementType.LIGHTNING].Max = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_LIGHTNING_DAMAGE_MAX);
            weaponDamage[ElementType.LIGHTNING].Min = CalculateStat(weaponDamage[ElementType.LIGHTNING].Min, maxStatBonuses, BonusType.LOCAL_LIGHTNING_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);
            weaponDamage[ElementType.LIGHTNING].Max = CalculateStat(weaponDamage[ElementType.LIGHTNING].Max, maxStatBonuses, BonusType.LOCAL_LIGHTNING_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);

            weaponDamage[ElementType.EARTH].Min = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_EARTH_DAMAGE_MIN);
            weaponDamage[ElementType.EARTH].Max = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_EARTH_DAMAGE_MAX);
            weaponDamage[ElementType.EARTH].Min = CalculateStat(weaponDamage[ElementType.EARTH].Min, maxStatBonuses, BonusType.LOCAL_EARTH_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);
            weaponDamage[ElementType.EARTH].Max = CalculateStat(weaponDamage[ElementType.EARTH].Max, maxStatBonuses, BonusType.LOCAL_EARTH_DAMAGE, BonusType.LOCAL_ELEMENTAL_DAMAGE);

            weaponDamage[ElementType.DIVINE].Min = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_DIVINE_DAMAGE_MIN);
            weaponDamage[ElementType.DIVINE].Max = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_DIVINE_DAMAGE_MAX);
            weaponDamage[ElementType.DIVINE].Min = CalculateStat(weaponDamage[ElementType.DIVINE].Min, maxStatBonuses, BonusType.LOCAL_DIVINE_DAMAGE, BonusType.LOCAL_PRIMORDIAL_DAMAGE);
            weaponDamage[ElementType.DIVINE].Max = CalculateStat(weaponDamage[ElementType.DIVINE].Max, maxStatBonuses, BonusType.LOCAL_DIVINE_DAMAGE, BonusType.LOCAL_PRIMORDIAL_DAMAGE);

            weaponDamage[ElementType.VOID].Min = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_VOID_DAMAGE_MIN);
            weaponDamage[ElementType.VOID].Max = CalculateStat(0, maxStatBonuses, BonusType.LOCAL_VOID_DAMAGE_MAX);
            weaponDamage[ElementType.VOID].Min = CalculateStat(weaponDamage[ElementType.VOID].Min, maxStatBonuses, BonusType.LOCAL_VOID_DAMAGE, BonusType.LOCAL_PRIMORDIAL_DAMAGE);
            weaponDamage[ElementType.VOID].Max = CalculateStat(weaponDamage[ElementType.VOID].Max, maxStatBonuses, BonusType.LOCAL_VOID_DAMAGE, BonusType.LOCAL_PRIMORDIAL_DAMAGE);

            float AttackSpeed = CalculateStat(unique.AttackSpeed, maxStatBonuses, BonusType.LOCAL_ATTACK_SPEED);
            float pDps        = (weaponDamage[0].Min + weaponDamage[0].Max) / 2f * AttackSpeed;

            int   eMin = weaponDamage[ElementType.FIRE].Min + weaponDamage[ElementType.COLD].Min + weaponDamage[ElementType.LIGHTNING].Min + weaponDamage[ElementType.EARTH].Min;
            int   eMax = weaponDamage[ElementType.FIRE].Max + weaponDamage[ElementType.COLD].Max + weaponDamage[ElementType.LIGHTNING].Max + weaponDamage[ElementType.EARTH].Max;
            float eDps = (eMin + eMax) / 2f * AttackSpeed;

            int   aMin = weaponDamage[ElementType.DIVINE].Min + weaponDamage[ElementType.VOID].Min;
            int   aMax = weaponDamage[ElementType.DIVINE].Max + weaponDamage[ElementType.VOID].Max;
            float aDps = (aMin + aMax) / 2f * AttackSpeed;

            pDpsLabel.Content = "pDps: " + pDps;
            eDpsLabel.Content = "eDps: " + eDps;
            aDpsLabel.Content = "aDps: " + aDps;
        }
Пример #7
0
        public override void OnAfterDelete()
        {
            base.OnAfterDelete();

            if (DamageStore != null)
            {
                DamageStore.Clear();
            }
        }
Пример #8
0
        public override void OnComplete()
        {
            Victoria victoria = ((TheSummoningQuest)System).Victoria;

            if (victoria != null)
            {
                SummoningAltar altar = victoria.Altar;

                if (altar != null)
                {
                    altar.CheckDaemon();
                }
            }

            PlayerMobile from = System.From;

            if (!from.Alive)
            {
                from.SendLocalizedMessage(1050033); // The devourer lies dead, unfortunately so do you.  You cannot claim your reward while dead.  You will need to face him again.
                ((TheSummoningQuest)System).WaitForSummon = true;
            }
            else
            {
                bool hasRights = true;

                if (m_Daemon != null)
                {
                    List <DamageStore> lootingRights = BaseCreature.GetLootingRights(m_Daemon.DamageEntries, m_Daemon.HitsMax);

                    for (int i = 0; i < lootingRights.Count; ++i)
                    {
                        DamageStore ds = lootingRights[i];

                        if (ds.m_HasRight && ds.m_Mobile == from)
                        {
                            hasRights = true;
                            break;
                        }
                    }
                }

                if (!hasRights)
                {
                    from.SendLocalizedMessage(1050034); // The devourer lies dead.  Unfortunately you did not sufficiently prove your worth in combating the devourer.  Victoria shall summon another incarnation of the devourer to the circle of stones.  Try again noble adventurer.
                    ((TheSummoningQuest)System).WaitForSummon = true;
                }
                else
                {
                    from.SendLocalizedMessage(1050035); // The devourer lies dead.  Search his corpse to claim your prize!

                    if (m_Daemon != null)
                    {
                        m_CorpseWithSkull = m_Daemon.Corpse as Corpse;
                    }
                }
            }
        }
Пример #9
0
        public void CheckQuest()
        {
            List <DamageStore> rights = GetLootingRights(  );

            ArrayList mobile = new ArrayList();

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = (DamageStore)rights[i];

                if (ds.m_HasRight)
                {
                    if (ds.m_Mobile is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)ds.m_Mobile;
                        QuestSystem  qs = pm.Quest;
                        if (qs is TheGraveDiggerQuest)
                        {
                            mobile.Add(ds.m_Mobile);
                        }
                    }
                }
            }

            for (int i = 0; i < mobile.Count; ++i)
            {
                PlayerMobile pm = (PlayerMobile)mobile[i % mobile.Count];
                QuestSystem  qs = pm.Quest;

                QuestObjective obj = qs.FindObjective(typeof(FindPureGrainAlcoholObjective));

                if (obj != null && !obj.Completed)
                {
                    Item pure = new PureGrainAlcohol();

                    if (!pm.PlaceInBackpack(pure))
                    {
                        pure.Delete();
                        pm.SendLocalizedMessage(1046260);                           // 負重過大的提示.
                    }
                    else
                    {
                        obj.Complete();
                        pm.SendMessage("你從巴克斯的屍體上獲得了酒精.");
                    }
                }
            }
        }
Пример #10
0
        public void CheckQuest()
        {
            List <DamageStore> rights = GetLootingRights(  );

            ArrayList mobile = new ArrayList();

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = (DamageStore)rights[i];

                if (ds.m_HasRight)
                {
                    if (ds.m_Mobile is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)ds.m_Mobile;
                        QuestSystem  qs = pm.Quest;
                        if (qs is TheGraveDiggerQuest)
                        {
                            mobile.Add(ds.m_Mobile);
                        }
                    }
                }
            }

            for (int i = 0; i < mobile.Count; ++i)
            {
                PlayerMobile pm = (PlayerMobile)mobile[i % mobile.Count];
                QuestSystem  qs = pm.Quest;

                QuestObjective obj = qs.FindObjective(typeof(FindRiceFlavorSticksObjective));

                if (obj != null && !obj.Completed)
                {
                    Item sticks = new RiceFlavorSticks();

                    if (!pm.PlaceInBackpack(sticks))
                    {
                        sticks.Delete();
                        pm.SendLocalizedMessage(1046260);                           // You need to clear some space in your inventory to continue with the quest.  Come back here when you have more space in your inventory.
                    }
                    else
                    {
                        obj.Complete();
                        pm.SendMessage("дЦ▐дя╙нвяЩ╣д▄фСwио╚@╣цак©упд╣д╣╬╡щ≈U.");
                    }
                }
            }
        }
Пример #11
0
        public void CheckQuest()
        {
            List <DamageStore> rights = BaseCreature.GetLootingRights(this.DamageEntries, this.HitsMax);

            ArrayList mobile = new ArrayList();

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = rights[i];

                if (ds.m_HasRight)
                {
                    if (ds.m_Mobile is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)ds.m_Mobile;
                        QuestSystem  qs = pm.Quest;
                        if (qs is TheGraveDiggerQuest)
                        {
                            mobile.Add(ds.m_Mobile);
                        }
                    }
                }
            }

            for (int i = 0; i < mobile.Count; ++i)
            {
                PlayerMobile pm = (PlayerMobile)mobile[i % mobile.Count];
                QuestSystem  qs = pm.Quest;

                QuestObjective obj = qs.FindObjective(typeof(FindPureGrainAlcoholObjective));

                if (obj != null && !obj.Completed)
                {
                    Item pure = new PureGrainAlcohol();

                    if (!pm.PlaceInBackpack(pure))
                    {
                        pure.Delete();
                        pm.SendLocalizedMessage(1046260);                           // You need to clear some space in your inventory to continue with the quest.  Come back here when you have more space in your inventory.
                    }
                    else
                    {
                        obj.Complete();
                        pm.SendMessage("You loot the alcohol off the gods corpse.");
                    }
                }
            }
        }
Пример #12
0
        public void CheckQuest()
        {
            List <DamageStore> rights = GetLootingRights( );           // this.DamageEntries, this.HitsMax

            ArrayList mobile = new ArrayList();

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = (DamageStore)rights[i];

                if (ds.m_HasRight)
                {
                    if (ds.m_Mobile is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)ds.m_Mobile;
                        QuestSystem  qs = pm.Quest;
                        if (qs is TheGraveDiggerQuest)
                        {
                            mobile.Add(ds.m_Mobile);
                        }
                    }
                }
            }

            for (int i = 0; i < mobile.Count; ++i)
            {
                PlayerMobile pm = (PlayerMobile)mobile[i % mobile.Count];
                QuestSystem  qs = pm.Quest;

                QuestObjective obj = qs.FindObjective(typeof(FindYeastObjective));

                if (obj != null && !obj.Completed)
                {
                    Item yeast = new Yeast();

                    if (!pm.PlaceInBackpack(yeast))
                    {
                        yeast.Delete();
                        pm.SendLocalizedMessage(1046260);                           // You need to clear some space in your inventory to continue with the quest.  Come back here when you have more space in your inventory.
                    }
                    else
                    {
                        obj.Complete();
                        pm.SendMessage("你從農民的屍體上找到了發酵粉.");
                    }
                }
            }
        }
Пример #13
0
		public static int GetLuckChanceForKiller( Mobile dead )
		{
			List<DamageStore> list = BaseCreature.GetLootingRights( dead.DamageEntries, dead.HitsMax );

			DamageStore highest = null;

			for ( int i = 0; i < list.Count; ++i )
			{
				DamageStore ds = list[i];

				if ( ds.HasRight && ( highest == null || ds.Damage > highest.Damage ) )
					highest = ds;
			}

			if ( highest == null )
				return 0;

			return GetLuckChance( highest.Mobile, dead );
		}
        private void CompileHelpersList(BaseCreature pirate)
        {
            if (Owner == null)
            {
                return;
            }

            Party p = Party.Get(Owner);
            List <DamageStore> rights = pirate.GetLootingRights();

            IPooledEnumerable eable = pirate.GetMobilesInRange(19);

            foreach (Mobile mob in eable)
            {
                if (mob == Owner || !(mob is PlayerMobile))
                {
                    continue;
                }

                Party mobParty = Party.Get(mob);

                //Add party memebers regardless of looting rights
                if (p != null && mobParty != null && p == mobParty)
                {
                    m_Helpers.Add(mob);
                    continue;
                }

                // add those with looting rights
                for (int i = rights.Count - 1; i >= 0; --i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight && ds.m_Mobile == mob)
                    {
                        m_Helpers.Add(ds.m_Mobile);
                        break;
                    }
                }
            }
            eable.Free();
        }
Пример #15
0
        public void GivePrizes()
        {
            List <DamageStore> rights = BaseCreature.GetLootingRights(this.DamageEntries, this.HitsMax);
            List <Mobile>      toGive = new List <Mobile>();

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = rights[i];

                if (ds.m_Damage >= 300)
                {
                    toGive.Add(ds.m_Mobile);
                }
            }

            for (int i = 0; i < toGive.Count; i++)
            {
                GivePrize(toGive[i]);
            }
        }
Пример #16
0
        public override void OnDeath(Container c)
        {
            if (IsLastBoss)
            {
                List <DamageStore> rights = GetLootingRights();

                for (var index = 0; index < rights.Count; index++)
                {
                    DamageStore ds = rights[index];

                    if (ds.m_HasRight)
                    {
                        int luck = ds.m_Mobile is PlayerMobile mobile ? mobile.RealLuck : ds.m_Mobile.Luck;

                        int chance = 1000 + (luck / 15);

                        if (chance > Utility.Random(5000))
                        {
                            Mobile m        = ds.m_Mobile;
                            Item   artifact = Loot.Construct(ArtifactDrops[Utility.Random(ArtifactDrops.Length)]);

                            if (artifact != null)
                            {
                                if (m.Backpack == null || !m.Backpack.TryDropItem(m, artifact, false))
                                {
                                    m.BankBox.DropItem(artifact);
                                    m.SendMessage(
                                        "For your valor in combating the fallen beast, a special reward has been placed in your bank box.");
                                }
                                else
                                {
                                    m.SendLocalizedMessage(
                                        1062317); // For your valor in combating the fallen beast, a special reward has been bestowed on you.
                                }
                            }
                        }
                    }
                }
            }
            base.OnDeath(c);
        }
Пример #17
0
        public static Mobile FindRandomPlayer(BaseCreature creature)
        {
            List <DamageStore> rights = BaseCreature.GetLootingRights(creature.DamageEntries, creature.HitsMax);

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = rights[i];

                if (!ds.m_HasRight)
                {
                    rights.RemoveAt(i);
                }
            }

            if (rights.Count > 0)
            {
                return(rights[Utility.Random(rights.Count)].m_Mobile);
            }

            return(null);
        }
Пример #18
0
        public void RegisterDamage(Mobile m, int damage)
        {
            if (m == null)
            {
                return;
            }

            if (DamageStore == null)
            {
                DamageStore = new Dictionary <Mobile, int>();
            }

            if (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile)
            {
                m = ((BaseCreature)m).GetMaster();
            }

            if (!DamageStore.ContainsKey(m))
            {
                DamageStore[m] = 0;
            }

            DamageStore[m] += damage;
        }
Пример #19
0
        public void OnCreatureKilled(BaseCreature killed)
        {
            if (Waves == null)
            {
                return;
            }

            Waves.ForEach(info =>
            {
                if (info.Creatures.Contains(killed))
                {
                    List <DamageStore> list = killed.GetLootingRights();
                    list.Sort();

                    for (int i = 0; i < list.Count; i++)
                    {
                        DamageStore ds = list[i];
                        Mobile m       = ds.m_Mobile;

                        if (ds.m_Mobile is BaseCreature && ((BaseCreature)ds.m_Mobile).GetMaster() is PlayerMobile)
                        {
                            m = ((BaseCreature)ds.m_Mobile).GetMaster();
                        }

                        if (!info.Credit.Contains(m))
                        {
                            info.Credit.Add(m);
                        }

                        if (!CurrentScore.ContainsKey(m))
                        {
                            CurrentScore[m] = killed.Fame / 998;
                        }
                        else
                        {
                            CurrentScore[m] += killed.Fame / 998;
                        }
                    }

                    list.Clear();
                    list.TrimExcess();

                    info.Creatures.Remove(killed);

                    if (info.Creatures.Count == 0)
                    {
                        foreach (Mobile m in info.Credit.Where(m => m.Region == this.Region && m is PlayerMobile))
                        {
                            double award = Math.Max(0, this.Map == Map.Felucca ? Stage * 2 : Stage);

                            if (award > 0)
                            {
                                //Score Bonus
                                if (!CurrentScore.ContainsKey(m))
                                {
                                    CurrentScore[m] = Stage * 125;
                                }
                                else
                                {
                                    CurrentScore[m] += Stage * 125;
                                }
                            }
                        }
                    }

                    if (killed.Corpse != null && !killed.Corpse.Deleted)
                    {
                        ((Corpse)killed.Corpse).BeginDecay(TimeSpan.FromMinutes(1));
                    }
                }
            });
        }
Пример #20
0
        public void GivePowerScrolls()
        {
            List <Mobile>      toGive = new List <Mobile>();
            List <DamageStore> rights = BaseCreature.GetLootingRights(this.DamageEntries, this.HitsMax);

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = rights[i];

                if (ds.m_HasRight)
                {
                    toGive.Add(ds.m_Mobile);
                }
            }

            if (toGive.Count == 0)
            {
                return;
            }

            // Randomize
            for (int i = 0; i < toGive.Count; ++i)
            {
                int    rand = Utility.Random(toGive.Count);
                Mobile hold = toGive[i];
                toGive[i]    = toGive[rand];
                toGive[rand] = hold;
            }

            for (int i = 0; i < 16; ++i)
            {
                int    level;
                double random = Utility.RandomDouble();

                if (0.1 >= random)
                {
                    level = 25;
                }
                else if (0.25 >= random)
                {
                    level = 20;
                }
                else if (0.45 >= random)
                {
                    level = 15;
                }
                else if (0.70 >= random)
                {
                    level = 10;
                }
                else
                {
                    level = 5;
                }

                Mobile m = toGive[i % toGive.Count];

                m.SendLocalizedMessage(1049524); // You have received a scroll of power!
                m.AddToBackpack(new StatCapScroll(225 + level));

                if (m is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)m;

                    for (int j = 0; j < pm.JusticeProtectors.Count; ++j)
                    {
                        Mobile prot = (Mobile)pm.JusticeProtectors[j];

                        if (prot.Map != m.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(m, prot))
                        {
                            continue;
                        }

                        int chance = 0;

                        switch (VirtueHelper.GetLevel(prot, VirtueName.Justice))
                        {
                        case VirtueLevel.Seeker: chance = 60; break;

                        case VirtueLevel.Follower: chance = 80; break;

                        case VirtueLevel.Knight: chance = 100; break;
                        }

                        if (chance > Utility.Random(100))
                        {
                            prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice!
                            prot.AddToBackpack(new StatCapScroll(225 + level));
                        }
                    }
                }
            }
        }
Пример #21
0
        public override bool OnBeforeDeath()
        {
            if (m_TrueForm)
            {
                List <DamageStore> rights = BaseCreature.GetLootingRights(this.DamageEntries, this.HitsMax);

                for (int i = rights.Count - 1; i >= 0; --i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight && ds.m_Mobile is PlayerMobile)
                    {
                        PlayerMobile.ChampionTitleInfo.AwardHarrowerTitle((PlayerMobile)ds.m_Mobile);
                    }
                }

                if (!NoKillAwards)
                {
                    GivePowerScrolls();

                    Map map = this.Map;

                    if (map != null)
                    {
                        for (int x = -16; x <= 16; ++x)
                        {
                            for (int y = -16; y <= 16; ++y)
                            {
                                double dist = Math.Sqrt(x * x + y * y);

                                if (dist <= 16)
                                {
                                    new GoodiesTimer(map, X + x, Y + y).Start();
                                }
                            }
                        }
                    }

                    m_DamageEntries = new Dictionary <Mobile, int>();

                    for (int i = 0; i < m_Tentacles.Count; ++i)
                    {
                        Mobile m = m_Tentacles[i];

                        if (!m.Deleted)
                        {
                            m.Kill();
                        }

                        RegisterDamageTo(m);
                    }

                    m_Tentacles.Clear();

                    RegisterDamageTo(this);
                    AwardArtifact(GetArtifact());

                    if (m_GateItem != null)
                    {
                        m_GateItem.Delete();
                    }
                }

                return(base.OnBeforeDeath());
            }
            else
            {
                Morph();
                return(false);
            }
        }
Пример #22
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems) : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            Owner = owner;

            CorpseName = GetCorpseName(owner);

            TimeOfDeath = DateTime.UtcNow;

            AccessLevel = owner.AccessLevel;

            //TEST: GUILD
            //Guild = owner.Guild as Guild;

            Kills    = owner.MurderCounts;
            Criminal = owner.Criminal;

            Hair       = hair;
            FacialHair = facialhair;

            NoBones = !owner.Player;

            m_EquipItems = equipItems;

            Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);

            bool addToAggressors = !(owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    Killer   = info.Attacker;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (addToAggressors && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    Killer   = info.Defender;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (addToAggressors)
                {
                    Aggressors.Add(info.Defender);
                }
            }

            if (!addToAggressors)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();

                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                List <DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);

                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);
        }
Пример #23
0
        public static bool CalcAwardInSilver(Mobile m, out int silver, out int gold)
        {
            // new award amounts
            silver = gold = 0;

            if (m == null || m is BaseCreature == false)
            {
                return(false);
            }

            BaseCreature bc = m as BaseCreature;

            // creature must be IOB aligned
            if (IOBSystem.IsIOBAligned(bc) == false)
            {
                return(false);
            }

            //creature must not be controlled
            if (bc.ControlMaster != null)
            {
                return(false);
            }

            // first find out how much gold this creature is dropping as that will be the gauge for the silver drop
            int MobGold = bc.GetGold();

            // meh, random I know
            gold   = MobGold / 2;               // cut the gold in half
            silver = MobGold / 10;              // and give him 10% in silver

            // now calc the damagers.
            bool         fail    = false;
            ArrayList    list    = BaseCreature.GetLootingRights(bc.DamageEntries);
            IOBAlignment IOBBase = IOBAlignment.None;

            for (int i = 0; i < list.Count; ++i)
            {
                DamageStore ds = (DamageStore)list[i];

                if (!ds.m_HasRight)
                {
                    continue;
                }

                if (ds.m_Mobile != null)
                {
                    // initialize the required IOBAlignment (one time)
                    if (IOBBase == IOBAlignment.None)
                    {
                        IOBBase = IOBSystem.GetIOBAlignment(ds.m_Mobile);
                    }

                    // ds.m_Mobile may be a basecreature or a playermobile
                    // 1. if the damager is not an ememy of the creature it killed, then no silver awards
                    // 2. if all damagers are not of the same alignment, then no silver awards
                    // 3. if the top damager was an interferer, no silver awards
                    if (IOBSystem.IsEnemy(ds.m_Mobile, m) == false || IOBBase != IOBSystem.GetIOBAlignment(ds.m_Mobile) || IOBBase == IOBAlignment.Healer)
                    {                           // no silver awards
                        fail = true;
                        break;
                    }
                }
            }

            // see if there were any non same-kin damagers.
            //	we won't reward silver if there was outside help
            if (fail == true)
            {
                return(false);
            }


            // okay, we have new amounts
            return(true);
        }
Пример #24
0
        public void GivePowerScrolls()
        {
            if (Map != Map.Felucca)
            {
                return;
            }

            List <Mobile>      toGive = new List <Mobile>();
            List <DamageStore> rights = BaseCreature.GetLootingRights(this.DamageEntries, this.HitsMax);

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = rights[i];

                if (ds.m_HasRight)
                {
                    toGive.Add(ds.m_Mobile);
                }
            }

            if (toGive.Count == 0)
            {
                return;
            }

            for (int i = 0; i < toGive.Count; i++)
            {
                Mobile m = toGive[i];

                if (!(m is PlayerMobile))
                {
                    continue;
                }

                bool gainedPath = false;

                int pointsToGain = 800;

                if (VirtueHelper.Award(m, VirtueName.Valor, pointsToGain, ref gainedPath))
                {
                    if (gainedPath)
                    {
                        m.SendLocalizedMessage(1054032); // You have gained a path in Valor!
                    }
                    else
                    {
                        m.SendLocalizedMessage(1054030); // You have gained in Valor!
                    }
                    //No delay on Valor gains
                }
            }

            // Randomize
            for (int i = 0; i < toGive.Count; ++i)
            {
                int    rand = Utility.Random(toGive.Count);
                Mobile hold = toGive[i];
                toGive[i]    = toGive[rand];
                toGive[rand] = hold;
            }

            for (int i = 0; i < 6; ++i)
            {
                Mobile m = toGive[i % toGive.Count];

                PowerScroll ps = CreateRandomPowerScroll();

                GivePowerScrollTo(m, ps);
            }
        }
Пример #25
0
        public Corpse(Mobile owner, ArrayList equipItems)
            : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.Now;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.LongTermMurders;
            m_Criminal    = owner.Criminal;

#if false
            // This corpse does not turn to bones if:
            //    (the owner is not a player) and (the owner doesn't have a human body)
            m_NoBones = !owner.Player && !owner.Body.IsHuman;
#else
            // This corpse does not turn to bones if:
            //    (the owner is not a player)
            m_NoBones = !owner.Player;
#endif

            m_Looters    = new ArrayList();
            m_EquipItems = equipItems;

            m_Aggressors = new ArrayList(owner.Aggressors.Count + owner.Aggressed.Count);
            bool addToAggressors = !(owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            // Adam: Now that we have the killer, see if the Killer is on a shared account with the player killed
            //	we ill pass this information along to the bounty system to prevent bounty farming by the murderer.
            if (m_Killer != null)
            {                   // no need to serialize this value as it's only good as long as the corpse lasts
                m_FriendlyFire = BountySystem.BountyKeeper.SharedAccount(m_Owner, m_Killer);
            }

            if (!addToAggressors)
            {
                BaseCreature bc = (BaseCreature)owner;

                if (bc.Controlled && bc.ControlMaster != null)
                {
                    m_Aggressors.Add(bc.ControlMaster);
                }
                else if (bc.Summoned && bc.SummonMaster != null)
                {
                    m_Aggressors.Add(bc.SummonMaster);
                }

                List <DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = (DamageStore)rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);
        }
Пример #26
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
            : base(0x2006)
        {
            Movable = false;

            Stackable = true;       // To supress console warnings, stackable must be true
            Amount    = owner.Body; // Protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Name = owner.Name;
            Hue  = owner.Hue;

            Direction = owner.Direction;
            Light     = (LightType)Direction;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            TimeOfDeath = DateTime.UtcNow;

            m_AccessLevel = owner.AccessLevel;
            Guild         = owner.Guild as Guild;
            Kills         = owner.Kills;

            SetFlag(CorpseFlag.Criminal, owner.Criminal);
            SetFlag(CorpseFlag.Murderer, owner.Murderer);

            Hair       = hair;
            FacialHair = facialhair;

            // This corpse does not turn to bones if: the owner is not a player
            SetFlag(CorpseFlag.NoBones, !owner.Player);

            // Flagging looters as criminal can happen by default
            SetFlag(CorpseFlag.LootCriminal, true);

            m_Looters    = new List <Mobile>();
            m_EquipItems = equipItems;

            m_Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            //bool addToAggressors = !( owner is BaseCreature );

            BaseCreature bc = owner as BaseCreature;

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (bc == null && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (bc == null)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (bc != null)
            {
                Mobile master = bc.GetMaster();

                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                List <DamageStore> rights = bc.GetLootingRights();
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(owner.CorpseDecayTime);
            DevourCorpse();

            if (owner is PlayerMobile)
            {
                if (PlayerCorpses == null)
                {
                    PlayerCorpses = new Dictionary <Corpse, int>();
                }

                PlayerCorpses[this] = 0;
            }
        }
Пример #27
0
        public Corpse(Mobile owner, ArrayList equipItems) : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.Now;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.Kills;
            m_Criminal    = owner.Criminal;

#if false
            // This corpse does not turn to bones if:
            //    (the owner is not a player) and (the owner doesn't have a human body)
            m_NoBones = !owner.Player && !owner.Body.IsHuman;
#else
            // This corpse does not turn to bones if:
            //    (the owner is not a player)
            m_NoBones = !owner.Player;
#endif

            m_Looters    = new ArrayList();
            m_EquipItems = equipItems;

            m_Aggressors = new ArrayList(owner.Aggressors.Count + owner.Aggressed.Count);
            bool addToAggressors = !(owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (!addToAggressors)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();
                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                ArrayList rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = (DamageStore)rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);
        }
Пример #28
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
            : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.Now;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.Kills;
            SetFlag(CorpseFlag.Criminal, owner.Criminal);

            m_Hair       = hair;
            m_FacialHair = facialhair;

            // This corpse does not turn to bones if: the owner is not a player
            SetFlag(CorpseFlag.NoBones, !owner.Player);

            m_Looters    = new List <Mobile>();
            m_EquipItems = equipItems;

            m_Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            //bool addToAggressors = !( owner is BaseCreature );

            bool isBaseCreature = (owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (!isBaseCreature && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (!isBaseCreature)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (isBaseCreature)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();
                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                List <DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);

            DevourCorpse();
        }
Пример #29
0
        public static int GetLuckChanceForKiller(Mobile dead)
        {
            ArrayList list = BaseCreature.GetLootingRights(dead.DamageEntries, dead.HitsMax);

            double luckTotal   = 0;
            int    damageTotal = 0;

            Hashtable partyDamage = new Hashtable();

            for (int i = 0; i < list.Count; ++i)
            {
                DamageStore ds = (DamageStore)list[i];

                if (ds.m_HasRight)
                {
                    Party p = Party.Get(ds.m_Mobile);
                    damageTotal += ds.m_Damage;

                    Console.WriteLine("Mobile {0} ({1}); Damage: {2} ", ds.m_Mobile.Name, ds.m_Mobile.Serial.ToString(), ds.m_Damage);

                    if (p != null)
                    {
                        if (partyDamage.Contains(p))
                        {
                            partyDamage[p] = (int)partyDamage[p] + ds.m_Damage;
                        }
                        else
                        {
                            partyDamage.Add(p, ds.m_Damage);
                        }
                    }
                }
            }

            for (int i = 0; i < list.Count; ++i)
            {
                DamageStore ds = (DamageStore)list[i];
                if (ds.m_HasRight)
                {
                    Party p = Party.Get(ds.m_Mobile);

                    if (p == null)
                    {
                        double scale = (double)ds.m_Damage / damageTotal;

                        luckTotal += ds.m_Mobile.Luck * scale;

                        PlayerMobile pm = ds.m_Mobile as PlayerMobile;

                        if (pm != null)
                        {
                            luckTotal += 10 * pm.Perfection * pm.Perfection * scale;
                        }
                    }
                }
            }

            foreach (Party p in partyDamage.Keys)
            {
                double scale = (double)((int)partyDamage[p]) / damageTotal;
                luckTotal += GetLuckChanceForParty(p) * scale;
            }

            return(GetLuckChance((int)luckTotal));
        }