Bots use tank and uav drone

This commit is contained in:
ineedbots 2021-06-02 20:01:20 -06:00
parent 97dd49aa95
commit 1edaa8f11a
3 changed files with 209 additions and 34 deletions

View File

@ -149,6 +149,11 @@ init()
level.bots_fullautoguns["mg36"] = true; level.bots_fullautoguns["mg36"] = true;
level.bots_fullautoguns["ak74u"] = true; level.bots_fullautoguns["ak74u"] = true;
level.bots_fullautoguns["25mm"] = true;
level.bots_fullautoguns["40mm"] = true;
level.bots_fullautoguns["105mm"] = true;
level.bots_fullautoguns["remote"] = true;
level thread fixGamemodes(); level thread fixGamemodes();

View File

@ -113,6 +113,7 @@ resetBotVars()
self.bot.towards_goal = undefined; self.bot.towards_goal = undefined;
self.bot.astar = []; self.bot.astar = [];
self.bot.moveTo = self.origin; self.bot.moveTo = self.origin;
self.bot.moveOrigin = self.origin;
self.bot.stop_move = false; self.bot.stop_move = false;
self.bot.greedy_path = false; self.bot.greedy_path = false;
self.bot.climbing = false; self.bot.climbing = false;
@ -227,11 +228,6 @@ onWeaponChange()
self.bot.cur_weap_dist_multi = SetWeaponDistMulti(newWeapon); self.bot.cur_weap_dist_multi = SetWeaponDistMulti(newWeapon);
self.bot.is_cur_sniper = IsWeapSniper(newWeapon); self.bot.is_cur_sniper = IsWeapSniper(newWeapon);
self.bot.is_cur_akimbo = isSubStr(newWeapon, "_akimbo"); self.bot.is_cur_akimbo = isSubStr(newWeapon, "_akimbo");
if (newWeapon == "none")
continue;
self changeToWeap(newWeapon);
} }
} }
@ -332,7 +328,109 @@ watchUsingRemote()
self watchUsingMortar(); self watchUsingMortar();
} }
if (IsDefined( self.using_remote_tank ) && self.using_remote_tank)
{
self watchUsingTank();
self.remoteTank = undefined;
}
if(isDefined(self.remoteUAV))
{
self watchUsingUav();
}
self.bot.targets = []; self.bot.targets = [];
self notify("kill_goal");
}
}
/*
Uses tank
*/
watchUsingTank()
{
tankKeys = getArrayKeys(level.ugvs);
tank = undefined;
for (i = tankKeys.size - 1; i >= 0; i--)
{
tempTank = level.ugvs[tankKeys[i]];
if (!isDefined(tempTank))
continue;
if (!isDefined(tempTank.owner))
continue;
if (tempTank.owner == self)
{
tank = tempTank;
break;
}
}
tankKeys = undefined;
if (!isDefined(tank))
return;
self.remoteTank = tank;
self thread useTankRocket(tank);
tank endon("death");
while (IsDefined( self.using_remote_tank ) && self.using_remote_tank)
{
if (self getCurrentWeapon() != "killstreak_remote_tank_remote_mp")
{
self changeToWeap("killstreak_remote_tank_remote_mp");
}
if (isDefined(self.bot.target))
self thread pressFire();
wait 0.05;
}
}
/*
useTankRocket
*/
useTankRocket(tank)
{
tank endon("death");
self endon("disconnect");
self endon("spawned_player");
while (IsDefined( self.using_remote_tank ) && self.using_remote_tank)
{
wait 3.5;
if (isDefined(self.bot.target))
self thread pressfrag();
}
}
/*
Uses uav
*/
watchUsingUav()
{
self.remoteUAV endon("end_remote");
while (isDefined(self.remoteUAV))
{
if (self getCurrentWeapon() != "uav_remote_mp")
{
self changeToWeap("uav_remote_mp");
}
if (isDefined( self.lockedTarget ))
self notify("remoteUAV_tag");
wait 0.05;
} }
} }
@ -515,17 +613,25 @@ watchC4Thrown(c4)
*/ */
doBotMovement_loop(data) doBotMovement_loop(data)
{ {
if (isDefined(self.remoteUAV))
self.bot.moveOrigin = self.remoteUAV.origin - (0, 0, 50);
else if (isDefined(self.remoteTank))
self.bot.moveOrigin = self.remoteTank.origin;
else
self.bot.moveOrigin = self.origin;
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);
if (DistanceSquared(self.origin, move_To) >= 49) if (DistanceSquared(self.bot.moveOrigin, move_To) >= 49)
{ {
cosa = cos(0-angles[1]); cosa = cos(0-angles[1]);
sina = sin(0-angles[1]); sina = sin(0-angles[1]);
// get the direction // get the direction
dir = move_To - self.origin; dir = move_To - self.bot.moveOrigin;
// rotate our direction according to our angles // rotate our direction according to our angles
dir = (dir[0] * cosa - dir[1] * sina, dir = (dir[0] * cosa - dir[1] * sina,
@ -583,6 +689,17 @@ doBotMovement_loop(data)
// move! // move!
self botMovement(int(dir[0]), int(dir[1])); self botMovement(int(dir[0]), int(dir[1]));
if (isDefined(self.remoteUAV))
{
if (abs(move_To[2] - self.bot.moveOrigin[2]) > 12)
{
if (move_To[2] > self.bot.moveOrigin[2])
self thread gostand();
else
self thread sprint();
}
}
} }
/* /*
@ -591,7 +708,7 @@ doBotMovement_loop(data)
doBotMovement() doBotMovement()
{ {
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("spawned_player");
data = spawnStruct(); data = spawnStruct();
data.wasMantling = false; data.wasMantling = false;
@ -600,7 +717,9 @@ doBotMovement()
{ {
wait 0.05; wait 0.05;
waittillframeend; if (!isAlive(self))
return;
self doBotMovement_loop(data); self doBotMovement_loop(data);
} }
} }
@ -932,6 +1051,9 @@ targetObjUpdateNoTrace(obj)
target_loop() target_loop()
{ {
myEye = self GetEye(); myEye = self GetEye();
if (isDefined(self.remoteUAV))
myEye = self.remoteUAV getTagOrigin("tag_origin");
theTime = getTime(); theTime = getTime();
myAngles = self GetPlayerAngles(); myAngles = self GetPlayerAngles();
myFov = self.pers["bots"]["skill"]["fov"]; myFov = self.pers["bots"]["skill"]["fov"];
@ -1020,7 +1142,11 @@ target_loop()
key = player getEntityNumber()+""; key = player getEntityNumber()+"";
obj = self.bot.targets[key]; obj = self.bot.targets[key];
daDist = distanceSquared(self.origin, player.origin); daDist = distanceSquared(self.origin, player.origin);
if (usingRemote)
daDist = 0;
isObjDef = isDefined(obj); isObjDef = isDefined(obj);
if((level.teamBased && self.team == player.team) || player.sessionstate != "playing" || !isReallyAlive(player)) if((level.teamBased && self.team == player.team) || player.sessionstate != "playing" || !isReallyAlive(player))
{ {
@ -1065,6 +1191,9 @@ target_loop()
canTargetPlayer = true; canTargetPlayer = true;
} }
if (isDefined(self.remoteUAV) && isDefined(player.UAVRemoteMarkedBy))
canTargetPlayer = false;
if(canTargetPlayer) if(canTargetPlayer)
{ {
@ -1297,7 +1426,11 @@ aim_loop()
usingRemote = self IsUsingRemote(); usingRemote = self IsUsingRemote();
curweap = self getCurrentWeapon(); curweap = self getCurrentWeapon();
eyePos = self getEye(); eyePos = self getEye();
if (isDefined(self.remoteUAV))
eyePos = self.remoteUAV getTagOrigin("tag_origin");
angles = self GetPlayerAngles(); angles = self GetPlayerAngles();
adsAmount = self PlayerADS(); adsAmount = self PlayerADS();
adsAimSpeedFact = self.pers["bots"]["skill"]["ads_aimspeed_multi"]; adsAimSpeedFact = self.pers["bots"]["skill"]["ads_aimspeed_multi"];
@ -1526,7 +1659,7 @@ aim_loop()
{ {
self thread bot_lookat(self.bot.script_aimpos, aimspeed); self thread bot_lookat(self.bot.script_aimpos, aimspeed);
} }
else if (!usingRemote) else if (!usingRemote || isDefined(self.remoteUAV) || isDefined(self.remoteTank))
{ {
lookat = undefined; lookat = undefined;
@ -1719,7 +1852,7 @@ walk_loop()
stepDist = 64; stepDist = 64;
forward = AnglesToForward(self GetPlayerAngles())*stepDist; forward = AnglesToForward(self GetPlayerAngles())*stepDist;
forward = (forward[0], forward[1], 0); forward = (forward[0], forward[1], 0);
myOrg = self.origin + (0, 0, 32); myOrg = self.bot.moveOrigin + (0, 0, 32);
goal = playerPhysicsTrace(myOrg, myOrg + forward, false, self); goal = playerPhysicsTrace(myOrg, myOrg + forward, false, self);
goal = PhysicsTrace(goal + (0, 0, 50), goal + (0, 0, -40), false, self); goal = PhysicsTrace(goal + (0, 0, 50), goal + (0, 0, -40), false, self);
@ -1779,28 +1912,28 @@ walk_loop()
walk() walk()
{ {
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("spawned_player");
for(;;) for(;;)
{ {
wait 0.05; wait 0.05;
if (!isAlive(self))
return;
self botMoveTo(self.origin); self botMoveTo(self.bot.moveOrigin);
if (!getDVarINt("bots_play_move")) if (!getDVarINt("bots_play_move"))
continue; continue;
if(level.gameEnded || !gameFlag( "prematch_done" ) || self.bot.isfrozen || self.bot.stop_move) if(level.gameEnded || !gameFlag( "prematch_done" ) || self.bot.isfrozen || self.bot.stop_move)
continue; continue;
if (self IsUsingRemote())
continue;
if(self maps\mp\_flashgrenades::isFlashbanged()) if(self maps\mp\_flashgrenades::isFlashbanged())
{ {
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;
self botMoveTo(self.origin + self GetVelocity()*500); self botMoveTo(self.bot.moveOrigin + self GetVelocity()*500);
continue; continue;
} }
@ -1816,11 +1949,11 @@ strafe(target)
self endon("kill_goal"); self endon("kill_goal");
self thread killWalkOnEvents(); self thread killWalkOnEvents();
angles = VectorToAngles(vectorNormalize(target.origin - self.origin)); angles = VectorToAngles(vectorNormalize(target.origin - self.bot.moveOrigin));
anglesLeft = (0, angles[1]+90, 0); anglesLeft = (0, angles[1]+90, 0);
anglesRight = (0, angles[1]-90, 0); anglesRight = (0, angles[1]-90, 0);
myOrg = self.origin + (0, 0, 16); myOrg = self.bot.moveOrigin + (0, 0, 16);
left = myOrg + anglestoforward(anglesLeft)*500; left = myOrg + anglestoforward(anglesLeft)*500;
right = myOrg + anglestoforward(anglesRight)*500; right = myOrg + anglestoforward(anglesRight)*500;
@ -1844,10 +1977,10 @@ strafe(target)
watchOnGoal(goal, dis) watchOnGoal(goal, dis)
{ {
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("spawned_player");
self endon("kill_goal"); self endon("kill_goal");
while(DistanceSquared(self.origin, goal) > dis) while(DistanceSquared(self.bot.moveOrigin, goal) > dis)
wait 0.05; wait 0.05;
self notify("goal_internal"); self notify("goal_internal");
@ -1858,7 +1991,7 @@ watchOnGoal(goal, dis)
*/ */
cleanUpAStar(team) cleanUpAStar(team)
{ {
self waittill_any("death", "disconnect", "kill_goal"); self waittill_any("spawned_player", "disconnect", "kill_goal");
for(i = self.bot.astar.size - 1; i >= 0; i--) for(i = self.bot.astar.size - 1; i >= 0; i--)
RemoveWaypointUsage(self.bot.astar[i], team); RemoveWaypointUsage(self.bot.astar[i], team);
@ -1873,7 +2006,7 @@ initAStar(goal)
if(level.teamBased) if(level.teamBased)
team = self.team; team = self.team;
self.bot.astar = AStarSearch(self.origin, goal, team, self.bot.greedy_path); self.bot.astar = AStarSearch(self.bot.moveOrigin, goal, team, self.bot.greedy_path);
if(isDefined(team)) if(isDefined(team))
self thread cleanUpAStar(team); self thread cleanUpAStar(team);
@ -1905,7 +2038,7 @@ killWalkOnEvents()
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("death");
ret = self waittill_any_return("flash_rumble_loop", "new_enemy", "new_goal_internal", "goal_internal", "bad_path_internal"); self waittill_any("flash_rumble_loop", "new_enemy", "new_goal_internal", "goal_internal", "bad_path_internal");
waittillframeend; waittillframeend;
@ -1951,7 +2084,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
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) if (DistanceSquared(self.bot.moveOrigin, level.waypoints[self.bot.astar[current]].origin) < DistanceSquared(self.bot.moveOrigin, goal) || DistanceSquared(level.waypoints[self.bot.astar[current]].origin, PlayerPhysicsTrace(self.bot.moveOrigin + (0,0,32), level.waypoints[self.bot.astar[current]].origin, false, self)) > 1.0)
{ {
while(current >= 0) while(current >= 0)
{ {
@ -1975,7 +2108,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) > dist) if(DistanceSquared(self.bot.moveOrigin, 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;
@ -1985,7 +2118,7 @@ doWalk(goal, dist, isScriptGoal)
self notify("finished_goal"); self notify("finished_goal");
wait 1; wait 1;
if(DistanceSquared(self.origin, goal) > dist) if(DistanceSquared(self.bot.moveOrigin, goal) > dist)
self notify("bad_path_internal"); self notify("bad_path_internal");
} }
@ -1999,18 +2132,18 @@ movetowards(goal)
self.bot.towards_goal = goal; self.bot.towards_goal = goal;
lastOri = self.origin; lastOri = self.bot.moveOrigin;
stucks = 0; stucks = 0;
timeslow = 0; timeslow = 0;
time = 0; time = 0;
while(distanceSquared(self.origin, goal) > level.bots_goalDistance) while(distanceSquared(self.bot.moveOrigin, goal) > level.bots_goalDistance)
{ {
self botMoveTo(goal); self botMoveTo(goal);
if(time > 3500) if(time > 3500)
{ {
time = 0; time = 0;
if(distanceSquared(self.origin, lastOri) < 128) if(distanceSquared(self.bot.moveOrigin, lastOri) < 128)
{ {
self thread knife(); self thread knife();
wait 0.5; wait 0.5;
@ -2024,7 +2157,7 @@ movetowards(goal)
self stand(); self stand();
} }
lastOri = self.origin; lastOri = self.bot.moveOrigin;
} }
else if(timeslow > 0 && (timeslow % 1000) == 0) else if(timeslow > 0 && (timeslow % 1000) == 0)
{ {
@ -2032,7 +2165,7 @@ movetowards(goal)
} }
else if(time > 2500) else if(time > 2500)
{ {
if(distanceSquared(self.origin, lastOri) < 128) if(distanceSquared(self.bot.moveOrigin, lastOri) < 128)
self crouch(); self crouch();
} }
@ -2074,7 +2207,7 @@ getRandomLargestStafe(dist)
{ {
//find a better algo? //find a better algo?
traces = NewHeap(::HeapTraceFraction); traces = NewHeap(::HeapTraceFraction);
myOrg = self.origin + (0, 0, 16); myOrg = self.bot.moveOrigin + (0, 0, 16);
traces HeapInsert(bulletTrace(myOrg, myOrg + (-100*dist, 0, 0), false, self)); traces HeapInsert(bulletTrace(myOrg, myOrg + (-100*dist, 0, 0), false, self));
traces HeapInsert(bulletTrace(myOrg, myOrg + (100*dist, 0, 0), false, self)); traces HeapInsert(bulletTrace(myOrg, myOrg + (100*dist, 0, 0), false, self));
@ -2126,6 +2259,36 @@ sprint()
self botAction("-sprint"); self botAction("-sprint");
} }
/*
Press gostand button for a frame
*/
gostand()
{
self endon("death");
self endon("disconnect");
self notify("bot_gostand");
self endon("bot_gostand");
self botAction("+gostand");
wait 0.05;
self botAction("-gostand");
}
/*
Press frag button for a frame
*/
pressfrag()
{
self endon("death");
self endon("disconnect");
self notify("bot_frag");
self endon("bot_frag");
self botAction("+frag");
wait 0.05;
self botAction("-frag");
}
/* /*
Bot will knife. Bot will knife.
*/ */
@ -2411,6 +2574,9 @@ bot_lookat(pos, time, vel)
steps = 1; steps = 1;
myEye = self GetEye(); // get our eye pos myEye = self GetEye(); // get our eye pos
if (isDefined(self.remoteUAV))
myEye = self.remoteUAV getTagOrigin("tag_origin"); // fix for iw5 kekware
myEye += (self getVelocity() * 0.05) * (steps - 1); // account for our velocity myEye += (self getVelocity() * 0.05) * (steps - 1); // account for our velocity
pos += (vel * 0.05) * (steps - 1); // add the velocity vector pos += (vel * 0.05) * (steps - 1); // add the velocity vector

View File

@ -1541,6 +1541,7 @@ onDeath()
self waittill("death"); self waittill("death");
self.wantSafeSpawn = true; self.wantSafeSpawn = true;
self ClearScriptGoal();
} }
} }
@ -4230,6 +4231,9 @@ bot_target_vehicle_loop()
if (target.model != "vehicle_ugv_talon_mp" && target.model != "vehicle_remote_uav") if (target.model != "vehicle_ugv_talon_mp" && target.model != "vehicle_remote_uav")
{ {
if (isDefined(self.remoteTank))
return;
if(!isDefined(rocketAmmo) && self BotGetRandom() < 90) if(!isDefined(rocketAmmo) && self BotGetRandom() < 90)
return; return;
} }
@ -4258,7 +4262,7 @@ bot_target_vehicle()
if(self HasScriptEnemy()) if(self HasScriptEnemy())
continue; continue;
if (self IsUsingRemote()) if (self IsUsingRemote() && !isDefined(self.remoteTank))
continue; continue;
self bot_target_vehicle_loop(); self bot_target_vehicle_loop();