예제 #1
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;
        }
예제 #2
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);
        }