Ejemplo n.º 1
0
        /// <summary>
        /// Method to Initialise the Guards
        ///
        /// Here we create the instances of the guard
        /// We add to the local array of guards
        /// We assign a Guard ID which is the Patrol ID
        /// We assign the guards component
        /// </summary>
        public void InitialiseGuards()
        {
            Component.AbstractKeep.Patrols.Add(PatrolID, this);

            //need this here becuase it's checked in add to world
            PatrolPath = PositionMgr.LoadPatrolPath(PatrolID, Component);

            int guardsOnPatrol = 1;

            if (Component != null && Component.AbstractKeep != null && Component.AbstractKeep is GameKeep)
            {
                guardsOnPatrol++;

                if (Component.AbstractKeep.Level > 4)
                {
                    guardsOnPatrol++;
                }
            }

            if (PatrolGuards.Count < guardsOnPatrol)
            {
                for (int i = 0; i < guardsOnPatrol; i++)
                {
                    CreatePatrolGuard(i);
                }
            }

            // tolakram - this might be redundant
            foreach (GameKeepGuard guard in PatrolGuards)
            {
                PositionMgr.LoadGuardPosition(SpawnPosition, guard);
            }

            ChangePatrolLevel();
        }
Ejemplo n.º 2
0
        private void CreatePatrolGuard(int type)
        {
            Assembly asm = Assembly.GetAssembly(typeof(GameServer));

            if (type < 0)
            {
                type = 0;
            }
            if (type > GuardTypes.Length - 1)
            {
                type = GuardTypes.Length - 1;
            }

            GameKeepGuard guard = (GameKeepGuard)asm.CreateInstance(GuardTypes[type].FullName, true);

            guard.TemplateID  = PatrolID;
            guard.Component   = Component;
            guard.PatrolGroup = this;
            PositionMgr.LoadGuardPosition(SpawnPosition, guard);
            guard.RefreshTemplate();
            PatrolGuards.Add(guard);
            Component.Keep.Guards.Add(Database.UniqueID.IDGenerator.GenerateID(), guard);
            guard.AddToWorld();

            if (ServerProperties.Properties.ENABLE_DEBUG)
            {
                guard.Name += " PatrolID " + PatrolID;
            }
        }
Ejemplo 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);
            }
        }
        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();
            }
        }
Ejemplo 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);
     }
 }
Ejemplo n.º 6
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);
     }
 }
Ejemplo n.º 7
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();
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 10
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();
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Method to start a Patrol patroling
        /// It sets a patrol leader
        /// And starts moving on Patrol
        /// </summary>
        public void StartPatrol()
        {
            if (PatrolPath == null)
            {
                PatrolPath = PositionMgr.LoadPatrolPath(PatrolID, Component);
            }

            foreach (GameKeepGuard guard in PatrolGuards)
            {
                if (guard.CurrentWayPoint == null)
                {
                    guard.CurrentWayPoint = PatrolPath;
                }

                guard.MoveOnPath(PATROL_SPEED);
            }
        }
Ejemplo n.º 12
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}");
            }
        }
Ejemplo n.º 13
0
        private void CreatePatrolGuard(int type)
        {
            Assembly asm = Assembly.GetAssembly(typeof(GameServer));

            if (type < 0)
            {
                type = 0;
            }

            if (type > GuardTypes.Length - 1)
            {
                type = GuardTypes.Length - 1;
            }

            GameKeepGuard guard = (GameKeepGuard)asm.CreateInstance(GuardTypes[type].FullName, true);

            guard.TemplateID  = PatrolID;
            guard.Component   = Component;
            guard.PatrolGroup = this;
            PositionMgr.LoadGuardPosition(SpawnPosition, guard);
            if (Component != null && Component.AbstractKeep != null)
            {
                Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { guard });
            }
            else
            {
                TemplateMgr.RefreshTemplate(guard);
            }

            PatrolGuards.Add(guard);
            Component.AbstractKeep.Guards.Add(DOL.Database.UniqueID.IDGenerator.GenerateID(), guard);
            guard.AddToWorld();

            if (ServerProperties.Properties.ENABLE_DEBUG)
            {
                guard.Name += " PatrolID " + PatrolID;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Method to Change a Patrol's Level
        ///
        /// This method handles the add and removing of guards
        /// </summary>
        public void ChangePatrolLevel()
        {
            int guardsToPatrol = 1;

            if (Component != null && Component.AbstractKeep != null && Component.AbstractKeep is GameKeep)
            {
                guardsToPatrol++;

                if (Component.AbstractKeep.Level > 4)
                {
                    guardsToPatrol++;
                }
            }

            PatrolPath = PositionMgr.LoadPatrolPath(PatrolID, Component);

            // Console.WriteLine(PatrolID + " guardstopatrol = " + guardsToPatrol + ", count = " + PatrolGuards.Count);

            while (guardsToPatrol > PatrolGuards.Count)
            {
                CreatePatrolGuard(PatrolGuards.Count);
            }

            int x = 0;
            int y = 0;

            List <GameKeepGuard> guardsToKeep = new List <GameKeepGuard>();

            for (int i = 0; i < PatrolGuards.Count; i++)
            {
                GameKeepGuard guard = PatrolGuards[i] as GameKeepGuard;

                // Console.WriteLine(PatrolID + " loading guard " + guard.Name);

                if (i < guardsToPatrol)
                {
                    // we need to reposition the patrol at their spawn point plus variation
                    if (x == 0)
                    {
                        x = guard.SpawnPoint.X;
                        y = guard.SpawnPoint.Y;
                    }
                    else
                    {
                        x += Util.Random(250, 350);
                        y += Util.Random(250, 350);
                    }

                    if (guard.IsAlive)
                    {
                        if (guard.IsMovingOnPath)
                        {
                            guard.StopMovingOnPath();
                        }

                        guard.MoveTo(guard.CurrentRegionID, x, y, guard.SpawnPoint.Z, guard.SpawnHeading);
                    }

                    guardsToKeep.Add(guard);
                }
                else
                {
                    guard.Delete();
                }
            }

            PatrolGuards = guardsToKeep;

            StartPatrol();
        }