コード例 #1
0
        public static bool RestrictionCheckNone(Character __instance, string restriction)
        {
            Character p = __instance;

            // Are we in a zone? if so select that zone.
            if (ZoneHandler.Zones.Count() == 0)
            {
                return(false);
            }
            ZoneHandler.Zone        z     = new ZoneHandler.Zone();
            ZoneHandler.ZoneTypes   zt    = new ZoneHandler.ZoneTypes();
            List <ZoneHandler.Zone> zlist = ZoneHandler.ListOccupiedZones(p.transform.position);

            if (zlist.Count == 0)
            {
                zt = ZoneHandler.FindZoneType("wilderness");
            }
            else
            {
                z  = ZoneHandler.TopZone(zlist);
                zt = ZoneHandler.FindZoneType(z.Type);
            }
            string key = "";

            // Lets set our admin list and keys...
            key = zt.Configurations;
            if (key.ToLower().Contains(restriction))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public static float RestrictionCheckFloatReturnCharacter(Character __instance, string restriction)
        {
            Character p = __instance;
            string    CharacterSteamID = (ZNet.instance.GetPeer(__instance.GetZDOID().m_userID)).m_socket.GetHostName();

            // Are we in a zone? if so select that zone.
            ZoneHandler.Zone        z     = new ZoneHandler.Zone();
            ZoneHandler.ZoneTypes   zt    = new ZoneHandler.ZoneTypes();
            List <ZoneHandler.Zone> zlist = ZoneHandler.ListOccupiedZones(p.transform.position);

            if (zlist.Count == 0)
            {
                zt = ZoneHandler.FindZoneType("wilderness");
            }
            else
            {
                z  = ZoneHandler.TopZone(zlist);
                zt = ZoneHandler.FindZoneType(z.Type);
            }
            string key    = "";
            string admins = "";

            // Lets set our admins and keys..
            admins = zt.Admins;
            key    = zt.Configurations;
            // Lets see if the user is actually an admin in the zone first..
            if (admins.Contains(CharacterSteamID))
            {
                // Ok they are an admin. Therefore, do not initialize the change...
                return(1);
            }
            if (key.ToLower().Contains(restriction))
            {
                string s = key.ToLower();
                string restrictioncheck = restriction + "(";
                int    indexStart       = s.IndexOf(restrictioncheck) + restrictioncheck.Length;
                string test             = "";
                for (int i = indexStart; i < indexStart + 20; i++)
                {
                    if (s[i] == ')')
                    {
                        break;
                    }
                    test += s[i];
                }
                float multiplier = 1;
                multiplier = Convert.ToSingle(test, new CultureInfo("en-US"));
                return(multiplier);
            }
            else
            {
                return(1);
            }
        }
コード例 #3
0
        public static bool RestrictionCheckCharacter(Character __instance, string restriction)
        {
            Character p = __instance;
            string    CharacterSteamID = (ZNet.instance.GetPeer(__instance.GetZDOID().m_userID)).m_socket.GetHostName();

            // Are we in a zone? if so select that zone.
            if (ZoneHandler.Zones.Count() == 0)
            {
                return(false);
            }
            ZoneHandler.Zone        z     = new ZoneHandler.Zone();
            ZoneHandler.ZoneTypes   zt    = new ZoneHandler.ZoneTypes();
            List <ZoneHandler.Zone> zlist = ZoneHandler.ListOccupiedZones(p.transform.position);

            if (zlist.Count == 0)
            {
                zt = ZoneHandler.FindZoneType("wilderness");
            }
            else
            {
                z  = ZoneHandler.TopZone(zlist);
                zt = ZoneHandler.FindZoneType(z.Type);
            }
            string key    = "";
            string admins = "";

            // Lets set our admin list and keys...
            admins = zt.Admins;
            key    = zt.Configurations;
            // Lets check and see if the user is actually an admin in the zone.
            if (admins.Contains(CharacterSteamID))
            {
                return(false);
            }
            if (key.ToLower().Contains(restriction))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        public static bool RestrictionCheck(string restriction)
        {
            Player p = Player.m_localPlayer;

            // Are we in a zone? if so select that zone.
            if (ZoneHandler.Zones.Count() == 0)
            {
                return(false);
            }
            ZoneHandler.Zone        z     = new ZoneHandler.Zone();
            ZoneHandler.ZoneTypes   zt    = new ZoneHandler.ZoneTypes();
            List <ZoneHandler.Zone> zlist = ZoneHandler.ListOccupiedZones(p.transform.position);

            if (zlist.Count == 0)
            {
                zt = ZoneHandler.FindZoneType("wilderness");
            }
            else
            {
                z  = ZoneHandler.TopZone(zlist);
                zt = ZoneHandler.FindZoneType(z.Type);
            }
            string key    = "";
            string admins = "";

            // Lets set our admin list and keys...
            admins = zt.Admins;
            key    = zt.Configurations;
            // Lets check and see if the user is actually an admin in the zone.
            if (admins.Contains(WorldofValheimZones.MySteamID))
            {
                return(false);
            }
            if (key.ToLower().Contains(restriction))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        // WorldofValheimZones.ServerSafeZonePath.Value
        public static void LoadZoneData(string ZonePath)
        {
            Debug.Log($"Loading zone file: {ZonePath}");
            // Clean up the old zone data
            ZoneT.Clear();
            Zones.Clear();
            int pos = 0;

            foreach (string text2 in File.ReadAllLines(ZonePath))
            {
                if (!string.IsNullOrWhiteSpace(text2) && text2[0] != '#')
                {
                    string[] array2 = text2.Split(' ');
                    // Check if it is a type
                    if (array2[0].ToLower() == "type:")
                    {
                        Debug.Log($"Loading Type: {array2[1]}");
                        ZoneTypes zt = new ZoneTypes {
                            Name = array2[1]
                        };

                        // Go through each argument to override defaults.

                        if (array2.Length >= 3)
                        {
                            zt.PVP = bool.Parse(array2[2]);
                        }

                        if (array2.Length >= 4)
                        {
                            zt.PVPEnforce = bool.Parse(array2[3]);
                        }

                        if (array2.Length >= 5)
                        {
                            zt.ShowPosition = bool.Parse(array2[4]);
                        }

                        if (array2.Length >= 6)
                        {
                            zt.PositionEnforce = bool.Parse(array2[5]);
                        }

                        ZoneT.Add(zt);
                    }
                    else if (array2[0].ToLower() == "configuration:")
                    {
                        string   texttosend      = text2.Replace(": ", "|");
                        string[] array           = texttosend.Replace(" | ", "|").Split('|');
                        ZoneHandler.ZoneTypes zt = ZoneHandler.FindZoneType(array[1]);
                        if (zt.Name.ToLower() != array[1].ToString().ToLower())
                        {
                            Debug.Log($"ERROR: While applying custom configuration for the Zone Type: {array[1]},");
                            Debug.Log($"Zone Type: {array[1]} Does not exist in the {WorldofValheimZones.ZonePath.Value} file!");
                            return;
                        }
                        else
                        {
                            Debug.Log($"Loading Custom Configuration for the Zone Type: {array[1]} with an Overridable Permission Node of: 'HackShardGaming.WoV-Zones.Override.{array[1]}'");
                            zt.Admins         = array[2];
                            zt.Configurations = array[3];
                        }
                    }
                    else
                    {
                        if (array2.Length != 7)
                        {
                            Debug.Log($"Zone {text2} is not correctly formated!");
                        }
                        else
                        {
                            Debug.Log($"Loading Zone: {array2[0]}");
                            Zone z = new Zone();
                            z.Name     = array2[0];
                            z.Type     = array2[1];
                            z.Priority = int.Parse(array2[2]);
                            z.Shape    = array2[3];
                            Vector2     posi = new Vector3();
                            CultureInfo info = new CultureInfo("en-US");
                            z.Position = new Vector2(Convert.ToSingle(array2[4], info), Convert.ToSingle(array2[5], info));
                            z.Radius   = Convert.ToSingle(array2[6], info);
                            //z.pvp = bool.Parse(array2[7]);
                            z.ID = pos;
                            Zones.Add(z);
                            pos++;
                        }
                    }
                }
            }
#if DEBUG
            _debug();
#endif
        }
コード例 #6
0
        /// <summary>
        /// FixedUpdate<> Patch
        /// Includes the following:
        ///     PushAway (Do not enter zone)
        ///     PeriodicDamage
        ///     PeriodicHeal
        ///     Last Updated: 4/24/2021
        ///     Status: 100% Working
        /// </summary>
        public static void FixedUpdatez()
        {
            if (WorldofValheimZones.EffectTick > 0)
            {
                WorldofValheimZones.EffectTick--;
            }
            if (WorldofValheimZones.HealTick > 0)
            {
                WorldofValheimZones.HealTick--;
            }
            if (WorldofValheimZones.DamageTick > 0)
            {
                WorldofValheimZones.DamageTick--;
            }
            Player p = Player.m_localPlayer;

            if (p != null)
            {
                // Are we in a zone? if so select that zone.
                ZoneHandler.Zone        z     = new ZoneHandler.Zone();
                ZoneHandler.ZoneTypes   zt    = new ZoneHandler.ZoneTypes();
                List <ZoneHandler.Zone> zlist = ZoneHandler.ListOccupiedZones(p.transform.position);
                if (zlist.Count == 0)
                {
                    zt = ZoneHandler.FindZoneType("wilderness");
                }
                else
                {
                    z  = ZoneHandler.TopZone(zlist);
                    zt = ZoneHandler.FindZoneType(z.Type);
                }
                // Lets set our strings...
                string admins = zt.Admins;
                string key    = zt.Configurations;
                // Lets see if the user is considered a Zone Admin!
                if (admins.Contains(WorldofValheimZones.MySteamID))
                {
                    return;
                }
                // Keep player out of an area.
                if (key.ToLower().Contains("pushaway"))
                {
                    Vector3 zposition  = new Vector3(z.Position.x, p.transform.position.y, z.Position.y);
                    Vector3 newVector3 = p.transform.position +
                                         (p.transform.position - zposition).normalized * 0.15f;
                    p.transform.position = new Vector3(newVector3.x, p.transform.position.y, newVector3.z);
                }
                // Deal damage to the player while they are in the area.
                if (key.ToLower().Contains("periodicdamage") && WorldofValheimZones.DamageTick <= 0)
                {
                    WorldofValheimZones.DamageTick = 100;
                    string s          = key.ToLower();
                    int    indexStart = s.IndexOf("periodicdamage(") + "periodicdamage(".Length;
                    string test       = "";
                    for (int i = indexStart; i < indexStart + 30; i++)
                    {
                        if (s[i] == ')')
                        {
                            break;
                        }
                        test += s[i];
                    }
                    int      damage = 0;
                    HitData  hit    = new HitData();
                    string[] array  = test.Split(',');
                    if (array.Count() == 2)
                    {
                        int.TryParse(array[1], out damage);
                        if (array[0].ToLower() == "fire")
                        {
                            hit.m_damage.m_fire = (float)damage;
                        }
                        else if (array[0].ToLower() == "frost")
                        {
                            hit.m_damage.m_frost = (float)damage;
                        }
                        else if (array[0].ToLower() == "poison")
                        {
                            hit.m_damage.m_poison = (float)damage;
                        }
                        else if (array[0].ToLower() == "lightning")
                        {
                            hit.m_damage.m_lightning = (float)damage;
                        }
                        else if (array[0].ToLower() == "pierce")
                        {
                            hit.m_damage.m_pierce = (float)damage;
                        }
                        else if (array[0].ToLower() == "blunt")
                        {
                            hit.m_damage.m_blunt = (float)damage;
                        }
                        else if (array[0].ToLower() == "slash")
                        {
                            hit.m_damage.m_slash = (float)damage;
                        }
                        else if (array[0].ToLower() == "damage")
                        {
                            hit.m_damage.m_damage = (float)damage;
                        }
                        else
                        {
                            hit.m_damage.m_fire = (float)damage;
                        }
                    }
                    else
                    {
                        int.TryParse(test, out damage);
                        hit.m_damage.m_fire = (float)damage;
                    }
                    p.Damage(hit);
                }
                // Heal the player while they are in the area
                if (key.ToLower().Contains("periodicheal") && WorldofValheimZones.HealTick <= 0)
                {
                    WorldofValheimZones.HealTick = 50;
                    string s          = key.ToLower();
                    int    indexStart = s.IndexOf("periodicheal(") + "periodicheal(".Length;
                    string test       = "";
                    for (int i = indexStart; i < indexStart + 20; i++)
                    {
                        if (s[i] == ')')
                        {
                            break;
                        }
                        test += s[i];
                    }
                    int damage = 0;
                    int.TryParse(test, out damage);
                    p.Heal(damage, true);
                }
            }
        }
コード例 #7
0
 public static void AddZone(long sender, ZPackage pkg)
 {
     if (pkg != null && pkg.Size() > 0)
     {                                                                                                 // Check that our Package is not null, and if it isn't check that it isn't empty.
         ZNetPeer peer = ZNet.instance.GetPeer(sender);                                                // Get the Peer from the sender, to later check the SteamID against our Adminlist.
         if (peer != null)
         {                                                                                             // Confirm the peer exists
             string permissionnode   = "HackShardGaming.WoV-Zones.Add";
             string peerSteamID      = ((ZSteamSocket)peer.m_socket).GetPeerID().m_SteamID.ToString(); // Get the SteamID from peer.
             bool   PlayerPermission = ValheimPermissions.ValheimDB.CheckUserPermission(peerSteamID, permissionnode);
             if (PlayerPermission)
             {
                 string   msg     = pkg.ReadString();
                 string[] results = msg.Split(' ');
                 string   Name    = results[0];
                 Debug.Log($"C-<S AddZone (RPC Call)");
                 string Type = results[1];
                 ZoneHandler.ZoneTypes zt = ZoneHandler.FindZoneType(results[1]);
                 if (zt.Name != Type)
                 {
                     msg = $"ERROR: The requested Zone Type {Type} does not exist!";
                     Util.RoutedBroadcast(sender, msg);
                     return;
                 }
                 int Priority = Int32.Parse(results[2]);
                 if (Priority < 1 || Priority > 5)
                 {
                     msg = $"ERROR: The requested Priority {Priority} is out of bounds! (Priorities are ranged from 1-5)!";
                     Util.RoutedBroadcast(sender, msg);
                     return;
                 }
                 string Shape = results[3];
                 if (Shape.ToLower() != "circle" && Shape.ToLower() != "square")
                 {
                     msg = $"ERROR: The requested Shape: {Shape} is incorrectly formated! (Shapes can either be circle or square only)";
                     Util.RoutedBroadcast(sender, msg);
                     return;
                 }
                 Single i = new float();
                 string X = results[4];
                 if (!Single.TryParse(X, out i))
                 {
                     msg = $"ERROR: The requested X {X} is incorrectly formated! (Correct Format is 0.0)!";
                     Util.RoutedBroadcast(sender, msg);
                     return;
                 }
                 string Y = results[5];
                 if (!Single.TryParse(Y, out i))
                 {
                     msg = $"ERROR: The requested Y {Y} is incorrectly formated! (Correct Format is 0.0)!";
                     Util.RoutedBroadcast(sender, msg);
                     return;
                 }
                 string R = results[6];
                 if (!Single.TryParse(R, out i))
                 {
                     msg = $"ERROR: The requested Radius {R} is incorrectly formated! (Correct Format is 0.0)!";
                     Util.RoutedBroadcast(sender, msg);
                     return;
                 }
                 string addline = Name + " " + Type + " " + Priority + " " + Shape + " " + X + " " + Y + " " + R;
                 File.AppendAllText(WorldofValheimZones.ZonePath.Value, addline + Environment.NewLine);
             }
             else
             {
                 Util.RoutedBroadcast(sender, $"Sorry! You do not have the permission to use !AddZone (Required Permission: {permissionnode})");
                 Debug.Log($"An unauthorized user {peerSteamID} attempted to use the AddZone RPC!");
                 string msg = pkg.ReadString();
                 Debug.Log($"Here is a log of the attempted AddZone {msg}");
             }
         }
     }
 }