public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
        {
            m_templateID = pos.TemplateID;
            m_component  = component;
            BannerType   = (eBannerType)pos.TemplateType;

            PositionMgr.LoadKeepItemPosition(pos, this);
            component.AbstractKeep.Banners[m_templateID] = this;
            if (BannerType == eBannerType.Guild)
            {
                if (component.AbstractKeep.Guild != null)
                {
                    ChangeGuild();
                    Z += 1500;
                    this.AddToWorld();
                }
            }
            else
            {
                ChangeRealm();
                Z += 1000;                      // this works around an issue where all banners are at keep level instead of on top
                // with a z value > height of the keep the banners show correctly - tolakram
                this.AddToWorld();
            }
        }
Exemplo n.º 2
0
        public static void LoadGuardPosition(DBKeepPosition pos, GameKeepGuard guard)
        {
            LoadKeepItemPosition(pos, guard);

            guard.SpawnPoint   = guard.Position;
            guard.SpawnHeading = guard.Heading;
        }
Exemplo n.º 3
0
        public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
        {
            m_templateID = pos.TemplateID;
            m_component  = component;

            PositionMgr.LoadKeepItemPosition(pos, this);
            component.AbstractKeep.Doors[m_templateID] = this;

            m_oldMaxHealth     = MaxHealth;
            m_health           = MaxHealth;
            m_name             = "Keep Door";
            m_oldHealthPercent = HealthPercent;
            m_doorID           = GenerateDoorID();
            m_model            = 0xFFFF;
            m_state            = eDoorState.Closed;

            if (AddToWorld())
            {
                StartHealthRegeneration();
                DoorMgr.RegisterDoor(this);
            }
            else
            {
                log.Error("Failed to load keep door from position! DoorID=" + m_doorID + ". Component SkinID=" + component.Skin + ". KeepID=" + component.AbstractKeep.KeepID);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Move a guard to a position
 /// </summary>
 /// <param name="position">The new position for the guard</param>
 public void MoveToPosition(DBKeepPosition position)
 {
     PositionMgr.LoadGuardPosition(position, this);
     if (!InCombat)
     {
         MoveTo(CurrentRegionID, X, Y, Z, Heading);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Move a guard to a position
 /// </summary>
 /// <param name="position">The new position for the guard</param>
 public void MoveToPosition(DBKeepPosition position)
 {
     PositionMgr.LoadGuardPosition(position, this);
     if (!this.InCombat)
     {
         this.MoveTo(this.CurrentRegionID, this.X, this.Y, this.Z, this.Heading);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a position
        /// </summary>
        /// <param name="type"></param>
        /// <param name="height"></param>
        /// <param name="player"></param>
        /// <param name="guardID"></param>
        /// <param name="component"></param>
        /// <returns></returns>
        public static DBKeepPosition CreatePosition(Type type, int height, GamePlayer player, string guardID, GameKeepComponent component)
        {
            DBKeepPosition pos = CreatePosition(guardID, component, player);

            pos.Height    = height;
            pos.ClassType = type.ToString();
            GameServer.Database.AddObject(pos);
            return(pos);
        }
Exemplo n.º 7
0
        public static void LoadGuardPosition(DBKeepPosition pos, GameKeepGuard guard)
        {
            LoadKeepItemPosition(pos, guard);

            guard.SpawnPoint.X = guard.X;
            guard.SpawnPoint.Y = guard.Y;
            guard.SpawnPoint.Z = guard.Z;
            guard.SpawnHeading = guard.Heading;
        }
Exemplo n.º 8
0
 public void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
 {
     m_templateID = pos.TemplateID;
     m_component  = component;
     component.Keep.Guards.Add(m_templateID + component.ID, this);
     PositionMgr.LoadGuardPosition(pos, this);
     RefreshTemplate();
     this.AddToWorld();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a guard patrol position
        /// </summary>
        /// <param name="guardID">The guard ID</param>
        /// <param name="component">The component object</param>
        /// <param name="player">The player object</param>
        /// <returns>The position object</returns>
        public static DBKeepPosition CreatePatrolPosition(string guardID, GameKeepComponent component, GamePlayer player, AbstractGameKeep.eKeepType keepType)
        {
            DBKeepPosition pos = CreatePosition(guardID, component, player);

            pos.Height    = 0;
            pos.ClassType = "DOL.GS.Keeps.Patrol";
            pos.KeepType  = (int)keepType;
            GameServer.Database.AddObject(pos);
            return(pos);
        }
Exemplo n.º 10
0
        public static void CreateDoor(int doorID, GamePlayer player)
        {
            int ownerKeepId = (doorID / 100000) % 1000;
            int towerNum    = (doorID / 10000) % 10;
            int keepID      = ownerKeepId + towerNum * 256;
            int componentID = (doorID / 100) % 100;
            int doorIndex   = doorID % 10;

            AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepID);

            if (keep == null)
            {
                player.Out.SendMessage("Cannot create door as keep is null!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            GameKeepComponent component = null;

            foreach (GameKeepComponent c in keep.KeepComponents)
            {
                if (c.ID == componentID)
                {
                    component = c;
                    break;
                }
            }

            if (component == null)
            {
                player.Out.SendMessage("Cannot create door as component is null!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            DBKeepPosition pos = new DBKeepPosition();

            pos.ClassType         = "DOL.GS.Keeps.GameKeepDoor";
            pos.TemplateType      = doorIndex;
            pos.ComponentSkin     = component.Skin;
            pos.ComponentRotation = component.ComponentHeading;
            pos.TemplateID        = Guid.NewGuid().ToString();
            int x, y;

            SaveXY(component, player.X, player.Y, out x, out y);
            pos.XOff = x;
            pos.YOff = y;

            pos.ZOff = player.Z - component.Z;

            pos.HOff = player.Heading - component.Heading;

            GameServer.Database.AddObject(pos);

            player.Out.SendMessage("Added door as a position to keep.  A server restart will be required to load this position.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
        }
Exemplo n.º 11
0
 public void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
 {
     if (component.Keep.DBKeep.BaseLevel < 50)
     {
         return;
     }
     m_component = component;
     PositionMgr.LoadKeepItemPosition(pos, this);
     this.m_component.Keep.TeleportStone = this;
     this.AddToWorld();
 }
        public void MoveToPosition(DBKeepPosition position)
        {
            PositionMgr.LoadKeepItemPosition(position, this);
            int zAdd = 1000;

            if (BannerType == eBannerType.Guild)
            {
                zAdd = 1500;
            }

            this.MoveTo(this.CurrentRegionID, this.X, this.Y, this.Z + zAdd, this.Heading);
        }
Exemplo n.º 13
0
        public static void LoadKeepItemPosition(DBKeepPosition pos, IKeepItem item)
        {
            item.CurrentRegionID = item.Component.CurrentRegionID;
            int x, y;

            LoadXY(item.Component, pos.XOff, pos.YOff, out x, out y);
            item.Position = new Vector3(x, y, item.Component.Keep.Z + pos.ZOff);

            item.Heading = (ushort)(item.Component.Heading + pos.HOff);

            item.DBPosition = pos;
        }
Exemplo n.º 14
0
        public static void LoadKeepItemPosition(DBKeepPosition pos, IKeepItem item)
        {
            item.CurrentRegionID = item.Component.CurrentRegionID;
            int x, y;

            LoadXY(item.Component, pos.XOff, pos.YOff, out x, out y);
            item.X = x;
            item.Y = y;

            item.Z = item.Component.AbstractKeep.Z + pos.ZOff;

            item.Heading = (ushort)(item.Component.Heading + pos.HOff);

            item.Position = pos;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Load the guard from a position
 /// </summary>
 /// <param name="pos">The position for the guard</param>
 /// <param name="component">The component it is being spawned on</param>
 public void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
 {
     m_templateID = pos.TemplateID;
     m_component  = component;
     component.AbstractKeep.Guards[m_templateID] = this;
     PositionMgr.LoadGuardPosition(pos, this);
     if (Component != null && Component.AbstractKeep != null)
     {
         Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { this });
     }
     else
     {
         TemplateMgr.RefreshTemplate(this);
     }
     this.AddToWorld();
 }
Exemplo n.º 16
0
 public static void AddPosition(DBKeepPosition position)
 {
     foreach (AbstractGameKeep keep in GameServer.KeepManager.GetAllKeeps())
     {
         foreach (GameKeepComponent component in keep.KeepComponents)
         {
             DBKeepPosition[] list = component.Positions[position.TemplateID] as DBKeepPosition[];
             if (list == null)
             {
                 list = new DBKeepPosition[4];
                 component.Positions[position.TemplateID] = list;
             }
             //list.SetValue(position, position.Height);
             list[position.Height] = position;
         }
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Creates a position
        /// </summary>
        /// <param name="templateID">The template ID</param>
        /// <param name="component">The component object</param>
        /// <param name="player">The creating player object</param>
        /// <returns>The position object</returns>
        public static DBKeepPosition CreatePosition(string templateID, GameKeepComponent component, GamePlayer player)
        {
            DBKeepPosition pos = new DBKeepPosition();

            pos.ComponentSkin     = component.Skin;
            pos.ComponentRotation = component.ComponentHeading;
            pos.TemplateID        = templateID;
            int x, y;

            SaveXY(component, player.X, player.Y, out x, out y);
            pos.XOff = x;
            pos.YOff = y;

            pos.ZOff = player.Z - component.Z;

            pos.HOff = player.Heading - component.Heading;
            return(pos);
        }
Exemplo n.º 18
0
        public void DeleteObject()
        {
            if (Component != null)
            {
                if (Component.Keep != null)
                {
                    Component.Keep.Banners.Remove(ObjectID.ToString());
                }

                Component.Delete();
            }

            Component  = null;
            DBPosition = null;

            base.Delete();
            CurrentRegion = null;
        }
        public void DeleteObject()
        {
            if (Component != null)
            {
                if (Component.AbstractKeep != null)
                {
                    Component.AbstractKeep.Banners.Remove(this.ObjectID);
                }

                Component.Delete();
            }

            Component = null;
            Position  = null;

            base.Delete();
            CurrentRegion = null;
        }
Exemplo n.º 20
0
        public virtual void LoadPositions()
        {
            ushort region = CurrentRegionID;

            if (CurrentRegion is BaseInstance)
            {
                region = (CurrentRegion as BaseInstance).Skin;
            }

            Battleground bg = GameServer.KeepManager.GetBattleground(region);

            this.Positions.Clear();

            List <QueryParameter> parameters = new List <QueryParameter>(3);

            parameters.Add(new QueryParameter("@Skin", Skin));
            string query = "`ComponentSkin` = @Skin";

            if (Skin != (int)eComponentSkin.Keep && Skin != (int)eComponentSkin.Tower && Skin != (int)eComponentSkin.Gate)
            {
                parameters.Add(new QueryParameter("@Rotation", ComponentHeading));
                query += " AND `ComponentRotation` = @Rotation";
            }
            if (bg != null && GameServer.Instance.Configuration.ServerType != eGameServerType.GST_PvE)
            {
                // Battlegrounds, ignore all but GameKeepDoor
                parameters.Add(new QueryParameter("@ClassType", "'DOL.GS.Keeps.GameKeepDoor'"));
                query = query + " AND `ClassType` = @ClassType";
            }

            var DBPositions = GameServer.Database.SelectObjects <DBKeepPosition>(query, parameters.ToArray());

            foreach (DBKeepPosition position in DBPositions)
            {
                DBKeepPosition[] list = this.Positions[position.TemplateID] as DBKeepPosition[];
                if (list == null)
                {
                    list = new DBKeepPosition[4];
                    this.Positions[position.TemplateID] = list;
                }

                list[position.Height] = position;
            }
        }
Exemplo n.º 21
0
        public void DeleteObject()
        {
            RemoveTimers();

            if (Component != null)
            {
                if (Component.AbstractKeep != null)
                {
                    Component.AbstractKeep.Doors.Remove(ObjectID);
                }

                Component.Delete();
            }

            Component = null;
            Position  = null;
            base.Delete();
            CurrentRegion = null;
        }
Exemplo n.º 22
0
        public virtual void LoadPositions()
        {
            ushort region = CurrentRegionID;

            if (CurrentRegion is BaseInstance)
            {
                region = (CurrentRegion as BaseInstance).Skin;
            }

            Battleground bg = GameServer.KeepManager.GetBattleground(region);

            Positions.Clear();

            string query = "`ComponentSkin` = '" + Skin + "'";

            if (Skin != (int)eComponentSkin.Keep && Skin != (int)eComponentSkin.Tower && Skin != (int)eComponentSkin.Gate)
            {
                query = query + " AND `ComponentRotation` = '" + ComponentHeading + "'";
            }

            if (bg != null)
            {
                // Battlegrounds, ignore all but GameKeepDoor
                query = query + " AND `ClassType` = 'DOL.GS.Keeps.GameKeepDoor'";
            }

            var DBPositions = GameServer.Database.SelectObjects <DBKeepPosition>(query);

            foreach (DBKeepPosition position in DBPositions)
            {
                DBKeepPosition[] list = Positions[position.TemplateID] as DBKeepPosition[];
                if (list == null)
                {
                    list = new DBKeepPosition[4];
                    Positions[position.TemplateID] = list;
                }

                list[position.Height] = position;
            }
        }
Exemplo n.º 23
0
        public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
        {
            if (pos == null || component == null)
            {
                return;
            }

            m_templateID = pos.TemplateID;
            m_component  = component;
            BannerType   = (eBannerType)pos.TemplateType;

            PositionMgr.LoadKeepItemPosition(pos, this);
            string sKey = this.TemplateID;

            if (component.Keep.Banners.ContainsKey(sKey) == false)
            {
                component.Keep.Banners.Add(sKey, this);
                if (BannerType == eBannerType.Guild)
                {
                    if (component.Keep.Guild != null)
                    {
                        ChangeGuild();
                        Position += Vector3.UnitZ * 1500;
                        this.AddToWorld();
                    }
                }
                else
                {
                    ChangeRealm();
                    Position += Vector3.UnitZ * 1000;                           // this works around an issue where all banners are at keep level instead of on top
                    // with a z value > height of the keep the banners show correctly - tolakram
                    this.AddToWorld();
                }
            }
            else if (log.IsWarnEnabled)
            {
                log.Warn($"LoadFromPosition(): There is already a Banner with TemplateID {this.TemplateID} on KeepID {component.Keep.KeepID}, not adding Banner for KeepPosition_ID {pos.ObjectId} on KeepComponent_ID {component.InternalID}");
            }
        }
Exemplo n.º 24
0
        public virtual void LoadPositions()
        {
            ushort region = CurrentRegionID;

            if (CurrentRegion is BaseInstance)
            {
                region = (CurrentRegion as BaseInstance).Skin;
            }

            Battleground bg = GameServer.KeepManager.GetBattleground(region);

            this.Positions.Clear();

            var whereClause = DB.Column(nameof(DBKeepPosition.ComponentSkin)).IsEqualTo(Skin);

            if (Skin != (int)eComponentSkin.Keep && Skin != (int)eComponentSkin.Tower && Skin != (int)eComponentSkin.Gate)
            {
                whereClause = whereClause.And(DB.Column(nameof(DBKeepPosition.ComponentRotation)).IsEqualTo(ComponentHeading));
            }
            if (bg != null && GameServer.Instance.Configuration.ServerType != eGameServerType.GST_PvE)
            {
                // Battlegrounds, ignore all but GameKeepDoor
                whereClause = whereClause.And(DB.Column(nameof(DBKeepPosition.ClassType)).IsEqualTo("DOL.GS.Keeps.GameKeepDoor"));
            }
            var DBPositions = DOLDB <DBKeepPosition> .SelectObjects(whereClause);

            foreach (DBKeepPosition position in DBPositions)
            {
                DBKeepPosition[] list = this.Positions[position.TemplateID] as DBKeepPosition[];
                if (list == null)
                {
                    list = new DBKeepPosition[4];
                    this.Positions[position.TemplateID] = list;
                }

                list[position.Height] = position;
            }
        }
Exemplo n.º 25
0
        public virtual void FillPositions()
        {
            foreach (DBKeepPosition[] positionGroup in this.Positions.Values)
            {
                for (int i = this.Height; i >= 0; i--)
                {
                    DBKeepPosition position = positionGroup[i] as DBKeepPosition;
                    if (position != null)
                    {
                        bool create = false;
                        if (position.ClassType == "DOL.GS.Keeps.GameKeepBanner")
                        {
                            if (this.AbstractKeep.Banners[position.TemplateID] == null)
                            {
                                create = true;
                            }
                        }
                        else if (position.ClassType == "DOL.GS.Keeps.GameKeepDoor")
                        {
                            if (this.AbstractKeep.Doors[position.TemplateID] == null)
                            {
                                create = true;
                            }
                        }
                        else if (position.ClassType == "DOL.GS.Keeps.FrontierTeleportStone")
                        {
                            if (this.AbstractKeep.TeleportStone == null)
                            {
                                create = true;
                            }
                        }
                        else if (position.ClassType == "DOL.GS.Keeps.Patrol")
                        {
                            if (position.KeepType == (int)AbstractGameKeep.eKeepType.Any || position.KeepType == (int)AbstractKeep.KeepType)
                            {
                                if (this.AbstractKeep.Patrols[position.TemplateID] == null)
                                {
                                    Patrol p = new Patrol(this);
                                    p.SpawnPosition = position;
                                    p.PatrolID      = position.TemplateID;
                                    p.InitialiseGuards();
                                }
                            }
                            continue;
                        }
                        else
                        {
                            if (this.AbstractKeep.Guards[position.TemplateID] == null)
                            {
                                create = true;
                            }
                        }
                        if (create)
                        {
                            //create the object
                            try
                            {
                                Assembly  asm = Assembly.GetExecutingAssembly();
                                IKeepItem obj = (IKeepItem)asm.CreateInstance(position.ClassType, true);
                                if (obj != null)
                                {
                                    obj.LoadFromPosition(position, this);
                                }

                                if (ServerProperties.Properties.ENABLE_DEBUG)
                                {
                                    if (obj is GameLiving)
                                    {
                                        (obj as GameLiving).Name += " is living, component " + obj.Component.ID;
                                    }
                                    else if (obj is GameObject)
                                    {
                                        (obj as GameObject).Name += " is object, component " + obj.Component.ID;
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                log.Error("GameKeepComponent:FillPositions: " + position.ClassType, ex);
                            }
                        }
                        else
                        {
                            //move the object
                            if (position.ClassType == "DOL.GS.Keeps.GameKeepBanner")
                            {
                                IKeepItem banner = this.AbstractKeep.Banners[position.TemplateID] as IKeepItem;
                                if (banner.Position != position)
                                {
                                    banner.MoveToPosition(position);
                                }
                            }
                            else if (position.ClassType == "DOL.GS.Keeps.GameKeepDoor")
                            {
                                //doors dont move
                            }
                            else if (position.ClassType == "DOL.GS.Keeps.FrontierPortalStone")
                            {
                                //these dont move
                            }
                            else
                            {
                                IKeepItem guard = this.AbstractKeep.Guards[position.TemplateID] as IKeepItem;
                                guard.MoveToPosition(position);
                            }
                        }
                        break;
                    }
                }
            }

            foreach (GameKeepGuard guard in this.AbstractKeep.Guards.Values)
            {
                if (guard.PatrolGroup != null)
                {
                    continue;
                }
                if (guard.HookPoint != null)
                {
                    continue;
                }
                if (guard.Position == null)
                {
                    continue;
                }
                if (guard.Position.Height > guard.Component.Height)
                {
                    guard.RemoveFromWorld();
                }
                else
                {
                    if (guard.Position.Height <= guard.Component.Height &&
                        guard.ObjectState != GameObject.eObjectState.Active && !guard.IsRespawning)
                    {
                        guard.AddToWorld();
                    }
                }
            }

            foreach (GameKeepBanner banner in this.AbstractKeep.Banners.Values)
            {
                if (banner.Position == null)
                {
                    continue;
                }
                if (banner.Position.Height > banner.Component.Height)
                {
                    banner.RemoveFromWorld();
                }
                else
                {
                    if (banner.Position.Height <= banner.Component.Height &&
                        banner.ObjectState != GameObject.eObjectState.Active)
                    {
                        banner.AddToWorld();
                    }
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// The command handler itself
        /// </summary>
        /// <param name="client">The client using the command</param>
        /// <param name="args">The command arguments</param>
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length == 1)
            {
                DisplaySyntax(client);
                return;
            }

            switch (args[1].ToLower())
            {
                #region Create
            case "create":
            {
                GameKeepGuard guard = null;
                if (args.Length < 3)
                {
                    DisplaySyntax(client);
                    return;
                }

                switch (args[2].ToLower())
                {
                    #region Lord
                case "lord":
                {
                    guard = new GuardLord();
                    break;
                }

                    #endregion Lord
                    #region Fighter
                case "fighter":
                {
                    guard = new GuardFighter();
                    break;
                }

                    #endregion Fighter
                    #region Archer
                case "archer":
                {
                    if (args.Length > 3)
                    {
                        guard = new GuardStaticArcher();
                    }
                    else
                    {
                        guard = new GuardArcher();
                    }
                    break;
                }

                    #endregion Archer
                    #region Healer
                case "healer":
                {
                    guard = new GuardHealer();
                    break;
                }

                    #endregion Healer
                    #region Stealther
                case "stealther":
                {
                    guard = new GuardStealther();
                    break;
                }

                    #endregion Stealther
                    #region Caster
                case "caster":
                {
                    if (args.Length > 3)
                    {
                        guard = new GuardStaticCaster();
                    }
                    else
                    {
                        guard = new GuardCaster();
                    }
                    break;
                }

                    #endregion Caster
                    #region Hastener
                case "hastener":
                {
                    guard = new FrontierHastener();
                    break;
                }

                    #endregion Hastener
                    #region Mission
                case "mission":
                {
                    guard = new MissionMaster();
                    break;
                }

                    #endregion Mission
                    #region Patrol
                case "patrol":
                {
                    if (args.Length < 4)
                    {
                        DisplayMessage(client, "You need to provide a name for this patrol.");
                        return;
                    }

                    AbstractGameKeep.eKeepType keepType = AbstractGameKeep.eKeepType.Any;

                    if (args.Length < 5)
                    {
                        DisplayMessage(client, "You need to provide the type of keep this patrol works with.");
                        int i = 0;
                        foreach (string str in Enum.GetNames(typeof(Keeps.AbstractGameKeep.eKeepType)))
                        {
                            DisplayMessage(client, "#" + i + ": " + str);
                            i++;
                        }
                        return;
                    }

                    try
                    {
                        keepType = (AbstractGameKeep.eKeepType)Convert.ToInt32(args[4]);
                    }
                    catch
                    {
                        DisplayMessage(client, "Type of keep specified was not valid.");
                        return;
                    }


                    if (client.Player.TargetObject is GameKeepComponent == false)
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Create.NoKCompTarget"));
                        return;
                    }
                    GameKeepComponent c = client.Player.TargetObject as GameKeepComponent;;
                    Patrol            p = new Patrol(c);
                    p.PatrolID      = args[3];
                    p.KeepType      = keepType;
                    p.SpawnPosition = PositionMgr.CreatePatrolPosition(p.PatrolID, c, client.Player, keepType);
                    p.PatrolID      = p.SpawnPosition.TemplateID;
                    p.InitialiseGuards();
                    DisplayMessage(client, "Patrol created for Keep Type " + Enum.GetName(typeof(AbstractGameKeep.eKeepType), keepType));
                    return;
                }
                    #endregion Patrol
                }

                if (guard == null)
                {
                    DisplaySyntax(client);
                    return;
                }

                GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
                if (component != null)
                {
                    int height = component.Height;
                    if (args.Length > 4)
                    {
                        int.TryParse(args[4], out height);
                    }

                    DBKeepPosition pos = PositionMgr.CreatePosition(guard.GetType(), height, client.Player, Guid.NewGuid().ToString(), component);
                    //PositionMgr.AddPosition(pos);
                    //PositionMgr.FillPositions();
                    DBKeepPosition[] list = component.Positions[pos.TemplateID] as DBKeepPosition[];
                    if (list == null)
                    {
                        list = new DBKeepPosition[4];
                        component.Positions[pos.TemplateID] = list;
                    }

                    list[pos.Height] = pos;
                    component.LoadPositions();
                    component.FillPositions();
                }
                else
                {
                    guard.CurrentRegion    = client.Player.CurrentRegion;
                    guard.X                = client.Player.X;
                    guard.Y                = client.Player.Y;
                    guard.Z                = client.Player.Z;
                    guard.Heading          = client.Player.Heading;
                    guard.Realm            = guard.CurrentZone.Realm;
                    guard.LoadedFromScript = false;
                    guard.SaveIntoDatabase();

                    foreach (AbstractArea area in guard.CurrentAreas)
                    {
                        if (area is KeepArea)
                        {
                            AbstractGameKeep keep = (area as KeepArea).Keep;
                            guard.Component      = new GameKeepComponent();
                            guard.Component.Keep = keep;
                            break;
                        }
                    }

                    TemplateMgr.RefreshTemplate(guard);
                    guard.AddToWorld();

                    if (guard.Component != null && guard.Component.Keep != null)
                    {
                        guard.Component.Keep.Guards.Add(DOL.Database.UniqueID.IDGenerator.GenerateID(), guard);
                    }
                }

                PositionMgr.FillPositions();

                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Create.GuardAdded"));
                break;
            }

                #endregion Create
                #region Position
            case "position":
            {
                switch (args[2].ToLower())
                {
                    #region Add
                case "add":
                {
                    if (!(client.Player.TargetObject is GameKeepGuard))
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.TargetGuard"));
                        return;
                    }

                    if (args.Length != 4)
                    {
                        DisplaySyntax(client);
                        return;
                    }

                    byte height = byte.Parse(args[3]);
                    //height = KeepMgr.GetHeightFromLevel(height);
                    GameKeepGuard guard = client.Player.TargetObject as GameKeepGuard;

                    if (PositionMgr.GetPosition(guard) != null)
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.PAlreadyAss", height));
                        return;
                    }

                    DBKeepPosition pos = PositionMgr.CreatePosition(guard.GetType(), height, client.Player, guard.TemplateID, guard.Component);
                    PositionMgr.AddPosition(pos);
                    PositionMgr.FillPositions();

                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.GuardPAdded"));
                    break;
                }

                    #endregion Add
                    #region Remove
                case "remove":
                {
                    if (!(client.Player.TargetObject is GameKeepGuard))
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.TargetGuard"));
                        return;
                    }

                    GameKeepGuard  guard = client.Player.TargetObject as GameKeepGuard;
                    DBKeepPosition pos   = guard.Position;
                    if (pos != null)
                    {
                        PositionMgr.RemovePosition(pos);

                        if (guard.LoadedFromScript)
                        {
                            if (guard.PatrolGroup != null)
                            {
                                foreach (GameKeepGuard g in guard.PatrolGroup.PatrolGuards)
                                {
                                    g.Delete();
                                }
                            }
                            else
                            {
                                guard.Delete();
                            }
                        }
                    }

                    PositionMgr.FillPositions();

                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.GuardRemoved"));
                    break;
                }

                    #endregion Remove
                    #region Default
                default:
                {
                    DisplaySyntax(client);
                    return;
                }
                    #endregion Default
                }
                break;
            }

                #endregion Position
                #region Path
            case "path":
            {
                switch (args[2].ToLower())
                {
                    #region Create
                case "create":
                {
                    RemoveAllTempPathObjects(client);

                    PathPoint startpoint = new PathPoint(client.Player.X, client.Player.Y, client.Player.Z, 100000, ePathType.Once);
                    client.Player.TempProperties.setProperty(TEMP_PATH_FIRST, startpoint);
                    client.Player.TempProperties.setProperty(TEMP_PATH_LAST, startpoint);
                    client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.CreationStarted"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    CreateTempPathObject(client, startpoint, "TMP PP 1");
                    break;
                }

                    #endregion Create
                    #region Add
                case "add":
                {
                    PathPoint path = (PathPoint)client.Player.TempProperties.getProperty <object>(TEMP_PATH_LAST, null);
                    if (path == null)
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.NoPathCreatedYet"));
                        return;
                    }

                    int speedlimit = 1000;
                    if (args.Length == 4)
                    {
                        try
                        {
                            speedlimit = int.Parse(args[3]);
                        }
                        catch
                        {
                            DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.NoValidSpLimit", args[2]));
                            return;
                        }
                    }

                    PathPoint newpp = new PathPoint(client.Player.X, client.Player.Y, client.Player.Z, speedlimit, path.Type);
                    path.Next  = newpp;
                    newpp.Prev = path;
                    client.Player.TempProperties.setProperty(TEMP_PATH_LAST, newpp);

                    int len = 0;
                    while (path.Prev != null)
                    {
                        len++;
                        path = path.Prev;
                    }
                    len += 2;

                    CreateTempPathObject(client, newpp, "TMP PP " + len);
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.PPAdded", len));
                    break;
                }

                    #endregion Add
                    #region Save
                case "save":
                {
                    PathPoint path = (PathPoint)client.Player.TempProperties.getProperty <object>(TEMP_PATH_LAST, null);
                    if (path == null)
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.NoPathCreatedYet"));
                        return;
                    }

                    GameKeepGuard guard = client.Player.TargetObject as GameKeepGuard;
                    if (guard == null || guard.PatrolGroup == null)
                    {
                        DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.TargPatrolGuard"));
                        return;
                    }

                    path.Type = ePathType.Loop;
                    PositionMgr.SavePatrolPath(guard.TemplateID, path, guard.Component);
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.Saved"));
                    RemoveAllTempPathObjects(client);
                    guard.PatrolGroup.InitialiseGuards();

                    PositionMgr.FillPositions();

                    DisplayMessage(client, "Patrol groups initialized!");

                    break;
                }

                    #endregion Save
                    #region Default
                default:
                {
                    DisplaySyntax(client);
                    return;
                }
                    #endregion Default
                }
                break;
            }

                #endregion Path
                #region Default
            default:
            {
                DisplaySyntax(client);
                return;
            }
                #endregion Default
            }
        }
Exemplo n.º 27
0
 public void MoveToPosition(DBKeepPosition position)
 {
 }