Fix weap swap vars, partial c4 support

This commit is contained in:
ineedbots 2021-05-04 16:54:05 -06:00
parent 5afc002126
commit 979d1135be
2 changed files with 76 additions and 15 deletions

View File

@ -303,10 +303,69 @@ spawned()
self thread aim(); self thread aim();
self thread watchHoldBreath(); self thread watchHoldBreath();
self thread onNewEnemy(); self thread onNewEnemy();
self thread watchGrenadeFire();
self notify("bot_spawned"); self notify("bot_spawned");
} }
/*
Watches when the bot fires a grenade
*/
watchGrenadeFire()
{
self endon("disconnect");
self endon("death");
for (;;)
{
self waittill( "grenade_fire", nade, weapname );
if ( weapname == "satchel_charge_mp" )
self thread watchC4Thrown(nade);
}
}
/*
Watches the c4
*/
watchC4Thrown(c4)
{
self endon("disconnect");
c4 endon("death");
wait 0.5;
for (;;)
{
wait 1 + randomInt(50) * 0.05;
shouldBreak = false;
for (i = 0; i < level.players.size; i++)
{
player = level.players[i];
if(player == self)
continue;
if((level.teamBased && self.team == player.team) || player.sessionstate != "playing" || !isAlive(player))
continue;
if (distanceSquared(c4.origin, player.origin) > 200*200)
continue;
if (!bulletTracePassed(c4.origin, player.origin + (0, 0, 25), false, c4))
continue;
shouldBreak = true;
}
if (shouldBreak)
break;
}
self notify( "alt_detonate" );
}
/* /*
Sets the factor of distance for a weapon Sets the factor of distance for a weapon
*/ */
@ -406,25 +465,24 @@ onWeaponChange()
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("death");
weap = self GetCurrentWeapon(); first = true;
self.bot.is_cur_full_auto = WeaponIsFullAuto(weap);
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(weap);
self.bot.is_cur_sniper = IsWeapSniper(weap);
if (weap != "none")
self changeToWeap(weap);
for(;;) for(;;)
{ {
newWeapon = undefined;
if (first)
{
first = false;
newWeapon = self getCurrentWeapon();
}
else
self waittill( "weapon_change", newWeapon ); self waittill( "weapon_change", newWeapon );
self.bot.is_cur_full_auto = WeaponIsFullAuto(newWeapon); self.bot.is_cur_full_auto = WeaponIsFullAuto(newWeapon);
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(weap); self.bot.cur_weap_dist_multi = SetWeaponDistMulti(newWeapon);
self.bot.is_cur_sniper = IsWeapSniper(weap); self.bot.is_cur_sniper = IsWeapSniper(newWeapon);
if (newWeapon == "none") if (newWeapon == "none")
{
continue; continue;
}
self changeToWeap(newWeapon); self changeToWeap(newWeapon);
} }

View File

@ -2061,6 +2061,8 @@ bot_use_equipment_think()
nade = undefined; nade = undefined;
if (self GetAmmoCount("mine_bouncing_betty_mp")) if (self GetAmmoCount("mine_bouncing_betty_mp"))
nade = "mine_bouncing_betty_mp"; nade = "mine_bouncing_betty_mp";
if (self GetAmmoCount("satchel_charge_mp"))
nade = "satchel_charge_mp";
if (!isDefined(nade)) if (!isDefined(nade))
continue; continue;
@ -2138,6 +2140,7 @@ bot_use_equipment_think()
if (self changeToWeapon(nade)) if (self changeToWeapon(nade))
{ {
if (nade != "satchel_charge_mp")
self thread fire_current_weapon(); self thread fire_current_weapon();
self waittill_any_timeout(5, "grenade_fire", "weapon_change"); self waittill_any_timeout(5, "grenade_fire", "weapon_change");
self notify("stop_firing_weapon"); self notify("stop_firing_weapon");
@ -2523,7 +2526,7 @@ bot_weapon_think()
} }
else else
{ {
if(curWeap != "none" && self getAmmoCount(curWeap) && curWeap != "satchel_charge_mp" && curWeap != "squadcommand_mp") if(curWeap != "none" && self getAmmoCount(curWeap) && curWeap != "squadcommand_mp")
{ {
if(randomInt(100) > self.pers["bots"]["behavior"]["switch"]) if(randomInt(100) > self.pers["bots"]["behavior"]["switch"])
continue; continue;
@ -2549,7 +2552,7 @@ bot_weapon_think()
if (maps\mp\gametypes\_weapons::isGrenade( weapon )) if (maps\mp\gametypes\_weapons::isGrenade( weapon ))
continue; continue;
if(curWeap == weapon || weapon == "satchel_charge_mp" || weapon == "none" || weapon == "mine_bouncing_betty_mp" || weapon == "" || weapon == "squadcommand_mp")//c4 no work if(curWeap == weapon || weapon == "satchel_charge_mp" || weapon == "none" || weapon == "mine_bouncing_betty_mp" || weapon == "" || weapon == "squadcommand_mp")
continue; continue;
weap = weapon; weap = weapon;