]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: fix bots randomly refusing to shoot with the devastator
authorterencehill <piuntn@gmail.com>
Mon, 15 Aug 2022 11:29:07 +0000 (13:29 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 15 Aug 2022 11:29:07 +0000 (13:29 +0200)
qcsrc/common/weapons/weapon/devastator.qc

index b4542a039cf4363024e32d82ee59df02c064726d..62d677df2ff88b0a9ad2ce53c9dfa9bfbfa943d3 100644 (file)
@@ -362,6 +362,18 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int
 
 METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
+    if (!WEP_CVAR(devastator, guidestop) && !actor.(weaponentity).rl_release)
+    {
+        int fired_rockets = 0;
+        IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
+        {
+            fired_rockets++;
+        });
+        // release PHYS_INPUT_BUTTON_ATCK after all fired rocket exploded otherwise bot can't fire again
+        if (!fired_rockets)
+            return;
+    }
+
     // aim and decide to fire if appropriate
     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
     if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!