mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-22 05:55:42 +00:00
Fixed weapon swap vars and added c4 watcher
This commit is contained in:
parent
6bd638ab00
commit
06990751c0
@ -209,27 +209,27 @@ onWeaponChange()
|
||||
{
|
||||
self endon("disconnect");
|
||||
self endon("death");
|
||||
|
||||
weap = self GetCurrentWeapon();
|
||||
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);
|
||||
|
||||
first = true;
|
||||
for(;;)
|
||||
{
|
||||
self waittill( "weapon_change", newWeapon );
|
||||
newWeapon = undefined;
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
newWeapon = self getCurrentWeapon();
|
||||
}
|
||||
else
|
||||
self waittill( "weapon_change", newWeapon );
|
||||
|
||||
self.bot.is_cur_full_auto = WeaponIsFullAuto(newWeapon);
|
||||
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(weap);
|
||||
self.bot.is_cur_sniper = IsWeapSniper(weap);
|
||||
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(newWeapon);
|
||||
self.bot.is_cur_sniper = IsWeapSniper(newWeapon);
|
||||
|
||||
if (newWeapon == "none")
|
||||
continue;
|
||||
|
||||
self changeToWeap(self GetCurrentWeapon());
|
||||
self changeToWeap(newWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,10 +440,69 @@ spawned()
|
||||
self thread onNewEnemy();
|
||||
self thread walk();
|
||||
self thread watchHoldBreath();
|
||||
self thread watchGrenadeFire();
|
||||
|
||||
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 == "c4_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" || !isReallyAlive(player))
|
||||
continue;
|
||||
|
||||
if (distanceSquared(c4.origin, player.origin) > 1024)
|
||||
continue;
|
||||
|
||||
if (!bulletTracePassed(c4.origin, player.origin + (0, 0, 25), false, c4))
|
||||
continue;
|
||||
|
||||
shouldBreak = true;
|
||||
}
|
||||
|
||||
if (shouldBreak)
|
||||
break;
|
||||
}
|
||||
|
||||
self notify( "alt_detonate" );
|
||||
}
|
||||
|
||||
/*
|
||||
Bot moves towards the point
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user