frag stuff

This commit is contained in:
Your Name 2020-08-07 14:32:39 -06:00
parent bc37334d90
commit 673e0a6c14
2 changed files with 109 additions and 34 deletions

View File

@ -55,6 +55,7 @@ init()
level.defuseObject = undefined; level.defuseObject = undefined;
level.bots_smokeList = List(); level.bots_smokeList = List();
level.bots_fragList = List();
level.bots_minSprintDistance = 315; level.bots_minSprintDistance = 315;
level.bots_minSprintDistance *= level.bots_minSprintDistance; level.bots_minSprintDistance *= level.bots_minSprintDistance;
@ -552,16 +553,42 @@ onGrenadeFire()
{ {
self waittill ( "grenade_fire", grenade, weaponName ); self waittill ( "grenade_fire", grenade, weaponName );
grenade.name = weaponName; grenade.name = weaponName;
if(weaponName == "smoke_grenade_mp") if(weaponName == "smoke_grenade_mp")
grenade thread AddToSmokeList(); grenade thread AddToSmokeList();
else if (isSubStr(weaponName, "frag_"))
if ( weaponName == "claymore" || weaponName == "claymore_mp" ) grenade thread AddToFragList();
{ else if ( weaponName == "claymore" || weaponName == "claymore_mp" )
grenade thread claymoreDetonationBotFix(); grenade thread claymoreDetonationBotFix();
}
} }
} }
AddToFragList()
{
grenade = spawnstruct();
grenade.origin = self getOrigin();
grenade.velocity = (0, 0, 0);
grenade.grenade = self;
grenade thread thinkFrag();
level.bots_fragList ListAdd(grenade);
}
thinkFrag()
{
while(isDefined(self.grenade))
{
nowOrigin = self.grenade getOrigin();
self.velocity = (nowOrigin - self.origin)*20; //lensq < 10000
self.origin = nowOrigin;
wait 0.05;
}
level.bots_fragList ListRemove(self);
}
/* /*
Adds a smoke grenade to the list of smokes in the game. Used to prevent bots from seeing through smoke. Adds a smoke grenade to the list of smokes in the game. Used to prevent bots from seeing through smoke.
*/ */

View File

@ -98,10 +98,9 @@ resetBotVars()
self.bot.isfrozen = false; self.bot.isfrozen = false;
self.bot.isreloading = false; self.bot.isreloading = false;
self.bot.isfragging = false; // gotta think about grenades self.bot.isfragging = false;
self.bot.issmoking = false;
self.bot.isfraggingafter = false; self.bot.isfraggingafter = false;
self.bot.issmokingafter = false; self.bot.tryingtofrag = false;
self.bot.semi_time = false; self.bot.semi_time = false;
self.bot.greedy_path = false; self.bot.greedy_path = false;
@ -116,7 +115,7 @@ resetBotVars()
self.bot.running = false; self.bot.running = false;
self.bot.max_run_time = getdvarfloat("scr_player_sprinttime"); self.bot.max_run_time = getdvarfloat("scr_player_sprinttime");
self.bot.run_time = self.bot.max_run_time; self.bot.run_time = self.bot.max_run_time;
self.bot.run_in_delay = false; self.bot.runningafter = false;
self.bot.fire_pressed = false; self.bot.fire_pressed = false;
@ -145,6 +144,7 @@ onPlayerSpawned()
self thread onLastStand(); self thread onLastStand();
self thread reload_watch(); self thread reload_watch();
self thread grenade_watch();
self thread adsHack(); self thread adsHack();
self thread fireHack(); self thread fireHack();
@ -160,14 +160,6 @@ onPlayerSpawned()
} }
} }
/*
Bot will knife.
*/
knife()
{
}
/* /*
Bot will reload. Bot will reload.
*/ */
@ -180,6 +172,13 @@ reload()
// the script should reload for us. // the script should reload for us.
} }
/*
Bot will knife.
*/
knife()
{
}
/* /*
Bot will hold the frag button for a time Bot will hold the frag button for a time
*/ */
@ -248,6 +247,11 @@ crouch()
*/ */
prone() prone()
{ {
curWeap = self GetCurrentWeapon();
if (curWeap == "riotshield_mp")
return;
self botSetStance("prone"); self botSetStance("prone");
} }
@ -262,6 +266,7 @@ sprint()
return; return;
self.bot.running = true; self.bot.running = true;
self.bot.runningafter = true;
} }
UseRunThink() UseRunThink()
@ -284,7 +289,7 @@ UseRunThink()
self.bot.isfrozen || self.bot.climbing || self.bot.isfrozen || self.bot.climbing ||
self.bot.isreloading || self.bot.isreloading ||
self.bot.ads_pressed || self.bot.fire_pressed || self.bot.ads_pressed || self.bot.fire_pressed ||
self.bot.isfragging || self.bot.issmoking || self.bot.isfragging ||
lengthsquared(self.bot.velocity) <= 25 || lengthsquared(self.bot.velocity) <= 25 ||
self IsStunned() || self isArtShocked() || self maps\mp\_flashgrenades::isFlashbanged()) self IsStunned() || self isArtShocked() || self maps\mp\_flashgrenades::isFlashbanged())
{ {
@ -307,14 +312,12 @@ doRunDelay()
self notify("bot_run_delay"); self notify("bot_run_delay");
self endon("bot_run_delay"); self endon("bot_run_delay");
self.bot.run_in_delay = true;
if (self _hasPerk("specialty_fastsprintrecovery")) if (self _hasPerk("specialty_fastsprintrecovery"))
wait 0.5; wait 0.5;
else else
wait 1; wait 1;
self.bot.run_in_delay = false; self.bot.runningafter = false;
} }
bot_lookat(pos, time) bot_lookat(pos, time)
@ -382,6 +385,34 @@ stanceHack()
} }
} }
grenade_watch()
{
self endon("disconnect");
self endon("death");
for (;;)
{
self waittill("grenade_pullback", weaponName);
self.bot.isfragging = true;
self.bot.isfraggingafter = true;
self waittill_notify_or_timeout( "grenade_fire", 5 );
self.bot.isfragging = false;
self thread doFragAfterThread();
}
}
doFragAfterThread()
{
self endon("disconnect");
self endon("death");
self endon("grenade_pullback");
wait 1;
self.bot.isfraggingafter = false;
}
emptyClipShoot() emptyClipShoot()
{ {
self endon("disconnect"); self endon("disconnect");
@ -548,16 +579,19 @@ fireHack()
shouldFire = self.bot.fire_pressed; shouldFire = self.bot.fire_pressed;
if (self.bot.isswitching || self.bot.run_in_delay || self.bot.running) if (self.bot.isswitching || self.bot.runningafter)
shouldFire = false; shouldFire = false;
if (self.bot.isfragging || self.bot.issmoking) if (self.bot.climbing)
shouldFire = false;
if (self.bot.tryingtofrag)
shouldFire = true; shouldFire = true;
if (level.gameEnded || !gameFlag( "prematch_done" )) if (level.gameEnded || !gameFlag( "prematch_done" ))
shouldFire = false; shouldFire = false;
if (self.bot.isfrozen || self.bot.climbing) if (self.bot.isfrozen)
shouldFire = false; shouldFire = false;
self FreezeControls(!shouldFire); self FreezeControls(!shouldFire);
@ -569,6 +603,7 @@ adsHack()
self endon("disconnect"); self endon("disconnect");
self endon("spawned_player"); self endon("spawned_player");
self setSpreadOverride(self.bot.ads_tightness);
for (;;) for (;;)
{ {
wait 0.05; wait 0.05;
@ -891,7 +926,7 @@ reload_thread()
if (self.bot.isfrozen || level.gameEnded || !gameFlag( "prematch_done" )) if (self.bot.isfrozen || level.gameEnded || !gameFlag( "prematch_done" ))
return; return;
if(isDefined(self.bot.target) || self.bot.isreloading || self.bot.isfraggingafter || self.bot.issmokingafter || self.bot.climbing) if(isDefined(self.bot.target) || self.bot.isreloading || self.bot.isfraggingafter || self.bot.climbing)
return; return;
cur = self getCurrentWEapon(); cur = self getCurrentWEapon();
@ -1330,11 +1365,14 @@ aim()
reaction_time = self.pers["bots"]["skill"]["reaction_time"]; reaction_time = self.pers["bots"]["skill"]["reaction_time"];
nadeAimOffset = 0; nadeAimOffset = 0;
myeye = self getEye(); myeye = self getEye();
if(self.bot.isfraggingafter || self.bot.issmokingafter) if(weaponClass(curweap) == "grenade")
nadeAimOffset = dist/3000; {
else if(weaponClass(curweap) == "grenade") if (getWeaponClass(curweap) == "weapon_projectile")
nadeAimOffset = dist/16000; nadeAimOffset = dist/16000;
else
nadeAimOffset = dist/3000;
}
if(no_trace_time) if(no_trace_time)
{ {
@ -1345,7 +1383,7 @@ aim()
if(isplay) if(isplay)
{ {
//better room to nade? cook time function with dist? //better room to nade? cook time function with dist?
if(!self.bot.isfraggingafter && !self.bot.issmokingafter) if(!self.bot.isfraggingafter)
{ {
nade = self getValidGrenade(); nade = self getValidGrenade();
if(isDefined(nade) && rand <= self.pers["bots"]["behavior"]["nade"] && bulletTracePassed(myEye, myEye + (0, 0, 75), false, self) && bulletTracePassed(last_pos, last_pos + (0, 0, 100), false, target)) //bots_minGrenadeDistance if(isDefined(nade) && rand <= self.pers["bots"]["behavior"]["nade"] && bulletTracePassed(myEye, myEye + (0, 0, 75), false, self) && bulletTracePassed(last_pos, last_pos + (0, 0, 100), false, target)) //bots_minGrenadeDistance
@ -1483,8 +1521,6 @@ stopNading()
{ {
if(self.bot.isfragging) if(self.bot.isfragging)
self thread frag(0); self thread frag(0);
if(self.bot.issmoking)
self thread smoke(0);
} }
/* /*
@ -1522,6 +1558,9 @@ canFire(curweap)
if(curweap == "none") if(curweap == "none")
return false; return false;
if (curweap == "riotshield_mp")
return false;
if (self IsUsingRemote()) if (self IsUsingRemote())
return true; return true;
@ -1546,6 +1585,12 @@ canAds(dist, curweap)
weapclass = (weaponClass(curweap)); weapclass = (weaponClass(curweap));
if(weapclass == "spread" || weapclass == "grenade") if(weapclass == "spread" || weapclass == "grenade")
return false; return false;
if (curweap == "riotshield_mp")
return false;
if (isSubStr(curweap, "_akimbo_"))
return false;
return true; return true;
} }
@ -1560,7 +1605,10 @@ isInRange(dist, curweap)
if (self IsUsingRemote()) if (self IsUsingRemote())
return true; return true;
if(weapclass == "spread" && dist > level.bots_maxShotgunDistance) if((weapclass == "spread" || isSubStr(curweap, "_akimbo_")) && dist > level.bots_maxShotgunDistance)
return false;
if (curweap == "riotshield_mp" && dist > level.bots_maxKnifeDistance)
return false; return false;
return true; return true;
@ -1594,7 +1642,7 @@ walk()
{ {
curweap = self getCurrentWeapon(); curweap = self getCurrentWeapon();
if(self.bot.target.entity.classname == "script_vehicle" || self.bot.isfraggingafter || self.bot.issmokingafter) if(self.bot.target.entity.classname == "script_vehicle" || self.bot.isfraggingafter)
{ {
continue; continue;
} }