Esempio n. 1
0
        public override void OnDeath(Container c)
        {
            base.OnDeath(c);

            //Player Swarm Followers
            if (TimesTamed > 0)
            {
                return;
            }

            int scoreValue = 1;

            int intestines = 0;
            int bones      = 0;

            double intestineChance     = 0;
            double normalItemChance    = 0;
            double magicItemChance     = 0;
            double survivalStoneChance = 0;
            double upgradeTokenChance  = 0;

            #region Upgrade Chances

            switch (DifficultyValue)
            {
            case 1:
                scoreValue = 1;
                bones      = 1;
                intestines = 1;

                intestineChance = .20;

                normalItemChance    = .1;
                magicItemChance     = .02;
                survivalStoneChance = .04;
                upgradeTokenChance  = .02;
                break;

            case 2:
                scoreValue = 1;
                bones      = 1;
                intestines = 1;

                intestineChance = .20;

                normalItemChance    = 0.125;
                magicItemChance     = 0.025;
                survivalStoneChance = .05;
                upgradeTokenChance  = .025;
                break;

            case 3:
                scoreValue = 2;
                bones      = 2;
                intestines = 1;

                intestineChance = .30;

                normalItemChance    = .15;
                magicItemChance     = .03;
                survivalStoneChance = .06;
                upgradeTokenChance  = .03;
                break;

            case 4:
                scoreValue = 2;
                bones      = 2;
                intestines = 1;

                intestineChance = .4;

                normalItemChance    = .2;
                magicItemChance     = .04;
                survivalStoneChance = .08;
                upgradeTokenChance  = .04;
                break;

            case 5:
                scoreValue = 3;
                bones      = 3;
                intestines = 1;

                intestineChance = .5;

                normalItemChance    = .25;
                magicItemChance     = .05;
                survivalStoneChance = .1;
                upgradeTokenChance  = .05;
                break;

            case 6:
                scoreValue = 3;
                bones      = 3;
                intestines = 1;

                intestineChance = .6;

                normalItemChance    = .3;
                magicItemChance     = .06;
                survivalStoneChance = .12;
                upgradeTokenChance  = .06;
                break;

            case 7:
                scoreValue = 4;
                bones      = 4;
                intestines = 1;

                intestineChance = .7;

                normalItemChance    = .4;
                magicItemChance     = .08;
                survivalStoneChance = .15;
                upgradeTokenChance  = 0.075;
                break;

            case 8:
                scoreValue = 5;
                bones      = 5;
                intestines = 1;

                intestineChance = .8;

                normalItemChance    = .5;
                magicItemChance     = .1;
                survivalStoneChance = .2;
                upgradeTokenChance  = .1;
                break;

            case 9:
                scoreValue = 6;
                bones      = 6;
                intestines = 1;

                intestineChance = .9;

                normalItemChance    = 1;
                magicItemChance     = .2;
                survivalStoneChance = .25;
                upgradeTokenChance  = .125;
                break;

            case 10:
                scoreValue = 40;
                bones      = 30;
                intestines = 1;

                intestineChance = 1;

                normalItemChance    = 2;
                magicItemChance     = 2;
                survivalStoneChance = 2;
                upgradeTokenChance  = 2;
                break;

            case 11:
                scoreValue = 80;
                bones      = 50;
                intestines = 1;

                intestineChance = 1;

                normalItemChance    = 2;
                magicItemChance     = 2;
                survivalStoneChance = 2;
                upgradeTokenChance  = 2;
                break;
            }

            #endregion

            Dictionary <PlayerMobile, int> m_PlayerDamageDealt = new Dictionary <PlayerMobile, int>();
            List <PlayerMobile>            m_PotentialPlayers  = new List <PlayerMobile>();

            bool playerThresholdReached = false;

            int totalDamage       = 0;
            int totalPlayerDamage = 0;

            //Determine Total Damaged Inflicted and Per Player
            foreach (DamageEntry entry in DamageEntries)
            {
                if (!entry.HasExpired)
                {
                    Mobile damager = entry.Damager;

                    if (damager == null)
                    {
                        continue;
                    }

                    totalDamage += entry.DamageGiven;

                    PlayerMobile playerDamager = damager as PlayerMobile;

                    if (playerDamager != null)
                    {
                        totalPlayerDamage += entry.DamageGiven;
                    }

                    BaseCreature creatureDamager = damager as BaseCreature;

                    if (creatureDamager != null)
                    {
                        if (creatureDamager.ControlMaster is PlayerMobile)
                        {
                            totalPlayerDamage += entry.DamageGiven;
                        }
                    }
                }
            }

            foreach (DamageEntry entry in DamageEntries)
            {
                if (!entry.HasExpired && entry.DamageGiven > 0)
                {
                    PlayerMobile player = null;

                    Mobile damager = entry.Damager;

                    if (damager == null)
                    {
                        continue;
                    }
                    if (damager.Deleted)
                    {
                        continue;
                    }

                    PlayerMobile pm_Damager = damager as PlayerMobile;
                    BaseCreature bc_Damager = damager as BaseCreature;

                    if (pm_Damager != null)
                    {
                        player = pm_Damager;
                    }

                    if (bc_Damager != null)
                    {
                        if (bc_Damager.Controlled && bc_Damager.ControlMaster is PlayerMobile)
                        {
                            if (!bc_Damager.ControlMaster.Deleted)
                            {
                                player = bc_Damager.ControlMaster as PlayerMobile;
                            }
                        }
                    }

                    if (player != null)
                    {
                        if (m_PlayerDamageDealt.ContainsKey(player))
                        {
                            m_PlayerDamageDealt[player] += entry.DamageGiven;
                        }

                        else
                        {
                            m_PlayerDamageDealt.Add(player, entry.DamageGiven);
                        }
                    }
                }
            }

            Queue m_Queue = new Queue();

            foreach (KeyValuePair <PlayerMobile, int> playerEntry in m_PlayerDamageDealt)
            {
                PlayerMobile player = playerEntry.Key;
                int          damage = playerEntry.Value;

                if (player.IsUOACZHuman)
                {
                    double damagePercentOfTotal = (double)damage / totalDamage;

                    if (damage >= 100 || damagePercentOfTotal > .10)
                    {
                        UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);
                        player.m_UOACZAccountEntry.UndeadKilledAsHuman++;

                        UOACZSystem.ChangeStat(player, UOACZSystem.UOACZStatType.HumanScore, scoreValue, true);

                        m_PotentialPlayers.Add(player);
                    }
                }
            }

            if (totalDamage == 0)
            {
                totalDamage = 1;
            }

            double playerDamageRatio = (double)totalPlayerDamage / (double)totalDamage;
            double npcHelpScalar     = playerDamageRatio;

            intestineChance     *= UOACZPersistance.HumanBalanceScalar;
            normalItemChance    *= UOACZPersistance.HumanBalanceScalar;
            magicItemChance     *= UOACZPersistance.HumanBalanceScalar;
            survivalStoneChance *= UOACZPersistance.HumanBalanceScalar;
            upgradeTokenChance  *= UOACZPersistance.HumanBalanceScalar;

            if (playerDamageRatio >= .25)
            {
                if (bones > 0)
                {
                    c.AddItem(new Bone(bones));
                }

                if (Utility.RandomDouble() <= (intestineChance * npcHelpScalar))
                {
                    for (int a = 0; a < intestines; a++)
                    {
                        c.AddItem(new UOACZIntestines());
                    }
                }
            }

            if (Utility.RandomDouble() <= (normalItemChance * npcHelpScalar))
            {
                if (Utility.RandomDouble() <= .4)
                {
                    BaseWeapon weapon = UOACZSystem.GetRandomCrudeBoneWeapon();

                    if (weapon != null)
                    {
                        c.AddItem(weapon);
                    }
                }

                else
                {
                    BaseArmor armor = UOACZSystem.GetRandomCrudeBoneArmor();

                    if (armor != null)
                    {
                        c.AddItem(armor);
                    }
                }
            }

            if (Utility.RandomDouble() <= (magicItemChance * npcHelpScalar))
            {
                switch (Utility.RandomMinMax(1, 2))
                {
                case 1:
                    BaseWeapon weapon = Loot.RandomWeapon();

                    weapon.AccuracyLevel   = (WeaponAccuracyLevel)Utility.RandomMinMax(1, 2);
                    weapon.DamageLevel     = (WeaponDamageLevel)Utility.RandomMinMax(1, 2);
                    weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.RandomMinMax(1, 2);

                    weapon.Identified = true;

                    c.AddItem(weapon);
                    break;

                case 2:
                    BaseArmor armor = Loot.RandomArmorOrShield();

                    armor.ProtectionLevel = (ArmorProtectionLevel)Utility.RandomMinMax(1, 2);
                    armor.DurabilityLevel = (ArmorDurabilityLevel)Utility.RandomMinMax(1, 2);

                    armor.Identified = true;

                    c.AddItem(armor);
                    break;
                }
            }

            bool dropSurvivalStone = false;
            bool dropUpgradeToken  = false;

            if (m_PotentialPlayers.Count >= 3)
            {
                survivalStoneChance *= .75;
                upgradeTokenChance  *= .75;
            }

            if (m_PotentialPlayers.Count >= 5)
            {
                survivalStoneChance *= .75;
                upgradeTokenChance  *= .75;
            }

            if (Utility.RandomDouble() <= (survivalStoneChance * npcHelpScalar))
            {
                dropSurvivalStone = true;
            }

            if (Utility.RandomDouble() <= (upgradeTokenChance * npcHelpScalar))
            {
                dropUpgradeToken = true;
            }

            foreach (PlayerMobile player in m_PotentialPlayers)
            {
                if (dropSurvivalStone)
                {
                    c.AddItem(new UOACZSurvivalStone(player));
                }

                if (dropUpgradeToken)
                {
                    c.AddItem(new UOACZHumanUpgradeToken(player));
                }
            }
        }