示例#1
0
        /// <summary>
        /// New - Resets the program settings and clears out the program data
        /// </summary>
        /// <returns></returns>
        public void New()
        {
            // Reset the address values
            StartAddress = 0;
            EndAddress   = 0;
            ExeAddress   = 0;

            // Reset the program format
            Format = 0;

            // Reset the program status flag
            m_protectionStatus = ProtectionStatus.Unprotected;

            m_programFormat = ProgramFormat.UnknownFile;

            // Reset the AutoRun flag
            AutoRun = AutoRunFlag.Disabled;

            // Reset the program name
            ProgramName = "";

            // Reset the program data
            if (m_programData != null)
            {
                m_programData.Initialize();
            }
        }
示例#2
0
        private HitInfo OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            if (entity is BasePlayer)
            {
                var player = entity as BasePlayer;
                if (protData.ContainsKey(player.userID))
                {
                    ProtectionStatus protInfo = protData[player.userID] as ProtectionStatus;
                    if (protInfo.isDebug)
                    {
                        ReplyChat(player, "DMG done! By: " + hitInfo.Initiator.ToString());
                    }
                    if (hitInfo.Initiator is BasePlayer && protInfo.MsgType != ProtectionStatus.msgType.Silent && hitInfo.Initiator != player) //
                    {
                        var attacker = hitInfo.Initiator as BasePlayer;

                        if (protInfo.isDebug)
                        {
                            ReplyChat(player, "Player name: " + attacker.displayName);
                        }

                        ulong attackerID = attacker.userID;
                        if (antiSpam.ContainsKey(attackerID))
                        {
                            if ((DateTime.Now - antiSpam[attackerID]).TotalSeconds > 30)
                            {
                                if (protInfo.MsgType != ProtectionStatus.msgType.OnlyTarget)
                                {
                                    attacker.ChatMessage(string.Format(APHelper["NoAPDamageAttacker"], player.displayName));
                                }
                                ReplyChat(player, string.Format(APHelper["NoAPDamagePlayer"], attacker.displayName));
                                antiSpam[attackerID] = DateTime.Now;
                            }
                        }
                        else
                        {
                            antiSpam.Add(attackerID, DateTime.Now);
                            if (protInfo.MsgType != ProtectionStatus.msgType.OnlyTarget)
                            {
                                attacker.ChatMessage(string.Format(APHelper["NoAPDamageAttacker"], player.displayName));
                            }
                            ReplyChat(player, string.Format(APHelper["NoAPDamagePlayer"], attacker.displayName));
                        }
                    }
                    if (protInfo.isDebug)
                    {
                        ReplyChat(player, "DMG is 0 now");
                    }
                    hitInfo.damageTypes.ScaleAll(0f);
                    return(hitInfo);
                }
            }
            return(null);
        }
 public ProtectMove(String name, String description, double accuracy, String target, int level, int energyPoints, int maxEnergyPoints, ProtectionStatus protectMoveType, double successionPercent)
 {
     MoveName            = name;
     MoveDescription     = description;
     PrimaryMoveAccuracy = accuracy;
     MoveTarget          = target;
     MoveLevel           = level;
     MoveEnergyPoints    = energyPoints;
     MoveMaxEnergyPoints = maxEnergyPoints;
     ProtectMoveType     = protectMoveType;
     SuccessionRate      = successionPercent;
     ProtectionAccuracy  = PrimaryMoveAccuracy;
     MoveType            = "PROTECT";
 }
 private HitInfo OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
 {
     if (entity is BasePlayer)
     {
         var player = entity as BasePlayer;
         if (protData.ContainsKey(player.userID.ToString()))
         {
             ProtectionStatus protInfo = protData[player.userID.ToString()] as ProtectionStatus;
             if (protInfo.Enabled)
             {
                 if (hitInfo.Initiator is BasePlayer && !protInfo.Silent && hitInfo.Initiator != player) //
                 {
                     var    attacker   = hitInfo.Initiator as BasePlayer;
                     string attackerID = attacker.userID.ToString();
                     if (antiSpam.ContainsKey(attackerID))
                     {
                         if ((DateTime.Now - antiSpam[attackerID]).TotalSeconds > 30)
                         {
                             if (!protInfo.NoMsgToPlayer)
                             {
                                 attacker.ChatMessage(string.Format(APHelper["NoAPDamageAttacker"], player.displayName));
                             }
                             player.ChatMessage(string.Format(APHelper["NoAPDamagePlayer"], attacker.displayName));
                             antiSpam[attackerID] = DateTime.Now;
                         }
                     }
                     else
                     {
                         antiSpam.Add(attackerID, DateTime.Now);
                         if (!protInfo.NoMsgToPlayer)
                         {
                             attacker.ChatMessage(string.Format(APHelper["NoAPDamageAttacker"], player.displayName));
                         }
                         player.ChatMessage(string.Format(APHelper["NoAPDamagePlayer"], attacker.displayName));
                     }
                 }
                 return(new HitInfo());
             }
         }
     }
     return(null);
 }
        private Move MakeProtectMove(MySqlDataReader reader, Move moveTwo, String name, String description, int level, String archetype, int energyPoints)
        {
            // primary_move_target, primary_move_accuracy, protect_move_type, succession_percent
            String           primaryMoveTarget   = reader.GetString("primary_move_target");
            double           primaryMoveAccuracy = reader.GetDouble("primary_move_accuracy");
            ProtectionStatus protectMoveType     = MakeProtectionStatus(reader.GetString("protect_move_type"));
            double           successionPercent   = reader.GetDouble("succession_percent");
            Move             move = null;

            if (moveTwo == null)
            {
                move = new ProtectMove(name, description, primaryMoveAccuracy, primaryMoveTarget, level, energyPoints, energyPoints, protectMoveType, successionPercent);
            }
            else
            {
                move = new ProtectMove(moveTwo, name, description, primaryMoveAccuracy, primaryMoveTarget, level, energyPoints, energyPoints, protectMoveType, successionPercent);
            }

            return(move);
        }
示例#6
0
 private void ProtectionStatus()
 {
     Status = DataProtectionService.Status();
     StateHasChanged();
 }
        void cmdToggleAP(BasePlayer player, string cmd, string[] args)
        {
            // Check if the player is an admin.
            if (player.net.connection.authLevel == 0)
            {
                return;
            }
            AdminGlobal.god = true;
            // Grab the player is Steam ID.
            string userID = player.userID.ToString();

            // Check if the player is turning Admin Protection on or off.
            if (protData != null)
            {
                bool silent = false;
                bool noMsg  = false;
                if (args.Length >= 2)
                {
                    if (args[0] == "p")
                    {
                        string targetPlayer = args[1];
                        string mode         = "";
                        if (args.Length > 2)
                        {
                            mode = args[2];
                        }
                        if (mode == "s")
                        {
                            silent = true;
                        }
                        else if (mode == "m")
                        {
                            noMsg = true;
                        }
                        List <BasePlayer> bpList = FindPlayerByName(targetPlayer);
                        if (bpList.Count > 1)
                        {
                            player.ChatMessage(APHelper["TooMuch"]);
                            foreach (var item in bpList)
                            {
                                player.ChatMessage(string.Format("<color=#81F23F>{0}</color>", item.displayName));
                            }
                        }
                        else if (bpList.Count == 1)
                        {
                            string targetUID = bpList[0].userID.ToString();
                            if (protData.ContainsKey(targetUID))
                            {
                                protData.Remove(targetUID);
                                player.ChatMessage(string.Format(APHelper["DisabledTo"], bpList[0].displayName));
                            }
                            else
                            {
                                protData.Add(targetUID, new ProtectionStatus(true, silent, noMsg, bpList[0].displayName, player.displayName));
                                player.ChatMessage(string.Format(APHelper["EnabledTo"], bpList[0].displayName) + " " + mode);
                            }
                            setMetabolizm(bpList[0]);
                        }
                        else
                        {
                            player.ChatMessage(APHelper["Error"]);
                        }
                    }
                    if (args[0] == "id")
                    {
                        string targetPlayer = args[1];
                        string mode         = "";
                        if (args.Length > 2)
                        {
                            mode = args[2];
                        }
                        if (mode == "s")
                        {
                            silent = true;
                        }
                        else if (mode == "m")
                        {
                            noMsg = true;
                        }

                        string targetUID = args[1];
                        if (protData.ContainsKey(targetUID))
                        {
                            player.ChatMessage(string.Format(APHelper["DisabledTo"], protData[targetUID].Name));
                            protData.Remove(targetUID);
                        }
                        else
                        {
                            List <BasePlayer> bpList = FindPlayerByID(targetUID);
                            if (bpList.Count > 1)
                            {
                                player.ChatMessage(APHelper["TooMuch"]);
                                foreach (var item in bpList)
                                {
                                    player.ChatMessage(string.Format("<color=#81F23F>{0}</color>", item.displayName));
                                }
                            }
                            else if (bpList.Count == 1)
                            {
                                protData.Add(targetUID, new ProtectionStatus(true, silent, noMsg, bpList[0].displayName, player.displayName));
                                player.ChatMessage(string.Format(APHelper["EnabledTo"], bpList[0].displayName) + " " + mode);
                                setMetabolizm(bpList[0]);
                            }
                        }
                    }
                }
                else
                {
                    if (protData.ContainsKey(userID))
                    {
                        ProtectionStatus protInfo = protData[userID];
                        if (protInfo.Enabled)
                        {
                            protData.Remove(userID);
                            player.ChatMessage(APHelper["Disabled"]);
                        }
                    }
                    else
                    {
                        if (args.Length > 0 && args.Length < 2)
                        {
                            if (args[0] == "s")
                            {
                                silent = true;
                            }
                            else if (args[0] == "m")
                            {
                                noMsg = true;
                            }
                        }
                        protData.Add(userID, new ProtectionStatus(true, silent, noMsg, player.displayName));
                        if (!silent && !noMsg)
                        {
                            player.ChatMessage(APHelper["Enabled"]);
                        }
                        else if (silent)
                        {
                            player.ChatMessage(APHelper["Enabled_s"]);
                        }
                        else
                        {
                            player.ChatMessage(APHelper["Enabled_m"]);
                        }
                    }
                    setMetabolizm(player);
                }
            }
            SaveData();
        }
示例#8
0
        void cmdToggleAP(BasePlayer player, string cmd, string[] args)
        {
            // Check if the player is an admin.
            if (player.net.connection.authLevel == 0)
            {
                return;
            }

            // Grab the player is Steam ID.
            ulong userID = player.userID;

            // Check if the player is turning Admin Protection on or off.
            if (protData != null)
            {
                if (args.Length >= 2)
                {
                    if (args[0] == "p")
                    {
                        string targetPlayer = args[1];
                        string mode         = "";
                        if (args.Length > 2)
                        {
                            mode = args[2];
                        }
                        ProtectionStatus.msgType msgType = ProtectionStatus.msgType.Normal;
                        if (mode == "s")
                        {
                            msgType = ProtectionStatus.msgType.Silent;
                        }
                        else if (mode == "m")
                        {
                            msgType = ProtectionStatus.msgType.OnlyTarget;
                        }
                        List <BasePlayer> bpList = FindPlayerByName(targetPlayer);
                        if (bpList.Count > 1)
                        {
                            ReplyChat(player, APHelper["TooMuch"]);
                            foreach (var item in bpList)
                            {
                                ReplyChat(player, string.Format("<color=#81F23F>{0}</color>", item.displayName));
                            }
                        }
                        else if (bpList.Count == 1)
                        {
                            ulong targetUID = bpList[0].userID;
                            if (protData.ContainsKey(targetUID))
                            {
                                setMetabolizm(bpList[0], false);
                                protData.Remove(targetUID);
                                ReplyChat(player, string.Format(APHelper["DisabledTo"], bpList[0].displayName));
                            }
                            else
                            {
                                protData.Add(targetUID, new ProtectionStatus(msgType, bpList[0].displayName, player.displayName));
                                setMetabolizm(bpList[0], true);
                                ReplyChat(player, string.Format(APHelper["EnabledTo"], bpList[0].displayName) + " " + mode);
                            }
                        }
                        else
                        {
                            ReplyChat(player, APHelper["Error"]);
                        }
                    }
                    if (args[0] == "id")
                    {
                        string mode = "";
                        if (args.Length > 2)
                        {
                            mode = args[2];
                        }
                        ProtectionStatus.msgType msgType = ProtectionStatus.msgType.Normal;
                        if (mode == "s")
                        {
                            msgType = ProtectionStatus.msgType.Silent;
                        }
                        else if (mode == "m")
                        {
                            msgType = ProtectionStatus.msgType.OnlyTarget;
                        }

                        ulong targetUID = 0;
                        ulong.TryParse(args[1], out targetUID);
                        if (protData.ContainsKey(targetUID))
                        {
                            ReplyChat(player, string.Format(APHelper["DisabledTo"], protData[targetUID].Name));
                            if (FindPlayerByID(targetUID).Count > 0)
                            {
                                setMetabolizm(FindPlayerByID(targetUID).First(), false);
                            }
                            protData.Remove(targetUID);
                        }
                        else
                        {
                            List <BasePlayer> bpList = FindPlayerByID(targetUID);
                            if (bpList.Count > 1)
                            {
                                ReplyChat(player, APHelper["TooMuch"]);
                                foreach (var item in bpList)
                                {
                                    ReplyChat(player, string.Format("<color=#81F23F>{0}</color>", item.displayName));
                                }
                            }
                            else if (bpList.Count == 1)
                            {
                                protData.Add(targetUID, new ProtectionStatus(msgType, bpList[0].displayName, player.displayName));
                                ReplyChat(player, string.Format(APHelper["EnabledTo"], bpList[0].displayName) + " " + mode);
                                setMetabolizm(bpList[0], true);
                            }
                        }
                    }
                }
                else
                {
                    if (protData.ContainsKey(userID))
                    {
                        ProtectionStatus protInfo = protData[userID];
                        setMetabolizm(player, false);
                        protData.Remove(userID);
                        ReplyChat(player, APHelper["Disabled"]);
                    }
                    else
                    {
                        ProtectionStatus.msgType msgType = ProtectionStatus.msgType.Normal;

                        if (args.Length > 0 && args.Length < 2)
                        {
                            if (args[0] == "s")
                            {
                                msgType = ProtectionStatus.msgType.Silent;
                            }
                            else if (args[0] == "m")
                            {
                                msgType = ProtectionStatus.msgType.OnlyTarget;
                            }
                        }
                        protData.Add(userID, new ProtectionStatus(msgType, player.displayName));
                        setMetabolizm(player, true);
                        if (msgType == ProtectionStatus.msgType.Normal)
                        {
                            ReplyChat(player, APHelper["Enabled"]);
                        }
                        else if (msgType == ProtectionStatus.msgType.Silent)
                        {
                            ReplyChat(player, APHelper["Enabled_s"]);
                        }
                        else
                        {
                            ReplyChat(player, APHelper["Enabled_m"]);
                        }
                    }
                }
            }
            SaveData();
        }