mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-22 05:55:42 +00:00
Move funcs around
This commit is contained in:
parent
461bd1cc09
commit
16d4f4795d
@ -1268,31 +1268,6 @@ set_diff()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
When the bot spawns.
|
|
||||||
*/
|
|
||||||
onSpawned()
|
|
||||||
{
|
|
||||||
self endon("disconnect");
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
self waittill("spawned_player");
|
|
||||||
|
|
||||||
if(randomInt(100) <= self.pers["bots"]["behavior"]["class"])
|
|
||||||
self.bot_change_class = undefined;
|
|
||||||
|
|
||||||
self.bot_lock_goal = false;
|
|
||||||
self.bot_oma_class = undefined;
|
|
||||||
self.help_time = undefined;
|
|
||||||
self.bot_was_follow_script_update = undefined;
|
|
||||||
self.bot_stuck_on_carepackage = undefined;
|
|
||||||
|
|
||||||
if (getDvarInt("bots_play_obj"))
|
|
||||||
self thread bot_dom_cap_think();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allows the bot to spawn when force respawn is disabled
|
Allows the bot to spawn when force respawn is disabled
|
||||||
Watches when the bot dies
|
Watches when the bot dies
|
||||||
@ -1329,6 +1304,123 @@ onGiveLoadout()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
When the bot spawns.
|
||||||
|
*/
|
||||||
|
onSpawned()
|
||||||
|
{
|
||||||
|
self endon("disconnect");
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
self waittill("spawned_player");
|
||||||
|
|
||||||
|
if(randomInt(100) <= self.pers["bots"]["behavior"]["class"])
|
||||||
|
self.bot_change_class = undefined;
|
||||||
|
|
||||||
|
self.bot_lock_goal = false;
|
||||||
|
self.bot_oma_class = undefined;
|
||||||
|
self.help_time = undefined;
|
||||||
|
self.bot_was_follow_script_update = undefined;
|
||||||
|
self.bot_stuck_on_carepackage = undefined;
|
||||||
|
|
||||||
|
if (getDvarInt("bots_play_obj"))
|
||||||
|
self thread bot_dom_cap_think();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
When the bot spawned, after the difficulty wait. Start the logic for the bot.
|
||||||
|
*/
|
||||||
|
onBotSpawned()
|
||||||
|
{
|
||||||
|
self endon("disconnect");
|
||||||
|
level endon("game_ended");
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
self waittill("bot_spawned");
|
||||||
|
|
||||||
|
self thread start_bot_threads();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Starts all the bot thinking
|
||||||
|
*/
|
||||||
|
start_bot_threads()
|
||||||
|
{
|
||||||
|
self endon("disconnect");
|
||||||
|
level endon("game_ended");
|
||||||
|
self endon("death");
|
||||||
|
|
||||||
|
gameFlagWait("prematch_done");
|
||||||
|
|
||||||
|
// inventory usage
|
||||||
|
if (getDvarInt("bots_play_killstreak"))
|
||||||
|
self thread bot_killstreak_think();
|
||||||
|
|
||||||
|
self thread bot_weapon_think();
|
||||||
|
self thread bot_perk_think();
|
||||||
|
|
||||||
|
// script targeting
|
||||||
|
if (getDvarInt("bots_play_target_other"))
|
||||||
|
{
|
||||||
|
self thread bot_target_vehicle();
|
||||||
|
self thread bot_equipment_kill_think();
|
||||||
|
self thread bot_turret_think();
|
||||||
|
}
|
||||||
|
|
||||||
|
// airdrop
|
||||||
|
if (getDvarInt("bots_play_take_carepackages"))
|
||||||
|
{
|
||||||
|
self thread bot_watch_stuck_on_crate();
|
||||||
|
self thread bot_crate_think();
|
||||||
|
}
|
||||||
|
|
||||||
|
// awareness
|
||||||
|
self thread bot_revenge_think();
|
||||||
|
self thread bot_uav_think();
|
||||||
|
self thread bot_listen_to_steps();
|
||||||
|
self thread follow_target();
|
||||||
|
|
||||||
|
// camp and follow
|
||||||
|
if (getDvarInt("bots_play_camp"))
|
||||||
|
{
|
||||||
|
self thread bot_think_follow();
|
||||||
|
self thread bot_think_camp();
|
||||||
|
}
|
||||||
|
|
||||||
|
// nades
|
||||||
|
if (getDvarInt("bots_play_nade"))
|
||||||
|
{
|
||||||
|
self thread bot_jav_loc_think();
|
||||||
|
self thread bot_use_tube_think();
|
||||||
|
self thread bot_use_grenade_think();
|
||||||
|
self thread bot_use_equipment_think();
|
||||||
|
self thread bot_watch_riot_weapons();
|
||||||
|
}
|
||||||
|
|
||||||
|
// obj
|
||||||
|
if (getDvarInt("bots_play_obj"))
|
||||||
|
{
|
||||||
|
self thread bot_dom_def_think();
|
||||||
|
self thread bot_dom_spawn_kill_think();
|
||||||
|
|
||||||
|
self thread bot_hq();
|
||||||
|
|
||||||
|
self thread bot_cap();
|
||||||
|
|
||||||
|
self thread bot_sab();
|
||||||
|
|
||||||
|
self thread bot_sd_defenders();
|
||||||
|
self thread bot_sd_attackers();
|
||||||
|
|
||||||
|
self thread bot_dem_attackers();
|
||||||
|
self thread bot_dem_defenders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Increments the number of bots approching the obj, decrements when needed
|
Increments the number of bots approching the obj, decrements when needed
|
||||||
Used for preventing too many bots going to one obj, or unreachable objs
|
Used for preventing too many bots going to one obj, or unreachable objs
|
||||||
@ -1665,95 +1757,113 @@ bot_use_bomb(bomb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
When the bot spawned, after the difficulty wait. Start the logic for the bot.
|
Fires the bots weapon until told to stop
|
||||||
*/
|
*/
|
||||||
onBotSpawned()
|
fire_current_weapon()
|
||||||
{
|
{
|
||||||
|
self endon("death");
|
||||||
self endon("disconnect");
|
self endon("disconnect");
|
||||||
level endon("game_ended");
|
self endon("weapon_change");
|
||||||
|
self endon("stop_firing_weapon");
|
||||||
|
|
||||||
for(;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
self waittill("bot_spawned");
|
self thread BotPressAttack(0.05);
|
||||||
|
wait 0.1;
|
||||||
self thread start_bot_threads();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Starts all the bot thinking
|
Changes to the weap
|
||||||
*/
|
*/
|
||||||
start_bot_threads()
|
changeToWeapon(weap)
|
||||||
{
|
{
|
||||||
self endon("disconnect");
|
self endon("disconnect");
|
||||||
level endon("game_ended");
|
|
||||||
self endon("death");
|
self endon("death");
|
||||||
|
level endon("game_ended");
|
||||||
|
|
||||||
gameFlagWait("prematch_done");
|
if (!self HasWeapon(weap))
|
||||||
|
return false;
|
||||||
|
|
||||||
// inventory usage
|
if (self GetCurrentWeapon() == weap)
|
||||||
if (getDvarInt("bots_play_killstreak"))
|
return true;
|
||||||
self thread bot_killstreak_think();
|
|
||||||
|
|
||||||
self thread bot_weapon_think();
|
self BotChangeToWeapon(weap);
|
||||||
self thread bot_perk_think();
|
|
||||||
|
|
||||||
// script targeting
|
self waittill_any_timeout(5, "weapon_change");
|
||||||
if (getDvarInt("bots_play_target_other"))
|
|
||||||
{
|
|
||||||
self thread bot_target_vehicle();
|
|
||||||
self thread bot_equipment_kill_think();
|
|
||||||
self thread bot_turret_think();
|
|
||||||
}
|
|
||||||
|
|
||||||
// airdrop
|
return (self GetCurrentWeapon() == weap);
|
||||||
if (getDvarInt("bots_play_take_carepackages"))
|
}
|
||||||
{
|
|
||||||
self thread bot_watch_stuck_on_crate();
|
|
||||||
self thread bot_crate_think();
|
|
||||||
}
|
|
||||||
|
|
||||||
// awareness
|
/*
|
||||||
self thread bot_revenge_think();
|
Bots throw the grenade
|
||||||
self thread bot_uav_think();
|
*/
|
||||||
self thread bot_listen_to_steps();
|
botThrowGrenade(nade, time)
|
||||||
self thread follow_target();
|
{
|
||||||
|
self endon("disconnect");
|
||||||
|
self endon("death");
|
||||||
|
level endon("game_ended");
|
||||||
|
|
||||||
// camp and follow
|
if (!self GetAmmoCount(nade))
|
||||||
if (getDvarInt("bots_play_camp"))
|
return false;
|
||||||
{
|
|
||||||
self thread bot_think_follow();
|
|
||||||
self thread bot_think_camp();
|
|
||||||
}
|
|
||||||
|
|
||||||
// nades
|
if (isSecondaryGrenade(nade))
|
||||||
if (getDvarInt("bots_play_nade"))
|
self thread BotPressSmoke(time);
|
||||||
{
|
else
|
||||||
self thread bot_jav_loc_think();
|
self thread BotPressFrag(time);
|
||||||
self thread bot_use_tube_think();
|
|
||||||
self thread bot_use_grenade_think();
|
|
||||||
self thread bot_use_equipment_think();
|
|
||||||
self thread bot_watch_riot_weapons();
|
|
||||||
}
|
|
||||||
|
|
||||||
// obj
|
ret = self waittill_any_timeout(5, "grenade_fire");
|
||||||
if (getDvarInt("bots_play_obj"))
|
|
||||||
{
|
|
||||||
self thread bot_dom_def_think();
|
|
||||||
self thread bot_dom_spawn_kill_think();
|
|
||||||
|
|
||||||
self thread bot_hq();
|
return (ret == "grenade_fire");
|
||||||
|
}
|
||||||
|
|
||||||
self thread bot_cap();
|
/*
|
||||||
|
Gets the object thats the closest in the array
|
||||||
|
*/
|
||||||
|
bot_array_nearest_curorigin(array)
|
||||||
|
{
|
||||||
|
result = undefined;
|
||||||
|
|
||||||
self thread bot_sab();
|
for(i = 0; i < array.size; i++)
|
||||||
|
if(!isDefined(result) || DistanceSquared(self.origin,array[i].curorigin) < DistanceSquared(self.origin,result.curorigin))
|
||||||
|
result = array[i];
|
||||||
|
|
||||||
self thread bot_sd_defenders();
|
return result;
|
||||||
self thread bot_sd_attackers();
|
}
|
||||||
|
|
||||||
self thread bot_dem_attackers();
|
/*
|
||||||
self thread bot_dem_defenders();
|
Returns an weapon thats a rocket with ammo
|
||||||
}
|
*/
|
||||||
|
getRocketAmmo()
|
||||||
|
{
|
||||||
|
answer = self getLockonAmmo();
|
||||||
|
|
||||||
|
if (isDefined(answer))
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
if(self getAmmoCount("rpg_mp"))
|
||||||
|
answer = "rpg_mp";
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a weapon thats lockon with ammo
|
||||||
|
*/
|
||||||
|
getLockonAmmo()
|
||||||
|
{
|
||||||
|
answer = undefined;
|
||||||
|
|
||||||
|
if(self getAmmoCount("at4_mp"))
|
||||||
|
answer = "at4_mp";
|
||||||
|
|
||||||
|
if(self getAmmoCount("stinger_mp"))
|
||||||
|
answer = "stinger_mp";
|
||||||
|
|
||||||
|
if(self getAmmoCount("javelin_mp"))
|
||||||
|
answer = "javelin_mp";
|
||||||
|
|
||||||
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2247,23 +2357,6 @@ bot_use_tube_think()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Fires the bots weapon until told to stop
|
|
||||||
*/
|
|
||||||
fire_current_weapon()
|
|
||||||
{
|
|
||||||
self endon("death");
|
|
||||||
self endon("disconnect");
|
|
||||||
self endon("weapon_change");
|
|
||||||
self endon("stop_firing_weapon");
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
self thread BotPressAttack(0.05);
|
|
||||||
wait 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bots thinking of using claymores and TIs
|
Bots thinking of using claymores and TIs
|
||||||
*/
|
*/
|
||||||
@ -2498,28 +2591,6 @@ bot_use_grenade_think()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Changes to the weap
|
|
||||||
*/
|
|
||||||
changeToWeapon(weap)
|
|
||||||
{
|
|
||||||
self endon("disconnect");
|
|
||||||
self endon("death");
|
|
||||||
level endon("game_ended");
|
|
||||||
|
|
||||||
if (!self HasWeapon(weap))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (self GetCurrentWeapon() == weap)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
self BotChangeToWeapon(weap);
|
|
||||||
|
|
||||||
self waittill_any_timeout(5, "weapon_change");
|
|
||||||
|
|
||||||
return (self GetCurrentWeapon() == weap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bots will use gremades/wweapons while having a target while using a shield
|
Bots will use gremades/wweapons while having a target while using a shield
|
||||||
*/
|
*/
|
||||||
@ -2592,28 +2663,6 @@ bot_watch_riot_weapons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Bots throw the grenade
|
|
||||||
*/
|
|
||||||
botThrowGrenade(nade, time)
|
|
||||||
{
|
|
||||||
self endon("disconnect");
|
|
||||||
self endon("death");
|
|
||||||
level endon("game_ended");
|
|
||||||
|
|
||||||
if (!self GetAmmoCount(nade))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (isSecondaryGrenade(nade))
|
|
||||||
self thread BotPressSmoke(time);
|
|
||||||
else
|
|
||||||
self thread BotPressFrag(time);
|
|
||||||
|
|
||||||
ret = self waittill_any_timeout(5, "grenade_fire");
|
|
||||||
|
|
||||||
return (ret == "grenade_fire");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BOts thinking of using javelins
|
BOts thinking of using javelins
|
||||||
*/
|
*/
|
||||||
@ -3489,41 +3538,6 @@ bot_weapon_think()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Returns an weapon thats a rocket with ammo
|
|
||||||
*/
|
|
||||||
getRocketAmmo()
|
|
||||||
{
|
|
||||||
answer = self getLockonAmmo();
|
|
||||||
|
|
||||||
if (isDefined(answer))
|
|
||||||
return answer;
|
|
||||||
|
|
||||||
if(self getAmmoCount("rpg_mp"))
|
|
||||||
answer = "rpg_mp";
|
|
||||||
|
|
||||||
return answer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Returns a weapon thats lockon with ammo
|
|
||||||
*/
|
|
||||||
getLockonAmmo()
|
|
||||||
{
|
|
||||||
answer = undefined;
|
|
||||||
|
|
||||||
if(self getAmmoCount("at4_mp"))
|
|
||||||
answer = "at4_mp";
|
|
||||||
|
|
||||||
if(self getAmmoCount("stinger_mp"))
|
|
||||||
answer = "stinger_mp";
|
|
||||||
|
|
||||||
if(self getAmmoCount("javelin_mp"))
|
|
||||||
answer = "javelin_mp";
|
|
||||||
|
|
||||||
return answer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bots think when to target vehicles
|
Bots think when to target vehicles
|
||||||
*/
|
*/
|
||||||
@ -4883,20 +4897,6 @@ bot_sab()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Gets the object thats the closest in the array
|
|
||||||
*/
|
|
||||||
bot_array_nearest_curorigin(array)
|
|
||||||
{
|
|
||||||
result = undefined;
|
|
||||||
|
|
||||||
for(i = 0; i < array.size; i++)
|
|
||||||
if(!isDefined(result) || DistanceSquared(self.origin,array[i].curorigin) < DistanceSquared(self.origin,result.curorigin))
|
|
||||||
result = array[i];
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bots play sd defenders
|
Bots play sd defenders
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user