Inheritance: Server.Items.Item
        public static void CreateReward(EventRewardInfo info, Mobile m)
        {
            if (m == null)
                return;

            Item item = null;
            switch (info.IncrID)
            {
                case 0: item = new MagicSewingKit(1); break;
                case 1:
                    string str = "PottedCactus";
                    int randint = Utility.Random(6);
                    if (randint > 0)
                        str = str + randint.ToString();

                    Type type = ScriptCompiler.FindTypeByName(str);
                    item = (Item)Activator.CreateInstance(type);
                    item.Weight = 100;
                    break;
                case 2:
                    if (Utility.RandomBool())
                        item = new PottedTree();
                    else
                        item = new PottedTree1();
                    break;
                case 3:
                    switch (Utility.Random(3))
                    {
                        case 0: item = new PottedPlant(); break;
                        case 1: item = new PottedPlant1(); break;
                        case 2: item = new PottedPlant2(); break;
                    }
                    break;
                case 4: item = new SpecialHairDye(); break;
                case 5: item = new SpecialBeardDye(); break;
                case 6: item = new TempHorseEthereal(50);
                        item.Hue = Utility.Random(795, 7);
                        break;
                case 7: item = new FireworksWand(99); break;
                case 8: item = new LayeredSashDeed(); break;
                case 9: item = new SkillBall(1); break;
                case 10: item = new SkillBall(5); break;
                case 11: item = new SkillBall(10); break;
                case 12: item = new SkillBall(25); break;
                case 13: item = new SkillBall(50); break;
                case 14: item = new PersonalisationDeed(); break;
                case 15: item = new CrystalPedestalAddonDeed(); break;
                case 16: item = new FountainStoneAddonDeed(); break;
                case 17: item = new FountainSandstoneAddonDeed(); break;
                case 18: item = new SquirrelStatueEastDeed(); break;
                case 19: item = new SquirrelStatueSouthDeed(); break;
                case 20: item = new ArcanistStatueEastDeed(); break;
                case 21: item = new ArcanistStatueSouthDeed(); break;
                case 22: item = new WarriorStatueEastDeed(); break;
                case 23: item = new WarriorStatueSouthDeed(); break;
                case 24: item = new TempRobe(31);
                        ((BaseClothing)item).Attributes.RegenHits = 3;
                        break;
                case 25: item = new TempCloak(31);
                        ((BaseClothing)item).Attributes.RegenHits = 3;
                        break;
                case 26: item = new CampfireDeed(); break;
                case 27: item = new FireDeed(); break;
                case 28: item = new SoulstoneFragment();
                        ((SoulstoneFragment)item).Account = m.Account.Username;
                        break;
                case 29: item = new NameChangeDeed(); break;
                case 30: item = new SexChangeDeed(); break;
                case 31: item = new KillResetDeedAOS(); break;
                case 32: item = new PetBondingDeed(); break;
                case 33: item = new WarHorseBondingDeed(); break;
                case 34: item = new AntiBlessDeed(); break;
                case 35: item = new WhisperingRose(m.Name); break;
                case 36: item = new WeddingDeed(); break;
                case 37: item = new KillBook();
                        ((KillBook)item).BookOwner = m;
                        break;
            }

            if (item != null)
            {
                m.AddToBackpack(item);
                m.SendMessage("The reward item has been placed into your backpack, have fun!");
            }
            else
            {
                m.SendMessage("That item is not available. Please report the bug at the site that will open in your browser.");
                m.LaunchBrowser( "http://bug.casiopia.net/" );
                m.AddToBackpack( new CopperBar(info.Price) );
            }
        }
		public GardenDonationBox()
		{
			Weight = 1.0;
			Hue = 1154;
			Item item = null;
			Name = "garden decoration chest";

			PlaceItemIn( 16, 51, (item = new FountainOfLife()) );
			PlaceItemIn( 58, 70, (item = new Beehive()) );
                        PlaceItemIn( 62, 44, (item = new PloughAddonDeed()) );

			PlaceItemIn( 44, 57, (new RareVase()) );
			PlaceItemIn( 89, 53, (new AncientFruitBowl()) );
			PlaceItemIn( 90, 81, (new LargeShell()) );
                        PlaceItemIn( 116, 33, (new WhisperingRoseDeed()) );
                        PlaceItemIn( 116, 64, (new WhisperingRoseDeed()) );

                        BaseContainer cont;
			PlaceItemIn( 131, 121, (cont = new Bag()) );
			cont.Hue = 2413;

			cont.PlaceItemIn( 131, 75, (item = new FlaxFlower()) );
                        cont.PlaceItemIn( 131, 75, (item = new FlaxFlower()) );
                        cont.PlaceItemIn( 131, 75, (item = new FlaxFlower()) );
                        cont.PlaceItemIn( 131, 75, (item = new FlaxFlower()) );
                        cont.PlaceItemIn( 131, 75, (item = new FlaxFlower()) );
                        cont.PlaceItemIn( 131, 75, (item = new FlaxFlower()) );

			cont.PlaceItemIn( 140, 51, (item = new FlaxBundle()) );
                        cont.PlaceItemIn( 140, 51, (item = new FlaxBundle()) );
                        cont.PlaceItemIn( 140, 51, (item = new FlaxBundle()) );
                        cont.PlaceItemIn( 140, 51, (item = new FlaxBundle()) );

			cont.PlaceItemIn( 58, 83, (item = new PottedTree1()) );
                        cont.PlaceItemIn( 58, 83, (item = new PottedTree1()) );
			cont.PlaceItemIn( 73, 83, (item = new PottedPlant()) );
                        cont.PlaceItemIn( 73, 83, (item = new PottedPlant()) );
                        cont.PlaceItemIn( 29, 68, (item = new PottedTree()) );
                        cont.PlaceItemIn( 29, 68, (item = new PottedTree()) );
                        cont.PlaceItemIn( 73, 83, (item = new PottedPlant1()) );
                        cont.PlaceItemIn( 73, 83, (item = new PottedPlant1()) );

			cont.PlaceItemIn( 47, 53, (item = new LillyPad1()) );
                        cont.PlaceItemIn( 47, 53, (item = new LillyPad1()) );
                        cont.PlaceItemIn( 47, 53, (item = new LillyPad1()) );
                        cont.PlaceItemIn( 47, 53, (item = new LillyPad1()) );
                        cont.PlaceItemIn( 47, 53, (item = new LillyPad1()) );
                        cont.PlaceItemIn( 47, 53, (item = new LillyPad1()) );

                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );
                        cont.PlaceItemIn( 29, 34, (item = new RoseVine()) );

		}
        public GardenDonationBox()
        {
            Weight = 1.0;
            Hue    = 1154;
            Item item = null;

            Name = "garden decoration chest";

            PlaceItemIn(16, 51, (item = new FountainOfLife()));
            PlaceItemIn(58, 70, (item = new Beehive()));
            PlaceItemIn(62, 44, (item = new PloughAddonDeed()));

            PlaceItemIn(44, 57, (new RareVase()));
            PlaceItemIn(89, 53, (new AncientFruitBowl()));
            PlaceItemIn(90, 81, (new LargeShell()));
            PlaceItemIn(116, 33, (new WhisperingRoseDeed()));
            PlaceItemIn(116, 64, (new WhisperingRoseDeed()));

            BaseContainer cont;

            PlaceItemIn(131, 121, (cont = new Bag()));
            cont.Hue = 2413;

            cont.PlaceItemIn(131, 75, (item = new FlaxFlower()));
            cont.PlaceItemIn(131, 75, (item = new FlaxFlower()));
            cont.PlaceItemIn(131, 75, (item = new FlaxFlower()));
            cont.PlaceItemIn(131, 75, (item = new FlaxFlower()));
            cont.PlaceItemIn(131, 75, (item = new FlaxFlower()));
            cont.PlaceItemIn(131, 75, (item = new FlaxFlower()));

            cont.PlaceItemIn(140, 51, (item = new FlaxBundle()));
            cont.PlaceItemIn(140, 51, (item = new FlaxBundle()));
            cont.PlaceItemIn(140, 51, (item = new FlaxBundle()));
            cont.PlaceItemIn(140, 51, (item = new FlaxBundle()));

            cont.PlaceItemIn(58, 83, (item = new PottedTree1()));
            cont.PlaceItemIn(58, 83, (item = new PottedTree1()));
            cont.PlaceItemIn(73, 83, (item = new PottedPlant()));
            cont.PlaceItemIn(73, 83, (item = new PottedPlant()));
            cont.PlaceItemIn(29, 68, (item = new PottedTree()));
            cont.PlaceItemIn(29, 68, (item = new PottedTree()));
            cont.PlaceItemIn(73, 83, (item = new PottedPlant1()));
            cont.PlaceItemIn(73, 83, (item = new PottedPlant1()));

            cont.PlaceItemIn(47, 53, (item = new LillyPad1()));
            cont.PlaceItemIn(47, 53, (item = new LillyPad1()));
            cont.PlaceItemIn(47, 53, (item = new LillyPad1()));
            cont.PlaceItemIn(47, 53, (item = new LillyPad1()));
            cont.PlaceItemIn(47, 53, (item = new LillyPad1()));
            cont.PlaceItemIn(47, 53, (item = new LillyPad1()));

            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
            cont.PlaceItemIn(29, 34, (item = new RoseVine()));
        }
Exemplo n.º 4
0
        private void GiveMagicItems()
        {
            ArrayList toGive = new ArrayList();

            LogHelper Logger = new LogHelper("HarrowerLoot.log", false);


            ArrayList allNonExpiredPMDamageEntries = new ArrayList();
            //New Looting method (Pix: 4/8/06)
            for (int i = 0; i < DamageEntries.Count; i++)
            {
                DamageEntry de = DamageEntries[i] as DamageEntry;
                if (de != null)
                {
                    Logger.Log(LogType.Text, string.Format("DE[{0}]: {1} ({2})", i, de.Damager, de.Damager != null ? de.Damager.Name : ""));
                    if (de.HasExpired)
                    {
                        Logger.Log(LogType.Text, string.Format("DE[{0}]: Expired", i));
                    }
                    else
                    {
                        if (de.Damager != null && !de.Damager.Deleted)
                        {
                            if (de.Damager is BaseCreature)
                            {
                                Logger.Log(LogType.Text, string.Format("DE[{0}]: BaseCreature", i));
                                BaseCreature bc = (BaseCreature)de.Damager;
                                if (bc.ControlMaster != null && !bc.ControlMaster.Deleted)
                                {
                                    //de.Damager = bc.ControlMaster;
                                    DamageEntry cmde = new DamageEntry(bc.ControlMaster);
                                    cmde.DamageGiven = de.DamageGiven;
                                    de = cmde;
                                    Logger.Log(LogType.Text, string.Format("DE[{0}]: New Damager: {1}", i, de.Damager.Name));
                                }
                            }

                            if (de.Damager is PlayerMobile)
                            {
                                Logger.Log(LogType.Text, string.Format("DE[{0}]: PlayerMobile", i));

                                if (de.Damager.Alive)
                                {
                                    Logger.Log(LogType.Text, string.Format("DE[{0}]: PM Alive", i));

                                    bool bFound = false;
                                    for (int j = 0; j < allNonExpiredPMDamageEntries.Count; j++)
                                    {
                                        DamageEntry de2 = (DamageEntry)allNonExpiredPMDamageEntries[j];
                                        if (de2.Damager == de.Damager)
                                        {
                                            Logger.Log(LogType.Text, string.Format("DE[{0}]: PM Found, adding damage", i));

                                            de2.DamageGiven += de.DamageGiven;
                                            bFound = true;
                                            break;
                                        }
                                    }

                                    if (!bFound)
                                    {
                                        Logger.Log(LogType.Text, string.Format("DE[{0}]: PM not found, adding", i));
                                        allNonExpiredPMDamageEntries.Add(de);
                                    }
                                }
                            }

                        }
                    }
                }
            }

            //Remove any PMs that are over 100 tiles away
            ArrayList toRemove = new ArrayList();
            for (int i = 0; i < allNonExpiredPMDamageEntries.Count; i++)
            {
                DamageEntry de = (DamageEntry)allNonExpiredPMDamageEntries[i];
                if (de.Damager.GetDistanceToSqrt(this.Location) > 100)
                {
                    Logger.Log(LogType.Text, string.Format("Removing {0} for being too far away at death", de.Damager.Name));
                    toRemove.Add(allNonExpiredPMDamageEntries[i]);
                }
            }
            for (int i = 0; i < toRemove.Count; i++)
            {
                allNonExpiredPMDamageEntries.Remove(toRemove[i]);
            }

            int topDamage = 0;
            int minDamage = 0;
            for (int i = 0; i < allNonExpiredPMDamageEntries.Count; i++)
            {
                DamageEntry de = (DamageEntry)allNonExpiredPMDamageEntries[i];
                if (de.DamageGiven > topDamage) topDamage = de.DamageGiven;

                Logger.Log(LogType.Text, string.Format("Non-Expired[{0}]: {1} (damage: {2})", i, de.Damager.Name, de.DamageGiven));

            }

            //Now filter on 'enough' damage
            if (HitsMax >= 3000) minDamage = topDamage / 16;
            else if (HitsMax >= 1000) minDamage = topDamage / 8;
            else if (HitsMax >= 200) minDamage = topDamage / 4;
            else minDamage = topDamage / 2;

            Logger.Log(LogType.Text, string.Format("HitsMax: {0}, TopDamage: {1}, MinDamage: {2}", HitsMax, topDamage, minDamage));


            for (int i = 0; i < allNonExpiredPMDamageEntries.Count; i++)
            {
                DamageEntry de = (DamageEntry)allNonExpiredPMDamageEntries[i];
                if (de.DamageGiven >= minDamage)
                {
                    toGive.Add(de.Damager);
                }
            }


            if (toGive.Count == 0)
                return;

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

            Logger.Log(LogType.Text, ""); // new line
            Logger.Log(LogType.Text, "Randomized list of players:");
            for (int i = 0; i < toGive.Count; ++i)
            {
                Mobile mob = toGive[i] as Mobile;
                Logger.Log(LogType.Mobile, mob, "alive:" + mob.Alive.ToString());
            }

            Logger.Log(LogType.Text, ""); // new line
            Logger.Log(LogType.Text, "Begin loot distribution: Who/What:");

            // Loop goes until we've generated MaxGifts items.
            for (int i = 0; i < MaxGifts; ++i)
            {
                Item reward = null;
                Mobile m = (Mobile)toGive[i % toGive.Count];

                switch (Utility.Random(10))
                {
                    case 0:			// Power/Vanq Weapon
                    case 1:
                    case 2:	// 3 in 10 chance	
                        {	// 33% chance at best
                            reward = CreateWeapon((0.32 >= Utility.RandomDouble()) ? 5 : 4);
                            break;
                        }
                    case 3:			// Fort/Invul Armor
                    case 4:
                    case 5:	// 3 in 10 chance 
                        {	// 33% chance at best
                            reward = CreateArmor((0.32 >= Utility.RandomDouble()) ? 5 : 4);
                            break;
                        }
                    case 6:		// hair/beard dye
                        {		// 1 in 10 chance
                            if (Utility.RandomBool())
                                reward = new SpecialHairDye();
                            else
                                reward = new SpecialBeardDye();
                            break;
                        }
                    case 7:		// special cloth
                        {		// 1 in 10 chance
                            reward = new UncutCloth(50);
                            if (Utility.RandomBool())
                                // best ore hues (vet rewards) + really dark 'evil cloth'
                                reward.Hue = Utility.RandomList(2213, 2219, 2207, 2425, 1109);
                            else
                                reward.Hue = 0x01;	// black cloth
                            break;
                        }

                    case 8:		// potted plant
                        {		// 1 in 10 chance
                            switch (Utility.Random(11))
                            {
                                default:	// should never happen
                                case 0: reward = new PottedCactus(); break;
                                case 1: reward = new PottedCactus1(); break;
                                case 2: reward = new PottedCactus2(); break;
                                case 3: reward = new PottedCactus3(); break;
                                case 4: reward = new PottedCactus4(); break;
                                case 5: reward = new PottedCactus5(); break;
                                case 6: reward = new PottedPlant(); break;
                                case 7: reward = new PottedPlant1(); break;
                                case 8: reward = new PottedPlant2(); break;
                                case 9: reward = new PottedTree(); break;
                                case 10: reward = new PottedTree1(); break;
                            }
                            break;
                        }

                    default:	// Should never happen
                    /* fall through*/

                    case 9:		// Magic Item Drop
                        {			// 1 in 10 chance
                            reward = Loot.RandomClothingOrJewelry();
                            if (reward != null)
                            {
                                int minLevel = 3;
                                int maxLevel = 3;
                                if (reward is BaseClothing)
                                    ((BaseClothing)reward).SetRandomMagicEffect(minLevel, maxLevel);
                                else if (reward is BaseJewel)
                                    ((BaseJewel)reward).SetRandomMagicEffect(minLevel, maxLevel);
                            }
                            break;
                        }
                }

                if (reward != null)
                {
                    // Drop the new weapon into their backpack and send them a message.
                    m.SendMessage("You have received a special item!");
                    m.AddToBackpack(reward);

                    Logger.Log(LogType.Mobile, m, "alive:" + m.Alive.ToString());
                    Logger.Log(LogType.Item, reward, string.Format("Hue:{0}:Rare:{1}",
                        reward.Hue,
                        (reward is BaseWeapon || reward is BaseArmor || reward is BaseClothing || reward is BaseJewel) ? "False" : "True"));
                }
            }

            // done logging
            Logger.Finish();
        }