Greatly reduce var usage (prevent exceeded child0/1 vars)

This commit is contained in:
ineedbots 2021-05-27 21:40:28 -06:00
parent a77d5f262c
commit 86dbc6c00a
3 changed files with 4414 additions and 4099 deletions

View File

@ -264,12 +264,10 @@ fixDem()
for (i = 0; i < level.bombZones.size; i++) for (i = 0; i < level.bombZones.size; i++)
{ {
bombzone = level.bombZones[i]; if (isDefined(level.bombZones[i].trigger.trigger_off))
level.bombZones[i].bombExploded = true;
if (isDefined(bombzone.trigger.trigger_off))
bombzone.bombExploded = true;
else else
bombzone.bombExploded = undefined; level.bombZones[i].bombExploded = undefined;
} }
wait 0.05; wait 0.05;
@ -307,18 +305,10 @@ fixKoth()
} }
/* /*
Audits all the important models cause iw5 script is kek Loop
*/ */
auditModels() auditModels_loop()
{ {
level.vest_boxes = [];
for (;;)
{
wait 0.05;
level.vest_boxes = array_removeUndefined(level.vest_boxes);
s_models = getEntArray("script_model", "classname"); s_models = getEntArray("script_model", "classname");
for (i = s_models.size - 1; i >= 0; i--) for (i = s_models.size - 1; i >= 0; i--)
@ -338,17 +328,29 @@ auditModels()
} }
} }
} }
/*
Audits all the important models cause iw5 script is kek
*/
auditModels()
{
level.vest_boxes = [];
for (;;)
{
wait 0.05;
level.vest_boxes = array_removeUndefined(level.vest_boxes);
auditModels_loop();
}
} }
/* /*
Watches radars Loop
*/ */
watchRadar() watchRadar_loop()
{ {
for (;;)
{
wait 1;
for ( i = level.players.size - 1; i >= 0; i-- ) for ( i = level.players.size - 1; i >= 0; i-- )
{ {
player = level.players[i]; player = level.players[i];
@ -388,17 +390,25 @@ watchRadar()
} }
} }
} }
}
/* /*
Watches scrambler Watches radars
*/ */
watchScrabler() watchRadar()
{ {
for (;;) for (;;)
{ {
wait 1; wait 1;
watchRadar_loop();
}
}
/*
Loop
*/
watchScrabler_loop()
{
for ( i = level.players.size - 1; i >= 0; i-- ) for ( i = level.players.size - 1; i >= 0; i-- )
{ {
player = level.players[i]; player = level.players[i];
@ -435,16 +445,25 @@ watchScrabler()
} }
} }
} }
}
/* /*
Adds a notify when the airdrop is dropped Watches scrambler
*/ */
addNotifyOnAirdrops() watchScrabler()
{ {
for (;;) for (;;)
{ {
wait 1; wait 1;
watchScrabler_loop();
}
}
/*
Loop
*/
addNotifyOnAirdrops_loop()
{
dropCrates = getEntArray( "care_package", "targetname" ); dropCrates = getEntArray( "care_package", "targetname" );
for (i = dropCrates.size - 1; i >= 0; i--) for (i = dropCrates.size - 1; i >= 0; i--)
@ -461,6 +480,17 @@ addNotifyOnAirdrops()
airdrop thread doNotifyOnAirdrop(); airdrop thread doNotifyOnAirdrop();
} }
} }
/*
Adds a notify when the airdrop is dropped
*/
addNotifyOnAirdrops()
{
for (;;)
{
wait 1;
addNotifyOnAirdrops_loop();
}
} }
/* /*
@ -565,14 +595,10 @@ add_bot()
} }
/* /*
A server thread for monitoring all bot's difficulty levels for custom server settings. Loop
*/ */
diffBots() diffBots_loop()
{ {
for(;;)
{
wait 1.5;
var_allies_hard = getDVarInt("bots_skill_allies_hard"); var_allies_hard = getDVarInt("bots_skill_allies_hard");
var_allies_med = getDVarInt("bots_skill_allies_med"); var_allies_med = getDVarInt("bots_skill_allies_med");
var_axis_hard = getDVarInt("bots_skill_axis_hard"); var_axis_hard = getDVarInt("bots_skill_axis_hard");
@ -643,16 +669,25 @@ diffBots()
} }
} }
} }
}
/* /*
A server thread for monitoring all bot's teams for custom server settings. A server thread for monitoring all bot's difficulty levels for custom server settings.
*/ */
teamBots() diffBots()
{ {
for(;;) for(;;)
{ {
wait 1.5; wait 1.5;
diffBots_loop();
}
}
/*
Loop
*/
teamBots_loop()
{
teamAmount = getDvarInt("bots_team_amount"); teamAmount = getDvarInt("bots_team_amount");
toTeam = getDvar("bots_team"); toTeam = getDvar("bots_team");
@ -772,21 +807,24 @@ teamBots()
} }
} }
} }
}
/* /*
A server thread for monitoring all bot's in game. Will add and kick bots according to server settings. A server thread for monitoring all bot's teams for custom server settings.
*/ */
addBots() teamBots()
{ {
level endon("game_ended");
bot_wait_for_host();
for(;;) for(;;)
{ {
wait 1.5; wait 1.5;
teamBots_loop();
}
}
/*
Loops
*/
addBots_loop()
{
botsToAdd = GetDvarInt("bots_manage_add"); botsToAdd = GetDvarInt("bots_manage_add");
if(botsToAdd > 0) if(botsToAdd > 0)
@ -887,6 +925,22 @@ addBots()
kick(tempBot getEntityNumber()); kick(tempBot getEntityNumber());
} }
} }
/*
A server thread for monitoring all bot's in game. Will add and kick bots according to server settings.
*/
addBots()
{
level endon("game_ended");
bot_wait_for_host();
for(;;)
{
wait 1.5;
addBots_loop();
}
} }
/* /*

View File

@ -250,13 +250,10 @@ reload_watch()
while(true) while(true)
{ {
ret = self waittill_any_timeout(7.5, "reload"); if (self waittill_any_timeout(7.5, "reload") == "timeout")
if (ret == "timeout")
break; break;
weap = self GetCurrentWeapon(); if (self GetWeaponAmmoClip(self GetCurrentWeapon()) >= WeaponClipSize(self GetCurrentWeapon()))
if (self GetWeaponAmmoClip(weap) >= WeaponClipSize(weap))
break; break;
} }
self.bot.isreloading = false; self.bot.isreloading = false;
@ -296,21 +293,6 @@ onLastStand()
self notify("kill_goal"); self notify("kill_goal");
if (!self inFinalStand() && !self IsUsingRemote())
{
pistol = undefined;
weaponsList = self GetWeaponsListPrimaries();
for (i = 0; i < weaponsList.size; i++)
{
weapon = weaponsList[i];
if ( maps\mp\gametypes\_weapons::isSideArm( weapon ) )
pistol = weapon;
}
if (isDefined(pistol))
self changeToWeap(pistol);
}
while (self inLastStand()) while (self inLastStand())
wait 0.05; wait 0.05;
} }
@ -459,6 +441,9 @@ watchGrenadeFire()
{ {
self waittill( "grenade_fire", nade, weapname ); self waittill( "grenade_fire", nade, weapname );
if (!isDefined(nade))
continue;
if (weapname == "c4_mp") if (weapname == "c4_mp")
self thread watchC4Thrown(nade); self thread watchC4Thrown(nade);
} }
@ -512,19 +497,8 @@ watchC4Thrown(c4)
/* /*
Bot moves towards the point Bot moves towards the point
*/ */
doBotMovement() doBotMovement_loop(data)
{ {
self endon("disconnect");
self endon("death");
FORWARDAMOUNT = 25;
wasMantling = false;
for (i = 0;; i+=0.05)
{
wait 0.05;
waittillframeend;
move_To = self.bot.moveTo; move_To = self.bot.moveTo;
angles = self GetPlayerAngles(); angles = self GetPlayerAngles();
dir = (0, 0, 0); dir = (0, 0, 0);
@ -552,35 +526,35 @@ doBotMovement()
// climb through windows // climb through windows
if (self isMantling()) if (self isMantling())
{ {
wasMantling = true; data.wasMantling = true;
self crouch(); self crouch();
} }
else if (wasMantling) else if (data.wasMantling)
{ {
wasMantling = false; data.wasMantling = false;
self stand(); self stand();
} }
startPos = self.origin + (0, 0, 50); startPos = self.origin + (0, 0, 50);
startPosForward = startPos + anglesToForward((0, angles[1], 0)) * FORWARDAMOUNT; startPosForward = startPos + anglesToForward((0, angles[1], 0)) * 25;
bt = bulletTrace(startPos, startPosForward, false, self); bt = bulletTrace(startPos, startPosForward, false, self);
if (bt["fraction"] >= 1) if (bt["fraction"] >= 1)
{ {
// check if need to jump // check if need to jump
bt = bulletTrace(startPosForward, startPosForward - (0, 0, 40), false, self); bt = bulletTrace(startPosForward, startPosForward - (0, 0, 40), false, self);
if (bt["fraction"] < 1 && bt["normal"][2] > 0.9 && i > 1.5 && !self isOnLadder()) if (bt["fraction"] < 1 && bt["normal"][2] > 0.9 && data.i > 1.5 && !self isOnLadder())
{ {
i = 0; data.i = 0;
self thread jump(); self thread jump();
} }
} }
// check if need to knife glass // check if need to knife glass
else if (bt["surfacetype"] == "glass") else if (bt["surfacetype"] == "glass")
{ {
if (i > 1.5) if (data.i > 1.5)
{ {
i = 0; data.i = 0;
self thread knife(); self thread knife();
} }
} }
@ -594,6 +568,25 @@ doBotMovement()
// move! // move!
self botMovement(int(dir[0]), int(dir[1])); self botMovement(int(dir[0]), int(dir[1]));
} }
/*
Bot moves towards the point
*/
doBotMovement()
{
self endon("disconnect");
self endon("death");
data = spawnStruct();
data.wasMantling = false;
for (data.i = 0;; data.i+=0.05)
{
wait 0.05;
waittillframeend;
self doBotMovement_loop(data);
}
} }
/* /*
@ -615,6 +608,33 @@ watchHoldBreath()
} }
} }
/*
Throws back frag grenades
*/
grenade_danager_loop()
{
myEye = self getEye();
for (i = level.bots_fragList.count-1; i >= 0; i--)
{
frag = level.bots_fragList.data[i];
if (level.teamBased && frag.team == self.team)
continue;
if (lengthSquared(frag.velocity) > 10000)
continue;
if(DistanceSquared(self.origin, frag.origin) > 20000)
continue;
if (!bulletTracePassed( myEye, frag.origin, false, frag.grenade ))
continue;
self thread frag();
break;
}
}
/* /*
Throws back frag grenades Throws back frag grenades
*/ */
@ -642,46 +662,15 @@ grenade_danager()
if (!getDvarInt("bots_play_nade")) if (!getDvarInt("bots_play_nade"))
continue; continue;
myEye = self getEye(); self grenade_danager_loop();
for (i = level.bots_fragList.count-1; i >= 0; i--)
{
frag = level.bots_fragList.data[i];
if (level.teamBased && frag.team == self.team)
continue;
if (lengthSquared(frag.velocity) > 10000)
continue;
if(DistanceSquared(self.origin, frag.origin) > 20000)
continue;
if (!bulletTracePassed( myEye, frag.origin, false, frag.grenade ))
continue;
self thread frag();
break;
}
} }
} }
/* /*
Bots will update its needed stance according to the nodes on the level. Will also allow the bot to sprint when it can. Bots will update its needed stance according to the nodes on the level. Will also allow the bot to sprint when it can.
*/ */
stance() stance_loop()
{ {
self endon("disconnect");
self endon("death");
for(;;)
{
self waittill_either("finished_static_waypoints", "new_static_waypoint");
self.bot.climbing = false;
if(self.bot.isfrozen || self IsUsingRemote())
continue;
toStance = "stand"; toStance = "stand";
if(self.bot.next_wp != -1) if(self.bot.next_wp != -1)
toStance = level.waypoints[self.bot.next_wp].type; toStance = level.waypoints[self.bot.next_wp].type;
@ -719,22 +708,42 @@ stance()
chance *= 2; chance *= 2;
if(toStance != "stand" || self.bot.isreloading || self.bot.issprinting || self.bot.isfraggingafter || self.bot.issmokingafter) if(toStance != "stand" || self.bot.isreloading || self.bot.issprinting || self.bot.isfraggingafter || self.bot.issmokingafter)
continue; return;
if(randomInt(100) > chance) if(randomInt(100) > chance)
continue; return;
if(isDefined(self.bot.target) && self canFire(curweap) && self isInRange(self.bot.target.dist, curweap)) if(isDefined(self.bot.target) && self canFire(curweap) && self isInRange(self.bot.target.dist, curweap))
continue; return;
if(self.bot.sprintendtime != -1 && time - self.bot.sprintendtime < 2000) if(self.bot.sprintendtime != -1 && time - self.bot.sprintendtime < 2000)
continue; return;
if(!isDefined(self.bot.towards_goal) || DistanceSquared(self.origin, self.bot.towards_goal) < level.bots_minSprintDistance || getConeDot(self.bot.towards_goal, self.origin, self GetPlayerAngles()) < 0.75) if(!isDefined(self.bot.towards_goal) || DistanceSquared(self.origin, self.bot.towards_goal) < level.bots_minSprintDistance || getConeDot(self.bot.towards_goal, self.origin, self GetPlayerAngles()) < 0.75)
continue; return;
self thread sprint(); self thread sprint();
} }
/*
Bots will update its needed stance according to the nodes on the level. Will also allow the bot to sprint when it can.
*/
stance()
{
self endon("disconnect");
self endon("death");
for(;;)
{
self waittill_either("finished_static_waypoints", "new_static_waypoint");
self.bot.climbing = false;
if(self.bot.isfrozen || self IsUsingRemote())
continue;
self stance_loop();
}
} }
/* /*
@ -904,21 +913,8 @@ targetObjUpdateNoTrace(obj)
/* /*
The main target thread, will update the bot's main target. Will auto target enemy players and handle script targets. The main target thread, will update the bot's main target. Will auto target enemy players and handle script targets.
*/ */
target() target_loop()
{ {
self endon("disconnect");
self endon("spawned_player");
for(;;)
{
wait 0.05;
if (!isAlive(self))
return;
if(self maps\mp\_flashgrenades::isFlashbanged())
continue;
myEye = self GetEye(); myEye = self GetEye();
theTime = getTime(); theTime = getTime();
myAngles = self GetPlayerAngles(); myAngles = self GetPlayerAngles();
@ -1098,7 +1094,7 @@ target()
} }
if(hasTarget && isDefined(bestTargets[self.bot.target.entity getEntityNumber()+""])) if(hasTarget && isDefined(bestTargets[self.bot.target.entity getEntityNumber()+""]))
continue; return;
closest = 2147483647; closest = 2147483647;
toBeTarget = undefined; toBeTarget = undefined;
@ -1127,6 +1123,27 @@ target()
self notify("new_enemy"); self notify("new_enemy");
} }
} }
/*
The main target thread, will update the bot's main target. Will auto target enemy players and handle script targets.
*/
target()
{
self endon("disconnect");
self endon("spawned_player");
for(;;)
{
wait 0.05;
if (!isAlive(self))
return;
if(self maps\mp\_flashgrenades::isFlashbanged())
continue;
self target_loop();
}
} }
/* /*
@ -1185,11 +1202,10 @@ watchToLook()
if(self.bot.target.dist <= level.bots_maxKnifeDistance) if(self.bot.target.dist <= level.bots_maxKnifeDistance)
continue; continue;
curweap = self getCurrentWEapon(); if(!self canFire(self getCurrentWEapon()))
if(!self canFire(curweap))
continue; continue;
if(!self isInRange(self.bot.target.dist, curweap)) if(!self isInRange(self.bot.target.dist, self getCurrentWEapon()))
continue; continue;
if (self.bot.is_cur_sniper) if (self.bot.is_cur_sniper)
@ -1201,8 +1217,7 @@ watchToLook()
if (!getDvarInt("bots_play_jumpdrop")) if (!getDvarInt("bots_play_jumpdrop"))
continue; continue;
thetime = getTime(); if(isDefined(self.bot.jump_time) && getTime() - self.bot.jump_time <= 5000)
if(isDefined(self.bot.jump_time) && thetime - self.bot.jump_time <= 5000)
continue; continue;
if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"]) if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"])
@ -1210,7 +1225,7 @@ watchToLook()
if(self getStance() != "stand") if(self getStance() != "stand")
continue; continue;
self.bot.jump_time = thetime; self.bot.jump_time = getTime();
self thread jump(); self thread jump();
} }
else else
@ -1218,7 +1233,7 @@ watchToLook()
if(getConeDot(self.bot.target.last_seen_pos, self.origin, self getPlayerAngles()) < 0.8 || self.bot.target.dist <= level.bots_noADSDistance) if(getConeDot(self.bot.target.last_seen_pos, self.origin, self getPlayerAngles()) < 0.8 || self.bot.target.dist <= level.bots_noADSDistance)
continue; continue;
self.bot.jump_time = thetime; self.bot.jump_time = getTime();
self prone(); self prone();
self notify("kill_goal"); self notify("kill_goal");
wait 2.5; wait 2.5;
@ -1258,21 +1273,8 @@ clear_bot_after_target()
/* /*
This is the bot's main aimming thread. The bot will aim at its targets or a node its going towards. Bots will aim, fire, ads, grenade. This is the bot's main aimming thread. The bot will aim at its targets or a node its going towards. Bots will aim, fire, ads, grenade.
*/ */
aim() aim_loop()
{ {
self endon("disconnect");
self endon("spawned_player"); // for remote killstreaks.
for(;;)
{
wait 0.05;
if (!isAlive(self))
return;
if(!gameFlag( "prematch_done" ) || level.gameEnded || self.bot.isfrozen || self maps\mp\_flashgrenades::isFlashbanged())
continue;
aimspeed = self.pers["bots"]["skill"]["aim_time"]; aimspeed = self.pers["bots"]["skill"]["aim_time"];
if(self IsStunned() || self isArtShocked()) if(self IsStunned() || self isArtShocked())
aimspeed = 1; aimspeed = 1;
@ -1299,7 +1301,7 @@ aim()
if (curweap == "javelin_mp" && getDvarInt("bots_play_fire")) if (curweap == "javelin_mp" && getDvarInt("bots_play_fire"))
self botFire(curweap); self botFire(curweap);
continue; return;
} }
if(isDefined(self.bot.target) && isDefined(self.bot.target.entity)) if(isDefined(self.bot.target) && isDefined(self.bot.target.entity))
@ -1377,7 +1379,7 @@ aim()
self thread bot_lookat(last_pos + (0, 0, self getEyeHeight() + nadeAimOffset), aimspeed); self thread bot_lookat(last_pos + (0, 0, self getEyeHeight() + nadeAimOffset), aimspeed);
else else
self thread bot_lookat(last_pos, aimspeed); self thread bot_lookat(last_pos, aimspeed);
continue; return;
} }
if (trace_time) if (trace_time)
@ -1416,11 +1418,11 @@ aim()
{ {
self clear_bot_after_target(); self clear_bot_after_target();
self thread knife(); self thread knife();
continue; return;
} }
if(!self canFire(curweap) || !self isInRange(dist, curweap)) if(!self canFire(curweap) || !self isInRange(dist, curweap))
continue; return;
canADS = (self canAds(dist, curweap) && conedot > 0.75); canADS = (self canAds(dist, curweap) && conedot > 0.75);
if (canADS) if (canADS)
@ -1439,7 +1441,7 @@ aim()
} }
if(curweap == "iw5_smaw_mp" && entIsVehicle(self.bot.target.entity) && (!IsDefined( self.stingerStage ) || self.stingerStage != 2)) if(curweap == "iw5_smaw_mp" && entIsVehicle(self.bot.target.entity) && (!IsDefined( self.stingerStage ) || self.stingerStage != 2))
continue; return;
if (trace_time > reaction_time) if (trace_time > reaction_time)
{ {
@ -1450,7 +1452,7 @@ aim()
self thread start_bot_after_target(target); self thread start_bot_after_target(target);
} }
continue; return;
} }
} }
} }
@ -1474,7 +1476,7 @@ aim()
self thread bot_lookat(aimpos, aimspeed); self thread bot_lookat(aimpos, aimspeed);
if(!self canFire(curweap) || !self isInRange(dist, curweap)) if(!self canFire(curweap) || !self isInRange(dist, curweap))
continue; return;
canADS = (self canAds(dist, curweap) && conedot > 0.75); canADS = (self canAds(dist, curweap) && conedot > 0.75);
if (canADS) if (canADS)
@ -1495,7 +1497,7 @@ aim()
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.95 || dist < level.bots_maxKnifeDistance) && getDvarInt("bots_play_fire"))
self botFire(curweap); self botFire(curweap);
continue; return;
} }
if (self.bot.next_wp != -1 && isDefined(level.waypoints[self.bot.next_wp].angles) && false) if (self.bot.next_wp != -1 && isDefined(level.waypoints[self.bot.next_wp].angles) && false)
@ -1521,6 +1523,27 @@ aim()
self thread bot_lookat(lookat + (0, 0, self getEyeHeight()), aimspeed); self thread bot_lookat(lookat + (0, 0, self getEyeHeight()), aimspeed);
} }
} }
/*
This is the bot's main aimming thread. The bot will aim at its targets or a node its going towards. Bots will aim, fire, ads, grenade.
*/
aim()
{
self endon("disconnect");
self endon("spawned_player"); // for remote killstreaks.
for(;;)
{
wait 0.05;
if (!isAlive(self))
return;
if(!gameFlag( "prematch_done" ) || level.gameEnded || self.bot.isfrozen || self maps\mp\_flashgrenades::isFlashbanged())
continue;
self aim_loop();
}
} }
/* /*
@ -1648,34 +1671,8 @@ killWalkCauseNoWaypoints()
/* /*
This is the main walking logic for the bot. This is the main walking logic for the bot.
*/ */
walk() walk_loop()
{ {
self endon("disconnect");
self endon("death");
for(;;)
{
wait 0.05;
self botMoveTo(self.origin);
if (!getDVarINt("bots_play_move"))
continue;
if(level.gameEnded || !gameFlag( "prematch_done" ) || self.bot.isfrozen || self.bot.stop_move)
continue;
if (self IsUsingRemote())
continue;
if(self maps\mp\_flashgrenades::isFlashbanged())
{
self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1;
self botMoveTo(self.origin + self GetVelocity()*500);
continue;
}
hasTarget = ((isDefined(self.bot.target) && isDefined(self.bot.target.entity)) || isDefined(self.bot.jav_loc)); hasTarget = ((isDefined(self.bot.target) && isDefined(self.bot.target.entity)) || isDefined(self.bot.jav_loc));
if(hasTarget) if(hasTarget)
{ {
@ -1683,17 +1680,17 @@ walk()
if(isDefined(self.bot.jav_loc) || entIsVehicle(self.bot.target.entity) || self.bot.isfraggingafter || self.bot.issmokingafter) if(isDefined(self.bot.jav_loc) || entIsVehicle(self.bot.target.entity) || self.bot.isfraggingafter || self.bot.issmokingafter)
{ {
continue; return;
} }
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" || (self.bot.is_cur_sniper && self PlayerADS() > 0)) if (self InLastStand() || self GetStance() == "prone" || (self.bot.is_cur_sniper && self PlayerADS() > 0))
continue; return;
if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"]) if(self.bot.target.rand <= self.pers["bots"]["behavior"]["strafe"])
self strafe(self.bot.target.entity); self strafe(self.bot.target.entity);
continue; return;
} }
} }
@ -1759,6 +1756,40 @@ walk()
self.bot.next_wp = -1; self.bot.next_wp = -1;
self.bot.second_next_wp = -1; self.bot.second_next_wp = -1;
} }
/*
This is the main walking logic for the bot.
*/
walk()
{
self endon("disconnect");
self endon("death");
for(;;)
{
wait 0.05;
self botMoveTo(self.origin);
if (!getDVarINt("bots_play_move"))
continue;
if(level.gameEnded || !gameFlag( "prematch_done" ) || self.bot.isfrozen || self.bot.stop_move)
continue;
if (self IsUsingRemote())
continue;
if(self maps\mp\_flashgrenades::isFlashbanged())
{
self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1;
self botMoveTo(self.origin + self GetVelocity()*500);
continue;
}
self walk_loop();
}
} }
/* /*
@ -1889,12 +1920,12 @@ doWalk(goal, dist, isScriptGoal)
self endon("kill_goal"); self endon("kill_goal");
self endon("goal_internal");//so that the watchOnGoal notify can happen same frame, not a frame later self endon("goal_internal");//so that the watchOnGoal notify can happen same frame, not a frame later
distsq = dist*dist; dist *= dist;
if (isScriptGoal) if (isScriptGoal)
self thread doWalkScriptNotify(); self thread doWalkScriptNotify();
self thread killWalkOnEvents(); self thread killWalkOnEvents();
self thread watchOnGoal(goal, distsq); self thread watchOnGoal(goal, dist);
current = self initAStar(goal); current = self initAStar(goal);
// skip waypoints we already completed to prevent rubber banding // skip waypoints we already completed to prevent rubber banding
@ -1904,9 +1935,7 @@ doWalk(goal, dist, isScriptGoal)
if (current >= 0) if (current >= 0)
{ {
// check if a waypoint is closer than the goal // check if a waypoint is closer than the goal
wpOrg = level.waypoints[self.bot.astar[current]].origin; if (DistanceSquared(self.origin, level.waypoints[self.bot.astar[current]].origin) < DistanceSquared(self.origin, goal) || DistanceSquared(level.waypoints[self.bot.astar[current]].origin, PlayerPhysicsTrace(self.origin + (0,0,32), level.waypoints[self.bot.astar[current]].origin, false, self)) > 1.0)
ppt = PlayerPhysicsTrace(self.origin + (0,0,32), wpOrg, false, self);
if (DistanceSquared(self.origin, wpOrg) < DistanceSquared(self.origin, goal) || DistanceSquared(wpOrg, ppt) > 1.0)
{ {
while(current >= 0) while(current >= 0)
{ {
@ -1930,7 +1959,7 @@ doWalk(goal, dist, isScriptGoal)
self.bot.second_next_wp = -1; self.bot.second_next_wp = -1;
self notify("finished_static_waypoints"); self notify("finished_static_waypoints");
if(DistanceSquared(self.origin, goal) > distsq) if(DistanceSquared(self.origin, goal) > dist)
{ {
self.bot.last_next_wp = -1; self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1; self.bot.last_second_next_wp = -1;
@ -1940,7 +1969,7 @@ doWalk(goal, dist, isScriptGoal)
self notify("finished_goal"); self notify("finished_goal");
wait 1; wait 1;
if(DistanceSquared(self.origin, goal) > distsq) if(DistanceSquared(self.origin, goal) > dist)
self notify("bad_path_internal"); self notify("bad_path_internal");
} }
@ -1976,6 +2005,7 @@ movetowards(goal)
self botMoveTo(randomDir); self botMoveTo(randomDir);
wait stucks; wait stucks;
self stand();
} }
lastOri = self.origin; lastOri = self.origin;

File diff suppressed because it is too large Load Diff