Exemple #1
0
        /// <summary>
        /// Called when the living is about to get an item from someone
        /// else
        /// </summary>
        /// <param name="source">Source from where to get the item</param>
        /// <param name="item">Item to get</param>
        /// <returns>true if the item was successfully received</returns>
        public override bool ReceiveItem(GameLiving source, InventoryItem item)
        {
            if (source == null || item == null)
            {
                return(false);
            }

            if (source is GamePlayer)
            {
                GamePlayer player = (GamePlayer)source;

                if (item.Item_Type == 40 && isItemInMerchantList(item))
                {
                    PathPoint path = MovementMgr.LoadPath(item.Id_nb);

                    if ((path != null) && ((Math.Abs(path.X - this.X)) < 500) && ((Math.Abs(path.Y - this.Y)) < 500))
                    {
                        player.Inventory.RemoveCountFromStack(item, 1);
                        InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, item.Template);

                        GameTaxi mount;

                        // item.Color of ticket is used for npctemplate. defaults to standard horse if item.color is 0
                        if (item.Color > 0)
                        {
                            mount = new GameTaxi(NpcTemplateMgr.GetTemplate(item.Color));
                        }
                        else
                        {
                            mount = new GameTaxi();

                            foreach (GameNPC npc in GetNPCsInRadius(400))
                            {
                                if (npc.Name == LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "GameStableMaster.ReceiveItem.HorseName"))
                                {
                                    mount.Model = npc.Model;
                                    mount.Name  = npc.Name;
                                    break;
                                }
                            }
                        }

                        switch ((eRace)player.Race)
                        {
                        case eRace.Lurikeen:
                            mount.Size = 31;
                            break;

                        case eRace.Kobold:
                            mount.Size = 38;
                            break;

                        case eRace.Dwarf:
                            mount.Size = 42;
                            break;

                        case eRace.Inconnu:
                            mount.Size = 45;
                            break;

                        case eRace.Frostalf:
                        case eRace.Shar:
                            mount.Size = 48;
                            break;

                        case eRace.Briton:
                        case eRace.Saracen:
                        case eRace.Celt:
                            mount.Size = 50;
                            break;

                        case eRace.Valkyn:
                            mount.Size = 52;
                            break;

                        case eRace.Avalonian:
                        case eRace.Highlander:
                        case eRace.Norseman:
                        case eRace.Elf:
                        case eRace.Sylvan:
                            mount.Size = 55;
                            break;

                        case eRace.Firbolg:
                            mount.Size = 62;
                            break;

                        case eRace.HalfOgre:
                        case eRace.AlbionMinotaur:
                        case eRace.MidgardMinotaur:
                        case eRace.HiberniaMinotaur:
                            mount.Size = 65;
                            break;

                        case eRace.Troll:
                            mount.Size = 67;
                            break;

                        default:
                            mount.Size = 55;
                            break;
                        }

                        mount.Realm         = source.Realm;
                        mount.X             = path.X;
                        mount.Y             = path.Y;
                        mount.Z             = path.Z;
                        mount.CurrentRegion = CurrentRegion;
                        mount.Heading       = path.GetHeading(path.Next);
                        mount.AddToWorld();
                        mount.CurrentWayPoint = path;
                        GameEventMgr.AddHandler(mount, GameNPCEvent.PathMoveEnds, new DOLEventHandler(OnHorseAtPathEnd));
                        new MountHorseAction(player, mount).Start(400);
                        new HorseRideAction(mount).Start(4000);
                        return(true);
                    }
                }
                else
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameStableMaster.Receive.UnknownWay"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
            }
            return(false);
        }
Exemple #2
0
		/// <summary>
		/// Called when the living is about to get an item from someone
		/// else
		/// </summary>
		/// <param name="source">Source from where to get the item</param>
		/// <param name="item">Item to get</param>
		/// <returns>true if the item was successfully received</returns>
		public override bool ReceiveItem(GameLiving source, InventoryItem item)
		{
			if (source == null || item == null) return false;

			if (source is GamePlayer)
			{
				GamePlayer player = (GamePlayer)source;

				if (item.Item_Type == 40 && isItemInMerchantList(item))
				{
					PathPoint path = MovementMgr.LoadPath(item.Id_nb);

					if ((path != null) && ((Math.Abs(path.X - this.X)) < 500) && ((Math.Abs(path.Y - this.Y)) < 500))
					{
						player.Inventory.RemoveCountFromStack(item, 1);
                        InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, item.Template);

						GameTaxi mount;
						
						// item.Color of ticket is used for npctemplate. defaults to standard horse if item.color is 0
						if (item.Color > 0)
						{
							mount = new GameTaxi(NpcTemplateMgr.GetTemplate(item.Color));
						}
						else
						{
                            mount = new GameTaxi();

                            foreach (GameNPC npc in GetNPCsInRadius(400))
                            { 
                                if (npc.Name == LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "GameStableMaster.ReceiveItem.HorseName"))
                                {
                                    mount.Model = npc.Model;
                                    mount.Name = npc.Name;
                                    break;
                                }
                            }
						}
						
						switch ((eRace)player.Race)
						{
							case eRace.Lurikeen:
								mount.Size = 31;
								break;
							case eRace.Kobold:
								mount.Size = 38;
								break;
							case eRace.Dwarf:
								mount.Size = 42;
								break;
							case eRace.Inconnu:
								mount.Size = 45;
								break;
							case eRace.Frostalf:
							case eRace.Shar:
								mount.Size = 48;
								break;
							case eRace.Briton:
							case eRace.Saracen:
							case eRace.Celt:
								mount.Size = 50;
								break;
							case eRace.Valkyn:
								mount.Size = 52;
								break;
							case eRace.Avalonian:
							case eRace.Highlander:
							case eRace.Norseman:
							case eRace.Elf:
							case eRace.Sylvan:
								mount.Size = 55;
								break;
							case eRace.Firbolg:
								mount.Size=62;
								break;
							case eRace.HalfOgre:
							case eRace.AlbionMinotaur:
							case eRace.MidgardMinotaur:
							case eRace.HiberniaMinotaur:
								mount.Size = 65;
								break;
							case eRace.Troll:
								mount.Size = 67;
								break;
							default:
								mount.Size = 55;
								break;
						}

						mount.Realm = source.Realm;
						mount.X = path.X;
						mount.Y = path.Y;
						mount.Z = path.Z;
						mount.CurrentRegion = CurrentRegion;
						mount.Heading = path.GetHeading( path.Next );
						mount.AddToWorld();
						mount.CurrentWayPoint = path;
						GameEventMgr.AddHandler(mount, GameNPCEvent.PathMoveEnds, new DOLEventHandler(OnHorseAtPathEnd));
						new MountHorseAction(player, mount).Start(400);
						new HorseRideAction(mount).Start(4000);
						return true;
					}
				}
				else
				{
					player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameStableMaster.ReceiveItem.UnknownWay"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
				}
			}
			return false;
		}