switch changes

This commit is contained in:
Your Name 2020-09-17 11:01:55 -06:00
parent f95391b906
commit 154332f014

View File

@ -149,6 +149,7 @@ resetBotVars()
self.bot.rand = randomInt(100); self.bot.rand = randomInt(100);
self.bot.isswitching = false; self.bot.isswitching = false;
self.bot.switch_to_after_none = undefined;
self.bot.stance = "stand"; self.bot.stance = "stand";
@ -986,8 +987,7 @@ onWeaponChange()
switch (newWeapon) switch (newWeapon)
{ {
case "none": case "none":
if(isDefined(self.lastDroppableWeapon) && self.lastDroppableWeapon != "none" && !self.disabledWeapon) self thread doNoneSwitch();
self setSpawnWeapon(self.lastDroppableWeapon);
break; break;
default: default:
self thread doSwitch(newWeapon); self thread doSwitch(newWeapon);
@ -996,17 +996,38 @@ onWeaponChange()
} }
} }
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);
}
doSwitch(newWeapon) doSwitch(newWeapon)
{ {
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("death");
self notify("bot_weapon_change"); self endon("weapon_change");
self endon("bot_weapon_change");
if (self.bot.climbing) if (self.bot.climbing)
return; return;
if (isDefined(self.lastDroppableWeapon) && self.lastDroppableWeapon != newWeapon) waittillframeend;
if (self.lastDroppableWeapon != newWeapon)
return; return;
if (!self inLastStand() && !self.bot.isfraggingafter && !self.bot.knifingafter) if (!self inLastStand() && !self.bot.isfraggingafter && !self.bot.knifingafter)