From 86097d7d51f90eebfcb534743aa625c6319d9407 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 17 Aug 2020 10:46:56 -0600 Subject: [PATCH] func and airdrop --- userraw/maps/mp/bots/_bot.gsc | 33 ++++++++++++++++++++++++++ userraw/maps/mp/bots/_bot_internal.gsc | 20 ++++++++-------- userraw/maps/mp/bots/_bot_script.gsc | 23 ++++++++++-------- userraw/maps/mp/bots/_bot_utility.gsc | 12 +++++++++- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/userraw/maps/mp/bots/_bot.gsc b/userraw/maps/mp/bots/_bot.gsc index 6ee5fb2..5ba4a2d 100644 --- a/userraw/maps/mp/bots/_bot.gsc +++ b/userraw/maps/mp/bots/_bot.gsc @@ -126,6 +126,7 @@ init() level thread fixGamemodes(); level thread onPlayerConnect(); + level thread addNotifyOnAirdrops(); level thread handleBots(); } @@ -201,6 +202,38 @@ fixGamemodes() } } +addNotifyOnAirdrops() +{ + for (;;) + { + wait 1; + dropCrates = getEntArray( "care_package", "targetname" ); + + for (i = dropCrates.size - 1; i >= 0; i--) + { + airdrop = dropCrates[i]; + + if (!isDefined(airdrop.owner)) + continue; + + if (isDefined(airdrop.doingPhysics)) + continue; + + airdrop.doingPhysics = true; + airdrop thread doNotifyOnAirdrop(); + } + } +} + +doNotifyOnAirdrop() +{ + self endon( "death" ); + self waittill( "physics_finished" ); + + self.doingPhysics = false; + self.owner notify("crate_physics_done"); +} + /* Thread when any player connects. Starts the threads needed. */ diff --git a/userraw/maps/mp/bots/_bot_internal.gsc b/userraw/maps/mp/bots/_bot_internal.gsc index c5e2c25..50a07ad 100644 --- a/userraw/maps/mp/bots/_bot_internal.gsc +++ b/userraw/maps/mp/bots/_bot_internal.gsc @@ -349,7 +349,7 @@ UseRunThink() self.bot.run_time -= 0.05; if (self.bot.run_time <= 0 || - isDefined(self.lastStand) || self getStance() != "stand" || + self inLastStand() || self getStance() != "stand" || level.gameEnded || !gameFlag( "prematch_done" ) || self.bot.isfrozen || self.bot.climbing || self.bot.isreloading || @@ -395,7 +395,7 @@ stanceHack() { wait 0.05; - if(isDefined(self.lastStand)) + if(self inLastStand()) continue; if (level.gameEnded || !gameFlag( "prematch_done" )) @@ -503,7 +503,7 @@ moveHack() stance = self getStance(); curWeap = self GetCurrentWeapon(); weapClass = weaponClass(curWeap); - inLastStand = isDefined(self.lastStand); + inLastStand = self inLastStand(); usingRemote = self isUsingRemote(); botAnim = ""; @@ -887,7 +887,7 @@ doSwitch(newWeapon) if (isDefined(self.lastDroppableWeapon) && self.lastDroppableWeapon != newWeapon) return; - if (!isDefined(self.lastStand) && !self.bot.isfraggingafter && !self.bot.knifingafter) + if (!self inLastStand() && !self.bot.isfraggingafter && !self.bot.knifingafter) self thread botDoAnim("pt_stand_core_pullout", 0.5, true); self.bot.isswitching = true; @@ -922,10 +922,10 @@ onLastStand() while (true) { - while (!isDefined(self.lastStand)) + while (!self inLastStand()) wait 0.05; - if (!isDefined(self.inFinalStand) || !self.inFinalStand) + if (!self inFinalStand()) { pistol = undefined; weaponsList = self GetWeaponsListPrimaries(); @@ -939,7 +939,7 @@ onLastStand() self setSpawnWeapon(pistol); } - while (isDefined(self.lastStand)) + while (self inLastStand()) wait 0.05; } } @@ -2140,7 +2140,7 @@ knife(ent, knifeDist) isplay = isPlayer(ent); usedRiot = self.hasRiotShieldEquipped; distsq = DistanceSquared(self.origin, ent.origin); - inLastStand = isDefined(self.lastStand); + inLastStand = self inLastStand(); stance = self getStance(); damage = 135; if (usedRiot) @@ -2295,7 +2295,7 @@ botThrowGrenade(grenName) self endon("disconnect"); level endon ( "game_ended" ); - if (isDefined(self.lastStand) && !self _hasPerk("specialty_laststandoffhand") && (!isDefined(self.inFinalStand) || !self.inFinalStand)) + if (self inLastStand() && !self _hasPerk("specialty_laststandoffhand") && !self inFinalStand()) return "laststand"; if (level.gameEnded || !gameFlag( "prematch_done" ) || self.bot.isfrozen || self.bot.climbing) @@ -2387,7 +2387,7 @@ jump() self endon("disconnect"); level endon ( "game_ended" ); - if (isDefined(self.lastStand) || self getStance() != "stand" || + if (self inLastStand() || self getStance() != "stand" || level.gameEnded || !gameFlag( "prematch_done" ) || self IsUsingRemote() || self.bot.isfrozen || self.bot.climbing || self.bot.jumpingafter) return; diff --git a/userraw/maps/mp/bots/_bot_script.gsc b/userraw/maps/mp/bots/_bot_script.gsc index 34c4fbd..67b0736 100644 --- a/userraw/maps/mp/bots/_bot_script.gsc +++ b/userraw/maps/mp/bots/_bot_script.gsc @@ -1019,13 +1019,6 @@ bot_killstreak_think() self endon("death"); level endon("game_ended"); - if (randomInt(2)) - self maps\mp\killstreaks\_killstreaks::tryGiveKillstreak("airdrop"); - else if (randomInt(2)) - self maps\mp\killstreaks\_killstreaks::tryGiveKillstreak("airdrop_sentry_minigun"); - else - self maps\mp\killstreaks\_killstreaks::tryGiveKillstreak("airdrop_mega"); - for (;;) { wait randomIntRange(1, 3); @@ -1039,7 +1032,7 @@ bot_killstreak_think() if(self HasThreat()) continue; - if(self IsBotReloading() || self IsBotFragging() || self IsKnifing()) + if(self IsBotReloading() || self IsBotFragging() || self IsBotKnifing()) continue; if(self isDefusing() || self isPlanting()) @@ -1052,6 +1045,9 @@ bot_killstreak_think() if (self isEMPed()) continue; + if (self botIsClimbing()) + continue; + streakName = self.pers["killstreaks"][0].streakName; ksWeap = maps\mp\killstreaks\_killstreaks::getKillstreakWeapon( streakName ); @@ -1088,9 +1084,13 @@ bot_killstreak_think() continue; self SetScriptGoal(self.origin, 16); - self throwBotGrenade(ksWeap); + if (self throwBotGrenade(ksWeap) != "grenade_fire") + { + self ClearScriptGoal(); + continue; + } - self waittill_any_timeout( 1, "bad_path" ); + self waittill_any_timeout( 15, "bad_path", "crate_physics_done" ); self ClearScriptGoal(); } else @@ -1139,6 +1139,9 @@ bot_killstreak_think() location = self.origin + (randomIntRange(-512, 512), randomIntRange(-512, 512), 0); directionYaw = randomInt(360); + + if (!isDefined(location)) + continue; case "helicopter": case "helicopter_flares": case "uav": diff --git a/userraw/maps/mp/bots/_bot_utility.gsc b/userraw/maps/mp/bots/_bot_utility.gsc index db01243..b310969 100644 --- a/userraw/maps/mp/bots/_bot_utility.gsc +++ b/userraw/maps/mp/bots/_bot_utility.gsc @@ -191,7 +191,7 @@ HasThreat() return (isDefined(self GetThreat())); } -IsKnifing() +IsBotKnifing() { return self.bot.knifing; } @@ -206,6 +206,16 @@ isPlanting() return (isDefined(self.isPlanting) && self.isPlanting); } +inLastStand() +{ + return (isDefined(self.lastStand) && self.lastStand); +} + +inFinalStand() +{ + return (isDefined(self.inFinalStand) && self.inFinalStand); +} + isWeaponDroppable(weap) { return (maps\mp\gametypes\_weapons::mayDropWeapon(weap));