Ejemplo n.º 1
0
		public static void Grab_OnCommand( CommandEventArgs e )
		{

			//   Get LootData attachment 
			LootData lootoptions = new LootData();
			// does player already have a lootdata attachment?
			if (XmlAttach.FindAttachment(e.Mobile, typeof(LootData))==null)
			{
				XmlAttach.AttachTo(e.Mobile, lootoptions);
				// give them one free lootbag
				e.Mobile.AddToBackpack ( new LootBag());
			}
			else
			{
				// they have the attachment, just load their options
				lootoptions=(LootData)XmlAttach.FindAttachment(e.Mobile,typeof(LootData));
			}

		//   Check args to see if they want to change loot options
		// if we have args after  "grab"
			if ( e.Length != 0 )
			{
				// we need to set the loot bag
				if (e.GetString(0) != "options")
				{
					e.Mobile.SendMessage ("Typing the command [grab  by itself loots corpses of your victims. [grab options will allow you to decide what you want to loot.");
				}
				// show loot options gump
				else if (e.GetString(0) == "options")
				{
				   e.Mobile.SendGump( new LootGump(e.Mobile));
				}
			}

			//   Check loot legalities
			Mobile from = e.Mobile;

			if ( from.Alive == false )
			{
				from.PlaySound( 1069 ); //hey
				from.SendMessage( "You cannot do that while you are dead!" );
				return;
			}
			//else if ( 0 != CompetitiveGrabRadius && BlockingMobilesInRange( from, GrabRadius ))
			//{
			//	from.PlaySound( 1069 ); //hey
			//	from.SendMessage( "You are too close to another player to do that!" );
			//	return;
			//}

			ArrayList grounditems = new ArrayList();
			ArrayList lootitems = new ArrayList();
			ArrayList corpses = new ArrayList();
			Container lootBag = GetLootBag( from );

			// Gather lootable corpses and items into lists
			foreach ( Item item in from.GetItemsInRange( GrabRadius ))
			{
				if ( !from.InLOS( item ) || !item.IsAccessibleTo( from ) || !(item.Movable || item is Corpse) )
					continue;

				// add to corpse list if corpse
				if ( item is Corpse && CorpseIsLootable( from, item as Corpse, false ) ) // && item.Killer == from
				{
					Corpse deadbody = item as Corpse;
					if ( deadbody.Killer == null )
						corpses.Add( item );
					else if ( deadbody.Killer == from )
					{
						corpses.Add( item );
					}
					else if ( deadbody.Killer is BaseCreature && !( deadbody.Killer is PlayerMobile ) )
					{
						BaseCreature pet = deadbody.Killer as BaseCreature;
						if ( pet.ControlMaster == from || pet.ControlMaster == null )
						{
							corpses.Add( item );
						}
					}
					
				}
	
				// otherwise add to ground items list if loot options indicate
//ORIGINALY HERE-Trying to clear up yellow startup saying that item moble never is
//				else if ( !( item is PlayerMobile ) )
//				{
//					if(lootoptions.GetGroundItems)
//						if (!(item is Corpse))
//							grounditems.Add( item );
//				}
//END ORIGINALY HERE
				else
					if(lootoptions.GetGroundItems)
						if (!(item is Corpse))
							grounditems.Add( item );
			}

			// see if we really want any of the junk lying on the ground
			GetItems(lootoptions, from, grounditems);

			grounditems.Clear();

			// now inspect and loot appropriate items in corpses
			foreach ( Item corpse in corpses )
            {
                Corpse bod = corpse as Corpse;
                PlayerMobile pm = from as PlayerMobile;
                //pm.PlayerLevel += 1;

                /*                                          // Uncomment for eventual modifications (not to allow grabbing certain bodies)
                Mobile own = bod.Owner as Mobile;
                if( (own is Mobile1) || (own is Mobile2) )  // Change mobile names according to what you want to get
                */
                {

                    // if we are looting hides/scales/meat then carve the corpse
                    if (lootoptions.GetHides && !(bod.Owner is PlayerMobile))
                        bod.Carve(from, null);

                    //rummage through the corpse for good stuff
                    foreach (Item item in bod.Items)
                        lootitems.Add(item);

                    //  now see if we really want any of this junk
                    GetItems(lootoptions, from, lootitems);

                    // alrighty then, we have all the items we want, now award gold for this corpse, delete it and increment the body count
//                    AwardGold(from, bod, lootBag); //REMED OUT SO THAT REGULAR MOBS WONT GIVE GOLD WHEN USE GRAB COMMAND
                    bod.Delete();

                    // empty lootitems arraylist
                    lootitems.Clear();
                }

            }
		}
Ejemplo n.º 2
0
		private static void GetItems(LootData lootoptions, Mobile from, ArrayList loothopefuls)
		{
			ArrayList itemstoloot = new ArrayList();

			Container lootBag = GetLootBag( from );

			foreach(Item item in loothopefuls)
			{

                if (item is Server.Items.Gold)
                    itemstoloot.Add(item);
                /*else if( !(item is xxx || item is yyy) ) // Uncomment for eventual customizations (not to allow grabbing certain items)
                     itemstoloot.Add(item);
                */
                else if (lootoptions.GetAll)
                    itemstoloot.Add(item);
                else
                {
                    if ((IsArtifact(item)) && (lootoptions.GetArtifacts))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseWeapon) && (lootoptions.GetWeapons))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseArmor) && (lootoptions.GetArmor))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseClothing || item is Server.Items.BaseShoes) && (lootoptions.GetClothing))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseJewel) && (lootoptions.GetJewelry))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.Diamond || item is Server.Items.Amber || item is Server.Items.Amethyst || item is Server.Items.Citrine || item is Server.Items.Emerald || item is Server.Items.Ruby || item is Server.Items.Sapphire || item is Server.Items.StarSapphire || item is Server.Items.Tourmaline) && (lootoptions.GetGems))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.Arrow || item is Server.Items.Bolt) && (lootoptions.GetArrows))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.CookableFood || item is Server.Items.Food) && (lootoptions.GetFood))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseHides) && (lootoptions.GetHides))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseScales) && (lootoptions.GetScales))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.Board || item is Server.Items.Log || item is Server.Items.Shaft) && (lootoptions.GetWood))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseIngot || item is Server.Items.BaseOre) && (lootoptions.GetOres))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BaseReagent) && (lootoptions.GetReagents))
                        itemstoloot.Add(item);
                    else if ((item is Server.Items.BasePotion) && (lootoptions.GetPotions))
                        itemstoloot.Add(item);
                    else if (lootoptions.GetOther) 
                        itemstoloot.Add(item);
                }

				
				// if we have any items
				if(itemstoloot != null)
				{
					// Drop all of the items into player's bag/pack
					foreach ( Item itemx in itemstoloot )
					{
						if ( !lootBag.TryDropItem( from, itemx, false ) )
							lootBag.DropItem( itemx );
						from.PlaySound( 0x2E6 ); // drop gold sound
					}
					itemstoloot.Clear();
				}
			}
		}