From a3b2e2e655c7cbbbe54bce77e615ac205b21fc1c Mon Sep 17 00:00:00 2001 From: INeedBots Date: Fri, 26 Mar 2021 19:37:20 -0600 Subject: [PATCH] added mw2 playstyle --- main_shared/maps/mp/bots/_bot_script.gsc | 49 +++++++++++++++++++++++ main_shared/maps/mp/bots/_bot_utility.gsc | 21 ++++++++++ 2 files changed, 70 insertions(+) diff --git a/main_shared/maps/mp/bots/_bot_script.gsc b/main_shared/maps/mp/bots/_bot_script.gsc index 00cd23b..96bd473 100644 --- a/main_shared/maps/mp/bots/_bot_script.gsc +++ b/main_shared/maps/mp/bots/_bot_script.gsc @@ -334,7 +334,10 @@ bot_spawn() self thread bot_radiation_think(); if (getDvarInt("bots_play_nade")) + { self thread bot_use_equipment_think(); + self thread bot_watch_think_mw2(); + } if (getDvarInt("bots_play_target_other")) { @@ -2531,6 +2534,52 @@ follow_target() } } +/* + Bots play mw2 +*/ +bot_watch_think_mw2() +{ + self endon("disconnect"); + self endon("death"); + level endon("game_ended"); + + for (;;) + { + wait randomIntRange(1, 4); + + if(self isDefusing() || self isPlanting()) + continue; + + if (self IsRemoteControlling()) + continue; + + if (self InLastStand()) + continue; + + if (isDefined(self GetThreat())) + continue; + + tube = self getValidTube(); + if (!isDefined(tube)) + { + if (self GetAmmoCount("m72_law_mp")) + tube = "m72_law_mp"; + else if (self GetAmmoCount("rpg_mp")) + tube = "rpg_mp"; + else + continue; + } + + if (self GetCurrentWeapon() == tube) + continue; + + if (randomInt(100) > 35) + continue; + + self ChangeToWeapon(tube); + } +} + /* Fast swaps or reload cancels don't work cause t5 bots wait for the anim to complete Bots will think to switch weapons diff --git a/main_shared/maps/mp/bots/_bot_utility.gsc b/main_shared/maps/mp/bots/_bot_utility.gsc index c921f94..15526b1 100644 --- a/main_shared/maps/mp/bots/_bot_utility.gsc +++ b/main_shared/maps/mp/bots/_bot_utility.gsc @@ -156,6 +156,27 @@ isWeaponAltmode(weap) return false; } +/* + Returns a valid grenade launcher weapon +*/ +getValidTube() +{ + weaps = self getweaponslist(); + + for (i = 0; i < weaps.size; i++) + { + weap = weaps[i]; + + if(!self getAmmoCount(weap)) + continue; + + if ((isSubStr(weap, "gl_") && !isSubStr(weap, "_gl_")) || weap == "china_lake_mp") + return weap; + } + + return undefined; +} + /* Taken from iw4 script */