Page 1 of 5 123 ... LastLast
Results 1 to 10 of 42
  1. #1
    Senior Member
    Join Date
    Oct 2015
    Location
    Germany
    Posts
    229

    Post baserape detector with auto nuke - BF4 insane limits (working code)

    BF4 baserape detector with auto nuke - insane limits (working code)

    this code start a auto-nuke on baserape situation (working with bf4 server + insane limits + conquest map). every 30 seconds it checks the TLPM rate (ticket lost per minute rate) each team. it is a baserape when team1 have a high TLPM rate and team2 a low TLPM rate.

    example: losing team: 70 TicketLost/Min AND winning team: 5 TicketLost/Min = baserape (preparing nuke)

    if a baserape is detected a nuke request will be sent (preparing nuke). after 3 requests in a row (you can change this value) the auto-nuke is started automatically. the auto-nuke will not start unless the losing team have less tickets than the winning team.


    IMPORTANT: the part "SETTINGS" in the code is set for a bf4 server with 32 slots, conquest large, metro / operation locker only. if you have more/less players (slots) or a different map you must change the settings! you can find the right settings when you activate the debug mode ("BDDebugInfosInProconPluginConsole = true") and the virtual mode (BDVirtualMode = true) on a full server.



    SETTINGS / CONFIGURATIONS
    in the SETTINGS area you can customize the following values. the most important key value is the "MinTicketLostPerMinuteLoserTeam" value in main settings.

    MAIN SETTINGS
    MinPlayers = 14 (minimum players to enable baserape detector / auto nuke)
    MinTicketsLoserTeam = 90 (minimum tickets remaining of LOSING team)
    MinTicketLostPerMinuteLoserTeam = 60 (!IMPORTANT! minimum TLPM rate (ticket lost per min) of LOSING team)
    MinRequestsToNuke = 3 (minimum nuke requests in a row to start the NUKE)

    ADVANCED SETTINGS
    MaxPlayers = 80 (maximal players to enable baserape detector / auto nuke)
    MinTicketDifferenceWinnerAndLoserTeam = 10 (minimum ticket gap between winning and losing team)
    MaxTicketDifferenceWinnerAndLoserTeam = 800 (maximal ticket gap between winning and losing team)
    MultiplicatorWinnerTeamTLPM = 5 (min. multiplication gap of TKLP rate between winning and losing team)
    MaxNukesPerRound = 3 (maximal # of nukes per round each team)
    SentChatInfoAboutPreparingNuke = true (displays preparing nuke status in in-game-chat for all players)
    DebugInfosInProconPluginConsole = false (true = displays debug infos in the procon console window)
    VirtualMode = false (true = no nuke, no kill, no in-game-chat message, no yell)


    INSTALLATION - LIMIT#1
    setup for insane limits
    Evaluation: OnIntervalServer
    Evaluation_interval: 30
    First_check: Code
    First_check_code: put here the code part 1

    Code:
    // BASERAPE DETECTOR + AUTO NUKE - PART1  -  Insane Limits BF4 Server  -  by maxdralle  //
    
    // DESCRIPTION: this code detect a baserape. if a baserape is detected a nuke request will be sent. after 4 requests in a row (you can change this value) the auto nuke is started automatically.
    // FUNCTION: this code check the TLPM rate (ticket lost per minute rate) each team. it is a baserape when team1 have a high TLPM rate and team2 a low TLPM rate. (example: LosingTeam: 70 TicketLost/Min AND WinningTeam: 5 TicketLost/Min = baserape)
    // SETUP Insane Limits: Evaluation: OnIntervalServer - Evaluation_interval: 30 - First_check: Code
    // IMPORTANT: the SETTINGS are set for a bf4 server with 32 slots, conquest large, metro / operation locker only. if you have more/less players (slots) or a different map you must change the settings! when your server is full set "BDDebugInfosInProconPluginConsole = true" to find the right settings.
    
    
    // MAIN SETTINGS / CONFIGURATIONS (you can change this values!! IMPORTANT VALUES ARE: "BDMinTicketLostPerMinuteLoserTeam"  AND  "BDMultiplicatorWinnerTeamTLPM")
    double BDMinPlayers = 14;    // CUSTOMIZE: minimum players to enable baserape detector / auto nuke
    double BDMinTicketsLoserTeam = 90;    // CUSTOMIZE: minimum tickets remaining of LOSING team
    double BDMinTicketLostPerMinuteLoserTeam = 60;    // CUSTOMIZE: minimum "ticket lost per min rate" of LOSING team
    double BDMinRequestsToNuke = 3;    // CUSTOMIZE: minimum nuke requests in a row to start the NUKE
    
    // ADVANCED SETTINGS
    double BDStartAfterSec = 420;    // CUSTOMIZE: after # sec of roundtime enable baserape detector
    double BDMaxTicketsWinnerTeam = server.StartTickets(1);
    double BDMaxPlayers = 80;    // CUSTOMIZE: maximal players to enable baserape detector / auto nuke
    double BDMinTicketDifferenceWinnerAndLoserTeam = 10;    // CUSTOMIZE: minimum ticket gap between winning and losing team
    double BDMaxTicketDifferenceWinnerAndLoserTeam = server.StartTickets(1) * 0.7;    // CUSTOMIZE: maximal ticket gap between winning and losing team
    double BDMultiplicatorWinnerTeamTLPM = 5;    // CUSTOMIZE: minimum multiplication gap of "ticket lost per min rate" between winning and losing team
    int BDMaxNukesPerRound = 3;    // CUSTOMIZE: maximal # of nukes per round each team
    bool BDSentChatInfoAboutPreparingNuke = true;    // CUSTOMIZE: displays preparing nuke status in in-game-chat for all players
    bool BDDebugInfosInProconPluginConsole = false;    // CUSTOMIZE: true = displays debug infos in the procon console window
    bool BDVirtualMode = false;    // CUSTOMIZE: true = no nuke, no in-game-chat message, no yell
    // END SETTINGS / CONFIGURATIONS
    
    
    // temporary variable
    double tmpBDLastTicketCounterWinnerTeam =  0;
    double tmpBDLastTicketCounterLoserTeam =  0;
    double tmpBDWinnerTeamTLPM = 0;
    double tmpBDLoserTeamTLPM = 0;
    double tmpBDLastLoserTeamID = 9;
    int tmpBDLoserTeamID = 2;
    int tmpBDWinnerTeamID = 1;
    int tmpBDNukeRequest = 0;
    int tmpBDNukeRequestTMP = 0;
    int tmpBDNukesPerRound = 0;
    BDMinTicketLostPerMinuteLoserTeam = BDMinTicketLostPerMinuteLoserTeam / 2;
    if (BDVirtualMode) BDSentChatInfoAboutPreparingNuke = false;
    
    // check gamemode + minimum thresholds to enable baserape detector check
    if ((server.PlayerCount >= BDMinPlayers) && (server.PlayerCount < BDMaxPlayers) && (server.TimeRound > BDStartAfterSec)) {
    	if (Regex.Match(server.Gamemode, @"(Conquest|ConquestSmall0|ConquestLarge0)").Success) {
    
    		// load last ticket score 30 sec before
    		if (server.RoundData.issetDouble("BDGlobalLastTicketCounterLoserTeam")) tmpBDLastTicketCounterLoserTeam = server.RoundData.getDouble("BDGlobalLastTicketCounterLoserTeam");
    		if (server.RoundData.issetDouble("BDGlobalLastTicketCounterWinnerTeam")) tmpBDLastTicketCounterWinnerTeam = server.RoundData.getDouble("BDGlobalLastTicketCounterWinnerTeam");
    		if (server.RoundData.issetDouble("BDGlobalLastLoserTeamID")) tmpBDLastLoserTeamID = server.RoundData.getDouble("BDGlobalLastLoserTeamID");
    		if (server.RoundData.issetInt("BDGlobalNukeRequest")) tmpBDNukeRequest = server.RoundData.getInt("BDGlobalNukeRequest");
    		if (server.RoundData.issetInt("BDGlobalNukesPerRoundTeam1")) tmpBDNukesPerRound = server.RoundData.getInt("BDGlobalNukesPerRoundTeam1");
    
    		// check ticket score to get winning and losing team
    		if (server.RemainTickets(1) < server.RemainTickets(2)) {
    			tmpBDWinnerTeamID = 2;
    			tmpBDLoserTeamID = 1;
    			if (server.RoundData.issetInt("BDGlobalNukesPerRoundTeam2")) tmpBDNukesPerRound = server.RoundData.getInt("BDGlobalNukesPerRoundTeam2");
    		}
    		if (tmpBDNukesPerRound <= BDMaxNukesPerRound) {
    			if (tmpBDLastLoserTeamID == tmpBDLoserTeamID) {
    				// check ticket lost per min rate
    				tmpBDLoserTeamTLPM = ((tmpBDLastTicketCounterLoserTeam - server.RemainTickets(tmpBDLoserTeamID) ) * 2);
    				tmpBDWinnerTeamTLPM = ((tmpBDLastTicketCounterWinnerTeam - server.RemainTickets(tmpBDWinnerTeamID)) * 2);	
    				if((tmpBDLastTicketCounterLoserTeam - BDMinTicketLostPerMinuteLoserTeam > server.RemainTickets(tmpBDLoserTeamID)) && (server.RemainTickets(tmpBDWinnerTeamID) - server.RemainTickets(tmpBDLoserTeamID) > BDMinTicketDifferenceWinnerAndLoserTeam) && (server.RemainTickets(tmpBDWinnerTeamID) - server.RemainTickets(tmpBDLoserTeamID) < BDMaxTicketDifferenceWinnerAndLoserTeam) && (server.RemainTickets(tmpBDLoserTeamID) > BDMinTicketsLoserTeam) && (server.RemainTickets(tmpBDWinnerTeamID) < BDMaxTicketsWinnerTeam)) {
    					if (tmpBDLoserTeamTLPM >= tmpBDWinnerTeamTLPM * BDMultiplicatorWinnerTeamTLPM) {
    						//baserape detected + add nuke request
    						tmpBDNukeRequest++;
    						tmpBDNukeRequestTMP++;
    						server.RoundData.setInt("BDGlobalNukeRequest", tmpBDNukeRequest);
    						if (Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) >= 50) {
    							if (BDDebugInfosInProconPluginConsole) plugin.ConsoleWrite("BASERAPE DETECTOR: " + Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) + "% (" + tmpBDNukeRequest + " requests) - Tickets: " + server.RemainTickets(tmpBDWinnerTeamID) + " - " + server.RemainTickets(tmpBDLoserTeamID) + " (TicketLost/Min.: " + Math.Ceiling((double)tmpBDWinnerTeamTLPM) + " - " + Math.Ceiling((double)tmpBDLoserTeamTLPM) + ")");
    							if (BDSentChatInfoAboutPreparingNuke) plugin.SendGlobalMessage("BASERAPE DETECTOR: Preparing auto-nuke." + Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) + "% ready");
    							if (BDSentChatInfoAboutPreparingNuke) plugin.PRoConChat("^1^bBASERAPE DETECTOR:^0^n Preparing auto-nuke." + Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) + "% ready");
    						}
    					} 
    				}
    			}
    
    			// debug info (procon plugin console)
    			if ((BDDebugInfosInProconPluginConsole) && (server.PlayerCount >= BDMinPlayers)) plugin.ConsoleWrite("BASERAPE DETECTOR DEBUG: " + Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) + "% baserape - Tickets: " + server.RemainTickets(tmpBDWinnerTeamID) + " - " + server.RemainTickets(tmpBDLoserTeamID) + " (TicketLost/Min.: " + Math.Ceiling((double)tmpBDWinnerTeamTLPM) + " - " + Math.Ceiling((double)tmpBDLoserTeamTLPM) + ") - Multipli: " + Math.Ceiling((double)tmpBDLoserTeamTLPM / (double)tmpBDWinnerTeamTLPM));
    			// check nuke request
    			if (tmpBDNukeRequestTMP != 0) {
    				if (tmpBDNukeRequest >= BDMinRequestsToNuke) {
    					//NUKE    NUKE    NUKE    NUKE
    					tmpBDNukesPerRound++;
    					plugin.ConsoleWrite("BASERAPE DETECTOR: Nuking for baserape! " + tmpBDNukesPerRound + "/" + BDMaxNukesPerRound + " (" + tmpBDNukeRequest + "x nuke requests in a row) -  Tickets: " + server.RemainTickets(tmpBDWinnerTeamID) + " - " + server.RemainTickets(tmpBDLoserTeamID) + " (TicketLost/Min.: " + Math.Ceiling((double)tmpBDWinnerTeamTLPM) + " - " + Math.Ceiling((double)tmpBDLoserTeamTLPM) + ")");
    					server.RoundData.setInt("BDGlobalNukeRequest", 0);
    					if (tmpBDWinnerTeamID == 1) server.RoundData.setInt("BDGlobalNukesPerRoundTeam1", tmpBDNukesPerRound);
    					if (tmpBDWinnerTeamID == 2) server.RoundData.setInt("BDGlobalNukesPerRoundTeam2", tmpBDNukesPerRound);
    					if (!BDVirtualMode) {
    						server.RoundData.setString("IL_NukeStartingTime", DateTime.Now.ToString());
    						server.RoundData.setInt("IL_NukeTeamID", tmpBDWinnerTeamID);
    						plugin.SendGlobalMessage("BASERAPE DETECTOR: Incomming auto-nuke...");
    						plugin.PRoConChat("^1^bBASERAPE DETECTOR:^0^n Incomming auto-nuke...");
    						plugin.SendGlobalYell(" Incomming auto-nuke", 8);
    						List<PlayerInfoInterface> players = new List<PlayerInfoInterface>();
    						if (tmpBDWinnerTeamID == 1) players.AddRange(team1.players);
    						if (tmpBDWinnerTeamID == 2) players.AddRange(team2.players);
    						foreach(PlayerInfoInterface player_info in players) {
    							plugin.KillPlayer(player_info.Name, 6);
    							plugin.KillPlayer(player_info.Name, 10);
    						}
    					}
    				}
    			} else {
    				// no baserape, reset nuke request
    				if ((BDSentChatInfoAboutPreparingNuke) && (Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) >= 50)) plugin.SendGlobalMessage("BASERAPE DETECTOR: Auto-nuke canceled");
    				if ((BDSentChatInfoAboutPreparingNuke) && (Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) >= 50)) plugin.PRoConChat("^1^bBASERAPE DETECTOR:^0^n Auto-nuke canceled");
    				if ((BDDebugInfosInProconPluginConsole) && (Math.Ceiling((double)100 / BDMinRequestsToNuke * tmpBDNukeRequest) >= 50)) plugin.ConsoleWrite("BASERAPE DETECTOR: Auto-nuke canceled. Requests: " + tmpBDNukeRequest);
    				server.RoundData.setInt("BDGlobalNukeRequest", 0);
    			}
    
    			// save ticket score for next check
    			server.RoundData.setDouble("BDGlobalLastLoserTeamID", tmpBDLoserTeamID);
    			server.RoundData.setDouble("BDGlobalLastTicketCounterLoserTeam", server.RemainTickets(tmpBDLoserTeamID));
    			server.RoundData.setDouble("BDGlobalLastTicketCounterWinnerTeam", server.RemainTickets(tmpBDWinnerTeamID));
    		}
    	}
    } else {
    //	if (server.TimeRound < BDStartAfterSec) server.RoundData.setInt("BDGlobalNukesPerRoundTeam1", 0);
    //	if (server.TimeRound < BDStartAfterSec) server.RoundData.setInt("BDGlobalNukesPerRoundTeam2", 0);
    }


    INSTALLATION - LIMIT#2
    this optional part will hold the nuke for 30 seconds.
    setup for insane limits
    Evaluation: OnSpawn
    First_check: Code
    First_check_code: put here the code part 2

    Code:
    // BASERAPE DETECTOR + AUTO NUKE - PART2 - KILL ON RESPAWN - 30SEC NUKE //
    // SETUP Insane Limits: Evaluation: OnSpawn - First_check: Code
    
    // MAIN SETTINGS
    double NukeHoldTime = 30;  // CUSTOMIZE: seconds to hold the nuke
    
    // END SETTINGS
    
    
    if ((server.RoundData.issetInt("IL_NukeTeamID")) && (server.RoundData.issetString("IL_NukeStartingTime"))) {
    	int NukeTeamID = server.RoundData.getInt("IL_NukeTeamID");
    	string NukeStartingTime = server.RoundData.getString("IL_NukeStartingTime");
    	if (NukeTeamID == player.TeamId) {
    		if ((server.TimeRound >= 120) && (((DateTime.Now - DateTime.Parse(NukeStartingTime)).TotalSeconds) < NukeHoldTime)) {
    			// HOLD NUKE
    			plugin.SendPlayerYell(player.Name, "Nuking for baserape",6);
    			plugin.SendPlayerMessage(player.Name, "Nuking for baserape. You can respawn in few seconds");
    			plugin.KillPlayer(player.Name, 1);
    		} else {
    			// stop nuke
    			if (server.RoundData.issetInt("IL_NukeTeamID")) server.RoundData.unsetInt("IL_NukeTeamID");
    			if (server.RoundData.issetString("IL_NukeStartingTime")) server.RoundData.unsetString("IL_NukeStartingTime");
    			plugin.SendGlobalMessage("BASERAPE DETECTOR: Nuke finished");
    			plugin.PRoConChat("^1^bBASERAPE DETECTOR:^0^n Nuke finished");
    		}
    	}
    }



    Changelog
    26.08.2017 - Add: individual timespan to hold the nuke
    Last edited by maxdralle; 27-08-2017 at 13:04. Reason: add: individual timespan to hold the nuke
    Developer of the VIP Slot Manager Plugin

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Location
    Russia
    Posts
    241
    Just want to ask, because i'm not familiar with programming. Whether to use the "return false;" at the end of the code ?

    One more question:
    Is it possible to exclude ticket lost due to respawn from counting and count only ticket lost due to full cap ?

  3. #3
    Senior Member
    Join Date
    Oct 2015
    Location
    Germany
    Posts
    229
    Quote Originally Posted by Chilace View Post
    Just want to ask, because i'm not familiar with programming. Whether to use the "return false;" at the end of the code ?
    the things with "return false;" is only necessary when we have a secound check in the limit...


    Quote Originally Posted by Chilace View Post
    One more question:
    Is it possible to exclude ticket lost due to respawn from counting and count only ticket lost due to full cap ?
    its a good idea to exclude the ticket lost on respawn event.
    i will try to include this. but the problem is, that not every respawn cost a ticket (kill by loadout enforcer, force move, kill by admin, ...).

  4. #4
    Ask for help, I won 't the compile command code, whatever I modify the code or complete code, the use of my procon will pop up the error code below, I checked the error code is by limiting the nuke, both please help me where is the analysis of the error, or do I need the code rule for the first com.lowagie.text.paragraph is to,
    The error code:
    [Insane Limits] ERROR: 1 error compiling Code
    [Insane Limits] ERROR: (CS1002, line: 27, column: 82): ; expected

    1, the server scale of 64 people, a variety of patterns
    2, the default 1000 votes
    3, the score margin of 400 votes to enable a nuclear bomb
    4, one station can only be enabled once a nuclear bomb
    Thank you very much, hope to get help.

  5. #5
    Senior Member
    Join Date
    Oct 2015
    Location
    Germany
    Posts
    229
    Quote Originally Posted by cssqw7_3 View Post
    Ask for help, I won 't the compile command code, whatever I modify the code or complete code, the use of my procon will pop up the error code below, I checked the error code is by limiting the nuke, both please help me where is the analysis of the error, or do I need the code rule for the first com.lowagie.text.paragraph is to,
    The error code:
    [Insane Limits] ERROR: 1 error compiling Code
    [Insane Limits] ERROR: (CS1002, line: 27, column: 82): ; expected

    1, the server scale of 64 people, a variety of patterns
    2, the default 1000 votes
    3, the score margin of 400 votes to enable a nuclear bomb
    4, one station can only be enabled once a nuclear bomb
    Thank you very much, hope to get help.
    the error code say: you changed the code and forgot a important character. maybe in you deleted a " ; " in the first 27 lines.

    copy the first limit again from this website to your layer. then change this:

    int BDMaxNukesPerRound = 3;

    into this

    int BDMaxNukesPerRound = 1;

  6. #6
    Thank you for your help, but after modification, no piece (large or small, or team deathmatch, and so on) conquer the map, even if it is vary considerably score (for example: 100-500 or 800) automatic bombs are not enabled, code inspection found no abnormalities, but still need to set up the action? Or say keep none?

  7. #7
    Senior Member
    Join Date
    Oct 2015
    Location
    Germany
    Posts
    229
    Quote Originally Posted by cssqw7_3 View Post
    Thank you for your help, but after modification, no piece (large or small, or team deathmatch, and so on) conquer the map, even if it is vary considerably score (for example: 100-500 or 800) automatic bombs are not enabled, code inspection found no abnormalities, but still need to set up the action? Or say keep none?
    what server do you have? how many slots? how many players? diffrent maps? cq large / small?

    keep the action to none!
    be sure that you insane setting "virtual_mode" is set to False

    in the code you have a lot of settings to fine tune. take a look at:

    MinPlayers
    MinTicketsLoserTeam
    MinTicketLostPerMinuteLoserTeam

    MaxTicketDifferenceWinnerAndLoserTeam
    MultiplicatorWinnerTeamTLPM

    DebugInfosInProconPluginConsole


    info: on detected baserape it nukes only the winning team (team with more remaining tickets).
    Last edited by maxdralle; 27-03-2017 at 09:44.

  8. #8
    Senior Member
    Join Date
    Jan 2012
    Location
    The Kingdom of England
    Posts
    124
    Thanks maxdralle for sharing this.

    What BF4 baserape detector with auto nuke settings do you recommend for the following server configuration?

    Map: Operation Metro 2014 (only)
    Mode: Conquest Large
    Game Size: 64
    Team Ticket Count: 2600

  9. #9
    Senior Member
    Join Date
    Oct 2015
    Location
    Germany
    Posts
    229
    yes, it is a good idea for a metro server.

    in your case i would try this settings;
    Code:
    double BDMinTicketLostPerMinuteLoserTeam = 60;
    if (server.PlayerCount < 40) BDMinTicketLostPerMinuteLoserTeam = 55;  //(add this line)
    if (server.PlayerCount < 30) BDMinTicketLostPerMinuteLoserTeam = 52;    //(add this line)
    
    double BDMultiplicatorWinnerTeamTLPM = 5;

    the BDMinTicketLostPerMinuteLoserTeam setting is important.
    you can find the right settings when you activate the debug mode ("BDDebugInfosInProconPluginConsole = true") and the virtual mode (BDVirtualMode = true) on a full server. then you get every 30 sec. a info about the TKPM rate in plugin log console like: Tickets: 575 - 73 (TicketLost/Min.: 36 - 21) - Multipli: 1

  10. #10
    Senior Member
    Join Date
    Jan 2012
    Location
    The Kingdom of England
    Posts
    124
    Quote Originally Posted by maxdralle View Post
    yes, it is a good idea for a metro server.

    in your case i would try this settings;
    Code:
    double BDMinTicketLostPerMinuteLoserTeam = 60;
    if (server.PlayerCount < 40) BDMinTicketLostPerMinuteLoserTeam = 55;  //(add this line)
    if (server.PlayerCount < 30) BDMinTicketLostPerMinuteLoserTeam = 52;    //(add this line)
    
    double BDMultiplicatorWinnerTeamTLPM = 5;

    the BDMinTicketLostPerMinuteLoserTeam setting is important.
    you can find the right settings when you activate the debug mode ("BDDebugInfosInProconPluginConsole = true") and the virtual mode (BDVirtualMode = true) on a full server. then you get every 30 sec. a info about the TKPM rate in plugin log console like: Tickets: 575 - 73 (TicketLost/Min.: 36 - 21) - Multipli: 1
    Thanks I’ll give that ago.

 

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •