]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Unhardcode a few more 0 slot cases
authorMario <mario@smbclan.net>
Wed, 5 Oct 2016 07:24:29 +0000 (17:24 +1000)
committerMario <mario@smbclan.net>
Wed, 5 Oct 2016 07:24:29 +0000 (17:24 +1000)
34 files changed:
mutators.cfg
qcsrc/client/view.qc
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/nix/sv_nix.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/mutators/mutator/pinata/sv_pinata.qc
qcsrc/common/stats.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/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/aim.qc
qcsrc/server/bot/default/aim.qh
qcsrc/server/bot/null/bot_null.qc
qcsrc/server/mutators/events.qh
qcsrc/server/weapons/weaponsystem.qc

index 787ec7e3c773c44757f000040cfa918a009db5a0..39b5480b2d4bab4dfde2fe00ebd15901f3d70d94 100644 (file)
@@ -50,22 +50,6 @@ set g_overkill_100h_anyway 1
 set g_overkill_powerups_replace 1
 set g_overkill_superguns_respawn_time 120
 
-set g_overkill_ammo_charge 0
-set g_overkill_ammo_charge_notice 1
-set g_overkill_ammo_charge_limit 1
-set g_overkill_ammo_charge_rate 0.5
-set g_overkill_ammo_charge_rate_vortex 0.5
-set g_overkill_ammo_charge_rate_machinegun 0.5
-set g_overkill_ammo_charge_rate_shotgun 0.5
-set g_overkill_ammo_charge_rate_hmg 0.25
-set g_overkill_ammo_charge_rate_rpc 1.5
-set g_overkill_ammo_decharge 0.1
-set g_overkill_ammo_decharge_machinegun 0.025
-set g_overkill_ammo_decharge_shotgun 0.15
-set g_overkill_ammo_decharge_vortex 0.2
-set g_overkill_ammo_decharge_rpc 1
-set g_overkill_ammo_decharge_hmg 0.01
-
 
 // =========
 //  vampire
index 98bd49dea30c35ee5577c1b929a76d1560255215..def064d499e6fca7979c2e150e674e4c49a590c4 100644 (file)
@@ -1154,10 +1154,6 @@ void HUD_Crosshair(entity this)
                                weapon_clipload = STAT(WEAPON_CLIPLOAD);
                                weapon_clipsize = STAT(WEAPON_CLIPSIZE);
 
-                               float ok_ammo_charge, ok_ammo_chargepool;
-                               ok_ammo_charge = STAT(OK_AMMO_CHARGE);
-                               ok_ammo_chargepool = STAT(OK_AMMO_CHARGEPOOL);
-
                                float vortex_charge, vortex_chargepool;
                                vortex_charge = STAT(VORTEX_CHARGE);
                                vortex_chargepool = STAT(VORTEX_CHARGEPOOL);
@@ -1204,13 +1200,6 @@ void HUD_Crosshair(entity this)
                                        ring_rgb = wcross_color;
                                        ring_image = "gfx/crosshair_ring.tga";
                                }
-                               else if (ok_ammo_charge)
-                               {
-                                       ring_value = ok_ammo_chargepool;
-                                       ring_alpha = autocvar_crosshair_ring_reload_alpha;
-                                       ring_rgb = wcross_color;
-                                       ring_image = "gfx/crosshair_ring.tga";
-                               }
                                else if(autocvar_crosshair_ring_reload && weapon_clipsize) // forces there to be only an ammo ring
                                {
                                        ring_value = bound(0, weapon_clipload / weapon_clipsize, 1);
index c26ef4619561548d36b233562f1b9d168ee65a52..29bdd265fc5f2a6dc59629b41c1250c3d8e5d6de 100644 (file)
@@ -1025,8 +1025,11 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
        entity player = M_ARGV(0, entity);
 
        player.metertime = 0;
-       .entity weaponentity = weaponentities[0];
-       player.(weaponentity).weapons = '0 0 0';
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               player.(weaponentity).weapons = '0 0 0';
+       }
 
        if (nexball_mode & NBM_BASKETBALL)
                player.weapons |= WEPSET(NEXBALL);
index b1fd56722f7bbf000c11edebb01059e643b0cd25..14f92145f4989b8f0be63191e2bf65c6e086379d 100644 (file)
@@ -841,11 +841,15 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                });
        }
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-
        if(player.buffs & BUFF_AMMO.m_itemid)
-       if(player.(weaponentity).clip_size)
-               player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
+       {
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(player.(weaponentity).clip_size)
+                               player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
+               }
+       }
 
        if((player.buffs & BUFF_INVISIBLE.m_itemid) && (player.oldbuffs & BUFF_INVISIBLE.m_itemid))
        if(player.alpha != autocvar_g_buffs_invisible_alpha)
@@ -872,9 +876,17 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                        player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_WEAPON_AMMO);
                        player.items |= IT_UNLIMITED_WEAPON_AMMO;
 
-                       if(player.(weaponentity).clip_load)
-                               player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load;
-                       player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
+                       if(player.buffs & BUFF_AMMO.m_itemid)
+                       {
+                               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                               {
+                                       .entity weaponentity = weaponentities[slot];
+                                       if(player.(weaponentity).clip_load)
+                                               player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load;
+                                       if(player.(weaponentity).clip_size)
+                                               player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
+                               }
+                       }
                }
 
                BUFF_ONREM(BUFF_AMMO)
@@ -884,8 +896,15 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                        else
                                player.items &= ~IT_UNLIMITED_WEAPON_AMMO;
 
-                       if(player.(weaponentity).buff_ammo_prev_clipload)
-                               player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload;
+                       if(player.buffs & BUFF_AMMO.m_itemid)
+                       {
+                               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                               {
+                                       .entity weaponentity = weaponentities[slot];
+                                       if(player.(weaponentity).buff_ammo_prev_clipload)
+                                               player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload;
+                               }
+                       }
                }
 
                BUFF_ONADD(BUFF_INVISIBLE)
index 8067f791a7e44a5a00f890aff4fc60e0184ac18e..24fa435b4c021dd5d8365cb815c8faccd6152c25 100644 (file)
@@ -63,9 +63,14 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
                        it.ammo_rockets = start_ammo_rockets;
                        it.ammo_fuel = start_ammo_fuel;
                        it.weapons = start_weapons;
-                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-                       if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
-                               it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity);
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                       {
+                               .entity weaponentity = weaponentities[slot];
+                               if(it.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                                       continue;
+                               if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
+                                       it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity);
+                       }
                });
        }
 
@@ -215,14 +220,20 @@ void NIX_GiveCurrentWeapon(entity this)
                this.weapons |= WEPSET(BLASTER);
        this.weapons |= e.m_wepset;
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
     Weapon w = Weapons_from(nix_weapon);
-       if(this.(weaponentity).m_switchweapon != w)
+    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+    {
+       .entity weaponentity = weaponentities[slot];
+       if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
+               continue;
+
+               if(this.(weaponentity).m_switchweapon != w)
                if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, weaponentity, true, false))
                {
                        if(client_hasweapon(this, w, weaponentity, true, false))
                                W_SwitchWeapon(this, w, weaponentity);
                }
+       }
 }
 
 MUTATOR_HOOKFUNCTION(nix, ForbidThrowCurrentWeapon)
index e454f0dccc7a11acf7edf20d04a43e8405e80dce..caf96a67b3fc7e11a7dad4b8a01d2587908e4eee 100644 (file)
@@ -61,9 +61,9 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
 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);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
     else
-        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
+        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
 }
 
 METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
index 54ae9d67eb32701ffe1d850cca4f021bb643b3f4..62f517da642433892657b69e26b49f103d7df5a1 100644 (file)
@@ -112,7 +112,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .entity wea
 
 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);
+    PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
 }
 
 METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
index 20d2ee78152d10d6b935f411735a720774ddb6c2..caabb28233881c293a674b4ac021b66adff82b00 100644 (file)
@@ -7,24 +7,14 @@ bool autocvar_g_overkill_powerups_replace;
 float autocvar_g_overkill_superguns_respawn_time;
 bool autocvar_g_overkill_100h_anyway;
 bool autocvar_g_overkill_100a_anyway;
-bool autocvar_g_overkill_ammo_charge;
-float autocvar_g_overkill_ammo_charge_notice;
-float autocvar_g_overkill_ammo_charge_limit;
 
 .vector ok_deathloc;
 .float ok_spawnsys_timer;
-.float ok_lastwep;
+.Weapon ok_lastwep[MAX_WEAPONSLOTS];
 .float ok_item;
 
-.float ok_notice_time;
-.float ammo_charge[Weapons_MAX];
-.float ok_use_ammocharge = _STAT(OK_AMMO_CHARGE);
-.float ok_ammo_charge = _STAT(OK_AMMO_CHARGEPOOL);
-
 .float ok_pauseregen_finished;
 
-void(entity ent, float wep) ok_DecreaseCharge;
-
 void ok_Initialize();
 
 REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
@@ -41,60 +31,10 @@ REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball &&
        }
 }
 
-MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo)
-{
-       entity actor = M_ARGV(0, entity);
-       if (actor.ok_use_ammocharge)
-       {
-               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-               ok_DecreaseCharge(actor, actor.(weaponentity).m_weapon.m_id);
-               return true;
-       }
-}
-
-MUTATOR_HOOKFUNCTION(ok, W_Reload)
-{
-       entity actor = M_ARGV(0, entity);
-       return actor.ok_use_ammocharge;
-}
-
 void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float);
 spawnfunc(weapon_hmg);
 spawnfunc(weapon_rpc);
 
-void ok_DecreaseCharge(entity ent, int wep)
-{
-       if(!ent.ok_use_ammocharge) return;
-
-       entity wepent = Weapons_from(wep);
-
-       if (wepent == WEP_Null) return;  // dummy
-
-       ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
-}
-
-void ok_IncreaseCharge(entity ent, int wep)
-{
-       entity wepent = Weapons_from(wep);
-
-       if (wepent == WEP_Null) return;  // dummy
-
-       if(ent.ok_use_ammocharge)
-       if(!PHYS_INPUT_BUTTON_ATCK(ent)) // not while attacking?
-               ent.ammo_charge[wep] = min(autocvar_g_overkill_ammo_charge_limit, ent.ammo_charge[wep] + cvar(sprintf("g_overkill_ammo_charge_rate_%s", wepent.netname)) * frametime / W_TICSPERFRAME);
-}
-
-float ok_CheckWeaponCharge(entity ent, int wep)
-{
-       if(!ent.ok_use_ammocharge) return true;
-
-       entity wepent = Weapons_from(wep);
-
-       if(wepent == WEP_Null) return false;  // dummy
-
-       return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
-}
-
 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
 {
        entity frag_attacker = M_ARGV(1, entity);
@@ -153,9 +93,12 @@ MUTATOR_HOOKFUNCTION(ok, PlayerDies)
 
        ok_DropItem(frag_target, targ);
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
 
-       frag_target.ok_lastwep = frag_target.(weaponentity).m_switchweapon.m_id;
+               frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon;
+       }
 }
 
 MUTATOR_HOOKFUNCTION(ok, MonsterDropItem)
@@ -206,23 +149,26 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
                return;
 
        entity player = M_ARGV(0, entity);
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 
        if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
                return;
 
-       if(player.ok_lastwep)
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               Weapon newwep = Weapons_from(player.ok_lastwep);
-               if(player.ok_lastwep == WEP_HMG.m_id)
-                       newwep = WEP_MACHINEGUN;
-               if(player.ok_lastwep == WEP_RPC.m_id)
-                       newwep = WEP_VORTEX;
-               player.(weaponentity).m_switchweapon = newwep;
-               player.ok_lastwep = 0;
-       }
+               .entity weaponentity = weaponentities[slot];
+               entity thiswep = player.(weaponentity);
 
-       ok_IncreaseCharge(player, player.(weaponentity).m_weapon.m_id);
+               if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
+               {
+                       Weapon newwep = player.ok_lastwep[slot];
+                       if(player.ok_lastwep[slot] == WEP_HMG)
+                               newwep = WEP_MACHINEGUN;
+                       if(player.ok_lastwep[slot] == WEP_RPC)
+                               newwep = WEP_VORTEX;
+                       thiswep.m_switchweapon = newwep;
+                       player.ok_lastwep[slot] = WEP_Null;
+               }
+       }
 
        if(PHYS_INPUT_BUTTON_ATCK2(player))
        if(!forbidWeaponUse(player) || player.weapon_blocked) // allow if weapon is blocked
@@ -231,44 +177,31 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
                player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player);
                makevectors(player.v_angle);
 
-               Weapon oldwep = player.(weaponentity).m_weapon;
-               player.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       player,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(vaporizer, shotangle),
-                       WEP_CVAR_SEC(vaporizer, damage),
-                       WEP_CVAR_SEC(vaporizer, edgedamage),
-                       WEP_CVAR_SEC(vaporizer, radius),
-                       WEP_CVAR_SEC(vaporizer, force),
-                       WEP_CVAR_SEC(vaporizer, speed),
-                       WEP_CVAR_SEC(vaporizer, spread),
-                       WEP_CVAR_SEC(vaporizer, delay),
-                       WEP_CVAR_SEC(vaporizer, lifetime)
-               );
-               player.(weaponentity).m_weapon = oldwep;
-       }
-
-       player.weapon_blocked = false;
-
-       player.ok_ammo_charge = player.ammo_charge[player.(weaponentity).m_weapon.m_id];
-
-       if(player.ok_use_ammocharge)
-       if(!ok_CheckWeaponCharge(player, player.(weaponentity).m_weapon.m_id))
-       {
-               if(autocvar_g_overkill_ammo_charge_notice && time > player.ok_notice_time && PHYS_INPUT_BUTTON_ATCK(player) && IS_REAL_CLIENT(player) && player.(weaponentity).m_weapon == player.(weaponentity).m_switchweapon)
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
-                       //Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_OVERKILL_CHARGE);
-                       player.ok_notice_time = time + 2;
-                       play2(player, SND(DRYFIRE));
+                       .entity weaponentity = weaponentities[slot];
+
+                       if(player.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                               continue;
+
+                       Weapon oldwep = player.(weaponentity).m_weapon;
+                       player.(weaponentity).m_weapon = WEP_BLASTER;
+                       W_Blaster_Attack(
+                               player,
+                               weaponentity,
+                               WEP_BLASTER.m_id | HITTYPE_SECONDARY,
+                               WEP_CVAR_SEC(vaporizer, shotangle),
+                               WEP_CVAR_SEC(vaporizer, damage),
+                               WEP_CVAR_SEC(vaporizer, edgedamage),
+                               WEP_CVAR_SEC(vaporizer, radius),
+                               WEP_CVAR_SEC(vaporizer, force),
+                               WEP_CVAR_SEC(vaporizer, speed),
+                               WEP_CVAR_SEC(vaporizer, spread),
+                               WEP_CVAR_SEC(vaporizer, delay),
+                               WEP_CVAR_SEC(vaporizer, lifetime)
+                       );
+                       player.(weaponentity).m_weapon = oldwep;
                }
-               Weapon wpn = player.(weaponentity).m_weapon;
-               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-               if(player.(weaponentity).state != WS_CLEAR)
-                       w_ready(wpn, player, weaponentity, PHYS_INPUT_BUTTON_ATCK(player) | (PHYS_INPUT_BUTTON_ATCK2(player) << 1));
-
-               player.weapon_blocked = true;
        }
 
        PHYS_INPUT_BUTTON_ATCK2(player) = false;
@@ -278,19 +211,14 @@ MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
 {
        entity player = M_ARGV(0, entity);
 
-       if(autocvar_g_overkill_ammo_charge)
-       {
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(player.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit));
-
-               player.ok_use_ammocharge = 1;
-               player.ok_notice_time = time;
-       }
-       else
-               player.ok_use_ammocharge = 0;
-
        // if player changed their weapon while dead, don't switch to their death weapon
        if(player.impulse)
-               player.ok_lastwep = 0;
+       {
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       player.ok_lastwep[slot] = WEP_Null;
+               }
+       }
 
        player.ok_pauseregen_finished = time + 2;
 }
@@ -357,16 +285,6 @@ MUTATOR_HOOKFUNCTION(ok, FilterItem)
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(ok, SpectateCopy)
-{
-       entity spectatee = M_ARGV(0, entity);
-       entity client = M_ARGV(1, entity);
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-
-       client.ammo_charge[client.(weaponentity).m_weapon.m_id] = spectatee.ammo_charge[spectatee.(weaponentity).m_weapon.m_id];
-       client.ok_use_ammocharge = spectatee.ok_use_ammocharge;
-}
-
 MUTATOR_HOOKFUNCTION(ok, SetStartItems)
 {
        WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
index 387c1c359fd1c563a66651a7f7c609efcedfa05c..ff942db310e4fbf434c725343e091cdab24b39f9 100644 (file)
@@ -6,14 +6,20 @@ MUTATOR_HOOKFUNCTION(pinata, PlayerDies)
 {
        entity frag_target = M_ARGV(2, entity);
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
-               if(frag_target.weapons & WepSet_FromWeapon(it))
-               if(frag_target.(weaponentity).m_switchweapon != it)
-               if(W_IsWeaponThrowable(frag_target, it.m_id))
-                       W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325', weaponentity);
-       ));
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+
+               if(frag_target.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                       continue;
+
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       if(frag_target.weapons & WepSet_FromWeapon(it))
+                       if(frag_target.(weaponentity).m_switchweapon != it)
+                       if(W_IsWeaponThrowable(frag_target, it.m_id))
+                               W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325', weaponentity);
+               ));
+       }
 
        return true;
 }
index 5cc278b04f783b6bd0ad19dae835ae30166c5c62..2ecdd06ca75ab7fa2cbbda01ab5fb0dab8eac2eb 100644 (file)
@@ -112,8 +112,6 @@ REGISTER_STAT(NADE_BONUS_SCORE, float)
 REGISTER_STAT(HEALING_ORB, float)
 REGISTER_STAT(HEALING_ORB_ALPHA, float)
 REGISTER_STAT(PLASMA, int)
-REGISTER_STAT(OK_AMMO_CHARGE, float)
-REGISTER_STAT(OK_AMMO_CHARGEPOOL, float)
 REGISTER_STAT(FROZEN, int)
 REGISTER_STAT(REVIVE_PROGRESS, float)
 REGISTER_STAT(ROUNDLOST, int)
index 7a703d3d0c001610796bd783b18f72e438290016..3d011345b10c74fb3c01f58b27de545329660816 100644 (file)
@@ -742,6 +742,7 @@ METHOD(Arc, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
     {
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(
                actor,
+               weaponentity,
             WEP_CVAR(arc, beam_botaimspeed),
             0,
             WEP_CVAR(arc, beam_botaimlifetime),
@@ -752,6 +753,7 @@ METHOD(Arc, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
     {
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(
                actor,
+               weaponentity,
             1000000,
             0,
             0.001,
index a4a6699a3a86c56cfbb1766f72b2f8c6e96254a0..cc2fedccfe84e21be7ccedc038aa9e12985eba1f 100644 (file)
@@ -159,12 +159,12 @@ METHOD(Blaster, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)
     if(WEP_CVAR(blaster, secondary))
     {
         if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage))
-            { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); }
+            { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); }
         else
-            { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
+            { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
     }
     else
-        { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
+        { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
 }
 
 METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponentity, int fire))
index 2ef356e35883f832a5ba2f8d7cd355d9213e3e14..e4d66ebe603a7598f2ef3151a750537e8b5fef57 100644 (file)
@@ -582,9 +582,9 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
 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);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false);
     else
-        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false);
+        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false);
 }
 METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index b75ca6f02aa0361f0da7397321406643aaefa8be..13600aad36dce5da9a7411c88fb1ec7e5606fa6a 100644 (file)
@@ -418,7 +418,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 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);
+    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!
     {
         // decide whether to detonate rockets
index 80314d5e6f58edd991f692d6c0ce400b4098cf27..86f327e1c2689551c5cdc02f1f554821244580d4 100644 (file)
@@ -497,9 +497,9 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)
         float shoot;
 
         if(WEP_CVAR_PRI(electro, speed))
-            shoot = bot_aim(actor, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
+            shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
         else
-            shoot = bot_aim(actor, 1000000, 0, 0.001, false);
+            shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
 
         if(shoot)
         {
@@ -509,7 +509,7 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)
     }
     else
     {
-        if(bot_aim(actor, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
         {
             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
             if(random() < 0.03) actor.bot_secondary_electromooth = 0;
index a7dca49bf8a93def11cc9e8b99c4f4ebdaca3b51..8ccd57b68ed8477e52a885aee29188d01b94d862 100644 (file)
@@ -370,7 +370,7 @@ METHOD(Fireball, wr_aim, void(entity thiswep, entity actor, .entity weaponentity
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
     if(actor.bot_primary_fireballmooth == 0)
     {
-        if(bot_aim(actor, WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), false))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), false))
         {
             PHYS_INPUT_BUTTON_ATCK(actor) = true;
             if(random() < 0.02) actor.bot_primary_fireballmooth = 0;
@@ -378,7 +378,7 @@ METHOD(Fireball, wr_aim, void(entity thiswep, entity actor, .entity weaponentity
     }
     else
     {
-        if(bot_aim(actor, WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), true))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), true))
         {
             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
             if(random() < 0.01) actor.bot_primary_fireballmooth = 1;
index a8620e50baaec92d268733dea339d062fdf3d218..cb4d365ad1a7c633ff4db54e92e1020baf89783d 100644 (file)
@@ -452,9 +452,9 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
 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);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
     else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
-        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
+        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
 }
 METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index d1b4286a20eeb5b2218c700a8f4aebf7dc1616a0..010ca4fe8e18183e7c7f970f311844df3eb790e0 100644 (file)
@@ -214,7 +214,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity)
 
 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);
+    PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
 }
 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index 1d5ddeeccbfa558bb81363c5740b4127515789d0..7344ba9d0da4e220f66b01d2a602029fce4adff9 100644 (file)
@@ -257,9 +257,9 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 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);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
     else
-        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
+        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
 }
 METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index b33ce2b19bf1e7f726b13ba797df19097f9d6829..0e1db0f1b3862833240c34c0011e7429a057f81c 100644 (file)
@@ -426,7 +426,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit
     if(actor.(weaponentity).minelayer_mines >= WEP_CVAR(minelayer, limit))
         PHYS_INPUT_BUTTON_ATCK(actor) = false;
     else
-        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false);
     if(skill >= 2) // skill 0 and 1 bots won't detonate mines!
     {
         // decide whether to detonate mines
index 9f1b4a749fbc43db48f43d9ab38705c18de086e8..d8cb2d0699c3a27c90205a681b7d38ba62226580 100644 (file)
@@ -315,7 +315,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
     if(actor.bot_secondary_grenademooth == 0) // WEAPONTODO: merge this into using WEP_CVAR_BOTH
     {
-        if(bot_aim(actor, WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true))
         {
             PHYS_INPUT_BUTTON_ATCK(actor) = true;
             if(random() < 0.01) actor.bot_secondary_grenademooth = 1;
@@ -323,7 +323,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
     }
     else
     {
-        if(bot_aim(actor, WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true))
         {
             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
             if(random() < 0.02) actor.bot_secondary_grenademooth = 0;
index ba972bc55985b11aec7aa5f952a7241b28278d23..eaa56e50cd276d0311f6d58ba2327f94d32c9a23 100644 (file)
@@ -303,7 +303,7 @@ METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor, .entity weaponent
     PHYS_INPUT_BUTTON_ATCK(actor) = false;
     PHYS_INPUT_BUTTON_ATCK2(actor) = false;
     if(!WEP_CVAR(porto, secondary))
-        if(bot_aim(actor, WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false))
             PHYS_INPUT_BUTTON_ATCK(actor) = true;
 }
 METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
index a2122451eafceceaae4a31c0f4cbc6b059ac56dd..37d8e0e23a22eee23405f8664fb4f2a73f4f2b00 100644 (file)
@@ -151,7 +151,7 @@ METHOD(Rifle, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
         actor.bot_secondary_riflemooth = 0;
     if(actor.bot_secondary_riflemooth == 0)
     {
-        if(bot_aim(actor, 1000000, 0, 0.001, false))
+        if(bot_aim(actor, weaponentity, 1000000, 0, 0.001, false))
         {
             PHYS_INPUT_BUTTON_ATCK(actor) = true;
             if(random() < 0.01) actor.bot_secondary_riflemooth = 1;
@@ -159,7 +159,7 @@ METHOD(Rifle, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
     }
     else
     {
-        if(bot_aim(actor, 1000000, 0, 0.001, false))
+        if(bot_aim(actor, weaponentity, 1000000, 0, 0.001, false))
         {
             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
             if(random() < 0.03) actor.bot_secondary_riflemooth = 0;
index bf60907e1d17e0063c560ef8e55782de84618e00..6cc78f576d74eaa2a1749cf6e4c12d9aec941454 100644 (file)
@@ -618,11 +618,11 @@ METHOD(Seeker, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     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);
+            PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false);
         else
-            PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
+            PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
     else
-        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
 }
 METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index a57f15731815e67d510ed511e7c445c743ef304d..823aac11c1d223a35ab068280503eb628194aa7b 100644 (file)
@@ -698,9 +698,9 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
 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); }
+        { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); }
     else
-        { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false); }
+        { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); }
 }
 METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index 1fcc3336b0b108bbfc2ca6497af8c5251cc57e54..f6d730fcb1f9dffc28331e6d17e718558f190779 100644 (file)
@@ -230,9 +230,9 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
 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);
+        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
     else
-        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
 }
 METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index 5d17d62dc06dd110401b5967b78fd1e3126fa152..7866f1b828e27d55312b3952c0b164a837b01e11 100644 (file)
@@ -355,9 +355,9 @@ void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity)
 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);
+        PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 1, false);
     else
-        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
+        PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
 }
 METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
index 1c98a7d5e8ead5708fdc57e9f225eb6f22aa469b..b3ba65c5056eba74be4d85dcde6874eff9e2a885 100644 (file)
@@ -148,16 +148,23 @@ MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys)
     entity player = M_ARGV(0, entity);
 
        // WEAPONTODO
-       float xyspeed = vlen(vec2(player.velocity));
-    .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-       if (player.(weaponentity).m_weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed))
-       {
-               // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
-               xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed));
-               float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed));
-               // add the extra charge
-               player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
-       }
+    if(!WEP_CVAR(vortex, charge) || !WEP_CVAR(vortex, charge_velocity_rate))
+        return;
+
+    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+    {
+        .entity weaponentity = weaponentities[slot];
+
+       if (player.(weaponentity).m_weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && vdist(vec2(player.velocity), >, WEP_CVAR(vortex, charge_minspeed)))
+       {
+            float xyspeed = vlen(vec2(player.velocity));
+               // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
+               xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed));
+               float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed));
+               // add the extra charge
+               player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
+       }
+    }
 }
 
 void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float issecondary)
@@ -217,7 +224,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
 
 METHOD(Vortex, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    if(bot_aim(actor, 1000000, 0, 1, false))
+    if(bot_aim(actor, weaponentity, 1000000, 0, 1, false))
         PHYS_INPUT_BUTTON_ATCK(actor) = true;
     else
     {
index 64957b92e09c0b7ea7b26e8955cebcc3e784a60f..7a43efa852e0f52012cacdc62fe2ef13a4ac9bed 100644 (file)
@@ -46,7 +46,7 @@ float skill;
 .float wpcost;
 .int wpflags;
 
-bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, float applygravity);
+bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity);
 void bot_clientconnect(entity this);
 void bot_clientdisconnect(entity this);
 void bot_cmdhelp(string scmd);
index 46d1775455793097f63c3ca6ed8bc26944278d24..c278be915a2278a3eabd89966c990cf6ad44c75e 100644 (file)
@@ -323,7 +323,7 @@ vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, flo
        return targorigin + targvelocity * (shotdelay + vlen(targorigin - shotorg) / shotspeed);
 }
 
-bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity)
+bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity)
 {
        float f, r, hf, distanceratio;
        vector v;
@@ -339,8 +339,6 @@ bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshott
        hf = this.dphitcontentsmask;
        this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-
        shotspeed *= W_WeaponSpeedFactor(this);
        shotspeedupward *= W_WeaponSpeedFactor(this);
        if (!shotspeed)
index dfe10e265688a8db44aa7c794ed76eb68bd69bd4..e7c60758aec2eca3c46fe3c588a8cce4e635551e 100644 (file)
@@ -91,7 +91,7 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1,
 
 float bot_shouldattack(entity this, entity targ);
 float bot_aimdir(entity this, vector v, float maxfiredeviation);
-bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity);
+bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity);
 float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, float shotspeed, float shotspeedupward, float maxtime, float shotdelay, entity ignore);
 
 vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, float shotdelay);
index b4102cb6c09a20178f8549f1051da6afa71f5f45..68ae41670644dd1e241752f946ba0d5aeb071c54 100644 (file)
@@ -1,7 +1,7 @@
 #include "bot_null.qh"
 
 #if 0
-bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, float applygravity) { return false; }
+bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity) { return false; }
 void bot_clientconnect(entity this) { }
 void bot_clientdisconnect(entity this) { }
 void bot_cmdhelp(string scmd) { }
index 179faf1f6b6e93d35ad66df811843326594e4504..232d2cfbe880b070e3f589b7ffe031c2dd1409fe 100644 (file)
@@ -366,7 +366,8 @@ MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
  * Called by W_DecreaseAmmo
  */
 #define EV_W_DecreaseAmmo(i, o) \
-    /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** actor */            i(entity, MUTATOR_ARGV_0_entity) \
+    /** weapon entity */    i(entity, MUTATOR_ARGV_1_entity) \
     /**/
 MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
 
index a99a3551b31a7b7817c56a93e2c80983a4ff4871..1a223cec283eac2a9c05dc462dba661d005e58a3 100644 (file)
@@ -634,7 +634,7 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector
 
 void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity)
 {
-       if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor)) return;
+       if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity))) return;
 
        if ((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return;