Beispiel #1
0
 /// <summary>
 /// Updates the Relic on the Warmap and such
 /// </summary>
 /// <param name="living"></param>
 protected virtual void Update(GameLiving living)
 {
     if (living == null)
     {
         return;
     }
     CurrentRegionID = living.CurrentRegionID;
     Position        = living.Position;
     Heading         = living.Heading;
     foreach (GameClient clt in WorldMgr.GetClientsOfRegion(CurrentRegionID))
     {
         if (clt == null || clt.Player == null)
         {
             continue;
         }
         if (XP > 0)
         {
             clt.Player.Out.SendMinotaurRelicMapUpdate((byte)RelicID, CurrentRegionID, (int)Position.X, (int)Position.Y, (int)Position.Z);
         }
         else
         {
             clt.Player.Out.SendMinotaurRelicMapRemove((byte)RelicID);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// This method forces the weather for this region to stop if it is running
        /// </summary>
        public void StopStorm()
        {
            if (!IsActive)
            {
                return;
            }

            uint currentLine = CurrentWeatherLine;

            //We are stopping
            m_weatherStartTick = 0;

            foreach (GameClient cl in WorldMgr.GetClientsOfRegion(m_regionID))
            {
                cl.Out.SendWeather(0, 0, 0, 0, 0);
                if (cl.Player.X > (currentLine - m_width) && cl.Player.X < (currentLine + m_width))
                {
                    cl.Out.SendMessage("The sky clears up again as the storm clouds disperse!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
            }
            m_weatherTimer.Change(ServerProperties.Properties.WEATHER_CHECK_INTERVAL, ServerProperties.Properties.WEATHER_CHECK_INTERVAL);
            if (log.IsInfoEnabled && ServerProperties.Properties.WEATHER_LOG_EVENTS)
            {
                log.Info("Rain was stopped in " + WorldMgr.GetRegion(m_regionID).Description);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Updates the Relic on the Warmap and such
        /// </summary>
        /// <param name="living"></param>
        protected virtual void Update(GameLiving living)
        {
            if (living == null)
            {
                return;
            }

            CurrentRegionID = living.CurrentRegionID;
            X       = living.X;
            Y       = living.Y;
            Z       = living.Z;
            Heading = living.Heading;
            foreach (GameClient clt in WorldMgr.GetClientsOfRegion(CurrentRegionID))
            {
                if (clt?.Player == null)
                {
                    continue;
                }

                if (Xp > 0)
                {
                    clt.Player.Out.SendMinotaurRelicMapUpdate((byte)RelicId, CurrentRegionID, X, Y, Z);
                }
                else
                {
                    clt.Player.Out.SendMinotaurRelicMapRemove((byte)RelicId);
                }
            }
        }
Beispiel #4
0
        public virtual void Repair(int amount)
        {
            if (amount > 0)
            {
                byte oldStatus = Status;
                Health            += amount;
                m_oldHealthPercent = HealthPercent;
                if (oldStatus != Status)
                {
                    foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegionID))
                    {
                        client.Out.SendKeepComponentDetailUpdate(this);
                    }
                }

                //if a tower is repaired reload the guards so they arent on the floor
                if (AbstractKeep is GameKeepTower && oldStatus == 0x02 && oldStatus != Status)
                {
                    foreach (GameKeepComponent component in AbstractKeep.KeepComponents)
                    {
                        component.FillPositions();
                    }
                }

                RepairedHealth = Health;
            }
        }
Beispiel #5
0
 /// <summary>
 /// boradcast the door status to all player near the door
 /// </summary>
 public virtual void BroadcastDoorStatus()
 {
     foreach (GameClient client in WorldMgr.GetClientsOfRegion(CurrentRegionID))
     {
         client.Player.SendDoorUpdate(this);
     }
 }
        /// <summary>
        /// upgrade keep to a target level
        /// </summary>
        /// <param name="targetLevel">the target level</param>
        public virtual void ChangeLevel(byte targetLevel)
        {
            this.Level = targetLevel;

            foreach (GameKeepComponent comp in this.KeepComponents)
            {
                comp.UpdateLevel();
                foreach (GameClient cln in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID))
                {
                    cln.Out.SendKeepComponentDetailUpdate(comp);
                }
                comp.FillPositions();
            }

            foreach (GameKeepGuard guard in this.Guards.Values)
            {
                SetGuardLevel(guard);
            }

            foreach (Patrol p in this.Patrols.Values)
            {
                p.ChangePatrolLevel();
            }

            foreach (GameKeepDoor door in this.Doors.Values)
            {
                door.UpdateLevel();
            }

            KeepGuildMgr.SendLevelChangeMessage(this);
            ResetPlayersOfKeep();

            this.SaveIntoDatabase();
        }
        //This void is outside of Instance,
        //because i want people to think carefully about how they change levels in their instance.
        public void UpdateInstanceLevel()
        {
            m_level = (byte)(GetInstanceLevel());
            //Set all mobs to that level...
            if (m_level > 0)
            {
                foreach (GameObject obj in Objects)
                {
                    if (obj == null)
                    {
                        continue;
                    }

                    GameNPC npc = obj as GameNPC;
                    if (npc == null)
                    {
                        continue;
                    }

                    npc.Level = (byte)m_level;
                }
                //Update to the players..
                foreach (GameClient client in WorldMgr.GetClientsOfRegion(ID))
                {
                    if (client != null)
                    {
                        client.Out.SendMessage("This instance is now level " + m_level, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    }
                }
            }
        }
Beispiel #8
0
            //When the timer ticks, it means there are no players in the region.
            //This, we remove the instance.
            protected override void OnTick()
            {
                if (m_instance == null)
                {
                    log.Warn("RegionRemovalTimer is not being stopped once the instance is destroyed!");
                    Stop();
                    return;
                }
                //If there are players, someone has callously forgotten to include
                //a base in one of their OnPlayerEnter/Exit overrides.
                //When this is a case, keep the timer ticking - we will eventually have it cleanup the instance,
                //it just wont be runnign at optimum speed.

                if (WorldMgr.GetClientsOfRegion(m_instance.ID).Count > 0)
                {
                    log.Warn("Players were still in the region on AutoRemoveregionTimer Tick! Please check the overridden voids OnPlayerEnter/Exit to ensure that a 'base.OnPlayerEnter/Exit' is included!");
                }
                else
                {
                    //Collapse the zone!
                    //Thats my favourite bit ;)
                    log.Info(m_instance.Name + " (ID: " + m_instance.ID + ") just reached the timeout for the removal timer. The region is empty, and will now be demolished and removed from the world. Entering OnCollapse!");
                    Stop();
                    WorldMgr.RemoveInstance(m_instance);
                }
            }
Beispiel #9
0
 private void Broadcast(GamePlayer player, string message)
 {
     foreach (GameClient c in WorldMgr.GetClientsOfRegion(player.CurrentRegionID))
     {
         if (GameServer.ServerRules.IsAllowedToUnderstand(c.Player, player))
         {
             c.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Scripts.Players.Trade.Message", player.Name, message), eChatType.CT_Trade, eChatLoc.CL_ChatWindow);
         }
     }
 }
Beispiel #10
0
        public override void TakeDamage(GameObject source, eDamageType damageType, int damageAmount, int criticalAmount)
        {
            if (damageAmount > 0)
            {
                Component.AbstractKeep.LastAttackedByEnemyTick = CurrentRegion.Time;
                base.TakeDamage(source, damageType, damageAmount, criticalAmount);

                // only on hp change
                if (m_oldHealthPercent != HealthPercent)
                {
                    m_oldHealthPercent = HealthPercent;
                    foreach (GameClient client in WorldMgr.GetClientsOfRegion(CurrentRegionID))
                    {
                        client.Out.SendObjectUpdate(this);
                    }
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Starts the storm in the region
        /// </summary>
        /// <param name="x"></param>
        /// <param name="duration"></param>
        /// <param name="speed"></param>
        /// <param name="fog"></param>
        /// <param name="intensity"></param>
        public void StartStorm(uint x, uint duration, ushort speed, ushort fog, ushort intensity)
        {
            m_startX           = x;
            m_width            = duration;
            m_speed            = speed;
            m_fogDiffusion     = fog;
            m_intensity        = intensity;
            m_weatherStartTick = Environment.TickCount;

            foreach (GameClient cl in WorldMgr.GetClientsOfRegion(m_regionID))
            {
                cl.Out.SendWeather(m_startX, m_width, m_speed, m_fogDiffusion, m_intensity);
            }

            if (log.IsInfoEnabled && ServerProperties.Properties.WEATHER_LOG_EVENTS)
            {
                log.Info(string.Format("It starts to rain in {0} ({1})", WorldMgr.GetRegion(m_regionID).Description, m_regionID));
            }
        }
Beispiel #12
0
        public override void TakeDamage(GameObject source, eDamageType damageType, int damageAmount, int criticalAmount)
        {
            if (damageAmount > 0)
            {
                this.AbstractKeep.LastAttackedByEnemyTick = this.CurrentRegion.Time;
                base.TakeDamage(source, damageType, damageAmount, criticalAmount);

                //only on hp change
                if (m_oldHealthPercent != HealthPercent)
                {
                    m_oldHealthPercent = HealthPercent;
                    foreach (GameClient client in WorldMgr.GetClientsOfRegion(CurrentRegionID))
                    {
                        client.Out.SendObjectUpdate(this);
                        client.Out.SendKeepComponentDetailUpdate(this);                         // I knwo this works, not sure if ObjectUpdate is needed - Tolakram
                    }
                }
            }
        }
        /// <summary>
        /// Send Packets to Add Keep and Components
        /// </summary>
        protected void SendKeepInfo()
        {
            foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID))
            {
                if (client.Player == null || client.ClientState != GameClient.eClientState.Playing || client.Player.ObjectState != GameObject.eObjectState.Active)
                {
                    continue;
                }

                GamePlayer player = client.Player;

                // Add Keep
                player.Out.SendKeepInfo(this);
                foreach (GameKeepComponent comp in this.KeepComponents)
                {
                    player.Out.SendKeepComponentInfo(comp);
                }
            }
        }
        /// <summary>
        /// Send Packets to Remove Keep and Components
        /// </summary>
        protected void SendRemoveKeep()
        {
            foreach (GameClient client in WorldMgr.GetClientsOfRegion(CurrentRegion.ID))
            {
                if (client.Player == null || client.ClientState != GameClient.eClientState.Playing || client.Player.ObjectState != GameObject.eObjectState.Active)
                {
                    continue;
                }

                GamePlayer player = client.Player;

                // Remove Keep
                foreach (GameKeepComponent comp in KeepComponents)
                {
                    player.Out.SendKeepComponentRemove(comp);
                }

                player.Out.SendKeepRemove(this);
            }
        }
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                client.Out.SendMessage("Use: /move <regionID>", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            ushort from_region = Convert.ToByte(args[1]);

            foreach (GameClient cl in WorldMgr.GetClientsOfRegion(from_region))
            {
                if (cl.Player.Realm == eRealm.Albion)
                {
                    cl.Player.MoveTo(1, 560421, 511840, 2344, 1);  //EDIT THIS line WHIT YOUR LOC want to be teleport
                    cl.Player.SaveIntoDatabase();
                    client.Out.SendMessage(cl.Player.Name + "", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else if (cl.Player.Realm == eRealm.Midgard)
                {
                    cl.Player.MoveTo(100, 804763, 723998, 4699, 1); //EDIT THIS LINE WHIT YOUR LOC want to be teleport
                    cl.Player.SaveIntoDatabase();
                    client.Out.SendMessage(cl.Player.Name + "", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else if (cl.Player.Realm == eRealm.Hibernia)
                {
                    cl.Player.MoveTo(200, 345684, 490996, 5200, 1); //EDIT THIS LINE WHIT YOUR LOC want to be teleport
                    cl.Player.SaveIntoDatabase();
                    client.Out.SendMessage(cl.Player.Name + "", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else
                {
                    client.Out.SendMessage(cl.Player.Name + "", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
            }
        }
        // This void is outside of Instance,
        // because i want people to think carefully about how they change levels in their instance.
        public void UpdateInstanceLevel()
        {
            _level = (byte)GetInstanceLevel();

            // Set all mobs to that level...
            if (_level > 0)
            {
                foreach (GameObject obj in Objects)
                {
                    if (!(obj is GameNPC npc))
                    {
                        continue;
                    }

                    npc.Level = (byte)_level;
                }

                // Update to the players..
                foreach (GameClient client in WorldMgr.GetClientsOfRegion(ID))
                {
                    client?.Out.SendMessage($"This instance is now level {_level}", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
            }
        }
Beispiel #17
0
        public override void Die(GameObject killer)
        {
            base.Die(killer);
            if (this.AbstractKeep is GameKeepTower && ServerProperties.Properties.CLIENT_VERSION_MIN >= (int)GameClient.eClientVersion.Version175)
            {
                if (IsRaized == false)
                {
                    Notify(KeepEvent.TowerRaized, this.AbstractKeep, new KeepEventArgs(this.AbstractKeep, killer.Realm));
                    PlayerMgr.BroadcastRaize(this.AbstractKeep, killer.Realm);
                    IsRaized = true;

                    foreach (GameKeepGuard guard in this.AbstractKeep.Guards.Values)
                    {
                        guard.MoveTo(guard.CurrentRegionID, guard.X, guard.Y, this.AbstractKeep.Z, guard.Heading);
                        guard.SpawnPoint.Z = this.AbstractKeep.Z;
                    }
                }
            }

            foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegionID))
            {
                client.Out.SendKeepComponentDetailUpdate(this);
            }
        }
        public override void Die(GameObject killer)
        {
            base.Die(killer);
            if (AbstractKeep is GameKeepTower)
            {
                if (IsRaized == false)
                {
                    Notify(KeepEvent.TowerRaized, AbstractKeep, new KeepEventArgs(AbstractKeep, killer.Realm));
                    PlayerMgr.BroadcastRaize(AbstractKeep, killer.Realm);
                    IsRaized = true;

                    foreach (GameKeepGuard guard in AbstractKeep.Guards.Values)
                    {
                        guard.MoveTo(guard.CurrentRegionID, guard.X, guard.Y, AbstractKeep.Z, guard.Heading);
                        guard.SpawnPoint.Z = AbstractKeep.Z;
                    }
                }
            }

            foreach (GameClient client in WorldMgr.GetClientsOfRegion(CurrentRegionID))
            {
                client.Out.SendKeepComponentDetailUpdate(this);
            }
        }
        private ArrayList GetTargets(GamePlayer player)
        {
            ArrayList      list = new ArrayList();
            eBroadcastType type = (eBroadcastType)ServerProperties.Properties.BROADCAST_TYPE;

            switch (type)
            {
            case eBroadcastType.Area:
            {
                bool found = false;
                foreach (AbstractArea area in player.CurrentAreas)
                {
                    if (area.CanBroadcast)
                    {
                        found = true;
                        foreach (GameClient thisClient in WorldMgr.GetClientsOfRegion(player.CurrentRegionID))
                        {
                            if (thisClient.Player.CurrentAreas.Contains(area))
                            {
                                list.Add(thisClient.Player);
                            }
                        }
                    }
                }
                if (!found)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Scripts.Players.Broadcast.NoHere"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                break;
            }

            case eBroadcastType.Realm:
            {
                foreach (GameClient thisClient in WorldMgr.GetClientsOfRealm(player.Realm))
                {
                    list.Add(thisClient.Player);
                }
                break;
            }

            case eBroadcastType.Region:
            {
                foreach (GameClient thisClient in WorldMgr.GetClientsOfRegion(player.CurrentRegionID))
                {
                    list.Add(thisClient.Player);
                }
                break;
            }

            case eBroadcastType.Server:
            {
                foreach (GameClient thisClient in WorldMgr.GetAllPlayingClients())
                {
                    list.Add(thisClient.Player);
                }
                break;
            }

            case eBroadcastType.Visible:
            {
                foreach (GamePlayer p in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                {
                    list.Add(p);
                }
                break;
            }

            case eBroadcastType.Zone:
            {
                foreach (GameClient thisClient in WorldMgr.GetClientsOfRegion(player.CurrentRegionID))
                {
                    if (thisClient.Player.CurrentZone == player.CurrentZone)
                    {
                        list.Add(thisClient.Player);
                    }
                }
                break;
            }
            }

            return(list);
        }
Beispiel #20
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length == 1)
            {
                DisplaySyntax(client);
                return;
            }

            AbstractGameKeep myKeep = GameServer.KeepManager.GetKeepCloseToSpot(client.Player.CurrentRegionID, client.Player, WorldMgr.OBJ_UPDATE_DISTANCE);

            if (myKeep == null)
            {
                DisplayMessage(client, "You are not near a keep.");
            }

            switch (args[1])
            {
                #region Create
            case "create":
            {
                if (args.Length < 3)
                {
                    int i = 0;
                    foreach (string str in Enum.GetNames(typeof(GameKeepComponent.eComponentSkin)))
                    {
                        client.Out.SendMessage("#" + i + ": " + str, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        i++;
                    }
                    DisplaySyntax(client);
                    return;
                }

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

                int skin = 0;
                try
                {
                    skin = Convert.ToInt32(args[2]);
                }
                catch
                {
                    int i = 0;
                    foreach (string str in Enum.GetNames(typeof(GameKeepComponent.eComponentSkin)))
                    {
                        client.Out.SendMessage("#" + i + ": " + str, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        i++;
                    }
                    DisplaySyntax(client);
                    return;
                }

                if (args.Length >= 4)
                {
                    int keepid = 0;
                    try
                    {
                        keepid = Convert.ToInt32(args[3]);
                        myKeep = GameServer.KeepManager.GetKeepByID(keepid);
                    }
                    catch
                    {
                        DisplaySyntax(client);
                        return;
                    }
                }

                GameKeepComponent component = new GameKeepComponent();
                component.X = client.Player.X;
                component.Y = client.Player.Y;
                component.Z = client.Player.Z;
                component.ComponentHeading = (client.Player.Heading - myKeep.Heading) / 1024;
                component.Heading          = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading);
                component.Keep             = myKeep;
                //todo good formula
                //component.ComponentX = (component.X - myKeep.X) / 148;
                //component.ComponentY = (component.Y - myKeep.Y) / 148;

                double angle = myKeep.Heading * ((Math.PI * 2) / 360);         // angle*2pi/360;

                //component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
                //    / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
                //component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));

                component.ComponentX = CalcCX(client.Player, myKeep, angle);
                component.ComponentY = CalcCY(client.Player, myKeep, angle);

                /*
                 * x = (component.X-myKeep.X)/148 = a*cos(t) - b*sin(t)
                 * y = (component.Y-myKeep.Y)/148 = a*sin(t) + b*cos(t)
                 * a = sqrt((x+b*sin(t))^2 + (y-b*cos(t))^2)
                 * a = sqrt(x²+y²+b² +2*x*b*sin(t)-2*y*b*cos(t))
                 * b = sqrt((x-a*cos(t))^2 + (y-a*sin(t))^2)
                 * b = sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))
                 * 0 = 2x²+2y²-2*x*a*cos(t)-2*y*a*sin(t)+2*x*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*sin(t)-2*y*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*cos(t)
                 * pfff
                 * so must find an other way to find it....
                 */
                component.Name          = myKeep.Name;
                component.Model         = INVISIBLE_MODEL;
                component.Skin          = skin;
                component.Level         = (byte)myKeep.Level;
                component.CurrentRegion = client.Player.CurrentRegion;
                component.Health        = component.MaxHealth;
                component.ID            = myKeep.KeepComponents.Count;
                component.Keep.KeepComponents.Add(component);
                component.SaveInDB = true;
                component.AddToWorld();
                component.SaveIntoDatabase();
                client.Out.SendKeepInfo(myKeep);
                client.Out.SendKeepComponentInfo(component);
                client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Create.KCCreated"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            } break;

                #endregion Create
                #region Move
            case "move":
            {
                GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;

                component.X = client.Player.X;
                component.Y = client.Player.Y;
                component.Z = client.Player.Z;
                component.ComponentHeading = (client.Player.Heading - myKeep.Heading) / 1024;
                component.Heading          = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading);
                component.Keep             = myKeep;
                //todo good formula
                //component.ComponentX = (component.X - myKeep.X) / 148;
                //component.ComponentY = (myKeep.Y - component.Y) / 148;
                double angle = myKeep.Heading * ((Math.PI * 2) / 360);         // angle*2pi/360;

                //component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
                //    / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
                //component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));

                component.ComponentX = CalcCX(client.Player, myKeep, angle);
                component.ComponentY = CalcCY(client.Player, myKeep, angle);

                client.Out.SendKeepInfo(myKeep);
                client.Out.SendKeepComponentInfo(component);
                client.Out.SendKeepComponentDetailUpdate(component);
                client.Out.SendMessage("Component moved.  Use /keepcomponent save to save, or reload to reload the original position.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            } break;

                #endregion
                #region Rotate
            case "rotate":
            {
                try
                {
                    ushort amount = Convert.ToUInt16(args[2]);

                    if (amount > 3)
                    {
                        amount = 3;
                    }

                    GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;

                    component.ComponentHeading = amount;
                    component.Heading          = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading);

                    client.Out.SendKeepInfo(myKeep);
                    client.Out.SendKeepComponentInfo(component);
                    client.Out.SendKeepComponentDetailUpdate(component);
                    client.Out.SendMessage("Component rotated.  Use /keepcomponent save to save, or reload to reload the original position.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                catch
                {
                    DisplayMessage(client, "/keepcomponent rotate [0 - 3]");
                }
            } break;

                #endregion
                #region Skin
            case "skin":
            {
                if (args.Length < 3)
                {
                    int i = 0;
                    foreach (string str in Enum.GetNames(typeof(GameKeepComponent.eComponentSkin)))
                    {
                        client.Out.SendMessage("#" + i + ": " + str, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        i++;
                    }
                    DisplaySyntax(client);
                    return;
                }

                int skin = 0;
                try
                {
                    skin = Convert.ToInt32(args[2]);
                }
                catch
                {
                    DisplaySyntax(client);
                    return;
                }
                GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
                if (component == null)
                {
                    DisplaySyntax(client);
                    return;
                }
                component.Skin = skin;
                foreach (GameClient cli in WorldMgr.GetClientsOfRegion(client.Player.CurrentRegionID))
                {
                    cli.Out.SendKeepComponentInfo(component);
                    cli.Out.SendKeepComponentDetailUpdate(component);
                }
                //client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Skin.YChangeSkin"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                client.Out.SendMessage("Component skin updated.  Use /keepcomponent save to save, or reload to reload the original skin.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            } break;

                #endregion Skin
                #region Delete
            case "delete":
            {
                GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
                if (component == null)
                {
                    DisplaySyntax(client);
                    return;
                }
                component.RemoveFromWorld();
                component.Delete();
                component.DeleteFromDatabase();
                client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Delete.YDeleteKC"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            } break;

                #endregion Delete
                #region Save
            case "save":
            {
                GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
                if (component == null)
                {
                    DisplaySyntax(client);
                    return;
                }
                component.SaveIntoDatabase();
                client.Out.SendMessage(string.Format("Saved ComponentID: {0}, KeepID: {1}, Skin: {2}, Health: {3}%",
                                                     component.ID,
                                                     (component.Keep == null ? "0" : component.Keep.KeepID.ToString()),
                                                     component.Skin,
                                                     component.HealthPercent), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            } break;

                #endregion Save
                #region Reload
            case "reload":
            {
                GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
                if (component == null)
                {
                    DisplaySyntax(client);
                    return;
                }

                var dbcomponent = DOLDB <DBKeepComponent> .SelectObject(DB.Column(nameof(DBKeepComponent.KeepID)).IsEqualTo(component.Keep.KeepID).And(DB.Column(nameof(DBKeepComponent.ID)).IsEqualTo(component.ID)));

                component.ComponentX       = dbcomponent.X;
                component.ComponentY       = dbcomponent.Y;
                component.ComponentHeading = dbcomponent.Heading;
                component.Skin             = dbcomponent.Skin;

                foreach (GameClient cli in WorldMgr.GetClientsOfRegion(client.Player.CurrentRegionID))
                {
                    cli.Out.SendKeepComponentInfo(component);
                    cli.Out.SendKeepComponentDetailUpdate(component);
                }

                client.Out.SendMessage("Component Reloaded", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                break;
            }

                #endregion Reload
                #region Default
            default:
            {
                DisplaySyntax(client);
                return;
            }
                #endregion Default
            }
        }
Beispiel #21
0
        public List <string> GetOnlineInfo(bool bGM)
        {
            List <string> output  = new List <string>();
            ArrayList     clients = WorldMgr.GetAllClients();

            int gms = 0, connecting = 0, charscreen = 0, enterworld = 0,
                playing = 0, linkdeath = 0, disconnecting = 0;
            int midTanks = 0, hibTanks = 0, albTanks = 0, midCasters = 0,
                hibCasters = 0, albCasters = 0, midSupport = 0,
                hibSupport = 0, albSupport = 0, hibStealthers = 0,
                midStealthers = 0, albStealthers = 0;

            #region filling classcount list
            classcount.Clear();
            classcount.Add(new ClassToCount("Armsman", 0));         // 0
            classcount.Add(new ClassToCount("Mercenary", 0));       //1
            classcount.Add(new ClassToCount("Paladin", 0));         //2
            classcount.Add(new ClassToCount("Reaver", 0));          //3
            classcount.Add(new ClassToCount("Heretic", 0));         //4
            classcount.Add(new ClassToCount("Albion Mauler", 0));   //5
            classcount.Add(new ClassToCount("Cabalist", 0));        //6
            classcount.Add(new ClassToCount("Sorcerer", 0));        //7
            classcount.Add(new ClassToCount("Theurgist", 0));       //8
            classcount.Add(new ClassToCount("Wizard", 0));          //9
            classcount.Add(new ClassToCount("Necromancer", 0));     //10
            classcount.Add(new ClassToCount("Cleric", 0));          //11
            classcount.Add(new ClassToCount("Friar", 0));           //12
            classcount.Add(new ClassToCount("Minstrel", 0));        //13
            classcount.Add(new ClassToCount("Infiltrator", 0));     //14
            classcount.Add(new ClassToCount("Scout", 0));           //15
            classcount.Add(new ClassToCount("Berserker", 0));       //16
            classcount.Add(new ClassToCount("Savage", 0));          //17
            classcount.Add(new ClassToCount("Skald", 0));           //18
            classcount.Add(new ClassToCount("Thane", 0));           //19
            classcount.Add(new ClassToCount("Warrior", 0));         //20
            classcount.Add(new ClassToCount("Valkyrie", 0));        //21
            classcount.Add(new ClassToCount("Midgard Mauler", 0));  //22
            classcount.Add(new ClassToCount("Bonedancer", 0));      //23
            classcount.Add(new ClassToCount("Runemaster", 0));      //24
            classcount.Add(new ClassToCount("Spiritmaster", 0));    //25
            classcount.Add(new ClassToCount("Warlock", 0));         //26
            classcount.Add(new ClassToCount("Healer", 0));          //27
            classcount.Add(new ClassToCount("Shaman", 0));          //28
            classcount.Add(new ClassToCount("Hunter", 0));          //29
            classcount.Add(new ClassToCount("Shadowblade", 0));     //30
            classcount.Add(new ClassToCount("Blademaster", 0));     //31
            classcount.Add(new ClassToCount("Champion", 0));        //32
            classcount.Add(new ClassToCount("Hero", 0));            //33
            classcount.Add(new ClassToCount("Valewalker", 0));      //34
            classcount.Add(new ClassToCount("Hibernia Mauler", 0)); //35
            classcount.Add(new ClassToCount("Vampiir", 0));         //36
            classcount.Add(new ClassToCount("Eldritch", 0));        //37
            classcount.Add(new ClassToCount("Enchanter", 0));       //38
            classcount.Add(new ClassToCount("Mentalist", 0));       //39
            classcount.Add(new ClassToCount("Animist", 0));         //40
            classcount.Add(new ClassToCount("Bainshee", 0));        //41
            classcount.Add(new ClassToCount("Bard", 0));            //42
            classcount.Add(new ClassToCount("Druid", 0));           //43
            classcount.Add(new ClassToCount("Warden", 0));          //44
            classcount.Add(new ClassToCount("Nightshade", 0));      //45
            classcount.Add(new ClassToCount("Ranger", 0));          //46
            #endregion


            // Number of Alb, Mid and Hib tanks:
            foreach (GameClient c in clients)
            {
                if (c == null)
                {
                    continue;
                }


                #region count GMs, and different client states
                if (c.ClientState == GameClient.eClientState.Connecting)
                {
                    ++connecting;
                }
                else if (c.ClientState == GameClient.eClientState.Disconnected)
                {
                    ++disconnecting;
                }
                else if (c.ClientState == GameClient.eClientState.CharScreen)
                {
                    ++charscreen;
                }
                else if (c.ClientState == GameClient.eClientState.Linkdead)
                {
                    ++linkdeath;
                }
                else if (c.ClientState == GameClient.eClientState.WorldEnter)
                {
                    ++enterworld;
                }
                else if (c.ClientState == GameClient.eClientState.Playing)
                {
                    ++playing;
                }
                else
                {
                    continue;
                }

                // if a legal playing client, count some special things
                if (!c.IsPlaying ||
                    c.Account == null ||
                    c.Player == null ||
                    c.Player.ObjectState != GameObject.eObjectState.Active)
                {
                    continue;
                }

                if (c.Account.PrivLevel >= (uint)ePrivLevel.GM)
                {
                    ++gms;
                    continue;
                }

                #endregion

                #region class specific counting
                switch (c.Player.CharacterClass.ID)
                {   // Alb tanks:
                case (int)eCharacterClass.Armsman:
                { ++albTanks; classcount[0].count++; }
                break;

                case (int)eCharacterClass.Mercenary:
                { ++albTanks; classcount[1].count++; }
                break;

                case (int)eCharacterClass.Paladin:
                { ++albTanks; classcount[2].count++; }
                break;

                case (int)eCharacterClass.Reaver:
                { ++albTanks; classcount[3].count++; }
                break;

                case (int)eCharacterClass.Heretic:
                { ++albTanks; classcount[4].count++; }
                break;

                case (int)eCharacterClass.Mauler_Alb:
                { ++albTanks; classcount[5].count++; }
                break;

                // Alb casters:
                case (int)eCharacterClass.Cabalist:
                { ++albCasters; classcount[6].count++; }
                break;

                case (int)eCharacterClass.Sorcerer:
                { ++albCasters; classcount[7].count++; }
                break;

                case (int)eCharacterClass.Theurgist:
                { ++albCasters; classcount[8].count++; }
                break;

                case (int)eCharacterClass.Wizard:
                { ++albCasters; classcount[9].count++; }
                break;

                case (int)eCharacterClass.Necromancer:
                { ++albCasters; classcount[10].count++; }
                break;

                // Alb support:
                case (int)eCharacterClass.Cleric:
                { ++albSupport; classcount[11].count++; }
                break;

                case (int)eCharacterClass.Friar:
                { ++albSupport; classcount[12].count++; }
                break;

                case (int)eCharacterClass.Minstrel:
                { ++albSupport; classcount[13].count++; }
                break;

                // Alb stealthers:
                case (int)eCharacterClass.Infiltrator:
                { ++albStealthers; classcount[14].count++; }
                break;

                case (int)eCharacterClass.Scout:
                { ++albStealthers; classcount[15].count++; }
                break;

                // Mid tanks:
                case (int)eCharacterClass.Berserker:
                { ++midTanks; classcount[16].count++; }
                break;

                case (int)eCharacterClass.Savage:
                { ++midTanks; classcount[17].count++; }
                break;

                case (int)eCharacterClass.Skald:
                { ++midTanks; classcount[18].count++; }
                break;

                case (int)eCharacterClass.Thane:
                { ++midTanks; classcount[19].count++; }
                break;

                case (int)eCharacterClass.Warrior:
                { ++midTanks; classcount[20].count++; }
                break;

                case (int)eCharacterClass.Valkyrie:
                { ++midTanks; classcount[21].count++; }
                break;

                case (int)eCharacterClass.Mauler_Mid:
                { ++midTanks; classcount[22].count++; }
                break;

                // Mid casters:
                case (int)eCharacterClass.Bonedancer:
                { ++midCasters; classcount[23].count++; }
                break;

                case (int)eCharacterClass.Runemaster:
                { ++midCasters; classcount[24].count++; }
                break;

                case (int)eCharacterClass.Spiritmaster:
                { ++midCasters; classcount[25].count++; }
                break;

                case (int)eCharacterClass.Warlock:
                { ++midCasters; classcount[26].count++; }
                break;

                // Mid support:
                case (int)eCharacterClass.Healer:
                { ++midSupport; classcount[27].count++; }
                break;

                case (int)eCharacterClass.Shaman:
                { ++midSupport; classcount[28].count++; }
                break;

                // Mid stealthers:
                case (int)eCharacterClass.Hunter:
                { ++midStealthers; classcount[29].count++; }
                break;

                case (int)eCharacterClass.Shadowblade:
                { ++midStealthers; classcount[30].count++; }
                break;

                // Hib tanks:
                case (int)eCharacterClass.Blademaster:
                { ++hibTanks; classcount[31].count++; }
                break;

                case (int)eCharacterClass.Champion:
                { ++hibTanks; classcount[32].count++; }
                break;

                case (int)eCharacterClass.Hero:
                { ++hibTanks; classcount[33].count++; }
                break;

                case (int)eCharacterClass.Valewalker:
                { ++hibTanks; classcount[34].count++; }
                break;

                case (int)eCharacterClass.Mauler_Hib:
                { ++hibTanks; classcount[35].count++; }
                break;

                case (int)eCharacterClass.Vampiir:
                { ++hibTanks; classcount[36].count++; }
                break;

                // Hib casters:
                case (int)eCharacterClass.Eldritch:
                { ++hibCasters; classcount[37].count++; }
                break;

                case (int)eCharacterClass.Enchanter:
                { ++hibCasters; classcount[38].count++; }
                break;

                case (int)eCharacterClass.Mentalist:
                { ++hibCasters; classcount[39].count++; }
                break;

                case (int)eCharacterClass.Animist:
                { ++hibCasters; classcount[40].count++; }
                break;

                case (int)eCharacterClass.Bainshee:
                { ++hibCasters; classcount[41].count++; }
                break;

                // Hib support:
                case (int)eCharacterClass.Bard:
                { ++hibSupport; classcount[42].count++; }
                break;

                case (int)eCharacterClass.Druid:
                { ++hibSupport; classcount[43].count++; }
                break;

                case (int)eCharacterClass.Warden:
                { ++hibSupport; classcount[44].count++; }
                break;

                // Hib stealthers:
                case (int)eCharacterClass.Nightshade:
                { ++hibStealthers; classcount[45].count++; }
                break;

                case (int)eCharacterClass.Ranger:
                { ++hibStealthers; classcount[46].count++; }
                break;
                }
                #endregion
            }



            #region overview and class-specific
            int entering = connecting + enterworld + charscreen;
            int leaving  = disconnecting + linkdeath;
            int albTotal = albTanks + albCasters + albSupport + albStealthers;
            int midTotal = midTanks + midCasters + midSupport + midStealthers;
            int hibTotal = hibTanks + hibCasters + hibSupport + hibStealthers;
            int total    = entering + playing + leaving;
            output.Add(string.Format("Currently online:  {0}\n Playing:  {1} | Entering:  {2} | Leaving:  {3}",
                                     total, playing, entering, leaving));
            if (showAddOnlineInfo == true)
            {
                output.Add(string.Format("\n  (Connecting:  {0} | CharScreen:  {1} | EnterWorld:  {2} \nPlaying:  {3} | LinkDeath:  {4} | Disconnected:  {5} \nGMs:  {6})",
                                         connecting, enterworld, charscreen, playing, linkdeath, disconnecting, gms));
            }
            if (showRealms == true)
            {
                output.Add(string.Format("\nAlbion:  {4} ( {5}% )\n  Tanks:  {0} | Casters:  {1} \n  Supporters:  {2} | Stealthers:  {3}",
                                         albTanks, albCasters, albSupport, albStealthers, albTotal, (int)(albTotal * 100 / total)));
                output.Add(string.Format("\nMidgard:  {4} ( {5}% )\n  Tanks:  {0} | Casters:  {1} \n  Supporters:  {2} | Stealthers:  {3}",
                                         midTanks, midCasters, midSupport, midStealthers, midTotal, (int)(midTotal * 100 / total)));
                output.Add(string.Format("\nHibernia:  {4} ( {5}% )\n  Tanks:  {0} | Casters:  {1} \n  Supporters:  {2} | Stealthers:  {3}",
                                         hibTanks, hibCasters, hibSupport, hibStealthers, hibTotal, (int)(hibTotal * 100 / total)));
            }
            Zone      zone          = null;
            ArrayList cls           = new ArrayList();
            int       albsinregion  = 0;
            int       midsinregion  = 0;
            int       hibsinregion  = 0;
            int       totalinregion = 0;
            if (zoneIDs.Length > 0 && showByZone == true)
            {
                for (int r = 0; r < zoneIDs.Length; r++)
                {
                    albsinregion  = 0;
                    midsinregion  = 0;
                    hibsinregion  = 0;
                    totalinregion = 0;

                    zone = WorldMgr.GetZone(zoneIDs[r]);

                    cls = WorldMgr.GetClientsOfRegion(zone.ZoneRegion.ID);
                    foreach (GameClient cir in cls)
                    {
                        if (!cir.IsPlaying ||
                            cir.Account == null ||
                            cir.Player == null ||
                            cir.Player.ObjectState != GameObject.eObjectState.Active)
                        {
                            continue;
                        }

                        if (cir.Account.PrivLevel >= (uint)ePrivLevel.GM)
                        {
                            continue;
                        }

                        if (cir.Player.CurrentZone.Description != zone.Description)
                        {
                            continue;
                        }



                        if (cir.Player.Realm == eRealm.Albion)
                        {
                            albsinregion++;
                        }
                        else if (cir.Player.Realm == eRealm.Midgard)
                        {
                            midsinregion++;
                        }
                        else if (cir.Player.Realm == eRealm.Hibernia)
                        {
                            hibsinregion++;
                        }

                        totalinregion++;
                    }


                    output.Add(string.Format("\nPlayers in {0}: {1} \n Albs: {2} | Mids: {3} | Hibs: {4}", zone.Description, totalinregion, albsinregion, midsinregion, hibsinregion));
                }
            }


            if (showDetailedClass == true)
            {
                output.Add(string.Format("\n"));
                lock (classcount)
                {
                    classcount.Sort(delegate(ClassToCount ctc1, ClassToCount ctc2) { return(ctc1.count.CompareTo(ctc2.count)); });
                    classcount.Reverse();
                    for (int c = 0; c < classcount.Count; c++)
                    {
                        if (classcount[c].count > 0)
                        {
                            output.Add(string.Format("{0}: {1} ({2}%)", classcount[c].name, classcount[c].count.ToString(), (int)(classcount[c].count * 100 / total)));
                        }
                    }
                }
            }


            #endregion


            return(output);
        }
        /// <summary>
        /// reset the realm when the lord have been killed
        /// </summary>
        /// <param name="realm"></param>
        public virtual void Reset(eRealm realm)
        {
            LastAttackedByEnemyTick = 0;
            StartCombatTick         = 0;

            Realm = realm;

            PlayerMgr.BroadcastCapture(this);

            Level = (byte)ServerProperties.Properties.STARTING_KEEP_LEVEL;

            //if a guild holds the keep, we release it
            if (Guild != null)
            {
                Release();
            }
            //we repair all keep components, but not if it is a tower and is raised
            foreach (GameKeepComponent component in this.KeepComponents)
            {
                if (!component.IsRaized)
                {
                    component.Repair(component.MaxHealth - component.Health);
                }
                foreach (GameKeepHookPoint hp in component.KeepHookPoints.Values)
                {
                    if (hp.Object != null)
                    {
                        hp.Object.Die(null);
                    }
                }
            }
            //change realm
            foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID))
            {
                client.Out.SendKeepComponentUpdate(this, false);
            }
            //we reset all doors
            foreach (GameKeepDoor door in Doors.Values)
            {
                door.Reset(realm);
            }

            //we make sure all players are not in the air
            ResetPlayersOfKeep();

            //we reset the guards
            foreach (GameKeepGuard guard in Guards.Values)
            {
                if (guard is GuardLord && guard.IsAlive)
                {
                    this.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { guard });
                }
                else if (guard is GuardLord == false)
                {
                    guard.Die(guard);
                }
            }

            //we reset the banners
            foreach (GameKeepBanner banner in Banners.Values)
            {
                banner.ChangeRealm();
            }

            //update guard level for every keep
            if (!IsPortalKeep && ServerProperties.Properties.USE_KEEP_BALANCING)
            {
                GameServer.KeepManager.UpdateBaseLevels();
            }

            //update the counts of keeps for the bonuses
            if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
            {
                KeepBonusMgr.UpdateCounts();
            }

            SaveIntoDatabase();

            GameEventMgr.Notify(KeepEvent.KeepTaken, new KeepEventArgs(this));
        }