Esempio n. 1
0
        protected virtual void LoadHookPoints()
        {
            if (!ServerProperties.Properties.LOAD_KEEPS || !ServerProperties.Properties.LOAD_HOOKPOINTS)
            {
                return;
            }

            Dictionary <string, List <DBKeepHookPoint> > hookPointList = new Dictionary <string, List <DBKeepHookPoint> >();

            var dbkeepHookPoints = GameServer.Database.SelectAllObjects <DBKeepHookPoint>();

            foreach (DBKeepHookPoint dbhookPoint in dbkeepHookPoints)
            {
                List <DBKeepHookPoint> currentArray;
                string key = dbhookPoint.KeepComponentSkinID + "H:" + dbhookPoint.Height;
                if (!hookPointList.ContainsKey(key))
                {
                    hookPointList.Add(key, currentArray = new List <DBKeepHookPoint>());
                }
                else
                {
                    currentArray = hookPointList[key];
                }
                currentArray.Add(dbhookPoint);
            }
            foreach (AbstractGameKeep keep in m_keepList.Values)
            {
                foreach (GameKeepComponent component in keep.KeepComponents)
                {
                    string key = component.Skin + "H:" + component.Height;
                    if ((hookPointList.ContainsKey(key)))
                    {
                        List <DBKeepHookPoint> HPlist = hookPointList[key];
                        if ((HPlist != null) && (HPlist.Count != 0))
                        {
                            foreach (DBKeepHookPoint dbhookPoint in hookPointList[key])
                            {
                                GameKeepHookPoint myhookPoint = new GameKeepHookPoint(dbhookPoint, component);
                                component.HookPoints.Add(dbhookPoint.HookPointID, myhookPoint);
                            }
                            continue;
                        }
                    }
                    //add this to keep hookpoint system until DB is not full
                    for (int i = 0; i < 38; i++)
                    {
                        component.HookPoints.Add(i, new GameKeepHookPoint(i, component));
                    }

                    component.HookPoints.Add(65, new GameKeepHookPoint(0x41, component));
                    component.HookPoints.Add(97, new GameKeepHookPoint(0x61, component));
                    component.HookPoints.Add(129, new GameKeepHookPoint(0x81, component));
                }
            }

            log.Info("Loading HookPoint items");

            //fill existing hookpoints with objects
            IList <DBKeepHookPointItem> items = GameServer.Database.SelectAllObjects <DBKeepHookPointItem>();

            foreach (AbstractGameKeep keep in m_keepList.Values)
            {
                foreach (var component in keep.KeepComponents)
                {
                    foreach (var hp in component.HookPoints.Values)
                    {
                        var item = items.FirstOrDefault(
                            it => it.KeepID == component.Keep.KeepID && it.ComponentID == component.ID && it.HookPointID == hp.ID);
                        if (item != null)
                        {
                            HookPointItem.Invoke(component.HookPoints[hp.ID], item.ClassType);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
		protected virtual void LoadHookPoints()
		{
			if (!ServerProperties.Properties.LOAD_KEEPS || !ServerProperties.Properties.LOAD_HOOKPOINTS)
				return;

			Dictionary<string, List<DBKeepHookPoint>> hookPointList = new Dictionary<string, List<DBKeepHookPoint>>();

			var dbkeepHookPoints = GameServer.Database.SelectAllObjects<DBKeepHookPoint>();
			foreach (DBKeepHookPoint dbhookPoint in dbkeepHookPoints)
			{
				List<DBKeepHookPoint> currentArray;
				string key = dbhookPoint.KeepComponentSkinID + "H:" + dbhookPoint.Height;
				if (!hookPointList.ContainsKey(key))
					hookPointList.Add(key, currentArray = new List<DBKeepHookPoint>());
				else
					currentArray = hookPointList[key];
				currentArray.Add(dbhookPoint);
			}
			foreach (AbstractGameKeep keep in m_keepList.Values)
			{
				foreach (GameKeepComponent component in keep.KeepComponents)
				{
					string key = component.Skin + "H:" + component.Height;
					if ((hookPointList.ContainsKey(key)))
					{
						List<DBKeepHookPoint> HPlist = hookPointList[key];
						if ((HPlist != null) && (HPlist.Count != 0))
						{
							foreach (DBKeepHookPoint dbhookPoint in hookPointList[key])
							{
								GameKeepHookPoint myhookPoint = new GameKeepHookPoint(dbhookPoint, component);
								component.KeepHookPoints.Add(dbhookPoint.HookPointID, myhookPoint);
							}
							continue;
						}
					}
					//add this to keep hookpoint system until DB is not full
					for (int i = 0; i < 38; i++)
						component.KeepHookPoints.Add(i, new GameKeepHookPoint(i, component));

					component.KeepHookPoints.Add(65, new GameKeepHookPoint(0x41, component));
					component.KeepHookPoints.Add(97, new GameKeepHookPoint(0x61, component));
					component.KeepHookPoints.Add(129, new GameKeepHookPoint(0x81, component));
				}
			}

			log.Info("Loading HookPoint items");

			//fill existing hookpoints with objects
			IList<DBKeepHookPointItem> items = GameServer.Database.SelectAllObjects<DBKeepHookPointItem>();
			foreach (AbstractGameKeep keep in m_keepList.Values)
			{
				foreach (GameKeepComponent component in keep.KeepComponents)
				{
					foreach (GameKeepHookPoint hp in component.KeepHookPoints.Values)
					{
						var item = items.FirstOrDefault(
							it => it.KeepID == component.AbstractKeep.KeepID && it.ComponentID == component.ID && it.HookPointID == hp.ID);
						if (item != null)
							HookPointItem.Invoke(component.KeepHookPoints[hp.ID] as GameKeepHookPoint, item.ClassType);
					}
				}
			}
		}
Esempio n. 3
0
 public HookpointTimer(GameKeepHookPoint hookpoint, GameKeepComponent component)
     : base(component)
 {
     m_hookpoint = hookpoint;
 }
        /// <summary>
        /// This method is important, because players could fall through air
        /// if they are on the top of a keep when it is captured because
        /// the keep size will reset
        /// </summary>
        protected void ResetPlayersOfKeep()
        {
            ushort distance = 0;
            int    id       = 0;

            if (this is GameKeepTower)
            {
                distance = 750;
                id       = 11;
            }
            else
            {
                distance = 1500;
                id       = 10;
            }


            GameKeepComponent component = null;

            foreach (GameKeepComponent c in this.KeepComponents)
            {
                if (c.Skin == id)
                {
                    component = c;
                    break;
                }
            }
            if (component == null)
            {
                return;
            }

            GameKeepHookPoint hookpoint = component.KeepHookPoints[97] as GameKeepHookPoint;

            if (hookpoint == null)
            {
                return;
            }

            //calculate target height
            int height = GameServer.KeepManager.GetHeightFromLevel(this.Level);

            //predict Z
            DBKeepHookPoint hp = GameServer.Database.SelectObjects <DBKeepHookPoint>("`HookPointID` = @HookPointID AND `Height` = @Height",
                                                                                     new[] { new QueryParameter("@HookPointID", 97), new QueryParameter("@Height", height) }).FirstOrDefault();

            if (hp == null)
            {
                return;
            }
            int z = component.Z + hp.Z;

            foreach (GamePlayer player in component.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                int d = hookpoint.GetDistance(player as IPoint2D);
                if (d > distance)
                {
                    continue;
                }

                if (player.Z > z)
                {
                    player.MoveTo(player.CurrentRegionID, player.X, player.Y, z, player.Heading);
                }
            }
        }
Esempio n. 5
0
		public HookpointTimer(GameKeepHookPoint hookpoint, GameKeepComponent component)
			: base(component)
		{
			m_hookpoint = hookpoint;
		}
Esempio n. 6
0
        public static void Invoke(GameKeepHookPoint hookpoint, string objectType)
        {
            if (!hookpoint.IsFree)
            {
                return;
            }

            GameLiving hookPointObj = CreateHPInstance(objectType);

            if (hookPointObj == null)
            {
                return;
            }

            //use default value so no need to load
            //hookPointObj.LoadFromDatabase(this.ObjectTemplate);
            hookPointObj.CurrentRegion = hookpoint.Component.CurrentRegion;
            hookPointObj.Realm         = hookpoint.Component.AbstractKeep.Realm;

            if (hookPointObj is GameSiegeWeapon)
            {
                ((GameSiegeWeapon)hookPointObj).EnableToMove = false;
            }

            hookPointObj.X       = hookpoint.X;
            hookPointObj.Y       = hookpoint.Y;
            hookPointObj.Z       = hookpoint.Z;
            hookPointObj.Heading = hookpoint.Heading;

            if (hookPointObj is GameSiegeWeapon)
            {
                (hookPointObj as GameSiegeWeapon).HookPoint = hookpoint;
            }
            if (hookPointObj is IKeepItem)
            {
                (hookPointObj as IKeepItem).Component = hookpoint.Component;
            }
            if (hookPointObj is GameSiegeCauldron)
            {
                (hookPointObj as GameSiegeCauldron).Component = hookpoint.Component;
            }
            if (hookPointObj is GameKeepGuard)
            {
                (hookPointObj as GameKeepGuard).HookPoint = hookpoint;
                Keeps.TemplateMgr.RefreshTemplate(hookPointObj as GameKeepGuard);
            }

            if (ServerProperties.Properties.ENABLE_DEBUG)
            {
                hookPointObj.Name += " hookpoint " + hookpoint.ID.ToString();
            }

            if (hookPointObj is GameNPC)
            {
                ((GameNPC)hookPointObj).RespawnInterval = -1;                //do not respawn
            }
            hookPointObj.AddToWorld();
            if (hookPointObj is GuardLord lord)
            {
                lord.Component.AbstractKeep.Guards.Add(hookPointObj.ObjectID.ToString(), lord);
                lord.RespawnInterval = 60 * 1000;
            }
            else if (hookPointObj is GameKeepGuard guard)
            {
                guard.Component.AbstractKeep.Guards.Add(hookPointObj.ObjectID.ToString(), guard);
                guard.RespawnInterval = Util.Random(60, 120) * 60 * 1000;
            }
            hookpoint.Object = hookPointObj;
        }
Esempio n. 7
0
		public override void SendHookPointStore(GameKeepHookPoint hookPoint)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.KeepComponentHookpointStore)))
			{

				pak.WriteShort((ushort)hookPoint.Component.AbstractKeep.KeepID);
				pak.WriteShort((ushort)hookPoint.Component.ID);
				pak.WriteShort((ushort)hookPoint.ID);
				pak.Fill(0x01, 3);
				HookPointInventory inventory;
				if (hookPoint.ID > 0x80) inventory = HookPointInventory.YellowHPInventory; //oil
				else if (hookPoint.ID > 0x60) inventory = HookPointInventory.GreenHPInventory;//big siege
				else if (hookPoint.ID > 0x40) inventory = HookPointInventory.LightGreenHPInventory; //small siege
				else if (hookPoint.ID > 0x20) inventory = HookPointInventory.BlueHPInventory;//npc
				else inventory = HookPointInventory.RedHPInventory;//guard
	
				pak.WriteByte((byte)inventory.GetAllItems().Count);//count
				pak.WriteShort(0);
				int i = 0;
				foreach (HookPointItem item in inventory.GetAllItems())
				{
					//TODO : must be quite like the merchant item.
					//the problem is to change how it is done maybe make the hookpoint item inherit from an interface in common with itemtemplate. have to think to that.
					pak.WriteByte((byte)i);
					i++;
					if (item.GameObjectType == "GameKeepGuard")//TODO: hack wrong must think how design thing to have merchante of gameobject(living or item)
						pak.WriteShort(0);
					else
						pak.WriteShort(item.Flag);
					pak.WriteShort(0);
					pak.WriteShort(0);
					pak.WriteShort(0);
					pak.WriteInt((uint)item.Gold);
					pak.WriteShort(item.Icon);
					pak.WritePascalString(item.Name);//item sell
				}
				SendTCP(pak);
			}
		}
Esempio n. 8
0
        public void Invoke(GamePlayer player, int payType, GameKeepHookPoint hookpoint, GameKeepComponent component)
        {
            if (!hookpoint.IsFree)
            {
                player.Out.SendMessage("The hookpoint is already used!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                return;
            }
            //1=or 2=BP 3=GuildBP 4=contract
            //todo enum
            switch (payType)
            {
            case 1:
            {
                if (!player.RemoveMoney(Gold * 100 * 100, "You buy " + this.GetName(1, false) + "."))
                {
                    InventoryLogging.LogInventoryAction(player, "(keep)", eInventoryActionType.Merchant, Gold * 10000);
                    player.Out.SendMessage("You dont have enough money!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                    return;
                }
            } break;

            case 2:
            {
                if (!player.RemoveBountyPoints(Gold, "You buy " + this.GetName(1, false) + "."))
                {
                    player.Out.SendMessage("You dont have enough bounty point!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                    return;
                }
            } break;

            case 3:
            {
                if (player.Guild == null)
                {
                    return;
                }
                if (!player.Guild.RemoveBountyPoints(Gold))
                {
                    player.Out.SendMessage("You dont have enough bounty point!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                    return;
                }
                else
                {
                    player.Out.SendMessage("You buy " + this.GetName(1, false) + ".", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                }
            } break;

            case 4:
            {
                player.Out.SendMessage("NOT IMPLEMENTED YET, SORRY", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                return;
            }
            }

            GameLiving hookPointObj = CreateHPInstance(this.GameObjectType);

            if (hookPointObj == null)
            {
                return;
            }
            //use default value so no need to load
            //hookPointObj.LoadFromDatabase(this.ObjectTemplate);
            hookPointObj.CurrentRegion = player.CurrentRegion;
            hookPointObj.Realm         = hookpoint.Component.AbstractKeep.Realm;

            if (hookPointObj is GameSiegeWeapon)
            {
                ((GameSiegeWeapon)hookPointObj).EnableToMove = false;
            }
            hookPointObj.X       = hookpoint.X;
            hookPointObj.Y       = hookpoint.Y;
            hookPointObj.Z       = hookpoint.Z;
            hookPointObj.Heading = hookpoint.Heading;

            if (hookPointObj is GameSiegeWeapon)
            {
                (hookPointObj as GameSiegeWeapon).HookPoint = hookpoint;
            }
            if (hookPointObj is IKeepItem)
            {
                (hookPointObj as IKeepItem).Component = component;
            }
            if (hookPointObj is GameSiegeCauldron)
            {
                (hookPointObj as GameSiegeCauldron).Component = component;
            }
            if (hookPointObj is GameKeepGuard)
            {
                (hookPointObj as GameKeepGuard).HookPoint = hookpoint;
                Keeps.TemplateMgr.RefreshTemplate(hookPointObj as GameKeepGuard);
            }
            if (hookPointObj is GameNPC)
            {
                ((GameNPC)hookPointObj).RespawnInterval = -1;                //do not respawn
            }
            hookPointObj.AddToWorld();
            if (hookPointObj is GuardLord lord)
            {
                lord.Component.AbstractKeep.Guards.Add(hookPointObj.ObjectID.ToString(), lord);
                lord.RespawnInterval = 60 * 1000;
            }
            else if (hookPointObj is GameKeepGuard guard)
            {
                guard.Component.AbstractKeep.Guards.Add(hookPointObj.ObjectID.ToString(), guard);
                guard.RespawnInterval = Util.Random(60, 120) * 60 * 1000;
            }

            hookpoint.Object = hookPointObj;

            //create the db entry
            Database.DBKeepHookPointItem item = new DOL.Database.DBKeepHookPointItem(component.AbstractKeep.KeepID, component.ID, hookpoint.ID, GameObjectType);
            GameServer.Database.AddObject(item);
        }
Esempio n. 9
0
		public virtual void SendHookPointStore(GameKeepHookPoint hookPoint)
		{
		}
Esempio n. 10
0
		public static void Invoke(GameKeepHookPoint hookpoint, string objectType)
		{
			if (!hookpoint.IsFree)
				return;

			GameLiving hookPointObj = CreateHPInstance(objectType);
			if (hookPointObj == null) return;

			//use default value so no need to load
			//hookPointObj.LoadFromDatabase(this.ObjectTemplate);
			hookPointObj.CurrentRegion = hookpoint.Component.CurrentRegion;
			hookPointObj.Realm = hookpoint.Component.Keep.Realm;

			if (hookPointObj is GameSiegeWeapon)
				((GameSiegeWeapon)hookPointObj).EnableToMove = false;

			hookPointObj.X = hookpoint.X;
			hookPointObj.Y = hookpoint.Y;
			hookPointObj.Z = hookpoint.Z;
			hookPointObj.Heading = hookpoint.Heading;

			if (hookPointObj is GameSiegeWeapon)
				(hookPointObj as GameSiegeWeapon).HookPoint = hookpoint;
			if (hookPointObj is IKeepItem)
				(hookPointObj as IKeepItem).Component = hookpoint.Component;
			if (hookPointObj is GameSiegeCauldron)
				(hookPointObj as GameSiegeCauldron).Component = hookpoint.Component;
			if (hookPointObj is GameKeepGuard)
			{
				(hookPointObj as GameKeepGuard).HookPoint = hookpoint;
				Keeps.TemplateMgr.RefreshTemplate(hookPointObj as GameKeepGuard);
			}

			if (ServerProperties.Properties.ENABLE_DEBUG)
				hookPointObj.Name += " hookpoint " + hookpoint.ID.ToString();

			if (hookPointObj is GameNPC)
			{
				((GameNPC)hookPointObj).RespawnInterval = -1;//do not respawn
			}
			hookPointObj.AddToWorld();
			if (hookPointObj is GameKeepGuard)
			{
				(hookPointObj as GameKeepGuard).Component.Keep.Guards.Add(hookPointObj.ObjectID, hookPointObj);
				((GameNPC)hookPointObj).RespawnInterval = Util.Random(10, 30) * 60 * 1000;
			}
			hookpoint.Object = hookPointObj;
		}
Esempio n. 11
0
		public void Invoke(GamePlayer player, int payType, GameKeepHookPoint hookpoint, GameKeepComponent component)
		{
			if (!hookpoint.IsFree)
			{
				player.Out.SendMessage("The hookpoint is already used!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
				return;
			}
			//1=or 2=BP 3=GuildBP 4=contract
			//todo enum
			switch (payType)
			{
				case 1:
					{
						if (!player.RemoveMoney(Gold * 100 * 100, "You buy " + this.GetName(1, false) + "."))
						{
                            InventoryLogging.LogInventoryAction(player, "(keep)", eInventoryActionType.Merchant, Gold * 10000);
							player.Out.SendMessage("You dont have enough money!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
							return;
						}
					} break;
				case 2:
					{
						if (!player.RemoveBountyPoints(Gold, "You buy " + this.GetName(1, false) + "."))
						{
							player.Out.SendMessage("You dont have enough bounty point!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
							return;
						}
					} break;
				case 3:
					{
						if (player.Guild == null) return;
						if (!player.Guild.RemoveBountyPoints(Gold))
						{
							player.Out.SendMessage("You dont have enough bounty point!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
							return;
						}
						else
							player.Out.SendMessage("You buy " + this.GetName(1, false) + ".", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);

					} break;
				case 4:
					{
						player.Out.SendMessage("NOT IMPLEMENTED YET, SORRY", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
						return;
					}

			}

			GameLiving hookPointObj = CreateHPInstance(this.GameObjectType);
			if (hookPointObj == null) return;
			//use default value so no need to load
			//hookPointObj.LoadFromDatabase(this.ObjectTemplate);
			hookPointObj.CurrentRegion = player.CurrentRegion;
			hookPointObj.Realm = hookpoint.Component.Keep.Realm;

			if (hookPointObj is GameSiegeWeapon)
				((GameSiegeWeapon)hookPointObj).EnableToMove = false;
			hookPointObj.X = hookpoint.X;
			hookPointObj.Y = hookpoint.Y;
			hookPointObj.Z = hookpoint.Z;
			hookPointObj.Heading = hookpoint.Heading;

			if (hookPointObj is GameSiegeWeapon)
				(hookPointObj as GameSiegeWeapon).HookPoint = hookpoint;
			if (hookPointObj is IKeepItem)
				(hookPointObj as IKeepItem).Component = component;
			if (hookPointObj is GameSiegeCauldron)
				(hookPointObj as GameSiegeCauldron).Component = component;
			if (hookPointObj is GameKeepGuard)
			{
				(hookPointObj as GameKeepGuard).HookPoint = hookpoint;
				Keeps.TemplateMgr.RefreshTemplate(hookPointObj as GameKeepGuard);
			}
			if (hookPointObj is GameNPC)
			{
				((GameNPC)hookPointObj).RespawnInterval = -1;//do not respawn
			}
			hookPointObj.AddToWorld();
			if (hookPointObj is GameKeepGuard)
			{
				(hookPointObj as GameKeepGuard).Component.Keep.Guards.Add(hookPointObj.ObjectID, hookPointObj);
				((GameNPC)hookPointObj).RespawnInterval = Util.Random(10, 30) * 60 * 1000;
			}
			hookpoint.Object = hookPointObj;

			//create the db entry
			Database.DBKeepHookPointItem item = new DOL.Database.DBKeepHookPointItem(component.Keep.KeepID, component.ID, hookpoint.ID, GameObjectType);
			GameServer.Database.AddObject(item);
		}
Esempio n. 12
0
		public void SendHookPointStore(GameKeepHookPoint hookPoint)
		{
			if (SendHookPointStoreMethod != null) SendHookPointStoreMethod(this, hookPoint);
		}