Exemplo n.º 1
0
        /// <summary>
        /// Reset the keep with special server rules handling
        /// </summary>
        /// <param name="lord">The lord that was killed</param>
        /// <param name="killer">The lord's killer</param>
        public override void ResetKeep(GuardLord lord, GameObject killer)
        {
            base.ResetKeep(lord, killer);
            eRealm realm = eRealm.None;

            // pvp servers, the realm changes to the group leaders realm
            if (killer is GamePlayer gamePlayer)
            {
                Group group = gamePlayer.Group;
                realm = group?.Leader.Realm ?? killer.Realm;
            }
            else if ((killer as GameNPC)?.Brain is IControlledBrain)
            {
                GamePlayer player = (((GameNPC)killer).Brain as IControlledBrain)?.GetPlayerOwner();
                Group      group  = null;
                if (player != null)
                {
                    group = player.Group;
                }

                realm = group?.Leader.Realm ?? killer.Realm;
            }

            lord.Component.AbstractKeep.Reset(realm);
        }
Exemplo n.º 2
0
        public void GetArmorAbsorb_AnySlot_L30GuardLord_32Percent()
        {
            var guard = new GuardLord();

            guard.Level        = 30;
            guard.Constitution = 60;

            var actual = guard.GetArmorAbsorb(eArmorSlot.NOTSET);

            Assert.AreEqual(0.32, actual, 0.001);
        }
Exemplo n.º 3
0
        private long m_nextCallForHelpTime = 0;         // Used to limit how often keep lords call for help
        /// <summary>
        /// Bring all alive keep guards to defend the lord
        /// </summary>
        /// <param name="trigger">The entity which triggered the BAF.</param>
        protected override void BringFriends(GameLiving trigger)
        {
            if (GameServer.Instance.Configuration.ServerType == eGameServerType.GST_PvE)
            {
                GuardLord lord        = Body as GuardLord;
                long      currenttime = DateTime.UtcNow.Ticks;

                if (lord != null && m_nextCallForHelpTime < currenttime)
                {
                    // Don't call for help more than once every minute
                    m_nextCallForHelpTime = currenttime + TimeSpan.TicksPerMinute;

                    int iGuardsResponding = 0;

                    foreach (GameKeepGuard guard in lord.Component.Keep.Guards.Values)
                    {
                        if (guard != null && guard.IsAlive && guard.IsAvailable)
                        {
                            if (guard.AssistLord(lord))
                            {
                                iGuardsResponding++;
                            }
                        }
                    }

                    string sMessage = $"{lord.Name} bellows for assistance ";
                    if (iGuardsResponding == 0)
                    {
                        sMessage += "but no guards respond!";
                    }
                    else
                    {
                        sMessage += $"and {iGuardsResponding} guards respond!";
                    }

                    foreach (GamePlayer player in lord.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE, true))
                    {
                        if (player != null)
                        {
                            ChatUtil.SendErrorMessage(player, sMessage);
                        }
                    }
                }
            }
            else
            {
                base.BringFriends(trigger);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reset the keep with special server rules handling
        /// </summary>
        /// <param name="lord">The lord that was killed</param>
        /// <param name="killer">The lord's killer</param>
        public override void ResetKeep(GuardLord lord, GameObject killer)
        {
            base.ResetKeep(lord, killer);
            eRealm realm = eRealm.None;

            //pvp servers, the realm changes to the group leaders realm
            if (killer is GamePlayer)
            {
                Group group = ((killer as GamePlayer).Group);
                if (group != null)
                {
                    realm = (eRealm)group.Leader.Realm;
                }
                else
                {
                    realm = (eRealm)killer.Realm;
                }
            }
            else if (killer is GameNPC && (killer as GameNPC).Brain is IControlledBrain)
            {
                GamePlayer player = ((killer as GameNPC).Brain as IControlledBrain).GetPlayerOwner();
                Group      group  = null;
                if (player != null)
                {
                    group = player.Group;
                }
                if (group != null)
                {
                    realm = (eRealm)group.Leader.Realm;
                }
                else
                {
                    realm = (eRealm)killer.Realm;
                }
            }
            lord.Component.Keep.Reset(realm);
        }
Exemplo n.º 5
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.º 6
0
 /// <summary>
 /// Reset the keep with special server rules handling
 /// </summary>
 /// <param name="lord">The lord that was killed</param>
 /// <param name="killer">The lord's killer</param>
 public override void ResetKeep(GuardLord lord, GameObject killer)
 {
     base.ResetKeep(lord, killer);
     lord.Component.Keep.Reset((eRealm)killer.Realm);
 }