mirror of
https://github.com/ineedbots/t4_bot_warfare.git
synced 2025-04-22 07:55:43 +00:00
Fix sniper, add reload cancel
This commit is contained in:
parent
73dc1c17b1
commit
4059b373c2
@ -155,6 +155,7 @@ resetBotVars()
|
|||||||
|
|
||||||
self.bot.is_cur_full_auto = false;
|
self.bot.is_cur_full_auto = false;
|
||||||
self.bot.cur_weap_dist_multi = 1;
|
self.bot.cur_weap_dist_multi = 1;
|
||||||
|
self.bot.is_cur_sniper = false;
|
||||||
|
|
||||||
self.bot.rand = randomInt(100);
|
self.bot.rand = randomInt(100);
|
||||||
|
|
||||||
@ -326,6 +327,20 @@ SetWeaponDistMulti(weap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Is the weap a sniper
|
||||||
|
*/
|
||||||
|
IsWeapSniper(weap)
|
||||||
|
{
|
||||||
|
if (weap == "none")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (maps\mp\gametypes\_missions::getWeaponClass(weap) != "weapon_sniper")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The hold breath thread.
|
The hold breath thread.
|
||||||
*/
|
*/
|
||||||
@ -393,6 +408,7 @@ onWeaponChange()
|
|||||||
weap = self GetCurrentWeapon();
|
weap = self GetCurrentWeapon();
|
||||||
self.bot.is_cur_full_auto = WeaponIsFullAuto(weap);
|
self.bot.is_cur_full_auto = WeaponIsFullAuto(weap);
|
||||||
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(weap);
|
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(weap);
|
||||||
|
self.bot.is_cur_sniper = IsWeapSniper(weap);
|
||||||
if (weap != "none")
|
if (weap != "none")
|
||||||
self changeToWeap(weap);
|
self changeToWeap(weap);
|
||||||
|
|
||||||
@ -402,6 +418,7 @@ onWeaponChange()
|
|||||||
|
|
||||||
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(weap);
|
||||||
|
self.bot.is_cur_sniper = IsWeapSniper(weap);
|
||||||
|
|
||||||
if (newWeapon == "none")
|
if (newWeapon == "none")
|
||||||
{
|
{
|
||||||
@ -442,7 +459,18 @@ reload_watch()
|
|||||||
{
|
{
|
||||||
self waittill("reload_start");
|
self waittill("reload_start");
|
||||||
self.bot.isreloading = true;
|
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;
|
self.bot.isreloading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1004,7 +1032,7 @@ watchToLook()
|
|||||||
if(!self isInRange(self.bot.target.dist, curweap))
|
if(!self isInRange(self.bot.target.dist, curweap))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (weaponClass(curweap) == "sniper")
|
if (self.bot.is_cur_sniper)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(randomInt(100) > self.pers["bots"]["behavior"]["jump"])
|
if(randomInt(100) > self.pers["bots"]["behavior"]["jump"])
|
||||||
@ -1166,7 +1194,7 @@ aim()
|
|||||||
{
|
{
|
||||||
if (self canAds(dist, curweap))
|
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();
|
self thread pressAds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1226,7 +1254,7 @@ aim()
|
|||||||
if (canADS)
|
if (canADS)
|
||||||
{
|
{
|
||||||
stopAdsOverride = false;
|
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)
|
if (self.pers["bots"]["behavior"]["quickscope"] && self.bot.last_fire_time != -1 && getTime() - self.bot.last_fire_time < 1000)
|
||||||
stopAdsOverride = true;
|
stopAdsOverride = true;
|
||||||
@ -1240,7 +1268,7 @@ aim()
|
|||||||
|
|
||||||
if (trace_time > reaction_time)
|
if (trace_time > reaction_time)
|
||||||
{
|
{
|
||||||
if((!canADS || adsAmount >= 1.0 || self InLastStand() || self GetStance() == "prone") && (conedot > 0.95 || dist < level.bots_maxKnifeDistance) && getDvarInt("bots_play_fire"))
|
if((!canADS || adsAmount >= 1.0 || self InLastStand() || self GetStance() == "prone") && (conedot > 0.99 || dist < level.bots_maxKnifeDistance) && getDvarInt("bots_play_fire"))
|
||||||
self botFire();
|
self botFire();
|
||||||
|
|
||||||
if (isplay)
|
if (isplay)
|
||||||
@ -1275,7 +1303,7 @@ aim()
|
|||||||
if (canADS)
|
if (canADS)
|
||||||
{
|
{
|
||||||
stopAdsOverride = false;
|
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)
|
if (self.pers["bots"]["behavior"]["quickscope"] && self.bot.last_fire_time != -1 && getTime() - self.bot.last_fire_time < 1000)
|
||||||
stopAdsOverride = true;
|
stopAdsOverride = true;
|
||||||
@ -1463,7 +1491,7 @@ walk()
|
|||||||
|
|
||||||
if(self.bot.target.isplay && self.bot.target.trace_time && self canFire(curweap) && self isInRange(self.bot.target.dist, curweap))
|
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;
|
continue;
|
||||||
|
|
||||||
if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"])
|
if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"])
|
||||||
|
@ -278,13 +278,10 @@ difficulty()
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
wait 5;
|
|
||||||
|
|
||||||
rankVar = GetDvarInt("bots_skill");
|
rankVar = GetDvarInt("bots_skill");
|
||||||
|
|
||||||
if(rankVar == 9)
|
if(rankVar != 9)
|
||||||
continue;
|
{
|
||||||
|
|
||||||
switch(self.pers["bots"]["skill"]["base"])
|
switch(self.pers["bots"]["skill"]["base"])
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -506,6 +503,9 @@ difficulty()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait 5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -991,6 +991,7 @@ start_bot_threads()
|
|||||||
self thread bot_killstreak_think();
|
self thread bot_killstreak_think();
|
||||||
|
|
||||||
self thread bot_weapon_think();
|
self thread bot_weapon_think();
|
||||||
|
self thread doReloadCancel();
|
||||||
|
|
||||||
// script targeting
|
// script targeting
|
||||||
if (getDvarInt("bots_play_target_other"))
|
if (getDvarInt("bots_play_target_other"))
|
||||||
@ -2410,6 +2411,65 @@ bot_revenge_think()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reload cancels
|
||||||
|
*/
|
||||||
|
doReloadCancel()
|
||||||
|
{
|
||||||
|
self endon("disconnect");
|
||||||
|
self endon("death");
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
self waittill("reload");
|
||||||
|
|
||||||
|
if(self BotIsFrozen())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(self isDefusing() || self isPlanting())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (self InLastStand())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
curWeap = self GetCurrentWeapon();
|
||||||
|
// check single reloads
|
||||||
|
if (self GetWeaponAmmoClip(curWeap) < WeaponClipSize(curWeap))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// check difficulty
|
||||||
|
if (self.pers["bots"]["skill"]["base"] <= 3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// check if got another weapon
|
||||||
|
weaponslist = self GetWeaponsListPrimaries();
|
||||||
|
weap = "";
|
||||||
|
while(weaponslist.size)
|
||||||
|
{
|
||||||
|
weapon = weaponslist[randomInt(weaponslist.size)];
|
||||||
|
weaponslist = array_remove(weaponslist, weapon);
|
||||||
|
|
||||||
|
if (!maps\mp\gametypes\_weapons::isSideArm( weapon ) && !maps\mp\gametypes\_weapons::isPrimaryWeapon( weapon ))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(curWeap == weapon || weapon == "none" || weapon == "")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
weap = weapon;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(weap == "")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// do the cancel
|
||||||
|
wait 0.1;
|
||||||
|
self BotChangeToWeapon(weap);
|
||||||
|
wait 0.25;
|
||||||
|
self BotChangeToWeapon(curWeap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bot logic for switching weapons.
|
Bot logic for switching weapons.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user