]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add weaponentity parameter to ammo checking
authorMario <mario@smbclan.net>
Thu, 29 Sep 2016 13:47:18 +0000 (23:47 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Sep 2016 13:47:18 +0000 (23:47 +1000)
39 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/monsters/monster/wyvern.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/t_items.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/racer_weapon.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.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/hook.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/scripting.qc
qcsrc/server/defs.qh
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/selection.qh
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/weaponsystem.qc
qcsrc/server/weapons/weaponsystem.qh

index 15f1d265eba484123d6ea4c7287b0a5be8483bf5..baa9cd8a348db8123745c9da8e85ab8d17c58614 100644 (file)
@@ -905,13 +905,13 @@ METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor))
     //weapon_setup(WEP_PORTO.m_id);
 }
 
-METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor))
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor, .entity weaponentity))
 {
     TC(BallStealer, this);
     return true;
 }
 
-METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor))
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor, .entity weaponentity))
 {
     TC(BallStealer, this);
     return true;
index 6f2b50e319476319c1b3f09fdab8ece89f2616f4..823242299b76fe03458f5184b020e4636229c424 100644 (file)
@@ -46,7 +46,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity
     }
 }
 
-METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
+METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor, .entity weaponentity)) {
     TC(WyvernAttack, this);
        return true;
 }
index 01b8a50c5508d0911a7dee2270ad2a29e5535bc3..0a2bc818161775c3660ce9786b18624c6346f952 100644 (file)
@@ -64,7 +64,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
                        it.ammo_fuel = start_ammo_fuel;
                        it.weapons = start_weapons;
                        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-                       if(!client_hasweapon(it, it.(weaponentity).m_weapon, true, false))
+                       if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
                                it.(weaponentity).m_switchweapon = w_getbestweapon(it);
                });
        }
@@ -212,9 +212,9 @@ void NIX_GiveCurrentWeapon(entity this)
        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
     Weapon w = Weapons_from(nix_weapon);
        if(this.(weaponentity).m_switchweapon != w)
-               if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, true, false))
+               if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, weaponentity, true, false))
                {
-                       if(client_hasweapon(this, w, true, false))
+                       if(client_hasweapon(this, w, weaponentity, true, false))
                                W_SwitchWeapon(this, w, weaponentity);
                }
 }
index 732f4f43fd225e6def1f16681d650ed4af516cd7..c04607e99c3c80c74da7dd096dce1124da579868 100644 (file)
@@ -20,7 +20,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
                return;
        }
 
-       if((!thiswep.wr_checkammo1(thiswep, actor) && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (!(actor.items & IT_SUPERWEAPON) && !(actor.items & IT_UNLIMITED_SUPERWEAPONS)))
+       if((!thiswep.wr_checkammo1(thiswep, actor, weaponentity) && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (!(actor.items & IT_SUPERWEAPON) && !(actor.items & IT_UNLIMITED_SUPERWEAPONS)))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
                w_ready(thiswep, actor, weaponentity, fire);
@@ -81,7 +81,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea
     }
 }
 
-METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
 
@@ -91,7 +91,7 @@ METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
     return ammo_amount;
 }
 
-METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
 
index 32d51f92438c8a27c830ef31d680428ebdbb3c1c..b9d61ee931ee4e216a83953c1cededcaa7b4c698 100644 (file)
@@ -137,14 +137,14 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en
     }
 }
 
-METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
     ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
     return ammo_amount;
 }
 
-METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return false;
 }
index 6949035771def8d53ad46eddd5885735e02081e0..1753f9d1f033ff47d86f26501cef0e38cd6dfba3 100644 (file)
@@ -711,7 +711,7 @@ float Item_GiveTo(entity item, entity player)
                        FOREACH(Weapons, it != WEP_Null, {
                                if(w & (it.m_wepset))
                                {
-                                       W_DropEvent(wr_pickup, player, it.m_id, item);
+                                       W_DropEvent(wr_pickup, player, it.m_id, item, weaponentity);
                                        W_GiveWeapon(player, it.m_id);
                                }
                        });
index 41a31743f621d94fcd8c35db61f72d499feeeded..e6364a6cd7b5abe36b2f9255c0ace9b931e66f8f 100644 (file)
@@ -289,9 +289,10 @@ bool racer_frame(entity this, float dt)
 #ifdef SVQC
 
        Weapon wep1 = WEP_RACER;
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
        if (!forbidWeaponUse(this))
        if (PHYS_INPUT_BUTTON_ATCK(this))
-       if (wep1.wr_checkammo1(wep1, vehic))
+       if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
        {
                string tagname = (vehic.cnt)
                    ? (vehic.cnt = 0, "tag_fire1")
@@ -302,7 +303,6 @@ bool racer_frame(entity this, float dt)
                // Fix z-aim (for chase mode)
                crosshair_trace(this);
                w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
-               .entity weaponentity = weaponentities[0];
                wep1.wr_think(wep1, vehic, weaponentity, 1);
        }
 
index d20210c6118434d1c83dffc44729c65080bf4a4e..838f0cf42773b81469326c48d17dfe88e32c9268 100644 (file)
@@ -34,7 +34,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone
     }
 }
 
-METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor))
+METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor, .entity weaponentity))
 {
     bool isPlayer = IS_PLAYER(actor);
     entity player = isPlayer ? actor : actor.owner;
index 1068e7430dd47a8cc36b008575f2077b98071d9e..8ede8f2c5d79868116d2c7749f5c1d979f720045 100644 (file)
@@ -356,11 +356,11 @@ bool raptor_frame(entity this, float dt)
        */
 
        Weapon wep1 = WEP_RAPTOR;
+       .entity weaponentity = weaponentities[0];
        if(!forbidWeaponUse(this))
        if(PHYS_INPUT_BUTTON_ATCK(this))
-       if (wep1.wr_checkammo1(wep1, vehic))
+       if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
        {
-           .entity weaponentity = weaponentities[0];
                wep1.wr_think(wep1, vehic, weaponentity, 1);
        }
 
index 4e16efbcc903df3227c1dc30ae419ef7e4f45731..5cb0f271c52fec0effb514dff201983fa2069c02 100644 (file)
@@ -30,7 +30,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weapon
         weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
 }
-METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor)) {
+METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor, .entity weaponentity)) {
     bool isPlayer = IS_PLAYER(actor);
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
index fc116721825697485730ed0ee5bdfd4a0e3224ac..a83629f9695ae15e8a614164c3228ed6aeeaec50 100644 (file)
@@ -89,9 +89,9 @@ CLASS(Weapon, Object)
     /** (SERVER) logic to run every frame */
     METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
     /** (SERVER) checks ammo for weapon primary */
-    METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor)) {return false;}
+    METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor, .entity weaponentity)) {return false;}
     /** (SERVER) checks ammo for weapon second */
-    METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor)) {return false;}
+    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)) {}
     /** (BOTH)   precaches models/sounds used by this weapon, also sets up weapon properties */
@@ -120,9 +120,9 @@ CLASS(Weapon, Object)
     /** (CLIENT) weapon specific glow */
     METHOD(Weapon, wr_glow, vector(Weapon this, entity actor, entity wepent)) { return '0 0 0'; }
     /** (SERVER) the weapon is dropped */
-    METHOD(Weapon, wr_drop, void(Weapon this, entity actor)) {}
+    METHOD(Weapon, wr_drop, void(Weapon this, entity actor, .entity weaponentity)) {}
     /** (SERVER) a weapon is picked up */
-    METHOD(Weapon, wr_pickup, void(Weapon this, entity actor)) {}
+    METHOD(Weapon, wr_pickup, void(Weapon this, entity actor, .entity weaponentity)) {}
     /** (SERVER) update cvar based properties */
     METHOD(Weapon, wr_update, void(Weapon this)) {}
        METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
index 6cee619816128daef945ab4b9d27328f1a403aed..c453870127c451eaa140879b2af8a6b7b089a869 100644 (file)
@@ -378,7 +378,7 @@ void W_Arc_Beam_Think(entity this)
                if(this == this.owner.(weaponentity).arc_beam) { this.owner.(weaponentity).arc_beam = NULL; }
                entity own = this.owner;
                Weapon w = WEP_ARC;
-               if(!w.wr_checkammo1(w, own) && !w.wr_checkammo2(w, own))
+               if(!w.wr_checkammo1(w, own, weaponentity) && !w.wr_checkammo2(w, own, weaponentity))
                if(!(own.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
@@ -835,11 +835,11 @@ METHOD(Arc, wr_init, void(entity thiswep))
         arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4);
     }
 }
-METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0));
 }
-METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     if(WEP_CVAR(arc, bolt))
     {
@@ -858,7 +858,7 @@ METHOD(Arc, wr_killmessage, Notification(entity thiswep))
     else
         return WEAPON_ARC_MURDER;
 }
-METHOD(Arc, wr_drop, void(entity thiswep, entity actor))
+METHOD(Arc, wr_drop, void(entity thiswep, entity actor, .entity weaponentity))
 {
     weapon_dropevent_item.arc_overheat = actor.arc_overheat;
     weapon_dropevent_item.arc_cooldown = actor.arc_cooldown;
@@ -867,9 +867,9 @@ METHOD(Arc, wr_drop, void(entity thiswep, entity actor))
     for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        actor.arc_BUTTON_ATCK_prev[slot] = false;
 }
-METHOD(Arc, wr_pickup, void(entity thiswep, entity actor))
+METHOD(Arc, wr_pickup, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    if ( !client_hasweapon(actor, thiswep, false, false) &&
+    if ( !client_hasweapon(actor, thiswep, weaponentity, false, false) &&
         weapon_dropevent_item.arc_overheat > time )
     {
         actor.arc_overheat = weapon_dropevent_item.arc_overheat;
index b669db758a599a1d933626973cfc9026117603fe..c1be1fe7659e8e1362d7261eb1d37911466c22b4 100644 (file)
@@ -233,12 +233,12 @@ METHOD(Blaster, wr_setup, void(entity thiswep, entity actor))
     actor.ammo_field = ammo_none;
 }
 
-METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return true; // infinite ammo
 }
 
-METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return true; // blaster has infinite ammo
 }
index a6df25064f51dfe1657cd51df69cdeab48eea050..570e14fbbfa852f69c8159c5ecf4027132b70fb6 100644 (file)
@@ -98,8 +98,9 @@ void W_Crylink_CheckLinks(entity e)
 void W_Crylink_Dequeue_Raw(entity own, entity prev, entity me, entity next)
 {
        W_Crylink_CheckLinks(next);
-       if(me == own.crylink_lastgroup)
-               own.crylink_lastgroup = ((me == next) ? NULL : next);
+       .entity weaponentity = me.weaponentity_fld;
+       if(me == own.(weaponentity).crylink_lastgroup)
+               own.(weaponentity).crylink_lastgroup = ((me == next) ? NULL : next);
        prev.queuenext = next;
        next.queueprev = prev;
        me.classname = "spike_oktoremove";
@@ -128,8 +129,9 @@ void W_Crylink_LinkExplode(entity e, entity e2, entity directhitentity)
 
        a = bound(0, 1 - (time - e.fade_time) * e.fade_rate, 1);
 
-       if(e == e.realowner.crylink_lastgroup)
-               e.realowner.crylink_lastgroup = NULL;
+       .entity weaponentity = e.weaponentity_fld;
+       if(e == e.realowner.(weaponentity).crylink_lastgroup)
+               e.realowner.(weaponentity).crylink_lastgroup = NULL;
 
        float isprimary = !(e.projectiledeathtype & HITTYPE_SECONDARY);
 
@@ -235,7 +237,8 @@ void W_Crylink_LinkJoinEffect_Think(entity this)
        // is there at least 2 projectiles very close?
        entity e, p;
        float n;
-       e = this.owner.crylink_lastgroup;
+       .entity weaponentity = this.weaponentity_fld;
+       e = this.owner.(weaponentity).crylink_lastgroup;
        n = 0;
        if(e)
        {
@@ -317,8 +320,9 @@ void W_Crylink_Touch(entity this, entity toucher)
 
        if(totaldamage && ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 2) || ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 1) && !W_Crylink_Touch_WouldHitFriendly(this, WEP_CVAR_BOTH(crylink, isprimary, radius)))))
        {
-               if(this == this.realowner.crylink_lastgroup)
-                       this.realowner.crylink_lastgroup = NULL;
+               .entity weaponentity = this.weaponentity_fld;
+               if(this == this.realowner.(weaponentity).crylink_lastgroup)
+                       this.realowner.(weaponentity).crylink_lastgroup = NULL;
                W_Crylink_LinkExplode(this.queuenext, this, toucher);
                this.classname = "spike_oktoremove";
                delete(this);
@@ -374,6 +378,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity)
                proj = new(spike);
                proj.reset = W_Crylink_Reset;
                proj.realowner = proj.owner = actor;
+               proj.weaponentity_fld = weaponentity;
                proj.bot_dodge = true;
                proj.bot_dodgerating = WEP_CVAR_PRI(crylink, damage);
                if(shots == 1) {
@@ -450,9 +455,9 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        }
        if(WEP_CVAR_PRI(crylink, joinspread) != 0)
        {
-               actor.crylink_lastgroup = proj;
+               actor.(weaponentity).crylink_lastgroup = proj;
                W_Crylink_CheckLinks(proj);
-               actor.crylink_waitrelease = 1;
+               actor.(weaponentity).crylink_waitrelease = 1;
        }
 }
 
@@ -482,6 +487,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        for(counter = 0; counter < shots; ++counter)
        {
                proj = new(spike);
+               proj.weaponentity_fld = weaponentity;
                proj.reset = W_Crylink_Reset;
                proj.realowner = proj.owner = actor;
                proj.bot_dodge = true;
@@ -567,9 +573,9 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        }
        if(WEP_CVAR_SEC(crylink, joinspread) != 0)
        {
-               actor.crylink_lastgroup = proj;
+               actor.(weaponentity).crylink_lastgroup = proj;
                W_Crylink_CheckLinks(proj);
-               actor.crylink_waitrelease = 2;
+               actor.(weaponentity).crylink_waitrelease = 2;
        }
 }
 
@@ -588,7 +594,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
 
     if(fire & 1)
     {
-        if(actor.crylink_waitrelease != 1)
+        if(actor.(weaponentity).crylink_waitrelease != 1)
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire)))
         {
             W_Crylink_Attack(thiswep, actor, weaponentity);
@@ -598,7 +604,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
 
     if((fire & 2) && autocvar_g_balance_crylink_secondary)
     {
-        if(actor.crylink_waitrelease != 2)
+        if(actor.(weaponentity).crylink_waitrelease != 2)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire)))
         {
             W_Crylink_Attack2(thiswep, actor, weaponentity);
@@ -606,27 +612,28 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         }
     }
 
-    if((actor.crylink_waitrelease == 1 && !(fire & 1)) || (actor.crylink_waitrelease == 2 && !(fire & 2)))
+    if((actor.(weaponentity).crylink_waitrelease == 1 && !(fire & 1)) || (actor.(weaponentity).crylink_waitrelease == 2 && !(fire & 2)))
     {
-        if(!actor.crylink_lastgroup || time > actor.crylink_lastgroup.teleport_time)
+        if(!actor.(weaponentity).crylink_lastgroup || time > actor.(weaponentity).crylink_lastgroup.teleport_time)
         {
             // fired and released now!
-            if(actor.crylink_lastgroup)
+            if(actor.(weaponentity).crylink_lastgroup)
             {
                 vector pos;
                 entity linkjoineffect;
-                float isprimary = (actor.crylink_waitrelease == 1);
+                float isprimary = (actor.(weaponentity).crylink_waitrelease == 1);
 
-                pos = W_Crylink_LinkJoin(actor.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed));
+                pos = W_Crylink_LinkJoin(actor.(weaponentity).crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed));
 
                 linkjoineffect = new(linkjoineffect);
+                linkjoineffect.weaponentity_fld = weaponentity;
                 setthink(linkjoineffect, W_Crylink_LinkJoinEffect_Think);
                 linkjoineffect.nextthink = time + w_crylink_linkjoin_time;
                 linkjoineffect.owner = actor;
                 setorigin(linkjoineffect, pos);
             }
-            actor.crylink_waitrelease = 0;
-            if(!thiswep.wr_checkammo1(thiswep, actor) && !thiswep.wr_checkammo2(thiswep, actor))
+            actor.(weaponentity).crylink_waitrelease = 0;
+            if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity) && !thiswep.wr_checkammo2(thiswep, actor, weaponentity))
             if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
             {
                 // ran out of ammo!
@@ -636,20 +643,20 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         }
     }
 }
-METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     // don't "run out of ammo" and switch weapons while waiting for release
-    if(actor.crylink_lastgroup && actor.crylink_waitrelease)
+    if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease)
         return true;
 
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
     ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
     return ammo_amount;
 }
-METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     // don't "run out of ammo" and switch weapons while waiting for release
-    if(actor.crylink_lastgroup && actor.crylink_waitrelease)
+    if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease)
         return true;
 
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
index 160971b1434bd79f00649f5795577dd6b0a961f5..6ca5fa101cf9ddef4d3773b0e4e7b0909965fab1 100644 (file)
@@ -537,7 +537,7 @@ METHOD(Devastator, wr_setup, void(entity thiswep, entity actor))
     for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        actor.rl_release[slot] = 1;
 }
-METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     #if 0
     // don't switch while guiding a missile
@@ -573,7 +573,7 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor))
     return ammo_amount;
     #endif
 }
-METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return false;
 }
index 79f6cadf3784b1e79fc5d7590b7158bf33a180fa..33299f653d66dfcc59d394928350ab82eb466fbb 100644 (file)
@@ -553,13 +553,13 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         }
     }
 }
-METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
     ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
     return ammo_amount;
 }
-METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount;
     if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
index 7ba71aaa733078bfd309a2ab8a134fdb512ab59e..703162fd847681f0e321baf22f01dcf8febe1feb 100644 (file)
@@ -410,11 +410,11 @@ METHOD(Fireball, wr_setup, void(entity thiswep, entity actor))
 {
     actor.ammo_field = ammo_none;
 }
-METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return true; // infinite ammo
 }
-METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return true; // fireball has infinite ammo
 }
index d819a479c390cb861b917787df4857d6176da9e6..f74de39b0d8cea0652e24ee99b32d5e430a3f1a7 100644 (file)
@@ -409,7 +409,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity)
                actor.(weaponentity).hagar_warning = false;
 
                // we aren't checking ammo during an attack, so we must do it here
-               if(!(thiswep.wr_checkammo1(thiswep, actor) + thiswep.wr_checkammo2(thiswep, actor)))
+               if(!(thiswep.wr_checkammo1(thiswep, actor, weaponentity) + thiswep.wr_checkammo2(thiswep, actor, weaponentity)))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
@@ -427,7 +427,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
                return;
        }
 
-       if(!thiswep.wr_checkammo1(thiswep, actor))
+       if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -505,13 +505,13 @@ METHOD(Hagar, wr_setup, void(entity thiswep, entity actor))
        }
     }
 }
-METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
     ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
     return ammo_amount;
 }
-METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
     ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
index e77944076bdeb57e235b847d902e0f210229afb2..3fe8e8c042b1867c3937badd58dda32221cb52e4 100644 (file)
@@ -176,7 +176,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
 
        if(PHYS_INPUT_BUTTON_ATCK(actor))
        {
-               if(!thiswep.wr_checkammo1(thiswep, actor))
+               if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -239,13 +239,13 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         }
     }
 }
-METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
     ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
     return ammo_amount;
 }
-METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
     ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
index 716aa247cc5160d9763c2de71a323d5bf205200a..2c4edd13df0738b97668c5754beaea0a9e3b24b0 100644 (file)
@@ -288,19 +288,16 @@ METHOD(Hook, wr_setup, void(entity thiswep, entity actor))
        actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
     }
 }
-METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor))
+METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor, .entity weaponentity))
 {
     if (!thiswep.ammo_factor) return true;
-    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       .entity weaponentity = weaponentities[slot];
-       if(actor.(weaponentity).hook)
-               return actor.ammo_fuel > 0;
-    }
+
+    if(actor.(weaponentity).hook)
+       return actor.ammo_fuel > 0;
 
     return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
 }
-METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor))
+METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor, .entity weaponentity))
 {
     // infinite ammo for now
     return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
index 4b2941648404fe976b7d83786a5980a1ff6312bc..c2b5667302821b78e2d325cb3d5f54a9f1b3f167 100644 (file)
@@ -154,7 +154,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit
        }
        if(PHYS_INPUT_BUTTON_ATCK(actor))
        {
-               if(!thiswep.wr_checkammo2(thiswep, actor))
+               if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -180,7 +180,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
                return;
        }
 
-       if(!thiswep.wr_checkammo1(thiswep, actor))
+       if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -278,7 +278,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
         if(fire & 2)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
         {
-            if(!thiswep.wr_checkammo2(thiswep, actor))
+            if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
             if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
             {
                 W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -312,7 +312,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
         }
     }
 }
-METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount;
     if(WEP_CVAR(machinegun, mode) == 1)
@@ -329,7 +329,7 @@ METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
     }
     return ammo_amount;
 }
-METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount;
     if(WEP_CVAR(machinegun, mode) == 1)
index 35507c341f49d1edfee9a5c768bc200a03bb43e9..89141b17f799dd0519e3c28ea1947dce2ee44243 100644 (file)
@@ -131,7 +131,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity)
        {
                entity own = this.realowner;
                Weapon w = WEP_MINE_LAYER;
-               if(!w.wr_checkammo1(w, own))
+               if(!w.wr_checkammo1(w, own, weaponentity))
                {
                        own.cnt = WEP_MINE_LAYER.m_id;
                        int slot = weaponslot(weaponentity);
@@ -163,7 +163,7 @@ void W_MineLayer_DoRemoteExplode(entity this)
        {
                entity own = this.realowner;
                Weapon w = WEP_MINE_LAYER;
-               if(!w.wr_checkammo1(w, own))
+               if(!w.wr_checkammo1(w, own, weaponentity))
                {
                        own.cnt = WEP_MINE_LAYER.m_id;
                        int slot = weaponslot(weaponentity);
@@ -524,7 +524,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
             sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
     }
 }
-METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     //int slot = 0; // TODO: unhardcode
     // actually do // don't switch while placing a mine
@@ -536,7 +536,7 @@ METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
     //}
     //return true;
 }
-METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     if(W_MineLayer_PlacedMines(actor, false))
         return true;
index fa089083d9646a2af0caad40f3fd1de928c8f0ed..dcb8a7121638eebf6f9b66be54ff50c023f1e482 100644 (file)
@@ -381,13 +381,13 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         }
     }
 }
-METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
     ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
     return ammo_amount;
 }
-METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
     ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
index e47d5dd3234caacf5e25c15edf12af2ac4c6c588..f55d31f6d76207b65a14c7772948528bd976d68f 100644 (file)
@@ -361,12 +361,12 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone
         }
     }
 }
-METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this))
+METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this, .entity weaponentity))
 {
     // always allow infinite ammo
     return true;
 }
-METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this))
+METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this, .entity weaponentity))
 {
     // always allow infinite ammo
     return true;
index b290728e588d61c7d8e4b61fbbfecd107d7f08a2..6dbcd31c280a6593fafeb67a0f1fd338ed5674f9 100644 (file)
@@ -200,13 +200,13 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         }
     }
 }
-METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
     ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
     return ammo_amount;
 }
-METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
     ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
index ca5ecf4dd652ead869c7026a07489271eb5e4106..2104c6edb84b9110fa7dd8fba80ffeded172e5bd 100644 (file)
@@ -667,7 +667,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         }
     }
 }
-METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount;
     if(WEP_CVAR(seeker, type) == 1)
@@ -682,7 +682,7 @@ METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor))
     }
     return ammo_amount;
 }
-METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount;
     if(WEP_CVAR(seeker, type) == 1)
index 28cbe69bbe5a1a04a7a52f400127070ff5d49732..ea756dfc762be0dcd496b58a98b0d883aac9ed62 100644 (file)
@@ -726,11 +726,11 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent
         }
     }
 }
-METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     return true; // infinite ammo
 }
-METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     // shockwave has infinite ammo
     return true;
index 13de3fb255bb7d393a162fb1f50f79ccb96f10f9..80d485e4b804b29c482bc81fb9023ab0b700c93f 100644 (file)
@@ -199,7 +199,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f
 // alternate secondary weapon frames
 void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       if (!thiswep.wr_checkammo2(thiswep, actor))
+       if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -213,7 +213,7 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity
 }
 void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       if (!thiswep.wr_checkammo2(thiswep, actor))
+       if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
@@ -285,13 +285,13 @@ METHOD(Shotgun, wr_setup, void(entity thiswep, entity actor))
 {
     actor.ammo_field = ammo_none;
 }
-METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
     ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
     return ammo_amount;
 }
-METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     if(IS_BOT_CLIENT(actor))
     if(vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
index 8fa9e7fe5bffd1febe6e47dc2ac712cab89f9586..b3cae67a6a995e4e59f91e53299b0e7bebe280d9 100644 (file)
@@ -465,8 +465,8 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
 #ifdef SVQC
 
 // infinite ammo
-METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor)) { return true; }
-METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor)) { return true; }
+METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor, .entity weaponentity)) { return true; }
+METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor, .entity weaponentity)) { return true; }
 
 METHOD(Tuba, wr_suicidemessage, Notification(Tuba this))
 {
index 01c884785ac686f5d0dd96f3eb2dabdeba5680e4..25464b2439d669646faa408d0f68c47a3d433b7b 100644 (file)
@@ -438,14 +438,14 @@ METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor))
     actor.ammo_field = (thiswep.ammo_field);
     actor.vaporizer_lasthit = 0;
 }
-METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
     float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo;
     ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
     return ammo_amount;
 }
-METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     if(!WEP_CVAR_SEC(vaporizer, ammo))
         return true;
index 351f8fc27a603acf68fd67f46b0505e8230a0667..331885b329d72e7f4e31352c288ffcd3534eaaea 100644 (file)
@@ -334,13 +334,13 @@ METHOD(Vortex, wr_setup, void(entity thiswep, entity actor))
 {
     actor.vortex_lasthit = 0;
 }
-METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
     ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
     return ammo_amount;
 }
-METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     if(WEP_CVAR(vortex, secondary))
     {
index b3bc26bbfecdae804db45248d322561ef2417a39..c721c0639ed134df077cf5223494d0c3b056d812 100644 (file)
@@ -585,8 +585,10 @@ 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, true, false))
+                       if(client_hasweapon(this, WEP_DEVASTATOR, weaponentity, true, false))
                        {
                                this.movement_x = maxspeed;
 
@@ -600,7 +602,6 @@ void havocbot_movetogoal(entity this)
                                        return;
                                }
 
-                               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                                this.(weaponentity).m_switchweapon = WEP_DEVASTATOR;
                                this.v_angle_x = 90;
                                PHYS_INPUT_BUTTON_ATCK(this) = true;
@@ -997,8 +998,9 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon)
        if (this.weapon_load[new_weapon] < 0)
        {
                bool other_weapon_available = false;
+               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                       if(it.wr_checkammo1(it, this) + it.wr_checkammo2(it, this))
+                       if(it.wr_checkammo1(it, this, weaponentity) + it.wr_checkammo2(it, this, weaponentity))
                                other_weapon_available = true;
                ));
                if(other_weapon_available)
@@ -1027,7 +1029,7 @@ void havocbot_chooseweapon(entity this)
                // If no weapon was chosen get the first available weapon
                if(this.(weaponentity).m_weapon==WEP_Null)
                FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                       if(client_hasweapon(this, it, true, false))
+                       if(client_hasweapon(this, it, weaponentity, true, false))
                        {
                                this.(weaponentity).m_switchweapon = it;
                                return;
@@ -1073,7 +1075,7 @@ void havocbot_chooseweapon(entity this)
                if ( distance > bot_distance_far ) {
                        for(i=0; i < Weapons_COUNT && bot_weapons_far[i] != -1 ; ++i){
                                w = bot_weapons_far[i];
-                               if ( client_hasweapon(this, Weapons_from(w), true, false) )
+                               if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
                                {
                                        if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
                                                continue;
@@ -1087,7 +1089,7 @@ void havocbot_chooseweapon(entity this)
                if ( distance > bot_distance_close) {
                        for(i=0; i < Weapons_COUNT && bot_weapons_mid[i] != -1 ; ++i){
                                w = bot_weapons_mid[i];
-                               if ( client_hasweapon(this, Weapons_from(w), true, false) )
+                               if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
                                {
                                        if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
                                                continue;
@@ -1100,7 +1102,7 @@ void havocbot_chooseweapon(entity this)
                // Choose weapons for close distance
                for(i=0; i < Weapons_COUNT && bot_weapons_close[i] != -1 ; ++i){
                        w = bot_weapons_close[i];
-                       if ( client_hasweapon(this, Weapons_from(w), true, false) )
+                       if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
                        {
                                if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
                                        continue;
index 19baa587d5bc89d64275d45ee673f13489b7139f..68b7da46a85eb6c91d3f25fd3e7552a4f84f2246 100644 (file)
@@ -570,7 +570,7 @@ float bot_cmd_select_weapon(entity this)
 
        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 
-       if(client_hasweapon(this, Weapons_from(id), true, false))
+       if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
                this.(weaponentity).m_switchweapon = Weapons_from(id);
        else
                return CMD_STATUS_ERROR;
index ce9d17403550d89dff8c2195373462094570d897..e60743c51397f2e2eb8fa0fb73f79a4c8a694898 100644 (file)
@@ -116,7 +116,7 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 
 // WEAPONTODO
 .float autoswitch;
-bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain);
 void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire);
 void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire);
 // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
index 809becc33ff8cc115788dc6f3f7c43af64dad248..f8ce9e750cd91091d8e3e54fae0f0857d6108afa 100644 (file)
@@ -38,7 +38,7 @@ void Weapon_whereis(Weapon this, entity cl)
        });
 }
 
-bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
+bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain)
 {
        float f = 0;
 
@@ -69,7 +69,7 @@ bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
                        }
                        else
                        {
-                               f = wpn.wr_checkammo1(wpn, this) + wpn.wr_checkammo2(wpn, this);
+                               f = wpn.wr_checkammo1(wpn, this, weaponentity) + wpn.wr_checkammo2(wpn, this, weaponentity);
 
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
                                if(wpn == WEP_MINE_LAYER)
@@ -166,7 +166,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl
 
                ++c;
 
-               if(!skipmissing || client_hasweapon(this, wep, true, false))
+               if(!skipmissing || client_hasweapon(this, wep, weaponentity, true, false))
                {
                        if(switchtonext)
                                return weaponwant;
@@ -223,7 +223,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl
                        --c;
                        if(c == 0)
                        {
-                               client_hasweapon(this, wep, true, true);
+                               client_hasweapon(this, wep, weaponentity, true, true);
                                break;
                        }
                }
@@ -263,7 +263,7 @@ void W_SwitchWeapon(entity this, Weapon w, .entity weaponentity)
 {
        if(this.(weaponentity).m_switchweapon != w)
        {
-               if(client_hasweapon(this, w, true, true))
+               if(client_hasweapon(this, w, weaponentity, true, true))
                        W_SwitchWeapon_Force(this, w, weaponentity);
                else
                        this.(weaponentity).selectweapon = w.m_id; // update selectweapon anyway
@@ -317,7 +317,7 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity)
 void W_LastWeapon(entity this, .entity weaponentity)
 {
        Weapon wep = Weapons_from(this.(weaponentity).cnt);
-       if (client_hasweapon(this, wep, true, false))
+       if (client_hasweapon(this, wep, weaponentity, true, false))
                W_SwitchWeapon(this, wep, weaponentity);
        else
                W_SwitchToOtherWeapon(this, weaponentity);
index 336dc1304adf8f7f0d13fbb7ce74611568fbe997..68c15139ea7dee762d87bf8a593f377f8c70d118 100644 (file)
@@ -4,7 +4,7 @@
 void Send_WeaponComplain(entity e, float wpn, float type);
 
 .float hasweapon_complain_spam;
-bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain);
 
 .int weaponcomplainindex;
 float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
index f3a72412bb1955abad7f2f7537c3dc021bfccccd..f36a0eebfad18a3a9e89cfb3d83f068677930f48 100644 (file)
@@ -47,7 +47,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        wep.colormap = own.colormap;
        wep.glowmod = weaponentity_glowmod(info, own, own.clientcolors, own.(weaponentity));
 
-       W_DropEvent(wr_drop,own,wpn,wep);
+       W_DropEvent(wr_drop,own,wpn,wep,weaponentity);
 
        if(WepSet_FromWeapon(Weapons_from(wpn)) & WEPSET_SUPERWEAPONS)
        {
index f5330d08edf2a963bdc3e0fdf8c52c734a3674bb..a37462eae8ed1d40de3365e2785680422d882625 100644 (file)
@@ -220,8 +220,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary
 {
        if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
        bool ammo = false;
-       if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor);
-       else ammo = thiswep.wr_checkammo1(thiswep, actor);
+       if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
+       else ammo = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
        if (ammo) return true;
        // always keep the Mine Layer if we placed mines, so that we can detonate them
        if (thiswep == WEP_MINE_LAYER)
@@ -243,8 +243,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary
 
        // check if the other firing mode has enough ammo
        bool ammo_other = false;
-       if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor);
-       else ammo_other = thiswep.wr_checkammo2(thiswep, actor);
+       if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
+       else ammo_other = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
        if (ammo_other)
        {
                if (time - actor.prevwarntime > 1)
@@ -742,7 +742,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
                                }
                                // switch away if the amount of ammo is not enough to keep using this weapon
                                Weapon w = actor.(weaponentity).m_weapon;
-                               if (!(w.wr_checkammo1(w, actor) + w.wr_checkammo2(w, actor)))
+                               if (!(w.wr_checkammo1(w, actor, weaponentity) + w.wr_checkammo2(w, actor, weaponentity)))
                                {
                                        actor.clip_load = -1;  // reload later
                                        W_SwitchToOtherWeapon(actor, weaponentity);
@@ -778,9 +778,9 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
        actor.clip_load = actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = -1;
 }
 
-void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item)
+void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)
 {
        Weapon w = Weapons_from(weapon_type);
        weapon_dropevent_item = weapon_item;
-       w.event(w, player);
+       w.event(w, player, weaponentity);
 }
index 389a52bcc4e91e0f313271a3a8f03f6b317e1592..2fb0f9956833236250c0266fc70b91a2b412d21a 100644 (file)
@@ -16,7 +16,7 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector
 
 void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity);
 
-void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item);
+void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity);
 
 void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound);