no more setspawnweapon

This commit is contained in:
INeedGames 2020-11-10 01:07:28 -06:00
parent ebd86b9e89
commit b6826c15d5

View File

@ -128,9 +128,6 @@ resetBotVars()
self.bot.rand = randomInt(100); self.bot.rand = randomInt(100);
self.bot.isswitching = false;
self.bot.switch_to_after_none = undefined;
self botStop(); self botStop();
} }
@ -166,72 +163,22 @@ onWeaponChange()
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("death");
self.bot.isswitching = false; weap = self GetCurrentWeapon();
self.bot.is_cur_full_auto = WeaponIsFullAuto(weap);
if (weap != "none")
self botWeapon(weap);
self.bot.is_cur_full_auto = WeaponIsFullAuto(self GetCurrentWeapon());
for(;;) for(;;)
{ {
self waittill( "weapon_change", newWeapon ); self waittill( "weapon_change", newWeapon );
self.bot.is_cur_full_auto = WeaponIsFullAuto(newWeapon); self.bot.is_cur_full_auto = WeaponIsFullAuto(newWeapon);
if(level.gameEnded || !gameFlag( "prematch_done" )) if (newWeapon == "none")
continue; continue;
switch (newWeapon) self botWeapon(self GetCurrentWeapon());
{
case "none":
self thread doNoneSwitch();
break;
default:
self thread doSwitch(newWeapon);
break;
} }
}
}
/*
When the bot switches to a none weapon, we fix it
*/
doNoneSwitch()
{
self endon("disconnect");
self endon("death");
self endon("weapon_change");
self.bot.isswitching = false;
while (self.disabledWeapon)
wait 0.05;
weap = self.lastDroppableWeapon;
if (isDefined(self.bot.switch_to_after_none))
{
weap = self.bot.switch_to_after_none;
self.bot.switch_to_after_none = undefined;
}
self SetSpawnWeapon(weap);
}
/*
When the bot switches to a weapon, we play the active animation, and shoot delay
*/
doSwitch(newWeapon)
{
self endon("disconnect");
self endon("death");
self endon("weapon_change");
waittillframeend;
if (self.lastDroppableWeapon != newWeapon)
return;
self.bot.isswitching = true;
wait 1; // fast pullout?
self.bot.isswitching = false;
} }
/* /*
@ -287,10 +234,6 @@ onLastStand()
if (!self inFinalStand() && !self IsUsingRemote()) if (!self inFinalStand() && !self IsUsingRemote())
{ {
while (self.disabledWeapon)
wait 0.05;
waittillframeend;
pistol = undefined; pistol = undefined;
weaponsList = self GetWeaponsListPrimaries(); weaponsList = self GetWeaponsListPrimaries();
foreach ( weapon in weaponsList ) foreach ( weapon in weaponsList )
@ -300,7 +243,7 @@ onLastStand()
} }
if (isDefined(pistol)) if (isDefined(pistol))
self setSpawnWeapon(pistol); self botWeapon(pistol);
} }
while (self inLastStand()) while (self inLastStand())
@ -332,7 +275,7 @@ watchUsingRemote()
if (isReallyAlive(self)) if (isReallyAlive(self))
{ {
self setSpawnWeapon(self getLastWeapon()); self botWeapon(self getLastWeapon());
self.bot.targets = []; self.bot.targets = [];
} }
} }
@ -344,7 +287,7 @@ watchUsingRemote()
if (isReallyAlive(self)) if (isReallyAlive(self))
{ {
self setSpawnWeapon(self getLastWeapon()); self botWeapon(self getLastWeapon());
self.bot.targets = []; self.bot.targets = [];
} }
} }
@ -362,7 +305,7 @@ watchUsingMinigun()
{ {
if (self getCurrentWeapon() != "heli_remote_mp") if (self getCurrentWeapon() != "heli_remote_mp")
{ {
self setspawnweapon("heli_remote_mp"); self botWeapon("heli_remote_mp");
} }
if (isDefined(self.bot.target)) if (isDefined(self.bot.target))
@ -386,7 +329,7 @@ watchAc130Weapon()
curWeap = self GetCurrentWeapon(); curWeap = self GetCurrentWeapon();
if (curWeap != "ac130_105mm_mp" && curWeap != "ac130_40mm_mp" && curWeap != "ac130_25mm_mp") if (curWeap != "ac130_105mm_mp" && curWeap != "ac130_40mm_mp" && curWeap != "ac130_25mm_mp")
self setSpawnWeapon("ac130_105mm_mp"); self botWeapon("ac130_105mm_mp");
if (isDefined(self.bot.target)) if (isDefined(self.bot.target))
self thread pressFire(); self thread pressFire();
@ -404,12 +347,12 @@ watchUsingAc130()
while (isDefined(level.ac130Player) && level.ac130player == self) while (isDefined(level.ac130Player) && level.ac130player == self)
{ {
self setspawnweapon("ac130_105mm_mp"); self botWeapon("ac130_105mm_mp");
wait 3+randomInt(3); wait 1+randomInt(2);
self setspawnweapon("ac130_40mm_mp"); self botWeapon("ac130_40mm_mp");
wait 4+randomInt(3); wait 2+randomInt(2);
self setspawnweapon("ac130_25mm_mp"); self botWeapon("ac130_25mm_mp");
wait 4+randomInt(3); wait 3+randomInt(2);
} }
} }
@ -450,10 +393,10 @@ doBotMovement()
waittillframeend; waittillframeend;
move_To = self.bot.moveTo; move_To = self.bot.moveTo;
angles = self GetPlayerAngles(); angles = self GetPlayerAngles();
dir = (0, 0, 0);
if (DistanceSquared(self.origin, move_To) < 49) if (DistanceSquared(self.origin, move_To) >= 49)
continue; {
cosa = cos(0-angles[1]); cosa = cos(0-angles[1]);
sina = sin(0-angles[1]); sina = sin(0-angles[1]);
@ -470,6 +413,7 @@ doBotMovement()
// invert the second component as the engine requires this // invert the second component as the engine requires this
dir = (dir[0], 0-dir[1], 0); dir = (dir[0], 0-dir[1], 0);
}
// move! // move!
self botMovement(int(dir[0]), int(dir[1])); self botMovement(int(dir[0]), int(dir[1]));
@ -1053,6 +997,7 @@ watchToLook()
self.bot.jump_time = thetime; self.bot.jump_time = thetime;
self prone(); self prone();
self notify("kill_goal");
wait 2.5; wait 2.5;
self crouch(); self crouch();
} }
@ -1249,6 +1194,9 @@ aim()
if (canADS) if (canADS)
self thread pressAds(); self thread pressAds();
if(curweap == "at4_mp" && entIsVehicle(self.bot.target.entity) && self.stingerStage != 2)
continue;
if (trace_time > reaction_time) if (trace_time > reaction_time)
{ {
if((!canADS || self playerads() == 1.0 || self InLastStand() || self GetStance() == "prone") && (conedot > 0.95 || dist < level.bots_maxKnifeDistance)) if((!canADS || self playerads() == 1.0 || self InLastStand() || self GetStance() == "prone") && (conedot > 0.95 || dist < level.bots_maxKnifeDistance))
@ -1363,9 +1311,6 @@ canFire(curweap)
if(curweap == "none") if(curweap == "none")
return false; return false;
if(curweap == "at4_mp" && isDefined(self.bot.target) && isDefined(self.bot.target.entity) && entIsVehicle(self.bot.target.entity) && self.stingerStage != 2)
return false;
if (curweap == "riotshield_mp" || curweap == "onemanarmy_mp") if (curweap == "riotshield_mp" || curweap == "onemanarmy_mp")
return false; return false;
@ -1464,13 +1409,16 @@ walk()
{ {
curweap = self getCurrentWeapon(); curweap = self getCurrentWeapon();
if(isDefined(self.bot.jav_loc) || entIsVehicle(self.bot.target.entity) || self.bot.isfraggingafter || self.bot.issmokingafter || self InLastStand() || self GetStance() == "prone") if(isDefined(self.bot.jav_loc) || entIsVehicle(self.bot.target.entity) || self.bot.isfraggingafter || self.bot.issmokingafter)
{ {
continue; continue;
} }
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")
continue;
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; continue;
@ -2044,8 +1992,6 @@ prone()
{ {
self botAction("-gocrouch"); self botAction("-gocrouch");
self botAction("+goprone"); self botAction("+goprone");
self notify("kill_goal");
} }
/* /*