]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Purge hardcoded slot 0 weapon entity use from most of the bot AI
authorMario <mario@smbclan.net>
Wed, 5 Oct 2016 06:38:35 +0000 (16:38 +1000)
committerMario <mario@smbclan.net>
Wed, 5 Oct 2016 06:38:35 +0000 (16:38 +1000)
24 files changed:
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/havocbot.qh

index 30e6174adc7f33c10393f632276734c86e336940..e454f0dccc7a11acf7edf20d04a43e8405e80dce 100644 (file)
@@ -58,7 +58,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
 }
 
-METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor))
+METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
index b4dec462618b94c86ec6986cf522d025ec7e4de0..54ae9d67eb32701ffe1d850cca4f021bb643b3f4 100644 (file)
@@ -110,7 +110,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .entity wea
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
 }
 
-METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor))
+METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
 }
index 9629b175d56f32a2f82e8c98f0edac4d7eac57e1..782f3c5cedcbf414c98c6712ce8e21ba44063044 100644 (file)
@@ -95,7 +95,7 @@ CLASS(Weapon, Object)
     /** (SERVER) checks ammo for weapon second */
     METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor, .entity weaponentity)) {return false;}
     /** (SERVER) runs bot aiming code for this weapon */
-    METHOD(Weapon, wr_aim, void(Weapon this, entity actor)) {}
+    METHOD(Weapon, wr_aim, void(Weapon this, entity actor, .entity weaponentity)) {}
     /** (BOTH)   precaches models/sounds used by this weapon, also sets up weapon properties */
     METHOD(Weapon, wr_init, void(Weapon this)) {}
     /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
index 889222d4ccb96c209a98c0c78e7b11564ee5708f..7a703d3d0c001610796bd783b18f72e438290016 100644 (file)
@@ -736,7 +736,7 @@ void Arc_Smoke(entity actor, .entity weaponentity)
        }
 }
 
-METHOD(Arc, wr_aim, void(entity thiswep, entity actor))
+METHOD(Arc, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(WEP_CVAR(arc, beam_botaimspeed))
     {
index 29e9c2a570cd50ca532b6bcccef2ce20760edae1..a4a6699a3a86c56cfbb1766f72b2f8c6e96254a0 100644 (file)
@@ -154,7 +154,7 @@ void W_Blaster_Attack(
        }
 }
 
-METHOD(Blaster, wr_aim, void(entity thiswep, entity actor))
+METHOD(Blaster, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(WEP_CVAR(blaster, secondary))
     {
index b820e94526c5f4741ffd69bb006f201f969a2982..2ef356e35883f832a5ba2f8d7cd355d9213e3e14 100644 (file)
@@ -579,7 +579,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        }
 }
 
-METHOD(Crylink, wr_aim, void(entity thiswep, entity actor))
+METHOD(Crylink, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(random() < 0.10)
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false);
index 31038fc4fca8c46024940ee7d972425f9dfa4572..b75ca6f02aa0361f0da7397321406643aaefa8be 100644 (file)
@@ -415,7 +415,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
 }
 
-METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
+METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     // aim and decide to fire if appropriate
     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
index 15387a90581141b6bb23d82fda7c6a280bae8903..80314d5e6f58edd991f692d6c0ce400b4098cf27 100644 (file)
@@ -488,7 +488,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
 
 .float bot_secondary_electromooth;
 
-METHOD(Electro, wr_aim, void(entity thiswep, entity actor))
+METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false;
     if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; }
index 54fbb0949c1d7a60f892d10cc333363d5b4f77ca..a7dca49bf8a93def11cc9e8b99c4f4ebdaca3b51 100644 (file)
@@ -364,7 +364,7 @@ void W_Fireball_Attack2(entity actor, .entity weaponentity)
        MUTATOR_CALLHOOK(EditProjectile, actor, proj);
 }
 
-METHOD(Fireball, wr_aim, void(entity thiswep, entity actor))
+METHOD(Fireball, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = false;
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
index b00b181cfd2509033b789ebbb9a91b4e44e2fb6f..a8620e50baaec92d268733dea339d062fdf3d218 100644 (file)
@@ -449,7 +449,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
        weapon_thinkf(actor, weaponentity, theframe, WEP_CVAR_PRI(hagar, refire), W_Hagar_Attack_Auto);
 }
 
-METHOD(Hagar, wr_aim, void(entity thiswep, entity actor))
+METHOD(Hagar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(random()>0.15)
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
index ba2b7f35143116cee4fb32c63382d1c3aa977b01..d1b4286a20eeb5b2218c700a8f4aebf7dc1616a0 100644 (file)
@@ -212,7 +212,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity)
        }
 }
 
-METHOD(HLAC, wr_aim, void(entity thiswep, entity actor))
+METHOD(HLAC, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
 }
index 009285b8c77e26c7e66f81d6140dd16aea7c8276..1d5ddeeccbfa558bb81363c5740b4127515789d0 100644 (file)
@@ -254,7 +254,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 
 }
 
-METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor))
+METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
index 0234cd15743fe131b37350ff352925a87cecc340..b33ce2b19bf1e7f726b13ba797df19097f9d6829 100644 (file)
@@ -420,10 +420,9 @@ bool W_MineLayer_PlacedMines(entity this, .entity weaponentity, bool detonate)
        return minfound;
 }
 
-METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
+METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     // aim and decide to fire if appropriate
-    .entity weaponentity = weaponentities[0]; // TODO: unhardcode
     if(actor.(weaponentity).minelayer_mines >= WEP_CVAR(minelayer, limit))
         PHYS_INPUT_BUTTON_ATCK(actor) = false;
     else
index 43119d45ae717f436328ba70991feca924c4bb48..9f1b4a749fbc43db48f43d9ab38705c18de086e8 100644 (file)
@@ -309,7 +309,7 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
 
 .float bot_secondary_grenademooth;
 
-METHOD(Mortar, wr_aim, void(entity thiswep, entity actor))
+METHOD(Mortar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = false;
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
index 782cb0e3e8b34ba16be8c78304bb589af7fc5107..ba972bc55985b11aec7aa5f952a7241b28278d23 100644 (file)
@@ -298,7 +298,7 @@ void W_Porto_Attack(entity actor, .entity weaponentity, float type)
        MUTATOR_CALLHOOK(EditProjectile, actor, gren);
 }
 
-METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor))
+METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = false;
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
index c1835f1007d5136a01ac5ccc676c65d1a145fe91..a2122451eafceceaae4a31c0f4cbc6b059ac56dd 100644 (file)
@@ -143,7 +143,7 @@ void W_Rifle_BulletHail(entity actor, .entity weaponentity, float mode, void(ent
 
 .float bot_secondary_riflemooth;
 
-METHOD(Rifle, wr_aim, void(entity thiswep, entity actor))
+METHOD(Rifle, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     PHYS_INPUT_BUTTON_ATCK(actor) = false;
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
index 93eba4396e9439051cf88d99bfdea0754d297893..bf60907e1d17e0063c560ef8e55782de84618e00 100644 (file)
@@ -614,9 +614,8 @@ void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity)
 // Begin: Genereal weapon functions
 // ============================
 
-METHOD(Seeker, wr_aim, void(entity thiswep, entity actor))
+METHOD(Seeker, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
     if(WEP_CVAR(seeker, type) == 1)
         if(W_Seeker_Tagged_Info(actor, weaponentity, actor.enemy) != NULL)
             PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false);
index 8dd56d940b48063c2038d443f8b49729f078a46d..a57f15731815e67d510ed511e7c445c743ef304d 100644 (file)
@@ -695,7 +695,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
        }
 }
 
-METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor))
+METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(vdist(actor.origin - actor.enemy.origin, <=, WEP_CVAR(shockwave, melee_range)))
         { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false); }
index b33f5890f263722cd3fb5046f927c527e6dce558..1fcc3336b0b108bbfc2ca6497af8c5251cc57e54 100644 (file)
@@ -227,7 +227,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
 
 .float shotgun_primarytime;
 
-METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor))
+METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(vdist(actor.origin - actor.enemy.origin, <=, WEP_CVAR_SEC(shotgun, melee_range)))
         PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
index 48469864ce22b42c47a1927eb8bb874a83d91b3a..bd6edcef0b1d48489ee189db892b81eb0425dc9e 100644 (file)
@@ -363,7 +363,7 @@ void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype)
 #endif
 
 #ifdef SVQC
-METHOD(Tuba, wr_aim, void(Tuba this, entity actor))
+METHOD(Tuba, wr_aim, void(Tuba this, entity actor, .entity weaponentity))
 {
        // bots cannot play the Tuba well yet
        // I think they should start with the recorder first
index cb55c5ddafede9f71efcc7ce43c2cd4f56dd12c5..5d17d62dc06dd110401b5967b78fd1e3126fa152 100644 (file)
@@ -352,7 +352,7 @@ void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity)
     }
 }
 
-METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor))
+METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(actor.(thiswep.ammo_field) > 0)
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 1, false);
index 7a30516ede14bf6a3387ba7699342c49972251dc..1c98a7d5e8ead5708fdc57e9f225eb6f22aa469b 100644 (file)
@@ -215,7 +215,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
 
 .float vortex_chargepool_pauseregen_finished;
 
-METHOD(Vortex, wr_aim, void(entity thiswep, entity actor))
+METHOD(Vortex, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     if(bot_aim(actor, 1000000, 0, 1, false))
         PHYS_INPUT_BUTTON_ATCK(actor) = true;
index 159cd6e729022f8807239df88acf430392aa37b1..db395b9c366360d662c29494902446198d1dde1d 100644 (file)
@@ -84,10 +84,16 @@ void havocbot_ai(entity this)
                return;
 
        havocbot_chooseenemy(this);
-       if (this.bot_chooseweapontime < time )
+
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               this.bot_chooseweapontime = time + autocvar_bot_ai_chooseweaponinterval;
-               havocbot_chooseweapon(this);
+               .entity weaponentity = weaponentities[slot];
+               if(this.(weaponentity).m_weapon != WEP_Null || slot == 0)
+               if(this.(weaponentity).bot_chooseweapontime < time)
+               {
+                       this.(weaponentity).bot_chooseweapontime = time + autocvar_bot_ai_chooseweaponinterval;
+                       havocbot_chooseweapon(this, weaponentity);
+               }
        }
        havocbot_aim(this);
        lag_update(this);
@@ -98,9 +104,6 @@ void havocbot_ai(entity this)
 
                if(this.weapons)
                {
-                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-                       Weapon w = this.(weaponentity).m_weapon;
-                       w.wr_aim(w, this);
                        if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(this))
                        {
                                PHYS_INPUT_BUTTON_ATCK(this) = false;
@@ -108,8 +111,16 @@ void havocbot_ai(entity this)
                        }
                        else
                        {
-                               if(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this))
-                                       this.lastfiredweapon = this.(weaponentity).m_weapon.m_id;
+                               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                               {
+                                       .entity weaponentity = weaponentities[slot];
+                                       Weapon w = this.(weaponentity).m_weapon;
+                                       if(w == WEP_Null && slot != 0)
+                                               continue;
+                                       w.wr_aim(w, this, weaponentity);
+                                       if(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this)) // TODO: what if we didn't fire this weapon, but the previous?
+                                               this.(weaponentity).lastfiredweapon = this.(weaponentity).m_weapon.m_id;
+                               }
                        }
                }
                else
@@ -156,22 +167,28 @@ void havocbot_ai(entity this)
        // if the bot is not attacking, consider reloading weapons
        if (!(this.aistatus & AI_STATUS_ATTACKING))
        {
-               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
 
-               // we are currently holding a weapon that's not fully loaded, reload it
-               if(skill >= 2) // bots can only reload the held weapon on purpose past this skill
-               if(this.(weaponentity).clip_load < this.(weaponentity).clip_size)
-                       this.impulse = 20; // "press" the reload button, not sure if this is done right
+                       if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                               continue;
 
-               // if we're not reloading a weapon, switch to any weapon in our invnetory that's not fully loaded to reload it next
-               // the code above executes next frame, starting the reloading then
-               if(skill >= 5) // bots can only look for unloaded weapons past this skill
-               if(this.(weaponentity).clip_load >= 0) // only if we're not reloading a weapon already
-               {
-                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                               if((this.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.(weaponentity).weapon_load[it.m_id] < it.reloading_ammo))
-                                       this.(weaponentity).m_switchweapon = it;
-                       ));
+                       // we are currently holding a weapon that's not fully loaded, reload it
+                       if(skill >= 2) // bots can only reload the held weapon on purpose past this skill
+                       if(this.(weaponentity).clip_load < this.(weaponentity).clip_size)
+                               this.impulse = 20; // "press" the reload button, not sure if this is done right
+
+                       // if we're not reloading a weapon, switch to any weapon in our invnetory that's not fully loaded to reload it next
+                       // the code above executes next frame, starting the reloading then
+                       if(skill >= 5) // bots can only look for unloaded weapons past this skill
+                       if(this.(weaponentity).clip_load >= 0) // only if we're not reloading a weapon already
+                       {
+                               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                                       if((this.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.(weaponentity).weapon_load[it.m_id] < it.reloading_ammo))
+                                               this.(weaponentity).m_switchweapon = it;
+                               ));
+                       }
                }
        }
 }
@@ -586,28 +603,36 @@ void havocbot_movetogoal(entity this)
                }
                else if(this.health>WEP_CVAR(devastator, damage)*0.5)
                {
-                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-
                        if(this.velocity.z < 0)
-                       if(client_hasweapon(this, WEP_DEVASTATOR, weaponentity, true, false))
                        {
-                               this.movement_x = maxspeed;
-
-                               if(this.rocketjumptime)
+                               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                                {
-                                       if(time > this.rocketjumptime)
+                                       .entity weaponentity = weaponentities[slot];
+
+                                       if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                                               continue;
+
+                                       if(client_hasweapon(this, WEP_DEVASTATOR, weaponentity, true, false))
                                        {
-                                               PHYS_INPUT_BUTTON_ATCK2(this) = true;
-                                               this.rocketjumptime = 0;
+                                               this.movement_x = maxspeed;
+
+                                               if(this.rocketjumptime)
+                                               {
+                                                       if(time > this.rocketjumptime)
+                                                       {
+                                                               PHYS_INPUT_BUTTON_ATCK2(this) = true;
+                                                               this.rocketjumptime = 0;
+                                                       }
+                                                       return;
+                                               }
+
+                                               this.(weaponentity).m_switchweapon = WEP_DEVASTATOR;
+                                               this.v_angle_x = 90;
+                                               PHYS_INPUT_BUTTON_ATCK(this) = true;
+                                               this.rocketjumptime = time + WEP_CVAR(devastator, detonatedelay);
+                                               return;
                                        }
-                                       return;
                                }
-
-                               this.(weaponentity).m_switchweapon = WEP_DEVASTATOR;
-                               this.v_angle_x = 90;
-                               PHYS_INPUT_BUTTON_ATCK(this) = true;
-                               this.rocketjumptime = time + WEP_CVAR(devastator, detonatedelay);
-                               return;
                        }
                }
                else
@@ -987,7 +1012,7 @@ LABEL(scan_targets)
                this.havocbot_stickenemy = false;
 }
 
-float havocbot_chooseweapon_checkreload(entity this, int new_weapon)
+float havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int new_weapon)
 {
        // bots under this skill cannot find unloaded weapons to reload idly when not in combat,
        // so skip this for them, or they'll never get to reload their weapons at all.
@@ -996,7 +1021,6 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon)
                return false;
 
        // if this weapon is scheduled for reloading, don't switch to it during combat
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
        if (this.(weaponentity).weapon_load[new_weapon] < 0)
        {
                bool other_weapon_available = false;
@@ -1011,12 +1035,10 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon)
        return false;
 }
 
-void havocbot_chooseweapon(entity this)
+void havocbot_chooseweapon(entity this, .entity weaponentity)
 {
        int i;
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-
        // ;)
        if(g_weaponarena_weapons == WEPSET(TUBA))
        {
@@ -1060,7 +1082,7 @@ void havocbot_chooseweapon(entity this)
        combo = false;
 
        if(autocvar_bot_ai_weapon_combo)
-       if(this.(weaponentity).m_weapon.m_id == this.lastfiredweapon)
+       if(this.(weaponentity).m_weapon.m_id == this.(weaponentity).lastfiredweapon)
        if(af > combo_time)
        {
                combo = true;
@@ -1078,7 +1100,7 @@ void havocbot_chooseweapon(entity this)
                                w = bot_weapons_far[i];
                                if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
                                {
-                                       if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
+                                       if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
                                                continue;
                                        this.(weaponentity).m_switchweapon = Weapons_from(w);
                                        return;
@@ -1092,7 +1114,7 @@ void havocbot_chooseweapon(entity this)
                                w = bot_weapons_mid[i];
                                if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
                                {
-                                       if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
+                                       if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
                                                continue;
                                        this.(weaponentity).m_switchweapon = Weapons_from(w);
                                        return;
@@ -1105,7 +1127,7 @@ void havocbot_chooseweapon(entity this)
                        w = bot_weapons_close[i];
                        if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
                        {
-                               if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
+                               if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
                                        continue;
                                this.(weaponentity).m_switchweapon = Weapons_from(w);
                                return;
index 4a391b6e7ceb9682a2df64023aa98751e88974d1..8ab4cba6e973309029860712ab799f87fd245ff5 100644 (file)
@@ -39,7 +39,7 @@ void havocbot_setupbot(entity this);
 void havocbot_movetogoal(entity this);
 void havocbot_chooserole(entity this);
 void havocbot_chooseenemy(entity this);
-void havocbot_chooseweapon(entity this);
+void havocbot_chooseweapon(entity this, .entity weaponentity);
 void havocbot_bunnyhop(entity this, vector dir);
 void havocbot_keyboard_movement(entity this, vector destorg);