improve checking for sniper and reload

This commit is contained in:
INeedBots 2021-03-19 14:04:57 -06:00
parent dbe50d85e2
commit 52e9373610

View File

@ -135,6 +135,7 @@ resetBotVars()
self.bot.is_cur_full_auto = false;
self.bot.cur_weap_dist_multi = 1;
self.bot.is_cur_sniper = false;
self.bot.rand = randomInt(100);
@ -186,6 +187,20 @@ SetWeaponDistMulti(weap)
}
}
/*
Is the weap a sniper
*/
IsWeapSniper(weap)
{
if (weap == "none")
return false;
if (weaponClass(weap) != "sniper")
return false;
return true;
}
/*
When the bot changes weapon.
*/
@ -197,6 +212,7 @@ onWeaponChange()
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);
@ -207,6 +223,7 @@ onWeaponChange()
self.bot.is_cur_full_auto = WeaponIsFullAuto(newWeapon);
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(weap);
self.bot.is_cur_sniper = IsWeapSniper(weap);
if (newWeapon == "none")
continue;
@ -228,7 +245,17 @@ reload_watch()
self waittill("reload_start");
self.bot.isreloading = true;
self waittill_notify_or_timeout("reload", 7.5);
while(true)
{
ret = self waittill_any_timeout(7.5, "reload");
if (ret == "timeout")
break;
weap = self GetCurrentWeapon();
if (self GetWeaponAmmoClip(weap) >= WeaponClipSize(weap))
break;
}
self.bot.isreloading = false;
}
}
@ -1090,7 +1117,7 @@ watchToLook()
if(!self isInRange(self.bot.target.dist, curweap))
continue;
if (weaponClass(curweap) == "sniper")
if (self.bot.is_cur_sniper)
continue;
if(randomInt(100) > self.pers["bots"]["behavior"]["jump"])
@ -1266,7 +1293,7 @@ aim()
{
if (self canAds(dist, curweap))
{
if (weaponClass(curweap) != "sniper" || !self.pers["bots"]["behavior"]["quickscope"])
if (!self.bot.is_cur_sniper || !self.pers["bots"]["behavior"]["quickscope"])
self thread pressAds();
}
}
@ -1326,7 +1353,7 @@ aim()
if (canADS)
{
stopAdsOverride = false;
if (weaponClass(curweap) == "sniper")
if (self.bot.is_cur_sniper)
{
if (self.pers["bots"]["behavior"]["quickscope"] && self.bot.last_fire_time != -1 && getTime() - self.bot.last_fire_time < 1000)
stopAdsOverride = true;
@ -1380,7 +1407,7 @@ aim()
if (canADS)
{
stopAdsOverride = false;
if (weaponClass(curweap) == "sniper")
if (self.bot.is_cur_sniper)
{
if (self.pers["bots"]["behavior"]["quickscope"] && self.bot.last_fire_time != -1 && getTime() - self.bot.last_fire_time < 1000)
stopAdsOverride = true;
@ -1590,7 +1617,7 @@ walk()
if(self.bot.target.isplay && self.bot.target.trace_time && self canFire(curweap) && self isInRange(self.bot.target.dist, curweap))
{
if (self InLastStand() || self GetStance() == "prone" || (weaponClass(curweap) == "sniper" && self PlayerADS() > 0))
if (self InLastStand() || self GetStance() == "prone" || (self.bot.is_cur_sniper && self PlayerADS() > 0))
continue;
if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"])