/// <summary>
		/// This method is called to drop loot after this mob dies
		/// </summary>
		/// <param name="killer">The killer</param>
		public virtual void DropLoot(GameObject killer)
		{
			// TODO: mobs drop "a small chest" sometimes
			ArrayList droplist = new ArrayList();
			ArrayList autolootlist = new ArrayList();
			ArrayList aplayer = new ArrayList();

			lock (m_xpGainers.SyncRoot)
			{
				if (m_xpGainers.Keys.Count == 0) return;

				ItemTemplate[] lootTemplates = LootMgr.GetLoot(this, killer);

				foreach (ItemTemplate lootTemplate in lootTemplates)
				{
					if(lootTemplate==null) continue;
					GameStaticItem loot;
					if (GameMoney.IsItemMoney(lootTemplate.Name))
					{
						long value = lootTemplate.Price;
						//GamePlayer killerPlayer = killer as GamePlayer;

						//[StephenxPimentel] - Zone Bonus XP Support
						if (ServerProperties.Properties.ENABLE_ZONE_BONUSES)
						{
							GamePlayer killerPlayer = killer as GamePlayer;
							if (killer is GameNPC)
							{
								if (killer is GameNPC && ((killer as GameNPC).Brain is IControlledBrain))
									killerPlayer = ((killer as GameNPC).Brain as IControlledBrain).GetPlayerOwner();
								else return;
							}

							int zoneBonus = (((int)value * ZoneBonus.GetCoinBonus(killerPlayer) / 100));
							if (zoneBonus > 0)
							{
								long amount = (long)(zoneBonus * ServerProperties.Properties.MONEY_DROP);
								killerPlayer.AddMoney(amount,
								                      ZoneBonus.GetBonusMessage(killerPlayer, (int)(zoneBonus * ServerProperties.Properties.MONEY_DROP), ZoneBonus.eZoneBonusType.COIN),
								                      eChatType.CT_Important, eChatLoc.CL_SystemWindow);
								InventoryLogging.LogInventoryAction(this, killerPlayer, eInventoryActionType.Loot, amount);
							}
						}

						if (Keeps.KeepBonusMgr.RealmHasBonus(DOL.GS.Keeps.eKeepBonusType.Coin_Drop_5, (eRealm)killer.Realm))
							value += (value / 100) * 5;
						else if (Keeps.KeepBonusMgr.RealmHasBonus(DOL.GS.Keeps.eKeepBonusType.Coin_Drop_3, (eRealm)killer.Realm))
							value += (value / 100) * 3;

						//this will need to be changed when the ML for increasing money is added
						if (value != lootTemplate.Price)
						{
							GamePlayer killerPlayer = killer as GamePlayer;
							if (killerPlayer != null)
								killerPlayer.Out.SendMessage(LanguageMgr.GetTranslation(killerPlayer.Client, "GameNPC.DropLoot.AdditionalMoney", Money.GetString(value - lootTemplate.Price)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
						}

						//Mythical Coin bonus property (Can be used for any equipped item, bonus 235)
						if (killer is GamePlayer)
						{
							GamePlayer killerPlayer = killer as GamePlayer;
							if (killerPlayer.GetModified(eProperty.MythicalCoin) > 0)
							{
								value += (value * killerPlayer.GetModified(eProperty.MythicalCoin)) / 100;
								killerPlayer.Out.SendMessage(LanguageMgr.GetTranslation(killerPlayer.Client,
								                                                        "GameNPC.DropLoot.ItemAdditionalMoney", Money.GetString(value - lootTemplate.Price)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
							}
						}
						
						loot = new GameMoney(value, this);
						loot.Name = lootTemplate.Name;
						loot.Model = (ushort)lootTemplate.Model;
					}
					else if (lootTemplate.Name.StartsWith("scroll|"))
					{
						String[] scrollData = lootTemplate.Name.Split('|');
						String artifactID = scrollData[1];
						int pageNumber = UInt16.Parse(scrollData[2]);
						loot = ArtifactMgr.CreateScroll(artifactID, pageNumber);
						loot.X = X;
						loot.Y = Y;
						loot.Z = Z;
						loot.Heading = Heading;
						loot.CurrentRegion = CurrentRegion;
						(loot as WorldInventoryItem).Item.IsCrafted = false;
						(loot as WorldInventoryItem).Item.Creator = Name;
					}
					else
					{
						InventoryItem invitem;
						
						if (lootTemplate is ItemUnique)
						{
							GameServer.Database.AddObject(lootTemplate);
							invitem = GameInventoryItem.Create(lootTemplate as ItemUnique);
						}
						else
							invitem = GameInventoryItem.Create(lootTemplate);
						
						loot = new WorldInventoryItem(invitem);
						loot.X = X;
						loot.Y = Y;
						loot.Z = Z;
						loot.Heading = Heading;
						loot.CurrentRegion = CurrentRegion;
						(loot as WorldInventoryItem).Item.IsCrafted = false;
						(loot as WorldInventoryItem).Item.Creator = Name;

						// This may seem like an odd place for this code, but loot-generating code further up the line
						// is dealing strictly with ItemTemplate objects, while you need the InventoryItem in order
						// to be able to set the Count property.
						// Converts single drops of loot with PackSize > 1 (and MaxCount >= PackSize) to stacks of Count = PackSize
						if ( ( (WorldInventoryItem)loot ).Item.PackSize > 1 && ( (WorldInventoryItem)loot ).Item.MaxCount >= ( (WorldInventoryItem)loot ).Item.PackSize )
						{
							( (WorldInventoryItem)loot ).Item.Count = ( (WorldInventoryItem)loot ).Item.PackSize;
						}
					}

					GamePlayer playerAttacker = null;
					foreach (GameObject gainer in m_xpGainers.Keys)
					{
						if (gainer is GamePlayer)
						{
							playerAttacker = gainer as GamePlayer;
							if (loot.Realm == 0)
								loot.Realm = ((GamePlayer)gainer).Realm;
						}
						loot.AddOwner(gainer);
						if (gainer is GameNPC)
						{
							IControlledBrain brain = ((GameNPC)gainer).Brain as IControlledBrain;
							if (brain != null)
							{
								playerAttacker = brain.GetPlayerOwner();
								loot.AddOwner(brain.GetPlayerOwner());
							}
						}
					}
					if (playerAttacker == null) return; // no loot if mob kills another mob

					
					droplist.Add(loot.GetName(1, false));
					loot.AddToWorld();

					foreach (GameObject gainer in m_xpGainers.Keys)
					{
						if (gainer is GamePlayer)
						{
							GamePlayer player = gainer as GamePlayer;
							if (player.Autoloot && loot.IsWithinRadius(player, 1500)) // should be large enough for most casters to autoloot
							{
								if (player.Group == null || (player.Group != null && player == player.Group.Leader))
									aplayer.Add(player);
								autolootlist.Add(loot);
							}
						}
					}
				}
			}

			BroadcastLoot(droplist);

			if (autolootlist.Count > 0)
			{
				foreach (GameObject obj in autolootlist)
				{
					foreach (GamePlayer player in aplayer)
					{
						player.PickupObject(obj, true);
						break;
					}
				}
			}
		}
Beispiel #2
0
		/// <summary>
		/// Receive an item from a living
		/// </summary>
		/// <param name="source"></param>
		/// <param name="item"></param>
		/// <returns>true if player took the item</returns>
		public virtual bool ReceiveItem(GameLiving source, WorldInventoryItem item)
		{
			return ReceiveItem(source, item.Item);
		}
Beispiel #3
0
		/// <summary>
		/// Creates a new GameInventoryItem based on an ItemTemplate. Will disappear
		/// after 3 minutes after being added to the world.
		/// </summary>
		/// <param name="template">The template to load and create an item from.</param>
		/// <returns>Item reference or null.</returns>
		public static WorldInventoryItem CreateFromTemplate(ItemTemplate template)
		{
			if (template == null)
				return null;

			WorldInventoryItem invItem = new WorldInventoryItem();

			invItem.m_item = GameInventoryItem.Create<ItemTemplate>(template);
			
			invItem.m_item.SlotPosition = 0;
			invItem.m_item.OwnerID = null;

			invItem.Level = (byte)template.Level;
			invItem.Model = (ushort)template.Model;
			invItem.Emblem = template.Emblem;
			invItem.Name = template.Name;

			return invItem;
		}
Beispiel #4
0
		public static WorldInventoryItem CreateUniqueFromTemplate(ItemTemplate template)
		{
			if (template == null)
				return null;

			WorldInventoryItem invItem = new WorldInventoryItem();
			ItemUnique item = new ItemUnique(template);
			GameServer.Database.AddObject(item);

			invItem.m_item = GameInventoryItem.Create<ItemUnique>(item);
			
			invItem.m_item.SlotPosition = 0;
			invItem.m_item.OwnerID = null;

			invItem.Level = (byte)template.Level;
			invItem.Model = (ushort)template.Model;
			invItem.Emblem = template.Emblem;
			invItem.Name = template.Name;

			return invItem;
		}
		public ItemDroppedEventArgs(InventoryItem sourceItem, WorldInventoryItem groundItem)
		{
			m_sourceItem = sourceItem;
			m_groundItem = groundItem;
		}
Beispiel #6
0
        protected void PlayerDied(DOLEvent e, object sender, EventArgs args)
        {
            DyingEventArgs arg = args as DyingEventArgs;
            if (arg == null) return;
            GameObject killer = arg.Killer as GameObject;
			GamePlayer playerKiller = null;

			if (killer is GamePlayer)
			{
				playerKiller = killer as GamePlayer;
			}
			else if (killer is GameNPC && (killer as GameNPC).Brain != null && (killer as GameNPC).Brain is AI.Brain.IControlledBrain)
			{
				playerKiller = ((killer as GameNPC).Brain as AI.Brain.IControlledBrain).Owner as GamePlayer;
			}

			Stop();
			m_player.Guild.SendMessageToGuildMembers(m_player.Name + " has dropped the guild banner!", eChatType.CT_Guild, eChatLoc.CL_SystemWindow);

			gameItem = new WorldInventoryItem(m_item);
			Point2D point = m_player.GetPointFromHeading(m_player.Heading, 30);
            gameItem.X = point.X;
            gameItem.Y = point.Y;
            gameItem.Z = m_player.Z;
            gameItem.Heading = m_player.Heading;
            gameItem.CurrentRegionID = m_player.CurrentRegionID;
			gameItem.AddOwner(m_player);

			if (playerKiller != null)
			{
				// Guild banner can be picked up by anyone in the enemy group
				if (playerKiller.Group != null)
				{
					foreach (GamePlayer player in playerKiller.Group.GetPlayersInTheGroup())
					{
						gameItem.AddOwner(player);
					}
				}
				else
				{
					gameItem.AddOwner(playerKiller);
				}
			}

			// Guild banner can be picked up by anyone in the dead players group
			if (m_player.Group != null)
			{
				foreach (GamePlayer player in m_player.Group.GetPlayersInTheGroup())
				{
					gameItem.AddOwner(player);
				}
			}

            gameItem.StartPickupTimer(10);
			m_item.OnLose(m_player);
            gameItem.AddToWorld();
        }
Beispiel #7
0
 public GameEmeraldSealsMerchant()
     : base()
 {
     m_moneyItem = WorldInventoryItem.CreateFromTemplate("EmeraldSeal");
 }
Beispiel #8
0
 public GameAuruliteMerchant()
     : base()
 {
     m_moneyItem = WorldInventoryItem.CreateFromTemplate("aurulite");
 }
Beispiel #9
0
 public GameSapphireSealsMerchant()
     : base()
 {
     m_moneyItem = WorldInventoryItem.CreateFromTemplate("SapphireSeal");
 }
Beispiel #10
0
 public GameDragonMerchant()
     : base()
 {
     m_moneyItem = WorldInventoryItem.CreateFromTemplate("dragonscales");
 }
Beispiel #11
0
 public GameAtlanteanGlassMerchant()
     : base()
 {
     m_moneyItem = WorldInventoryItem.CreateFromTemplate("atlanteanglass");
 }
Beispiel #12
0
        protected void PlayerDied(DOLEvent e, object sender, EventArgs args)
        {
            DyingEventArgs arg = args as DyingEventArgs;

            if (arg == null)
            {
                return;
            }

            GameObject killer       = arg.Killer as GameObject;
            GamePlayer playerKiller = null;

            if (killer is GamePlayer)
            {
                playerKiller = killer as GamePlayer;
            }
            else if (killer is GameNPC && (killer as GameNPC).Brain != null && (killer as GameNPC).Brain is AI.Brain.IControlledBrain)
            {
                playerKiller = ((killer as GameNPC).Brain as AI.Brain.IControlledBrain).Owner as GamePlayer;
            }

            Stop();
            m_player.Guild.SendMessageToGuildMembers(m_player.Name + " has dropped the guild banner!", eChatType.CT_Guild, eChatLoc.CL_SystemWindow);

            gameItem = new WorldInventoryItem(m_item);
            Point2D point = m_player.GetPointFromHeading(m_player.Heading, 30);

            gameItem.X               = point.X;
            gameItem.Y               = point.Y;
            gameItem.Z               = m_player.Z;
            gameItem.Heading         = m_player.Heading;
            gameItem.CurrentRegionID = m_player.CurrentRegionID;
            gameItem.AddOwner(m_player);

            if (playerKiller != null)
            {
                // Guild banner can be picked up by anyone in the enemy group
                if (playerKiller.Group != null)
                {
                    foreach (GamePlayer player in playerKiller.Group.GetPlayersInTheGroup())
                    {
                        gameItem.AddOwner(player);
                    }
                }
                else
                {
                    gameItem.AddOwner(playerKiller);
                }
            }

            // Guild banner can be picked up by anyone in the dead players group
            if (m_player.Group != null)
            {
                foreach (GamePlayer player in m_player.Group.GetPlayersInTheGroup())
                {
                    gameItem.AddOwner(player);
                }
            }

            gameItem.StartPickupTimer(10);
            m_item.OnLose(m_player);
            gameItem.AddToWorld();
        }
Beispiel #13
0
        /// <summary>
        /// Create a scroll or book containing the given page numbers.
        /// </summary>
        /// <param name="artifactID"></param>
        /// <param name="pageNumbers"></param>
        /// <returns></returns>
        private static WorldInventoryItem CreatePages(String artifactID, Book pageNumbers)
        {
            if (artifactID == null || pageNumbers == Book.NoPage)
            {
                return(null);
            }

            Artifact artifact;

            lock (m_artifacts)
                artifact = m_artifacts[artifactID];

            if (artifact == null)
            {
                return(null);
            }

            WorldInventoryItem scroll = WorldInventoryItem.CreateUniqueFromTemplate("artifact_scroll");

            if (scroll == null)
            {
                return(null);
            }

            String scrollTitle = null;
            int    scrollModel = 499;
            short  gold        = 4;

            switch (pageNumbers)
            {
            case Book.Page1:
                scrollTitle = artifact.Scroll1;
                scrollModel = artifact.ScrollModel1;
                gold        = 2;
                break;

            case Book.Page2:
                scrollTitle = artifact.Scroll2;
                scrollModel = artifact.ScrollModel1;
                gold        = 3;
                break;

            case Book.Page3:
                scrollTitle = artifact.Scroll3;
                scrollModel = artifact.ScrollModel1;
                break;

            case (Book)((int)Book.Page1 | (int)Book.Page2):
                scrollTitle = artifact.Scroll12;
                scrollModel = artifact.ScrollModel2;
                break;

            case (Book)((int)Book.Page1 | (int)Book.Page3):
                scrollTitle = artifact.Scroll13;
                scrollModel = artifact.ScrollModel2;
                break;

            case (Book)((int)Book.Page2 | (int)Book.Page3):
                scrollTitle = artifact.Scroll23;
                scrollModel = artifact.ScrollModel2;
                break;

            case Book.AllPages:
                scrollTitle = artifact.BookID;
                scrollModel = artifact.BookModel;
                gold        = 5;
                break;
            }

            scroll.Name       = scrollTitle;
            scroll.Item.Name  = scrollTitle;
            scroll.Model      = (ushort)scrollModel;
            scroll.Item.Model = (ushort)scrollModel;

            // Correct for possible errors in generic scroll template (artifact_scroll)
            scroll.Item.Price      = Money.GetMoney(0, 0, gold, 0, 0);
            scroll.Item.IsDropable = true;
            scroll.Item.IsPickable = true;
            scroll.Item.IsTradable = true;

            return(scroll);
        }