mirror of
https://github.com/ineedbots/t4_bot_warfare.git
synced 2025-04-22 07:55:43 +00:00
greatly reduce var usage
This commit is contained in:
parent
bb74baec06
commit
30eae3d3d9
@ -365,12 +365,8 @@ add_bot()
|
|||||||
/*
|
/*
|
||||||
A server thread for monitoring all bot's difficulty levels for custom server settings.
|
A server thread for monitoring all bot's difficulty levels for custom server settings.
|
||||||
*/
|
*/
|
||||||
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");
|
||||||
@ -441,16 +437,25 @@ diffBots()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
A server thread for monitoring all bot's difficulty levels for custom server settings.
|
||||||
|
*/
|
||||||
|
diffBots()
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
wait 1.5;
|
||||||
|
|
||||||
|
diffBots_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A server thread for monitoring all bot's teams for custom server settings.
|
A server thread for monitoring all bot's teams for custom server settings.
|
||||||
*/
|
*/
|
||||||
teamBots()
|
teamBots_loop()
|
||||||
{
|
{
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
wait 1.5;
|
|
||||||
teamAmount = getDvarInt("bots_team_amount");
|
teamAmount = getDvarInt("bots_team_amount");
|
||||||
toTeam = getDvar("bots_team");
|
toTeam = getDvar("bots_team");
|
||||||
|
|
||||||
@ -570,21 +575,25 @@ teamBots()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
A server thread for monitoring all bot's teams for custom server settings.
|
||||||
|
*/
|
||||||
|
teamBots()
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
wait 1.5;
|
||||||
|
|
||||||
|
teamBots_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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 in game. Will add and kick bots according to server settings.
|
||||||
*/
|
*/
|
||||||
addBots()
|
addBots_loop()
|
||||||
{
|
{
|
||||||
level endon("game_ended");
|
|
||||||
|
|
||||||
bot_wait_for_host();
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
wait 1.5;
|
|
||||||
|
|
||||||
botsToAdd = GetDvarInt("bots_manage_add");
|
botsToAdd = GetDvarInt("bots_manage_add");
|
||||||
|
|
||||||
if(botsToAdd > 0)
|
if(botsToAdd > 0)
|
||||||
@ -685,6 +694,22 @@ addBots()
|
|||||||
tempBot RemoveTestClient();
|
tempBot RemoveTestClient();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -207,19 +207,8 @@ onPlayerSpawned()
|
|||||||
/*
|
/*
|
||||||
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);
|
||||||
@ -247,35 +236,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,6 +278,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; true; data.i += 0.05)
|
||||||
|
{
|
||||||
|
wait 0.05;
|
||||||
|
|
||||||
|
waittillframeend;
|
||||||
|
self doBotMovement_loop(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -374,8 +382,7 @@ watchC4Thrown(c4)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
weap = self getCurrentWeapon();
|
if ( self getCurrentWeapon() != "satchel_charge_mp" )
|
||||||
if ( weap != "satchel_charge_mp" )
|
|
||||||
self notify( "alt_detonate" );
|
self notify( "alt_detonate" );
|
||||||
else
|
else
|
||||||
self thread pressFire();
|
self thread pressFire();
|
||||||
@ -438,12 +445,7 @@ watchHoldBreath()
|
|||||||
/*
|
/*
|
||||||
When the bot enters laststand, we fix the weapons
|
When the bot enters laststand, we fix the weapons
|
||||||
*/
|
*/
|
||||||
onLastStand()
|
onLastStand_loop()
|
||||||
{
|
|
||||||
self endon("disconnect");
|
|
||||||
self endon("death");
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
while (!self inLastStand())
|
while (!self inLastStand())
|
||||||
wait 0.05;
|
wait 0.05;
|
||||||
@ -470,6 +472,19 @@ onLastStand()
|
|||||||
if (isDefined(self.previousPrimary) && self.previousPrimary != "none")
|
if (isDefined(self.previousPrimary) && self.previousPrimary != "none")
|
||||||
self changeToWeap(self.previousPrimary);
|
self changeToWeap(self.previousPrimary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
When the bot enters laststand, we fix the weapons
|
||||||
|
*/
|
||||||
|
onLastStand()
|
||||||
|
{
|
||||||
|
self endon("disconnect");
|
||||||
|
self endon("death");
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
self onLastStand_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -524,14 +539,8 @@ sprint_watch()
|
|||||||
/*
|
/*
|
||||||
Update's the bot if it is reloading.
|
Update's the bot if it is reloading.
|
||||||
*/
|
*/
|
||||||
reload_watch()
|
reload_watch_loop()
|
||||||
{
|
{
|
||||||
self endon("disconnect");
|
|
||||||
self endon("death");
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
self waittill("reload_start");
|
|
||||||
self.bot.isreloading = true;
|
self.bot.isreloading = true;
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
@ -551,24 +560,32 @@ reload_watch()
|
|||||||
}
|
}
|
||||||
self.bot.isreloading = false;
|
self.bot.isreloading = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bots will update its needed stance according to the nodes on the level. Will also allow the bot to sprint when it can.
|
Update's the bot if it is reloading.
|
||||||
*/
|
*/
|
||||||
stance()
|
reload_watch()
|
||||||
{
|
{
|
||||||
self endon("disconnect");
|
self endon("disconnect");
|
||||||
self endon("death");
|
self endon("death");
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
self waittill_either("finished_static_waypoints", "new_static_waypoint");
|
self waittill("reload_start");
|
||||||
|
|
||||||
|
self reload_watch_loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bots will update its needed stance according to the nodes on the level. Will also allow the bot to sprint when it can.
|
||||||
|
*/
|
||||||
|
stance_loop()
|
||||||
|
{
|
||||||
self.bot.climbing = false;
|
self.bot.climbing = false;
|
||||||
|
|
||||||
if(self.bot.isfrozen)
|
if(self.bot.isfrozen)
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
toStance = "stand";
|
toStance = "stand";
|
||||||
if(self.bot.next_wp != -1)
|
if(self.bot.next_wp != -1)
|
||||||
@ -607,22 +624,37 @@ 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 stance_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -849,18 +881,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("death");
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
wait 0.05;
|
|
||||||
|
|
||||||
if(self isFlared())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
myEye = self GetEyePos();
|
myEye = self GetEyePos();
|
||||||
theTime = getTime();
|
theTime = getTime();
|
||||||
myAngles = self GetPlayerAngles();
|
myAngles = self GetPlayerAngles();
|
||||||
@ -1016,7 +1038,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;
|
||||||
@ -1045,6 +1067,24 @@ 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("death");
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
wait 0.05;
|
||||||
|
|
||||||
|
if(self isFlared())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
self target_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1103,11 +1143,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)
|
||||||
@ -1119,8 +1158,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"])
|
||||||
@ -1128,7 +1166,7 @@ watchToLook()
|
|||||||
if(self getStance() != "stand")
|
if(self getStance() != "stand")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
self.bot.jump_time = thetime;
|
self.bot.jump_time = getTime();
|
||||||
self jump();
|
self jump();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1136,7 +1174,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;
|
||||||
@ -1145,7 +1183,6 @@ watchToLook()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Assigns the bot's after target (bot will keep firing at a target after no sight or death)
|
Assigns the bot's after target (bot will keep firing at a target after no sight or death)
|
||||||
*/
|
*/
|
||||||
@ -1177,18 +1214,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("death");
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
wait 0.05;
|
|
||||||
|
|
||||||
if(level.inPrematchPeriod || level.gameEnded || self.bot.isfrozen || self isFlared())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
aimspeed = self.pers["bots"]["skill"]["aim_time"];
|
aimspeed = self.pers["bots"]["skill"]["aim_time"];
|
||||||
|
|
||||||
if(self IsGased() || self isArtShocked())
|
if(self IsGased() || self isArtShocked())
|
||||||
@ -1278,7 +1305,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);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_time)
|
if (trace_time)
|
||||||
@ -1286,12 +1313,12 @@ aim()
|
|||||||
if(isplay)
|
if(isplay)
|
||||||
{
|
{
|
||||||
if (!target IsPlayerModelOK())
|
if (!target IsPlayerModelOK())
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
aimpos = target getTagOrigin( bone );
|
aimpos = target getTagOrigin( bone );
|
||||||
|
|
||||||
if (!isDefined(aimpos))
|
if (!isDefined(aimpos))
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
aimpos += offset;
|
aimpos += offset;
|
||||||
aimpos += aimoffset;
|
aimpos += aimoffset;
|
||||||
@ -1320,13 +1347,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;
|
||||||
|
|
||||||
//c4 logic here, but doesnt work anyway
|
|
||||||
|
|
||||||
canADS = (self canAds(dist, curweap) && conedot > 0.75);
|
canADS = (self canAds(dist, curweap) && conedot > 0.75);
|
||||||
if (canADS)
|
if (canADS)
|
||||||
@ -1353,7 +1378,7 @@ aim()
|
|||||||
self thread start_bot_after_target(target);
|
self thread start_bot_after_target(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1375,7 +1400,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)
|
||||||
@ -1396,7 +1421,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();
|
self botFire();
|
||||||
|
|
||||||
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)
|
||||||
@ -1422,6 +1447,24 @@ 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("death");
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
wait 0.05;
|
||||||
|
|
||||||
|
if(level.inPrematchPeriod || level.gameEnded || self.bot.isfrozen || self isFlared())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
self aim_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1529,52 +1572,29 @@ 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.inPrematchPeriod || level.gameEnded || self.bot.isfrozen || self.bot.stop_move)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(self isFlared())
|
|
||||||
{
|
|
||||||
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);
|
hasTarget = isDefined(self.bot.target) && isDefined(self.bot.target.entity);
|
||||||
if(hasTarget)
|
if(hasTarget)
|
||||||
{
|
{
|
||||||
curweap = self getCurrentWeapon();
|
curweap = self getCurrentWeapon();
|
||||||
|
|
||||||
if ((isPlayer(self.bot.target.entity) && self.bot.target.entity isInVehicle()) || self.bot.target.entity.classname == "script_vehicle")
|
if ((isPlayer(self.bot.target.entity) && self.bot.target.entity isInVehicle()) || self.bot.target.entity.classname == "script_vehicle")
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
if(self.bot.isfraggingafter || self.bot.issmokingafter)
|
if(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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1640,6 +1660,37 @@ 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.inPrematchPeriod || level.gameEnded || self.bot.isfrozen || self.bot.stop_move)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(self isFlared())
|
||||||
|
{
|
||||||
|
self.bot.last_next_wp = -1;
|
||||||
|
self.bot.last_second_next_wp = -1;
|
||||||
|
self botMoveTo(self.origin + self GetVelocity()*500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
self walk_loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1770,12 +1821,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
|
||||||
@ -1785,9 +1836,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)
|
||||||
{
|
{
|
||||||
@ -1811,7 +1860,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;
|
||||||
@ -1821,7 +1870,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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user