[Preview] Retarded Insane Bots

Topic created · 9 Posts · 201 Views
  • Hello everyone. [Post updated]

    Videos first:

    DOME gameplay
    Youtube Video

    LOOKOUT gameplay
    Youtube Video

    AGROUND gameplay
    Youtube Video

    I've modified AIBots animated movement script by S3VDITO (found here) in order for bots to target and engage the player (and other bots too).
    Save the script as retbots.chai in C:\Users\<your username>\AppData\Local\Plutonium\storage\iw5\scripts folder
    (remove all other chai scripts before running of course)

    UPDATE: now script runs with any count of bots and there was added some kind of player protection after spawn - the bots won't target the player for some random seconds after spawn.

    The bots shoot infinitely and move to the player when see him and engage him (and other bots; only first 9 bots are attacked - set the bots_under_attack_max variable, you may decrease or increase the count but on my system I've got slowdowns if more than 9 bots were attacked by other bots).

    The script works in DM; also I've tried it in Gungame, but only the player has weapon progress, the bots have default weapons as in DM.

    Sorry for bad code, no time to fix it at all. That's just proof-of-concept!

    I don't have deep knowledge of Plutonium MW3 scripts, I am sure there are more experienced devlopers who can improve this code. The bots are still stupid, but they attack you and don't run around like dummies.

    The script is provided AS-IS, no warranties of any kind

    Many thanks to S3VDITO !


    1. Works in Deathmatch or Gungame
    2. In order to increase difficulty use Hardcore
    3. You may also edit bot speed in script - gsc.setDvar("testClients_doSpeed", 12) - increase speed to get more insane gameplay
    4. Decrease the number of bots if the game lags or it is too difficult to play
    5. bots_under_attack_max variable - allows to set the number of bots under attack from other bots
    6. BE SURE to enter bot xx command in console BEFORE the countdown before match ends. Do it right after the level loads.

    Download script

    Here is the script source:

    // Retarded Insane bots version
    // Feel free to modify this code as you want!
    // Many thanks and credits to:
    // AIBots by S3VDITO
    gsc.setDvar("testClients_doAttack", 1);
    gsc.setDvar("testClients_doCrouch", 0);
    gsc.setDvar("testClients_doMove", 1);
    gsc.setDvar("testClients_doReload", 0);
    gsc.setDvar("testClients_doWatchKillcam", 1);
    gsc.setDvar("scr_dm_playerrespawndelay", 0); // for hardcore
    //gsc.setDvarIfUninitialized("testClients_doSpeed", 4);
    gsc.setDvar("testClients_doSpeed", 12);
    global bot_speed = to_float(gsc.getDvar("testClients_doSpeed"));
    global players_list = [];
    global player_target_list = [];
    global bots_under_attack_max = 9;
    global protectPlayer = false;
    global protectPlayerInterval = 3000;
    level.onNotify("connected", fun(args) {
    	var player = args[0];
    	if(player.getGuid().find("bot") != 0)
    		print("Player connected");
    		player.onNotify("spawned_player", fun[player](arguments) {
    level.onNotify("prematch_done", fun(args) {
    	if(gsc.getDvar("g_gametype") == "dm" || gsc.getDvar("g_gametype") == "gun") {
    		for(var entRef = 0; entRef < players_list.size(); ++entRef)
    			var tempEntBot = gsc.getEntByNum(entRef);
    			if(tempEntBot.getGuid().find("bot") == 0)
    				var animBody;
    				//var animBody = gsc.spawn("script_model", tempEntBot.getOrigin());
    				//animBody.LinkTo(tempEntBot, "tag_origin", [-4, 0, -1], [-4, 0, -1]);
    				setInterval(fun[tempEntBot, animBody]() { 
    					botMoveOnPlayer(tempEntBot, gsc.getEntByNum(0), animBody); 
    				}, 1);
    				var bots_under_attack = players_list.size() - 1;
    				if (bots_under_attack > bots_under_attack_max)
    					bots_under_attack = bots_under_attack_max;
    				for(var i = 0; i < bots_under_attack; ++i)
    					var targetBot = gsc.getEntByNum(i+1);
    					setInterval(fun[tempEntBot, targetBot, animBody]() { 
    						botMove(tempEntBot, targetBot, animBody); 
    					}, 1);
    				//setInterval(fun[animBody]() { 
    				//	animBody.scriptModelPlayAnim("pb_stumble_pistol_walk_forward");
    				//}, 1000);
    		setInterval(fun[protectPlayer]() { 
    			protectPlayer = false;
    		}, protectPlayerInterval);
    def botMove(bot, target, animModel)
    	var bot_weapon_origin = bot.getTagOrigin("tag_weapon_left");
    	if(LockSightTest(bot, target) == false)
    		// animModel.scriptModelPlayAnim("pb_stand_alert_pistol");
    		var angle = gsc.vectorToAngles([target.getTagOrigin("j_helmet")[0] - bot_weapon_origin[0], target.getTagOrigin("j_helmet")[1] - bot_weapon_origin[1], target.getTagOrigin("j_helmet")[2] - 25 - bot_weapon_origin[2]]);
    		// Spaming field bug =(
    		//animModel.set("angles", bot.getPlayerAngles());
    	var moveTarget = target.getOrigin();
    	var distance = gsc.distanceSquared(moveTarget, bot.getOrigin());
    	if(gsc.distance(moveTarget, bot.getOrigin()) <= 256)
    		// bot_speed = 0;
    		bot_speed = to_float(gsc.getDvar("testClients_doSpeed"));
    		var normalize = gsc.vectorNormalize([moveTarget[0] - bot.getOrigin()[0], moveTarget[1] - bot.getOrigin()[1], moveTarget[2] - bot.getOrigin()[2]]);
    		bot.setOrigin([bot.getOrigin()[0] + normalize[0] * bot_speed, bot.getOrigin()[1] + normalize[1] * bot_speed, bot.getOrigin()[2] + normalize[2] * bot_speed]);
    def botMoveOnPlayer(bot, target, animModel)
    	// Prevent massive spawn killing of human player! The bots will not lock on player after player spawn
    	if (protectPlayer == true)
    	botMove(bot, target, animModel);
    def HideTestClientParts(bot)
    def protectPlayerOnSpawn(player)
    	protectPlayer = true;
    // Stolen from _stinger.gsc :)
    def LockSightTest(self, target)
    	var eyePos = self.GetEye();
    	var passed = gsc.SightTracePassed(eyePos, target.getOrigin(), false, target);
    	if ( passed == 1)
    		return true;
    	var front = target.GetPointInBounds(1, 0, 0);
    	passed = gsc.SightTracePassed( eyePos, front, false, target );
    	if (passed == 1)
    		return true;
    	var back = target.GetPointInBounds(-1, 0, 0);
    	passed = gsc.SightTracePassed( eyePos, back, false, target );
    	if (passed == 1)
    		return true;
    	return false;
  • I was in the same boat as you. I've wanted this for so long. How do I install this to get started?

  • Well, the installation is easy.
    Once again, put the script in C:\Users\<your username>\AppData\Local\Plutonium\storage\iw5\scripts\ folder
    "C:" - is your Windows system disk
    "<your username>" - is your user's folder
    (you might need to enable showing hidden folders in Windows Explorer)

    When you put the script in this folder it runs automatically when you start the private match
    So, start Free-for-all private match (DOME map is good), immediately open the console with ~, write the command:
    bot 12
    and press Enter
    Then you may choose the team and class

    And you should be running deathmatch with 12 bots. If everything is OK, you may try to increase the bot count the next time (it may cause lags depending on your CPU).

    But dont expect much as i said! My knowledge of the game engine is very limited.
    If anything is wrong, delete the script.

  • This post is deleted!
  • @rrq1257 Ok seems to be working good now. I hope you are looking to expand this further. The possibilities are endless

  • @rrq1257 said in [Preview] Retarded Insane Bots:

    (remove all other chai scripts before running of course)

    Nice work!

  • Do you plan on expanding on this further?

  • UPDATE: I've modified the code. Now script runs with any count of bots and there was added some kind of player protection after spawn - the bots won't target the player for some random seconds after spawn.

    I don't know how to make the script better. Maybe someone else will be able to develop a true bot script.

  • @rrq1257 One day. Does this mod now work on all maps? I had some maps where the bots acted like they normally do.

Log in to reply