Inheritance: MonoBehaviour
Esempio n. 1
0
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches.
            if (player.CharacterClass.ID == (int)TrainedClass)
            {
                OfferTraining(player);
            }
            else
            {
                // perhaps player can be promoted
                if (CanPromotePlayer(player))
                {
                    player.Out.SendMessage(this.Name + " says, \"Is it your wish to [join the Academy] and lend us your power as a Sorcerer?\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
                    if (!player.IsLevelRespecUsed)
                    {
                        OfferRespecialize(player);
                    }
                }
                else
                {
                    CheckChampionTraining(player);
                }
            }
            return true;
        }
Esempio n. 2
0
		/// <summary>
		/// Player has picked a subselection.
		/// </summary>
		/// <param name="player"></param>
		/// <param name="subSelection"></param>
		protected override void OnSubSelectionPicked(GamePlayer player, Teleport subSelection)
		{
			switch (subSelection.TeleportID.ToLower())
			{
				case "shrouded isles":
					{
						String reply = String.Format("The isles of Avalon are an excellent choice. {0} {1}",
						                             "Would you prefer the harbor of [Gothwaite] or perhaps one of the outlying towns",
						                             "like [Wearyall] Village, Fort [Gwyntell], or Caer [Diogel]?");
						SayTo(player, reply);
						return;
					}
				case "housing":
					{
						String reply = String.Format("I can send you to your [personal] house. If you do {0} {1} {2} {3}",
						                             "not have a personal house or wish to be sent to the housing [entrance] then you will",
						                             "arrive just inside the housing area. I can also send you to your [guild] house. If your",
						                             "guild does not own a house then you will not be transported. You may go to your [Hearth] bind",
						                             "as well if you are bound inside a house.");
						SayTo(player, reply);
						return;
					}
			}
			base.OnSubSelectionPicked(player, subSelection);
		}
Esempio n. 3
0
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches.
            if (player.CharacterClass.ID == (int)TrainedClass)
            {
                OfferTraining(player);
            }
            else
            {
                // perhaps player can be promoted
                if (CanPromotePlayer(player))
                {
                    player.Out.SendMessage(this.Name + " says, \"Do you desire to [join the House of Odin] and defend our realm as a Runemaster?\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
                    if (!player.IsLevelRespecUsed)
                    {
                        OfferRespecialize(player);
                    }
                }
                else
                {
                    CheckChampionTraining(player);
                }
            }
            return true;
        }
Esempio n. 4
0
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches.
            if (player.CharacterClass.ID == (int) TrainedClass)
            {
                player.Out.SendMessage(this.Name + " says, \"Training makes for a strong, healthy Hero! Keep up the good work, " + player.Name + "!\"", eChatType.CT_Say, eChatLoc.CL_ChatWindow);
            }
            else
            {
                // perhaps player can be promoted
                if (CanPromotePlayer(player))
                {
                    player.Out.SendMessage(this.Name + " says, \"You wish to follow the [Path of Affinity] and walk as a Valewalker?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
                    if (!player.IsLevelRespecUsed)
                    {
                        OfferRespecialize(player);
                    }
                }
                else
                {
                    CheckChampionTraining(player);
                }
            }
            return true;
        }
Esempio n. 5
0
		/// <summary>
		/// Adds a player to the looking for group list
		/// </summary>
		/// <param name="member">player to add to the list</param>
		public static void SetPlayerLooking(GamePlayer member)
		{
			if (member.LookingForGroup == false && m_lfgPlayers.AddIfNotExists(member, true))
			{
				member.LookingForGroup = true;
			}
		}
Esempio n. 6
0
		/// <summary>
		/// Interact with trainer
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
 		public override bool Interact(GamePlayer player)
 		{		
 			if (!base.Interact(player)) return false;
								
			// check if class matches.				
			if (player.CharacterClass.ID == (int)TrainedClass)
			{
				OfferTraining(player);
			}
			else 
			{
				// perhaps player can be promoted
				if (CanPromotePlayer(player)) 
				{
					player.Out.SendMessage(this.Name + " says, \"Do you wish to [join the Guild of Shadows] and seek your fortune as a Mercenary?\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
					if (!player.IsLevelRespecUsed)
					{
						OfferRespecialize(player);
					}
				}
				else
				{
					CheckChampionTraining(player);
				}
			}
			return true;
 		}
Esempio n. 7
0
		/// <summary>
		/// Interact with trainer
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
		public override bool Interact(GamePlayer player)
		{
			if (!base.Interact(player)) return false;
			
			// check if class matches.
			if (player.CharacterClass.ID == (int)TrainedClass)
			{
				OfferTraining(player);
			}
			else
			{
				// perhaps player can be promoted
				if (CanPromotePlayer(player))
				{
					player.Out.SendMessage(this.Name + " says, \"You have come to seek admittance into the [Temple of Arawn] to worship the old god that your ancestors worshipped?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
					if (!player.IsLevelRespecUsed)
					{
						OfferRespecialize(player);
					}
				}
				else
				{
					CheckChampionTraining(player);
				}
			}
			return true;
		}
Esempio n. 8
0
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches.
            if (player.CharacterClass.ID == (int)TrainedClass)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AnimistTrainer.Interact.Text2", this.Name, player.GetName(0, false)), eChatType.CT_Say, eChatLoc.CL_ChatWindow);
            }
            else
            {
                // perhaps player can be promoted
                if (CanPromotePlayer(player))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AnimistTrainer.Interact.Text1", this.Name), eChatType.CT_System, eChatLoc.CL_PopupWindow);
                    if (!player.IsLevelRespecUsed)
                    {
                        OfferRespecialize(player);
                    }
                }
                else
                {
                    CheckChampionTraining(player);
                }
            }
            return true;
        }
        /// <summary>
        /// Player has picked a destination.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="destination"></param>
        protected override void OnDestinationPicked(GamePlayer player, Teleport destination)
        {
            // Not porting to where we already are.

            List<String> playerAreaList = new List<String>();
            foreach (AbstractArea area in player.CurrentAreas)
                playerAreaList.Add(area.Description);

            if (playerAreaList.Contains(destination.TeleportID))
                return;

            switch (destination.TeleportID.ToLower())
            {
                case "aegirhamn":
                    break;
                case "bjarken":
                    break;
                case "hagall":
                    break;
                case "knarr":
                    break;
                default:
                    return;
            }

            SayTo(player, "Have a safe journey!");
            base.OnDestinationPicked(player, destination);
        }
Esempio n. 10
0
        public override void Execute(XmlGame game, GamePlayer player)
        {
            StringBuilder msg = new StringBuilder();
            msg.Append(String.Format("{0} stole ", player.XmlPlayer.Name));

            foreach (GamePlayer gamePlayer in game.Players)
            {
                //steal only form opponents
                if (!gamePlayer.XmlPlayer.Equals(player.XmlPlayer.ID))
                {
                    // and only if he has the type of resource
                    if (gamePlayer.Resources[Resource, true] > 0)
                    {
                        // add resources by the development card owner
                        player.Resources[Resource, true] += gamePlayer.Resources[Resource, true];

                        msg.Append(String.Format("{0} {1} from {2}, ",
                            gamePlayer.Resources[Resource, true], Resource.ToString(), gamePlayer.XmlPlayer.Name));

                        // remove resources at victims
                        gamePlayer.Resources[Resource, true] = 0;
                    }
                }
            }

            // remove the trailing ","
            _Message = msg.ToString().Substring(0, msg.ToString().Length - 2);

            base.Execute(game, player);
        }
Esempio n. 11
0
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches
            if (player.CharacterClass.ID == (int) TrainedClass)
            {
                // player can be promoted
                if (player.Level>=5)
                {
                    player.Out.SendMessage(this.Name + " says, \"You must now seek your training elsewhere. Which path would you like to follow? [Bard], [Druid] or [Warden]?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
                }
                else
                {
                    OfferTraining(player);
                }

                // ask for basic equipment if player doesnt own it
                if (player.Inventory.GetFirstItemByID(PRACTICE_WEAPON_ID, eInventorySlot.MinEquipable, eInventorySlot.LastBackpack) == null)
                {
                    player.Out.SendMessage(this.Name + " says, \"Do you require a [practice weapon]?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
                }
                if (player.Inventory.GetFirstItemByID(PRACTICE_SHIELD_ID, eInventorySlot.MinEquipable, eInventorySlot.LastBackpack) == null)
                {
                    player.Out.SendMessage(this.Name + " says, \"Do you require a [training shield]?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
                }
            }
            else
            {
                CheckChampionTraining(player);
            }
            return true;
        }
Esempio n. 12
0
		public override bool Interact(GamePlayer player)
		{
			if (!base.Interact(player))
				return false;

			House house = HouseMgr.GetHouseByPlayer(player);

			if (house != null)
			{
				//the player might be targeting a lot he already purchased that has no house on it yet
				if (house.HouseNumber != DatabaseItem.HouseNumber && player.Client.Account.PrivLevel != (int)ePrivLevel.Admin)
				{
					ChatUtil.SendSystemMessage(player, "You already own a house!");
					return false;
				}
			}

			if (string.IsNullOrEmpty(DatabaseItem.OwnerID))
			{
				player.Out.SendCustomDialog("Do you want to buy this lot?\r\n It costs " + Money.GetString(HouseTemplateMgr.GetLotPrice(DatabaseItem)) + "!", BuyLot);
			}
			else
			{
				if (HouseMgr.IsOwner(DatabaseItem, player))
				{
					player.Out.SendMerchantWindow(HouseTemplateMgr.GetLotMarkerItems(this), eMerchantWindowType.Normal);
				}
				else
				{
					ChatUtil.SendSystemMessage(player, "You do not own this lot!");
				}
			}

			return true;
		}
Esempio n. 13
0
			/// <summary>
			/// Constructs a new UseSkillAction
			/// </summary>
			/// <param name="actionSource">The action source</param>
			/// <param name="flagSpeedData">The skill type</param>
			/// <param name="index">The skill index</param>
			/// <param name="type">The skill type</param>
			public UseSkillAction(GamePlayer actionSource, int flagSpeedData, int index, int type)
				: base(actionSource)
			{
				m_flagSpeedData = flagSpeedData;
				m_index = index;
				m_type = type;
			}
Esempio n. 14
0
		/// <summary>
		/// Constructs a new Quest
		/// </summary>
		/// <param name="taskPlayer">The player doing this task</param>
		public AbstractTask(GamePlayer taskPlayer)
		{
			m_taskPlayer = taskPlayer;

			DBTask dbTask=null;

			// Check if player already has a task
			// if yes reuse dbtask object to keep TasksDone from old dbtask object.
			if (taskPlayer.Task!=null)
			{
				dbTask = taskPlayer.Task.m_dbTask;
			}
			else // if player has no active task, load dbtask an use tasksdone
			{
				// Load Task object of player ...
				var tasks = GameServer.Database.FindObjectByKey<DBTask>(taskPlayer.QuestPlayerID);
				if (tasks != null)
					dbTask = tasks;
			}

			// this should happen only if player never did a task and has no entry in DBTask.
			if (dbTask==null)
			{
				dbTask = new DBTask();
				dbTask.Character_ID = taskPlayer.QuestPlayerID;
			}

			dbTask.TaskType = GetType().FullName;

			m_dbTask = dbTask;

			ParseCustomProperties();
			SaveIntoDatabase();
		}
Esempio n. 15
0
		public override void OnLevelUp(GamePlayer player)
		{

			base.OnLevelUp(player);

			player.AddSpecialization(SkillBase.GetSpecialization(Specs.Shields));
			player.AddSpecialization(SkillBase.GetSpecialization(Specs.Stormcalling));
			player.AddSpellLine(SkillBase.GetSpellLine("Stormcalling"));

			if (player.Level >= 10)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Protect, 1));
			}
			if (player.Level >= 12)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Shield, ShieldLevel.Large));
				player.AddAbility(SkillBase.GetAbility(Abilities.MidArmor, ArmorLevel.Chain));
			}
			if (player.Level >= 15)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Intercept));
				player.AddAbility(SkillBase.GetAbility(Abilities.Tireless));
			}
			if (player.Level >= 20)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Protect, 2));
			}
		}
Esempio n. 16
0
		/// <summary>
		/// Update all skills and add new for current level
		/// </summary>
		/// <param name="player"></param>
		public override void OnLevelUp(GamePlayer player) 
		{
			base.OnLevelUp(player);

			// Specializations
			player.AddSpecialization(SkillBase.GetSpecialization(Specs.Blades));
			player.AddSpecialization(SkillBase.GetSpecialization(Specs.Blunt));
			player.AddSpecialization(SkillBase.GetSpecialization(Specs.Shields));

			// Spell lines
			player.AddSpellLine(SkillBase.GetSpellLine("Nurture Warden Spec"));
			player.AddSpellLine(SkillBase.GetSpellLine("Regrowth Warden Spec"));

			if (player.Level >= 5) 
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Shield, ShieldLevel.Large));
			}
			if (player.Level >= 7) 
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Weapon_Shortbows));
			}
			if (player.Level >= 10) 
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.HibArmor, ArmorLevel.Reinforced));
			}
			if (player.Level >= 15)
			{
				player.AddSpecialization(SkillBase.GetSpecialization(Specs.Parry));
				player.AddAbility(SkillBase.GetAbility(Abilities.Tireless));
			}
			if (player.Level >= 20)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.HibArmor, ArmorLevel.Scale));
			}
		}
Esempio n. 17
0
		/// <summary>
		/// This function is called when player accept the combine
		/// </summary>
		/// <param name="player"></param>
		/// <param name="item"></param>
		public override bool IsAllowedToCombine(GamePlayer player, InventoryItem item)
		{
			if (!base.IsAllowedToCombine(player, item)) 
                return false;
			
			if (((InventoryItem)player.TradeWindow.TradeItems[0]).Object_Type != 
                (int)eObjectType.AlchemyTincture)
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, 
                    "Alchemy.IsAllowedToCombine.AlchemyTinctures"), PacketHandler.eChatType.CT_System, 
                    PacketHandler.eChatLoc.CL_SystemWindow);
				
                return false;
			}

			if (player.TradeWindow.ItemsCount > 1)
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language,
                    "Alchemy.IsAllowedToCombine.OneTincture"), PacketHandler.eChatType.CT_System, 
                    PacketHandler.eChatLoc.CL_SystemWindow);

				return false;
			}

			if (item.ProcSpellID != 0 || item.SpellID != 0)
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, 
                    "Alchemy.IsAllowedToCombine.AlreadyImbued", item.Name), 
                    PacketHandler.eChatType.CT_System, PacketHandler.eChatLoc.CL_SystemWindow);

				return false;
			}

			return true;
		}
Esempio n. 18
0
		/// <summary>
		/// Interact with trainer
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
		public override bool Interact(GamePlayer player)
		{
			if (!base.Interact(player)) return false;

			// check if class matches.
			if (player.CharacterClass.ID == (int) TrainedClass)
			{
				player.Out.SendMessage(this.Name + " says, \"You wish to learn more of our ways? Fine then.\"", eChatType.CT_Say, eChatLoc.CL_ChatWindow);
			}
			else
			{
				// perhaps player can be promoted
				if (CanPromotePlayer(player))
				{
					player.Out.SendMessage(this.Name + " says, \"You know, the way of a [Ranger] is not for everyone. Are you sure this is your choice?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
					if (!player.IsLevelRespecUsed)
					{
						OfferRespecialize(player);
					}
				}
				else
				{
					CheckChampionTraining(player);
				}
			}
			return true;
		}
Esempio n. 19
0
        /// <summary>
        /// Buys an item off a housing merchant.  If the list has been customized then this must be modified to
        /// match that customized list.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="slot"></param>
        /// <param name="count"></param>
        /// <param name="merchantType"></param>
        public virtual void BuyHousingItem(GamePlayer player, ushort slot, byte count, DOL.GS.PacketHandler.eMerchantWindowType merchantType)
        {
            MerchantTradeItems items = null;

            switch (merchantType)
            {
                case eMerchantWindowType.HousingInsideShop:
                    items = HouseTemplateMgr.IndoorShopItems;
                    break;
                case eMerchantWindowType.HousingOutsideShop:
                    items = HouseTemplateMgr.OutdoorShopItems;
                    break;
                case eMerchantWindowType.HousingBindstoneHookpoint:
                    items = HouseTemplateMgr.IndoorBindstoneShopItems;
                    break;
                case eMerchantWindowType.HousingCraftingHookpoint:
                    items = HouseTemplateMgr.IndoorCraftShopItems;
                    break;
                case eMerchantWindowType.HousingNPCHookpoint:
                    items = HouseTemplateMgr.IndoorNPCShopItems;
                    break;
                case eMerchantWindowType.HousingVaultHookpoint:
                    items = HouseTemplateMgr.IndoorVaultShopItems;
                    break;
            }

            GameMerchant.OnPlayerBuy(player, slot, count, items);
        }
Esempio n. 20
0
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches.
            if (player.CharacterClass.ID == (int) TrainedClass)
            {
                player.Out.SendMessage(this.Name + " says, \"Ahh, well met " + player.Name + ". Back for more lore and knowledge, eh.\"", eChatType.CT_Say, eChatLoc.CL_ChatWindow);
            }
            else
            {
                // perhaps player can be promoted
                if (CanPromotePlayer(player))
                {
                    player.Out.SendMessage(this.Name + " says, \"Do you wish to walk the Path of Essence, pursuing a life of storytelling and [song]? Of brave deeds which grow braver with every telling?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
                    if (!player.IsLevelRespecUsed)
                    {
                        OfferRespecialize(player);
                    }
                }
                else
                {
                    CheckChampionTraining(player);
                }
            }
            return true;
        }
Esempio n. 21
0
		public override void SendPlayerCreate(GamePlayer playerToCreate)
		{
			Region playerRegion = playerToCreate.CurrentRegion;
			if (playerRegion == null)
			{
				if (log.IsWarnEnabled)
					log.Warn("SendPlayerCreate: playerRegion == null");
				return;
			}

			Zone playerZone = playerToCreate.CurrentZone;
			if (playerZone == null)
			{
				if (log.IsWarnEnabled)
					log.Warn("SendPlayerCreate: playerZone == null");
				return;
			}

			if (m_gameClient.Player == null || playerToCreate.IsVisibleTo(m_gameClient.Player) == false)
				return;

			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.PlayerCreate172));
			pak.WriteShort((ushort)playerToCreate.Client.SessionID);
			pak.WriteShort((ushort)playerToCreate.ObjectID);
			pak.WriteShort(playerToCreate.Model);
			pak.WriteShort((ushort)playerToCreate.Z);
            //Dinberg:Instances - Zoneskin ID for clientside positioning 'bluff'.
			pak.WriteShort(playerZone.ZoneSkinID);
			pak.WriteShort((ushort)playerRegion.GetXOffInZone(playerToCreate.X, playerToCreate.Y));
			pak.WriteShort((ushort)playerRegion.GetYOffInZone(playerToCreate.X, playerToCreate.Y));
			pak.WriteShort(playerToCreate.Heading);

			pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.EyeSize)); //1-4 = Eye Size / 5-8 = Nose Size
			pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.LipSize)); //1-4 = Ear size / 5-8 = Kin size
			pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.EyeColor)); //1-4 = Skin Color / 5-8 = Eye Color
			pak.WriteByte(playerToCreate.GetDisplayLevel(m_gameClient.Player));
			pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.HairColor)); //Hair: 1-4 = Color / 5-8 = unknown
			pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.FaceType)); //1-4 = Unknown / 5-8 = Face type
			pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.HairStyle)); //1-4 = Unknown / 5-8 = Hair Style

			int flags = (GameServer.ServerRules.GetLivingRealm(m_gameClient.Player, playerToCreate) & 0x03) << 2;
			if (playerToCreate.IsAlive == false)
				flags |= 0x01;
			if (playerToCreate.IsUnderwater)
				flags |= 0x02; //swimming
			if (playerToCreate.IsStealthed)
				flags |= 0x10;
			if (playerToCreate.IsWireframe)
				flags |= 0x20;
			pak.WriteByte((byte)flags);

			pak.WritePascalString(GameServer.ServerRules.GetPlayerName(m_gameClient.Player, playerToCreate));
			pak.WritePascalString(GameServer.ServerRules.GetPlayerGuildName(m_gameClient.Player, playerToCreate));
			pak.WritePascalString(GameServer.ServerRules.GetPlayerLastName(m_gameClient.Player, playerToCreate));
			pak.WriteByte(0x00); //Trialing 0 ... needed!
			SendTCP(pak);

			//if (GameServer.ServerRules.GetColorHandling(m_gameClient) == 1) // PvP
			SendObjectGuildID(playerToCreate, playerToCreate.Guild); //used for nearest friendly/enemy object buttons and name colors on PvP server
		}
Esempio n. 22
0
        /// <summary>
        /// Check if player is eligible for this quest.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool CheckQuestQualification(GamePlayer player)
        {
            if (!base.CheckQuestQualification(player))
                return false;

            return (player.Level >= 45);
        }
Esempio n. 23
0
		/// <summary>
		/// Interact with trainer
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
		public override bool Interact(GamePlayer player)
		{
			if (!base.Interact(player)) return false;

			// check if class matches.
			if (player.CharacterClass.ID == (int) TrainedClass)
			{
				player.Out.SendMessage(this.Name + " says, \"Do you wish to learn some more, " + player.Name + "? Step up and receive your training!\"", eChatType.CT_Say, eChatLoc.CL_ChatWindow);
			}
			else
			{
				// perhaps player can be promoted
				if (CanPromotePlayer(player))
				{
					player.Out.SendMessage(this.Name + " says, \"" + player.Name + ", do you choose the Path of Affinity, and life as a [Vampiir]?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
					if (!player.IsLevelRespecUsed)
					{
						OfferRespecialize(player);
					}
				}
				else
				{
					CheckChampionTraining(player);
				}
			}
			return true;
		}
Esempio n. 24
0
		/// <summary>
		/// Interact with trainer
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
		public override bool Interact(GamePlayer player)
		{
			if (!base.Interact(player)) return false;
			
			// check if class matches.
			if (player.CharacterClass.ID == (int) TrainedClass)
			{
				player.Out.SendMessage(this.Name + " says, \"I shall impart all that I know, young Druid.\"", eChatType.CT_Say, eChatLoc.CL_ChatWindow);
			}
			else
			{
				// perhaps player can be promoted
				if (CanPromotePlayer(player))
				{
					player.Out.SendMessage(this.Name + " says, \"Do you wish to walk the Path of Harmony and learn the ways of the [Druid]?\"", eChatType.CT_System, eChatLoc.CL_PopupWindow);
					if (!player.IsLevelRespecUsed)
					{
						OfferRespecialize(player);
					}
				}
				else
				{
					CheckChampionTraining(player);
				}
			}
			return true;
		}
        /// <summary>
        /// Interact with trainer
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player)) return false;

            // check if class matches.
            if (player.CharacterClass.ID == (int)TrainedClass)
            {
                OfferTraining(player);
            }
            else
            {
                // perhaps player can be promoted
                if (CanPromotePlayer(player))
                {
                    player.Out.SendMessage(this.Name + " says, \"You have come far to find us! Is it your wish to [join the Guild of Shadows] and become our dagger of the night? An Infiltrator!\"", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
                    if (!player.IsLevelRespecUsed)
                    {
                        OfferRespecialize(player);
                    }
                }
                else
                {
                    CheckChampionTraining(player);
                }
            }
            return true;
        }
        public override bool IsValid(GamePlayer player)
        {
            BusinessLocation bl = player.Locations[Location];
            LocationStorage ls = bl.Storage;            
            ItemQuantity iq = ls.GetItem(Item);
            int q;
            if (iq == null)
            {
                q = 0;
            }
            else
            {
                q = iq.StoredQuantity;
            }       

            switch (ComparisonType)
            {
                case ComparisonEnum.Equal:
                    return q == Quantity;
                case ComparisonEnum.GreaterThan:
                    return q > Quantity;
                case ComparisonEnum.GreaterThanOrEqual:
                    return q >= Quantity;
                case ComparisonEnum.LessThan:
                    return q < Quantity;
                case ComparisonEnum.LessThanOrEqual:
                    return q <= Quantity;
                case ComparisonEnum.NotEqual:
                    return q != Quantity;
            }

            return false;
        }
Esempio n. 27
0
		/// <summary>
		/// Interact with trainer
		/// </summary>
		/// <param name="player"></param>
		/// <returns></returns>
		public override bool Interact(GamePlayer player)
		{
			if (!base.Interact(player)) return false;

			// check if class matches
			if (player.CharacterClass.ID == (int)TrainedClass)
			{
				OfferTraining(player);
			}
			else
			{
				// perhaps player can be promoted
				if (CanPromotePlayer(player))
				{
					player.Out.SendMessage(this.Name + " says, \"Do you desire to [join the Temple of the Iron Fist] and fight for the glorious realm of Albion?\"", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
					if (!player.IsLevelRespecUsed)
					{
						OfferRespecialize(player);
					}
				}
				else
				{
					CheckChampionTraining(player);
				}
			}
			return true;
		}
        /// <summary>
        /// Interact with the NPC.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player) || player == null)
                return false;

            if (GlobalConstants.IsExpansionEnabled((int)eClientExpansion.DarknessRising))
            {
                if (player.CurrentRegion.Expansion == (int)eClientExpansion.DarknessRising)
                {
                    SayTo(player, "Do you wish to [exit]?");
                }
                else
                {
                    SayTo(player, "Do you require an audience with the [King]?");
                }
                return true;
            }
            else
            {
                String reply = "I am afraid, but the King is busy right now.";

                if (player.Inventory.CountItemTemplate("Personal_Bind_Recall_Stone", eInventorySlot.Min_Inv, eInventorySlot.Max_Inv) == 0)
                    reply += " If you're only here to get your Personal Bind Recall Stone then I'll see what I can [do].";

                SayTo(player, reply);
                return false;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Interacting with the djinn resets the timer.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            lock (m_syncObject)
                m_timer.Restart();

            return base.Interact(player);
        }
Esempio n. 30
0
		public override void OnLevelUp(GamePlayer player)
		{

			base.OnLevelUp(player);

			player.AddSpecialization(SkillBase.GetSpecialization(Specs.Battlesongs));
			player.AddSpellLine(SkillBase.GetSpellLine("Battlesongs"));
			player.AddAbility(SkillBase.GetAbility(Abilities.Shield, ShieldLevel.Medium));

			if (player.Level >= 12)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Protect, 1));
			}
			if (player.Level >= 15)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Tireless));
			}
			if (player.Level >= 19)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.Protect, 2));
			}
			if (player.Level >= 20)
			{
				player.AddAbility(SkillBase.GetAbility(Abilities.MidArmor, ArmorLevel.Chain));
				player.AddAbility(SkillBase.GetAbility(Abilities.Evade, 1));
			}
		}
Esempio n. 31
0
 public override string GetValue(GamePlayer player)
 {
     return("Banbharun");
 }
Esempio n. 32
0
 public override bool IsSuitable(GamePlayer player)
 {
     return(player.Realm == eRealm.Midgard && player.RealmLevel >= 30 && player.RealmLevel < 40);
 }
Esempio n. 33
0
 public override string GetValue(GamePlayer player)
 {
     return("Elding Vakten");
 }
Esempio n. 34
0
 public override string GetDescription(GamePlayer player)
 {
     return("Realm Rank");
 }
Esempio n. 35
0
 public override bool IsSuitable(GamePlayer player)
 {
     return(player.Realm == eRealm.Hibernia && player.RealmLevel >= 110 && player.RealmLevel < 120 && player.DBCharacter.Gender == 1);
 }
Esempio n. 36
0
 public override bool IsSuitable(GamePlayer player)
 {
     return(player.Realm == eRealm.Albion && player.RealmLevel >= 40 && player.RealmLevel < 50);
 }
Esempio n. 37
0
 public override string GetValue(GamePlayer player)
 {
     return("Ard Bantiarna");
 }
Esempio n. 38
0
 public override bool IsSuitable(GamePlayer player)
 {
     return(player.Realm == eRealm.Hibernia && player.RealmLevel >= 90 && player.RealmLevel < 100);
 }
Esempio n. 39
0
 public override string GetValue(GamePlayer player)
 {
     return("Gilded Spear");
 }
Esempio n. 40
0
 public override string GetValue(GamePlayer player)
 {
     return("Eagle Knight");
 }
Esempio n. 41
0
 public override string GetValue(GamePlayer player)
 {
     return("Silver Hand");
 }
Esempio n. 42
0
 public override string GetValue(GamePlayer player)
 {
     return("Emerald Ridere");
 }
Esempio n. 43
0
 public override string GetValue(GamePlayer player)
 {
     return("Grove Protector");
 }
Esempio n. 44
0
 public override string GetValue(GamePlayer player)
 {
     return("Thunderer");
 }
Esempio n. 45
0
 public override string GetValue(GamePlayer player)
 {
     return("Gryphon Knight");
 }
Esempio n. 46
0
 public override string GetValue(GamePlayer player)
 {
     return("Raven Ardent");
 }
Esempio n. 47
0
 public override string GetValue(GamePlayer player)
 {
     return("Lady");
 }
Esempio n. 48
0
 public override string GetValue(GamePlayer player)
 {
     return("Baronetess");
 }
Esempio n. 49
0
        public override void SendPlayerCreate(GamePlayer playerToCreate)
        {
            Region playerRegion = playerToCreate.CurrentRegion;

            if (playerRegion == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("SendPlayerCreate: playerRegion == null");
                }
                return;
            }

            Zone playerZone = playerToCreate.CurrentZone;

            if (playerZone == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("SendPlayerCreate: playerZone == null");
                }
                return;
            }

            if (m_gameClient.Player == null || playerToCreate.IsVisibleTo(m_gameClient.Player) == false)
            {
                return;
            }

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.PlayerCreate172)))
            {
                pak.WriteShort((ushort)playerToCreate.Client.SessionID);
                pak.WriteShort((ushort)playerToCreate.ObjectID);
                pak.WriteShort(playerToCreate.Model);
                pak.WriteShort((ushort)playerToCreate.Position.Z);
                //Dinberg:Instances - Zoneskin ID for clientside positioning 'bluff'.
                pak.WriteShort(playerZone.ZoneSkinID);
                pak.WriteShort((ushort)playerRegion.GetXOffInZone(playerToCreate.Position.X, playerToCreate.Position.Y));
                pak.WriteShort((ushort)playerRegion.GetYOffInZone(playerToCreate.Position.X, playerToCreate.Position.Y));
                pak.WriteShort(playerToCreate.Heading);

                pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.EyeSize));                 //1-4 = Eye Size / 5-8 = Nose Size
                pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.LipSize));                 //1-4 = Ear size / 5-8 = Kin size
                pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.EyeColor));                //1-4 = Skin Color / 5-8 = Eye Color
                pak.WriteByte(playerToCreate.GetDisplayLevel(m_gameClient.Player));
                pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.HairColor));               //Hair: 1-4 = Color / 5-8 = unknown
                pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.FaceType));                //1-4 = Unknown / 5-8 = Face type
                pak.WriteByte(playerToCreate.GetFaceAttribute(eCharFacePart.HairStyle));               //1-4 = Unknown / 5-8 = Hair Style

                int flags = (GameServer.ServerRules.GetLivingRealm(m_gameClient.Player, playerToCreate) & 0x03) << 2;
                if (playerToCreate.IsAlive == false)
                {
                    flags |= 0x01;
                }
                if (playerToCreate.IsUnderwater)
                {
                    flags |= 0x02;                     //swimming
                }
                if (playerToCreate.IsStealthed)
                {
                    flags |= 0x10;
                }
                if (playerToCreate.IsWireframe)
                {
                    flags |= 0x20;
                }
                pak.WriteByte((byte)flags);

                pak.WritePascalString(GameServer.ServerRules.GetPlayerName(m_gameClient.Player, playerToCreate));
                pak.WritePascalString(GameServer.ServerRules.GetPlayerGuildName(m_gameClient.Player, playerToCreate));
                pak.WritePascalString(GameServer.ServerRules.GetPlayerLastName(m_gameClient.Player, playerToCreate));
                pak.WriteByte(0x00);                 //Trialing 0 ... needed!
                SendTCP(pak);
            }

            // Update Cache
            m_gameClient.GameObjectUpdateArray[new Tuple <ushort, ushort>(playerToCreate.CurrentRegionID, (ushort)playerToCreate.ObjectID)] = GameTimer.GetTickCount();

            SendObjectGuildID(playerToCreate, playerToCreate.Guild);             //used for nearest friendly/enemy object buttons and name colors on PvP server
        }
Esempio n. 50
0
 public override bool IsSuitable(GamePlayer player)
 {
     return(player.Realm == eRealm.Albion && player.RealmLevel >= 100 && player.RealmLevel < 110 && player.DBCharacter.Gender == 1);
 }
Esempio n. 51
0
 /// <summary>
 /// This constructor is needed to load quests from the DB.
 /// </summary>
 /// <param name="questingPlayer"></param>
 /// <param name="dbQuest"></param>
 public ArtifactQuest(GamePlayer questingPlayer, DBQuest dbQuest)
     : base(questingPlayer, dbQuest)
 {
 }
Esempio n. 52
0
        /// <summary>
        /// Artifact delve information.
        /// </summary>
        public override void Delve(List <String> delve, GamePlayer player)
        {
            if (player == null)
            {
                return;
            }

            // Artifact specific information.

            if (ArtifactLevel < 10)
            {
                delve.Add(string.Format("Artifact (Current level: {0})", ArtifactLevel));
                delve.Add(string.Format("- {0}% exp earned towards level {1}",
                                        ArtifactMgr.GetXPGainedForLevel(this), ArtifactLevel + 1));
                delve.Add(string.Format("- Artifact will gain new abilities at level {0}",
                                        GainsNewAbilityAtLevel()));
                delve.Add(string.Format("(Earns exp: {0})",
                                        ArtifactMgr.GetEarnsXP(this)));
            }
            else
            {
                delve.Add("Artifact:");
                delve.Add("Current level: 10");
            }

            // Item bonuses.

            delve.Add("");
            delve.Add("Magical Bonuses:");

            for (ArtifactBonus.ID bonusID = ArtifactBonus.ID.MinStat; bonusID <= ArtifactBonus.ID.MaxStat; ++bonusID)
            {
                DelveMagicalBonus(delve, Template.GetBonusAmount(bonusID), Template.GetBonusType(bonusID), m_levelRequirements[(int)bonusID]);
            }

            for (ArtifactBonus.ID bonusID = ArtifactBonus.ID.MinStat; bonusID <= ArtifactBonus.ID.MaxStat; ++bonusID)
            {
                DelveFocusBonus(delve, Template.GetBonusAmount(bonusID), Template.GetBonusType(bonusID), m_levelRequirements[(int)bonusID]);
            }

            delve.Add("");

            for (ArtifactBonus.ID bonusID = ArtifactBonus.ID.MinStat; bonusID <= ArtifactBonus.ID.MaxStat; ++bonusID)
            {
                DelveBonus(delve, Template.GetBonusAmount(bonusID), Template.GetBonusType(bonusID), m_levelRequirements[(int)bonusID]);
            }

            // Spells & Procs

            DelveMagicalAbility(delve, ArtifactBonus.ID.Spell, m_levelRequirements[(int)ArtifactBonus.ID.Spell]);
            DelveMagicalAbility(delve, ArtifactBonus.ID.ProcSpell, m_levelRequirements[(int)ArtifactBonus.ID.ProcSpell]);
            DelveMagicalAbility(delve, ArtifactBonus.ID.Spell1, m_levelRequirements[(int)ArtifactBonus.ID.Spell1]);
            DelveMagicalAbility(delve, ArtifactBonus.ID.ProcSpell1, m_levelRequirements[(int)ArtifactBonus.ID.ProcSpell1]);

            delve.Add("");

            // Weapon & Armor Stats.

            if ((Object_Type >= (int)eObjectType.GenericWeapon) &&
                (Object_Type <= (int)eObjectType.MaulerStaff) ||
                (Object_Type == (int)eObjectType.Instrument))
            {
                DelveWeaponStats(delve, player);
            }
            else if (Object_Type >= (int)eObjectType.Cloth &&
                     Object_Type <= (int)eObjectType.Scale)
            {
                DelveArmorStats(delve, player);
            }

            // Reuse Timer

            int reuseTimer = ArtifactMgr.GetReuseTimer(this);

            if (reuseTimer > 0)
            {
                TimeSpan reuseTimeSpan = new TimeSpan(0, 0, reuseTimer);
                delve.Add("");
                delve.Add(String.Format("Can use item every {0} min",
                                        reuseTimeSpan.ToString().Substring(3)));
            }

            if (player.Client.Account.PrivLevel > 1)
            {
                WriteTechnicalInfo(delve, player.Client);
            }
        }
Esempio n. 53
0
 /// <summary>
 /// Handle interaction with the scholar.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="text"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public virtual bool Interact(Scholar scholar, GamePlayer player)
 {
     return(false);
 }
Esempio n. 54
0
        /// <summary>
        /// This is used to build a server side "Position Object"
        /// Usually Position Packet Should only be relayed
        /// The only purpose of this method is refreshing postion when there is Lag
        /// </summary>
        /// <param name="player"></param>
        public override void SendPlayerForgedPosition(GamePlayer player)
        {
            using (GSUDPPacketOut pak = new GSUDPPacketOut(GetPacketCode(eServerPackets.PlayerPosition)))
            {
                // PID
                pak.WriteShort((ushort)player.Client.SessionID);

                // Write Speed
                if (player.Steed != null && player.Steed.ObjectState == GameObject.eObjectState.Active)
                {
                    player.Heading = player.Steed.Heading;
                    pak.WriteShort(0x1800);
                }
                else
                {
                    short rSpeed = player.CurrentSpeed;
                    if (player.IsIncapacitated)
                    {
                        rSpeed = 0;
                    }

                    ushort content;
                    if (rSpeed < 0)
                    {
                        content = (ushort)((Math.Abs(rSpeed) > 511 ? 511 : Math.Abs(rSpeed)) + 0x200);
                    }
                    else
                    {
                        content = (ushort)(rSpeed > 511 ? 511 : rSpeed);
                    }

                    if (!player.IsAlive)
                    {
                        content += 5 << 10;
                    }
                    else
                    {
                        ushort state = 0;

                        if (player.IsSwimming)
                        {
                            state = 1;
                        }

                        if (player.IsClimbing)
                        {
                            state = 7;
                        }

                        if (player.IsSitting)
                        {
                            state = 4;
                        }

                        content += (ushort)(state << 10);
                    }

                    content += (ushort)(player.IsStrafing ? 1 << 13 : 0 << 13);

                    pak.WriteShort(content);
                }

                // Get Off Corrd
                var offX = player.Position.X - player.CurrentZone.XOffset;
                var offY = player.Position.Y - player.CurrentZone.YOffset;

                pak.WriteShort((ushort)player.Position.Z);
                pak.WriteShort((ushort)offX);
                pak.WriteShort((ushort)offY);

                // Write Zone
                pak.WriteShort(player.CurrentZone.ZoneSkinID);

                // Copy Heading && Falling or Write Steed
                if (player.Steed != null && player.Steed.ObjectState == GameObject.eObjectState.Active)
                {
                    pak.WriteShort((ushort)player.Steed.ObjectID);
                    pak.WriteShort((ushort)player.Steed.RiderSlot(player));
                }
                else
                {
                    // Set Player always on ground, this is an "anti lag" packet
                    ushort contenthead = (ushort)(player.Heading + (true ? 0x1000 : 0));
                    pak.WriteShort(contenthead);
                    // No Fall Speed.
                    pak.WriteShort(0);
                }

                // Write Flags
                byte flagcontent = 0;

                if (player.IsDiving)
                {
                    flagcontent += 0x04;
                }

                if (player.IsWireframe)
                {
                    flagcontent += 0x01;
                }

                if (player.IsStealthed)
                {
                    flagcontent += 0x02;
                }

                if (player.IsTorchLighted)
                {
                    flagcontent += 0x80;
                }

                pak.WriteByte(flagcontent);

                // Write health + Attack
                byte healthcontent = (byte)(player.HealthPercent + (player.AttackState ? 0x80 : 0));

                pak.WriteByte(healthcontent);

                SendUDP(pak);
            }

            // Update Cache
            m_gameClient.GameObjectUpdateArray[new Tuple <ushort, ushort>(player.CurrentRegionID, (ushort)player.ObjectID)] = GameTimer.GetTickCount();
        }
Esempio n. 55
0
 public override bool IsCompleted(GamePlayer player)
 {
     return(base.Value <= 0);
 }
Esempio n. 56
0
 public ArtifactQuest(GamePlayer questingPlayer)
     : base(questingPlayer)
 {
 }
Esempio n. 57
0
		/// <summary>
		/// This thread updates the NPCs and objects around the player at very short
		/// intervalls! But since the update is very quick the thread will
		/// sleep most of the time!
		/// </summary>
		public static void WorldUpdateThreadStart()
		{
			// Tasks Collection of running Player updates, with starting time.
			var clientsUpdateTasks = new Dictionary<GameClient, Tuple<long, Task, Region>>();
			
			bool running = true;
			
			if (log.IsInfoEnabled)
			{
				log.InfoFormat("World Update Thread Starting - ThreadId = {0}", Thread.CurrentThread.ManagedThreadId);
			}
			
			while (running)
			{
				try
				{
					// Start Time of the loop
					long begin = GameTimer.GetTickCount();
					
					// Get All Clients
					var clients = WorldMgr.GetAllClients();
					
					// Clean Tasks Dict on Client Exiting.
					foreach(GameClient cli in clientsUpdateTasks.Keys.ToArray())
					{
						if (cli == null)
							continue;
						
						GamePlayer player = cli.Player;
						
						bool notActive = cli.ClientState != GameClient.eClientState.Playing || player == null || player.ObjectState != GameObject.eObjectState.Active;
						bool notConnected = !clients.Contains(cli);
						
						if (notConnected || (notActive && IsTaskCompleted(cli, clientsUpdateTasks)))
						{
							clientsUpdateTasks.Remove(cli);
							cli.GameObjectUpdateArray.Clear();
							cli.HouseUpdateArray.Clear();
						}
					}
					
					// Browse all clients to check if they can be updated.
					for (int cl = 0; cl < clients.Count; cl++)
					{
						GameClient client = clients[cl];
						
						// Check that client is healthy
						if (client == null)
							continue;

						GamePlayer player = client.Player;
						
						if (client.ClientState == GameClient.eClientState.Playing && player == null)
						{
							if (log.IsErrorEnabled)
								log.Error("account has no active player but is playing, disconnecting! => " + client.Account.Name);
							
							// Disconnect buggy Client
							GameServer.Instance.Disconnect(client);
							continue;
						}
						
						// Check that player is active.
						if (client.ClientState != GameClient.eClientState.Playing || player == null || player.ObjectState != GameObject.eObjectState.Active)
							continue;
						
						// Start Update Task
						StartPlayerUpdateTask(client, clientsUpdateTasks, begin);
					}
					
					long took = GameTimer.GetTickCount() - begin;
					
					if (took >= 500)
					{
						if (log.IsWarnEnabled)
							log.WarnFormat("World Update Thread (NPC/Object update) took {0} ms", took);
					}

					// relaunch update thread every 100 ms to check if any player need updates.
					Thread.Sleep((int)Math.Max(1, 100 - took));
				}
				catch (ThreadAbortException)
				{
					if (log.IsInfoEnabled)
						log.Info("World Update Thread stopping...");
					
					running = false;
					break;
				}
				catch (Exception e)
				{
					if (log.IsErrorEnabled)
						log.Error("Error in World Update (NPC/Object Update) Thread!", e);
				}
			}
		}
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int gold           = 0;
            int money          = 0;
            int offer          = 0;
            int gifttoken      = 0;
            int totalGold      = 0;
            int totalMoney     = 0;
            int totalOffer     = 0;
            int totalGifttoken = 0;
            List <ItemJoinShopInfo> itemPrice = new List <ItemJoinShopInfo>();
            int             GroupID           = packet.ReadInt();
            eMessageType    eMsg     = eMessageType.Normal;
            string          msg      = "UserBuyItemHandler.Success";
            List <ItemInfo> buyItems = new List <ItemInfo>();
            int             result;

            if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                result = 1;
            }
            else
            {
                List <ShopItemInfo> infos = ShopMgr.FindShopByGroupID(GroupID);
                foreach (ShopItemInfo info in infos)
                {
                    ItemInfo item = ShopMgr.CreateItem(info, 102, 1, "", "", true);
                    buyItems.Add(item);
                    ShopMgr.GetShopItemBuyConditions(info, 1, ref gold, ref money, ref offer, ref gifttoken);
                    itemPrice.Add(new ItemJoinShopInfo(info.TemplateID, item.Count, money, gold, gifttoken, offer, ""));
                    totalGold      += gold;
                    totalMoney     += money;
                    totalOffer     += offer;
                    totalGifttoken += gifttoken;
                }
                if (buyItems.Count == 0)
                {
                    result = 1;
                }
                else
                {
                    if (totalGold <= player.PlayerCharacter.Gold && totalMoney <= player.PlayerCharacter.Money && totalOffer <= player.PlayerCharacter.Offer && totalGifttoken <= player.PlayerCharacter.GiftToken)
                    {
                        player.RemoveGold(totalGold);
                        player.RemoveMoney(totalMoney, LogMoneyType.Shop, LogMoneyType.Shop_BuySale);
                        player.RemoveOffer(totalOffer);
                        player.RemoveGiftToken(totalGifttoken);
                        foreach (ItemJoinShopInfo log in itemPrice)
                        {
                            //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_BuySale, player.PlayerCharacter.ID, log.Moneys, log.Gold, log.GiftToken, log.Offer, log.OtherPay, log.TemplateID, 5, log.Data);
                        }
                        List <ItemInfo> remainitems  = new List <ItemInfo>();
                        List <ItemInfo> sendMailItem = new List <ItemInfo>();
                        for (int i = 0; i < buyItems.Count; i++)
                        {
                            if (!player.HideBag.AddItemTo(buyItems[i], buyItems.Count - (i + 1)))
                            {
                                remainitems.Add(buyItems[i]);
                            }
                        }
                        player.StackItem(ref remainitems);
                        foreach (ItemInfo info2 in remainitems)
                        {
                            if (!player.AddItem(info2))
                            {
                                sendMailItem.Add(info2);
                            }
                        }
                        if (sendMailItem.Count > 0)
                        {
                            using (new PlayerBussiness())
                            {
                                string title = "";
                                if (player.SendItemsToMail(sendMailItem, "", title, eMailType.BuyItem))
                                {
                                    player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                                }
                                eMsg = eMessageType.ERROR;
                                msg  = "UserBuyItemHandler.Mail";
                            }
                        }
                        player.OnPaid(totalMoney, totalGold, totalOffer, totalGifttoken, "");
                        player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0]));
                        player.SaveIntoDatabase();
                        result = 0;
                    }
                    else
                    {
                        if (money > player.PlayerCharacter.Money)
                        {
                            player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.Money", new object[0]));
                        }
                        result = 1;
                    }
                }
            }
            return(result);
        }
Esempio n. 59
0
		/// <summary>
		/// Send Housing Items depending on last refresh.
		/// </summary>
		/// <param name="player"></param>
		/// <param name="nowTicks"></param>
		public static void UpdatePlayerHousing(GamePlayer player, long nowTicks)
		{
			// If no house update needed exit.
			if (player.CurrentRegion == null || !player.CurrentRegion.HousingEnabled)
				return;
			
			// Get All House in Region
			IDictionary<int, House> housesDict = HouseMgr.GetHouses(player.CurrentRegionID);
			// Build Vincinity List
			var houses = housesDict.Values.Where(h => h != null && player.IsWithinRadius(h, HousingConstants.HouseViewingDistance)).ToArray();
			
			try
			{
				// Clean Cache
				foreach (var houseEntry in player.Client.HouseUpdateArray)
				{
					var houseKey = houseEntry.Key;
					House house = HouseMgr.GetHouse(houseKey.Item1, houseKey.Item2);
					
					// We have a House in cache that is not in vincinity
					if (!houses.Contains(house) && (nowTicks - houseEntry.Value) >= (GetPlayerHousingUpdateInterval >> 2))
					{
						long dummy;
						player.Client.HouseUpdateArray.TryRemove(houseKey, out dummy);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while Cleaning House cache for Player : {0}, Exception : {1}", player.Name, e);
			}
			
			try
			{
				// Now Send remaining houses
				foreach (House lhouse in houses)
				{
					House house = lhouse;
					
					// Get last update time
					long lastUpdate;
					if (player.Client.HouseUpdateArray.TryGetValue(new Tuple<ushort, ushort>(house.RegionID, (ushort)house.HouseNumber), out lastUpdate))
					{
						// This House Needs Update
						if ((nowTicks - lastUpdate) >= GetPlayerHousingUpdateInterval)
						{
							player.Client.Out.SendHouseOccupied(house, house.IsOccupied);							
						}
					}
					else
					{
						// Not in cache, House entering in range !
						player.Client.Out.SendHouse(house);
						player.Client.Out.SendGarden(house);
						player.Client.Out.SendHouseOccupied(house, house.IsOccupied);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while updating Houses for Player : {0}, Exception : {1}", player.Name, e);
			}
		}
Esempio n. 60
0
 public override void RemoveTrigger(GamePlayer player)
 {
     player.AfterKillingLiving -= new GamePlayer.PlayerGameKillEventHandel(this.player_AfterKillingLiving);
 }