]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Weapons: pass weaponentity field instead of slot
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 2 Nov 2015 02:01:24 +0000 (13:01 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 2 Nov 2015 02:12:09 +0000 (13:12 +1100)
57 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/monster/wyvern.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/casings.qc
qcsrc/common/turrets/turret.qh
qcsrc/common/turrets/turret/ewheel_weapon.qc
qcsrc/common/turrets/turret/flac_weapon.qc
qcsrc/common/turrets/turret/hellion_weapon.qc
qcsrc/common/turrets/turret/hk_weapon.qc
qcsrc/common/turrets/turret/machinegun_weapon.qc
qcsrc/common/turrets/turret/mlrs_weapon.qc
qcsrc/common/turrets/turret/phaser_weapon.qc
qcsrc/common/turrets/turret/plasma_weapon.qc
qcsrc/common/turrets/turret/tesla_weapon.qc
qcsrc/common/turrets/turret/walker_weapon.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/hmg.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/rpc.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/scripting.qc
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/mutator_nades.qc
qcsrc/server/mutators/mutator/mutator_overkill.qc
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/weaponsystem.qc
qcsrc/server/weapons/weaponsystem.qh

index 9a8df7854666d17508dfae51a38d7450bdc07bad..69ad8f5f3a79b20f9566ce357a79fa7d14a50ae5 100644 (file)
@@ -132,7 +132,7 @@ void DropOwner(void)
 
 void GiveBall(entity plyr, entity ball)
 {SELFPARAM();
-       int slot = 0; // TODO: find ballstealer
+       .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
        entity ownr = ball.owner;
        if(ownr)
        {
@@ -141,7 +141,7 @@ void GiveBall(entity plyr, entity ball)
                if(ownr.metertime)
                {
                        ownr.metertime = 0;
-                       ownr.weaponentity[slot].state = WS_READY;
+                       ownr.(weaponentity).state = WS_READY;
                }
                WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
        }
@@ -179,8 +179,8 @@ void GiveBall(entity plyr, entity ball)
                ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
        }
 
-       plyr.weaponentity[slot].weapons = plyr.weapons;
-       plyr.weaponentity[slot].switchweapon = plyr.weapon;
+       plyr.(weaponentity).weapons = plyr.weapons;
+       plyr.(weaponentity).switchweapon = plyr.weapon;
        plyr.weapons = WEPSET(NEXBALL);
        setself(plyr);
        Weapon w = WEP_NEXBALL;
@@ -210,8 +210,8 @@ void DropBall(entity ball, vector org, vector vel)
        if(ball.owner.metertime)
        {
                ball.owner.metertime = 0;
-               int slot = 0; // TODO: find ballstealer
-               ball.owner.weaponentity[slot].state = WS_READY;
+               .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
+               ball.owner.(weaponentity).state = WS_READY;
        }
 
        WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
@@ -855,34 +855,34 @@ float ball_customize()
        return true;
 }
 
-       METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, int slot, int fire))
+       METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
        {
                if(fire & 1)
-                       if(weapon_prepareattack(thiswep, actor, slot, false, autocvar_g_balance_nexball_primary_refire))
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire))
                                if(autocvar_g_nexball_basketball_meter)
                                {
                                        if(self.ballcarried && !self.metertime)
                                                self.metertime = time;
                                        else
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                                }
                                else
                                {
                                        W_Nexball_Attack(-1);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                                }
                if(fire & 2)
-                       if(weapon_prepareattack(thiswep, actor, slot, true, autocvar_g_balance_nexball_secondary_refire))
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
                        {
                                W_Nexball_Attack2();
-                               weapon_thinkf(actor, slot, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
+                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
                        }
 
                if(!(fire & 1) && self.metertime && self.ballcarried)
                {
                        W_Nexball_Attack(time - self.metertime);
                        // DropBall or stealing will set metertime back to 0
-                       weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                }
        }
        METHOD(BallStealer, wr_setup, void(BallStealer thiswep))
@@ -968,16 +968,16 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
                }
                else
                {
-                       int slot = 0; // TODO
-                       if(self.weaponentity[slot].weapons)
+                       .entity weaponentity = weaponentities[0]; // TODO
+                       if(self.(weaponentity).weapons)
                        {
-                               self.weapons = self.weaponentity[slot].weapons;
+                               self.weapons = self.(weaponentity).weapons;
                                Weapon w = WEP_NEXBALL;
                                w.wr_resetplayer(w);
-                               self.switchweapon = self.weaponentity[slot].switchweapon;
+                               self.switchweapon = self.(weaponentity).switchweapon;
                                W_SwitchWeapon(self.switchweapon);
 
-               self.weaponentity[slot].weapons = '0 0 0';
+                               self.(weaponentity).weapons = '0 0 0';
                        }
                }
 
@@ -998,8 +998,8 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
 {
        SELFPARAM();
        this.metertime = 0;
-       int slot = 0;
-       this.weaponentity[slot].weapons = '0 0 0';
+       .entity weaponentity = weaponentities[0];
+       this.(weaponentity).weapons = '0 0 0';
 
        if (nexball_mode & NBM_BASKETBALL)
                this.weapons |= WEPSET(NEXBALL);
index 36f4a2584e9fe9332e6c1dbb19262348aa5137d7..72b8d158634e06c3c16834e951553154038369e5 100644 (file)
@@ -41,20 +41,20 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike));
 
 void M_Mage_Attack_Spike(vector dir);
 void M_Mage_Attack_Push();
-METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, int slot, int fire)) {
+METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire)) {
     if (fire & 1)
-    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, slot, false, 0.2)) {
+    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) {
         if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range;
         actor.enemy = Monster_FindTarget(actor);
         W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
        if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
         M_Mage_Attack_Spike(w_shotdir);
-        weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, w_ready);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
     if (fire & 2)
-    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, slot, true, 0.5)) {
+    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
         M_Mage_Attack_Push();
-        weapon_thinkf(actor, slot, WFRAME_FIRE2, 0, w_ready);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
@@ -356,6 +356,7 @@ void M_Mage_Defend_Shield()
 
 float M_Mage_Attack(float attack_type, entity targ)
 {SELFPARAM();
+    .entity weaponentity = weaponentities[0];
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -363,7 +364,8 @@ float M_Mage_Attack(float attack_type, entity targ)
                        if(random() <= 0.7)
                        {
                                Weapon wep = WEP_MAGE_SPIKE;
-                               wep.wr_think(wep, self, 0, 2);
+
+                               wep.wr_think(wep, self, weaponentity, 2);
                                return true;
                        }
 
@@ -385,7 +387,7 @@ float M_Mage_Attack(float attack_type, entity targ)
                                        self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_spike_delay);
                                        self.anim_finished = time + 1;
                                        Weapon wep = WEP_MAGE_SPIKE;
-                                       wep.wr_think(wep, self, 0, 1);
+                                       wep.wr_think(wep, self, weaponentity, 1);
                                        return true;
                                }
                        }
index 01a006e13f85c478653006e205cab5bb6b16514e..e1f063dbb64aded9ebe95fa9db2be39dbd2aade2 100644 (file)
@@ -50,10 +50,10 @@ float autocvar_g_monster_spider_attack_bite_delay;
 
 void M_Spider_Attack_Web();
 
-METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, int slot, int fire)) {
+METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, slot, false, autocvar_g_monster_spider_attack_web_delay)) {
+    if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay)) {
                if (!isPlayer) {
                        actor.spider_web_delay = time + 3;
                        setanim(actor, actor.anim_shoot, true, true, true);
@@ -64,17 +64,17 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, int slot
         W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
        if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
                M_Spider_Attack_Web();
-        weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, w_ready);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
         return;
     }
     if (fire & 2)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, true, 0.5)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
        if (isPlayer) {
                actor.enemy = Monster_FindTarget(actor);
                actor.attack_range = 60;
        }
        Monster_Attack_Melee(actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true);
-        weapon_thinkf(actor, slot, WFRAME_FIRE2, 0, w_ready);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
@@ -155,17 +155,18 @@ void M_Spider_Attack_Web()
 
 bool M_Spider_Attack(int attack_type, entity targ)
 {SELFPARAM();
+    .entity weaponentity = weaponentities[0];
        switch(attack_type)
        {
                Weapon wep = WEP_SPIDER_ATTACK;
                case MONSTER_ATTACK_MELEE:
                {
-                       wep.wr_think(wep, self, 0, 2);
+                       wep.wr_think(wep, self, weaponentity, 2);
                        return true;
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       wep.wr_think(wep, self, 0, 1);
+                       wep.wr_think(wep, self, weaponentity, 1);
                        return true;
                }
        }
index 5cac8982920d5e781c00e67adac8b94f5d0f21ae..ebf178f40dae87455ec2e9c76e98fe3f47cf7f9c 100644 (file)
@@ -48,9 +48,9 @@ float autocvar_g_monster_wyvern_attack_fireball_speed;
 void M_Wyvern_Attack_Fireball_Explode();
 void M_Wyvern_Attack_Fireball_Touch();
 
-METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, int slot, int fire)) {
+METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire)) {
     if (fire & 1)
-    if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, slot, false, 1.2)) {
+    if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) {
         if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
                if (IS_MONSTER(actor)) {
                        actor.attack_finished_single[0] = time + 1.2;
@@ -73,7 +73,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, int slot
                missile.touch = M_Wyvern_Attack_Fireball_Touch;
                CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
 
-        weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, w_ready);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
 }
 
@@ -121,6 +121,7 @@ void M_Wyvern_Attack_Fireball_Touch()
 float M_Wyvern_Attack(float attack_type, entity targ)
 {
        SELFPARAM();
+       .entity weaponentity = weaponentities[0];
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -128,7 +129,7 @@ float M_Wyvern_Attack(float attack_type, entity targ)
                {
                        w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin);
                        Weapon wep = WEP_WYVERN_ATTACK;
-                       wep.wr_think(wep, self, 0, 1);
+                       wep.wr_think(wep, self, weaponentity, 1);
                        return true;
                }
        }
index c91d0d0762e2f268a1e77f55ff93b6bd9e4cea42..46ecb3accd9102cf2aaa1e238bab59bde5bcab52 100644 (file)
@@ -911,13 +911,13 @@ void Monster_Move(float runspeed, float walkspeed, float stpspeed)
 
 void Monster_Remove(entity mon)
 {
-       int slot = 0;
+       .entity weaponentity = weaponentities[0];
        if(!mon) { return; }
 
        if(!MUTATOR_CALLHOOK(MonsterRemove, mon))
                Send_Effect(EFFECT_ITEM_PICKUP, mon.origin, '0 0 0', 1);
 
-       if(mon.weaponentity[slot]) { remove(mon.weaponentity[slot]); }
+       if(mon.(weaponentity)) { remove(mon.(weaponentity)); }
        if(mon.iceblock) { remove(mon.iceblock); }
        WaypointSprite_Kill(mon.sprite);
        remove(mon);
index 249757b7b5d16591cfadb8e8290873e87c401895..5400030b428c4ebe542240ac793ce2bd9e320c87 100644 (file)
@@ -12,8 +12,9 @@ REGISTER_MUTATOR(casings, true);
 #ifdef SVQC
 void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
 {SELFPARAM();
-    int slot = 0; // TODO: parameter
-    vector org = self.origin + self.view_ofs + self.weaponentity[slot].spawnorigin.x * v_forward - self.weaponentity[slot].spawnorigin.y * v_right + self.weaponentity[slot].spawnorigin.z * v_up;
+    .entity weaponentity = weaponentities[0]; // TODO: parameter
+    entity wep = self.(weaponentity);
+    vector org = self.origin + self.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
 
     if (!sound_allowed(MSG_BROADCAST, casingowner))
         casingtype |= 0x80;
index ab8ee0111589064d37cf8159615e0d3703832ec9..dcb641404a2e869e6e05cc2c7a4e903aa809dc1a 100644 (file)
@@ -43,11 +43,14 @@ CLASS(Turret, Object)
 
     }
     ATTRIB(Turret, m_weapon, Weapon, WEP_Null)
+#ifdef SVQC
     /** (SERVER) called when turret attacks */
     METHOD(Turret, tr_attack, void(Turret this)) {
         Weapon w = this.m_weapon;
-        w.wr_think(w, self, 0, 1);
+        .entity weaponentity = weaponentities[0];
+        w.wr_think(w, self, weaponentity, 1);
     }
+#endif
     /** (ALL) */
     METHOD(Turret, tr_config, void(Turret this)) {
         // TODO
index 874d0aa43225ad122008994aae18221a37d5411d..dd1bbb363527829ff0b30e270cefea8a59c6cd71 100644 (file)
@@ -16,17 +16,17 @@ REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack));
 #ifdef SVQC
 
 void turret_initparams(entity);
-METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
 
         turret_do_updates(actor);
index e480d084e169f95ea3d74c9391d8d689afe480aa..1a30e254cf53bc0ad09ac3575711834baff97f8d 100644 (file)
@@ -16,10 +16,10 @@ REGISTER_WEAPON(FLAC, NEW(FlacAttack));
 #ifdef SVQC
 
 void turret_flac_projectile_think_explode();
-METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
@@ -27,7 +27,7 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, int slot, int fi
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.tur_impacttime = 10;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
 
         turret_tag_fire_update();
index 336af150af201bdfa71736aeff9cc45838acc9b2..20eee23587f7f40f88371941739d4433f6ab291f 100644 (file)
@@ -19,10 +19,10 @@ float autocvar_g_turrets_unit_hellion_shot_speed_gain;
 float autocvar_g_turrets_unit_hellion_shot_speed_max;
 
 void turret_hellion_missile_think();
-METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
@@ -30,7 +30,7 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, int slot, int
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.shot_radius = 500;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         if (!isPlayer) {
             if (actor.tur_head.frame != 0)
index 46a6f5ba3558c137ddc3c270060fb3ab54d9a219..12589f15e3e4a229410b4cf7765f863b63ba9a81 100644 (file)
@@ -23,18 +23,18 @@ float autocvar_g_turrets_unit_hk_shot_speed_max;
 float autocvar_g_turrets_unit_hk_shot_speed_turnrate;
 
 void turret_hk_missile_think();
-METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
        bool isPlayer = IS_PLAYER(actor);
        if (fire & 1)
-       if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+       if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
                if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, FALSE, FALSE);
         te_explosion (missile.origin);
index 78de4efb1e34a34c7f07d56c3515ac6c0a4d09f7..4c7b5b752b79f52fbd81ea73ad96268e384850ea 100644 (file)
@@ -17,18 +17,18 @@ REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack));
 
 void W_MachineGun_MuzzleFlash();
 
-METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(machinegun, sustained_refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(machinegun, sustained_refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
         }
         fireBullet (actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, 0);
         W_MachineGun_MuzzleFlash();
index 666810da808f767da1814b83bda2ade668896ee3..dde35f2780a4415c70290ff57837dd9ccc86f3eb 100644 (file)
@@ -15,11 +15,11 @@ REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack));
 
 #ifdef SVQC
 
-METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(machinegun, sustained_refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(machinegun, sustained_refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
@@ -27,7 +27,7 @@ METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, int slot,
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.shot_radius = 500;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
         }
         turret_tag_fire_update();
         entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS.m_id, PROJECTILE_ROCKET, TRUE, TRUE);
index 7d5a967aa70bfe89f52162dd6d95d4e857d30a3a..69717ed3e3b422c96df780ed321bf305bd024c65 100644 (file)
@@ -18,11 +18,11 @@ void beam_think();
 
 .int fireflag;
 
-METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
@@ -30,7 +30,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, int slot
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.shot_speed = 1;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         entity beam = spawn();
         beam.ticrate = 0.1; //autocvar_sys_ticrate;
index f8cf670e1c1e6c329a016fc25986b47bae9879df..caaae6fe96296738131ad654c7afe359f7acef65 100644 (file)
@@ -15,17 +15,17 @@ REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
 
 #ifdef SVQC
 
-METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
        bool isPlayer = IS_PLAYER(actor);
        if (fire & 1)
-       if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+       if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
                if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA.m_id, PROJECTILE_ELECTRO_BEAM, true, true);
         missile.missile_flags = MIF_SPLASH;
index a40e1ad9ed7f20ac8e3a3d0a3c0ae9d30e48fa0e..772fced69a964e68b9ae787a57050aadb53e7f84 100644 (file)
@@ -16,17 +16,17 @@ REGISTER_WEAPON(TESLA, NEW(TeslaCoilTurretAttack));
 #ifdef SVQC
 
 entity toast(entity from, float range, float damage);
-METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
 
         float d = actor.shot_dmg;
index b2b960d5165a97dcee7a92a0ff0f659409b47923..192cbfc6d399e9c13b232e2603471db5e8a07653 100644 (file)
@@ -15,17 +15,17 @@ REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack));
 
 #ifdef SVQC
 
-METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         sound (actor, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
         fireBullet (actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_WALK_GUN.m_id, 0);
index c92bfadd6c29157ab3746f9c327e8a4983c34c99..38e343f65e8827a9a9e5a7b3c33b1e0de5638b7b 100644 (file)
@@ -321,7 +321,8 @@ float racer_frame()
                // Fix z-aim (for chase mode)
                crosshair_trace(player);
                w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
-               wep1.wr_think(wep1, self, 0, 1);
+               .entity weaponentity = weaponentities[0];
+               wep1.wr_think(wep1, self, weaponentity, 1);
        }
 
        if(autocvar_g_vehicle_racer_rocket_locktarget)
index 50c09d132f74294dd6002675bc36edf05da4d712..21f4313c6337a716d37b8a09caa7b3a1c4ca704a 100644 (file)
@@ -42,13 +42,13 @@ float autocvar_g_vehicle_racer_rocket_climbspeed;
 float autocvar_g_vehicle_racer_rocket_locked_maxangle;
 
 void racer_fire_rocket(entity player, vector org, vector dir, entity trg);
-METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
     bool isPlayer = IS_PLAYER(actor);
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     if (fire & 1)
-    if (weapon_prepareattack(thiswep, player, slot, false, autocvar_g_vehicle_racer_cannon_refire)) {
+    if (weapon_prepareattack(thiswep, player, weaponentity, false, autocvar_g_vehicle_racer_cannon_refire)) {
         if (veh) {
             veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost;
             veh.wait = time;
@@ -61,13 +61,13 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, int slot, int f
                                autocvar_g_vehicle_racer_cannon_damage, autocvar_g_vehicle_racer_cannon_radius, autocvar_g_vehicle_racer_cannon_force,  0,
                                DEATH_VH_WAKI_GUN.m_id, PROJECTILE_WAKICANNON, 0, true, true, player);
         bolt.velocity = normalize(dir) * autocvar_g_vehicle_racer_cannon_speed;
-        weapon_thinkf(player, slot, WFRAME_FIRE1, 0, w_ready);
+        weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
     if (fire & 2)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, slot, false, 0.2)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) {
         if (isPlayer) W_SetupShot_Dir(actor, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0);
         racer_fire_rocket(player, w_shotorg, w_shotdir, NULL);
-        weapon_thinkf(actor, slot, WFRAME_FIRE2, 0, w_ready);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
index 7d90dd485b42f1f89fdd0172faf9adfac83c51ff..712b2caf06953cb1f87cbad34bbae13917aa889b 100644 (file)
@@ -392,7 +392,8 @@ float raptor_frame()
        if(player.BUTTON_ATCK)
        if (wep1.wr_checkammo1(wep1))
        {
-               wep1.wr_think(wep1, self, 0, 1);
+           .entity weaponentity = weaponentities[0];
+               wep1.wr_think(wep1, self, weaponentity, 1);
        }
 
        if(self.vehicle_flags  & VHF_SHIELDREGEN)
@@ -411,7 +412,8 @@ float raptor_frame()
                if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
                if(player.BUTTON_ATCK2)
                {
-                       wep2a.wr_think(wep2a, self, 1, 2);
+                   .entity weaponentity = weaponentities[1];
+                       wep2a.wr_think(wep2a, self, weaponentity, 2);
                        raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
                        raptor.lip   = time;
                }
@@ -422,7 +424,8 @@ float raptor_frame()
                if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire)
                if(player.BUTTON_ATCK2)
                {
-                       wep2b.wr_think(wep2b, self, 1, 2);
+                   .entity weaponentity = weaponentities[1];
+                       wep2b.wr_think(wep2b, self, weaponentity, 2);
                        raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire;
                        raptor.lip   = time;
                }
index 3f8d2767b06ec3bc53d3a324204c5a18f9086aa1..6783a92cc9a4aa1d128ded8cdb73572b3b30e337 100644 (file)
@@ -51,14 +51,14 @@ float autocvar_g_vehicle_raptor_bomblet_radius;
 float autocvar_g_vehicle_raptor_bomblet_force;
 float autocvar_g_vehicle_raptor_bomblet_explode_delay;
 
-METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     // 1 [wait] 1 [wait] 2 [wait] 2 [wait] [wait]
     float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4);
     if (fire & 1)
-    if (weapon_prepareattack(thiswep, player, slot, false, t)) {
+    if (weapon_prepareattack(thiswep, player, weaponentity, false, t)) {
         if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0);
         vector org = w_shotorg;
         vector dir = w_shotdir;
@@ -74,7 +74,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, int slot, int
                                org, normalize(dir + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
                                autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force,  0,
                                DEATH_VH_RAPT_CANNON.m_id, PROJECTILE_RAPTORCANNON, 0, true, true, player);
-        weapon_thinkf(player, slot, WFRAME_FIRE1, 0, w_ready);
+        weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
 }
 METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) {
@@ -88,15 +88,15 @@ METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) {
 float autocvar_g_vehicle_raptor_bombs_refire;
 
 void raptor_bombdrop();
-METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     if (fire & 2)
-    if (!isPlayer || weapon_prepareattack(thiswep, player, slot, true, autocvar_g_vehicle_raptor_bombs_refire)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_bombs_refire)) {
         if (veh) setself(veh);
         raptor_bombdrop();
-        weapon_thinkf(player, slot, WFRAME_FIRE2, 0, w_ready);
+        weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
@@ -109,12 +109,12 @@ void raptor_flare_think();
 void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force);
 void raptor_flare_touch();
 
-METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, int slot, int fire)) {
+METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     if (fire & 2)
-    if (!isPlayer || weapon_prepareattack(thiswep, player, slot, true, autocvar_g_vehicle_raptor_flare_refire)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_flare_refire)) {
         for(int i = 0; i < 3; ++i) {
             entity _flare = spawn();
             setmodel(_flare, MDL_VEH_RAPTOR_FLARE);
@@ -134,7 +134,7 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, int slot, int f
             _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
             _flare.touch = raptor_flare_touch;
         }
-        weapon_thinkf(player, slot, WFRAME_FIRE2, 0, w_ready);
+        weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
index 63ce4c31a7ef50eda58cb609d18a28868c636946..3a878a461d1f933a93160409ae4f873e5aae5ff7 100644 (file)
@@ -3,6 +3,19 @@
 #include "../items/item/pickup.qh"
 
 const int MAX_WEAPONSLOTS = 2;
+.entity weaponentities[MAX_WEAPONSLOTS];
+
+int weaponslot(.entity weaponentity)
+{
+       for (int i = 0; i < MAX_WEAPONSLOTS; ++i)
+       {
+               if (weaponentities[i] == weaponentity)
+               {
+                       return i;
+               }
+       }
+       return 0;
+}
 
 .int ammo_shells;
 .int ammo_nails;
@@ -52,7 +65,7 @@ CLASS(Weapon, Object)
     /** (SERVER) setup weapon data */
     METHOD(Weapon, wr_setup, void(Weapon this)) {}
     /** (SERVER) logic to run every frame */
-    METHOD(Weapon, wr_think, void(Weapon this, entity actor, int slot, int fire)) {}
+    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)) {return false;}
     /** (SERVER) checks ammo for weapon second */
index 07ddea83317a6bcc09179830fa0a6279085227d7..a9fc3fdb6e048a24afdbf518862f5314db748674 100644 (file)
@@ -656,7 +656,7 @@ void Arc_Smoke()
                                );
                        }
                }
-               METHOD(Arc, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        Arc_Player_SetHeat(actor);
                        Arc_Smoke();
@@ -669,21 +669,21 @@ void Arc_Smoke()
                                {
                                        #if 0
                                        if(actor.animstate_startframe == actor.anim_shoot.x && actor.animstate_numframes == actor.anim_shoot.y)
-                                               weapon_thinkf(actor, slot, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
                                        else
                                        #endif
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
                                }
 
                                if((!actor.arc_beam) || wasfreed(actor.arc_beam))
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, boolean(fire & 2), 0))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, boolean(fire & 2), 0))
                                        {
                                                W_Arc_Beam(boolean(fire & 2));
 
                                                if(!actor.arc_BUTTON_ATCK_prev)
                                                {
-                                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
+                                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
                                                        actor.arc_BUTTON_ATCK_prev = true;
                                                }
                                        }
@@ -695,18 +695,19 @@ void Arc_Smoke()
                        if(actor.arc_BUTTON_ATCK_prev)
                        {
                                sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
-                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
+                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
+                               int slot = weaponslot(weaponentity);
                                ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor();
                        }
                        actor.arc_BUTTON_ATCK_prev = false;
 
                        #if 0
                        if(fire & 2)
-                       if(weapon_prepareattack(thiswep, actor, slot, true, autocvar_g_balance_arc_secondary_refire))
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_arc_secondary_refire))
                        {
                                W_Arc_Attack2();
                                actor.arc_count = autocvar_g_balance_arc_secondary_count;
-                               weapon_thinkf(actor, slot, WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
+                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
                                actor.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor();
                        }
                        #endif
index 8c483b346a5c6e2b6acf4066c321347719b878ba..f67849c80c164d83010befc0ad8cb9cb552839ff 100644 (file)
@@ -161,11 +161,11 @@ void W_Blaster_Attack(
                                { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
                }
 
-               METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, int slot, int fire))
+               METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(fire & 1)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(blaster, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(blaster, refire)))
                                {
                                        W_Blaster_Attack(
                                                actor,
@@ -180,7 +180,7 @@ void W_Blaster_Attack(
                                                WEP_CVAR_PRI(blaster, delay),
                                                WEP_CVAR_PRI(blaster, lifetime)
                                        );
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready);
                                }
                        }
                        else if(fire & 2)
@@ -196,7 +196,7 @@ void W_Blaster_Attack(
 
                                        case 1: // normal projectile secondary
                                        {
-                                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(blaster, refire)))
+                                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(blaster, refire)))
                                                {
                                                        W_Blaster_Attack(
                                                                actor,
@@ -211,7 +211,7 @@ void W_Blaster_Attack(
                                                                WEP_CVAR_SEC(blaster, delay),
                                                                WEP_CVAR_SEC(blaster, lifetime)
                                                        );
-                                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready);
+                                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready);
                                                }
 
                                                break;
index 11e6924d81360585208297ba95eebed0672c27ff..af8b34c4a7d4837b3baeb971c9fe4bf49a496cc6 100644 (file)
@@ -574,7 +574,7 @@ void W_Crylink_Attack2(Weapon thiswep)
                        else
                                self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false);
                }
-               METHOD(Crylink, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -584,20 +584,20 @@ void W_Crylink_Attack2(Weapon thiswep)
                        if(fire & 1)
                        {
                                if(actor.crylink_waitrelease != 1)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(crylink, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire)))
                                {
                                        W_Crylink_Attack(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
                                }
                        }
 
                        if((fire & 2) && autocvar_g_balance_crylink_secondary)
                        {
                                if(actor.crylink_waitrelease != 2)
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(crylink, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire)))
                                {
                                        W_Crylink_Attack2(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
                                }
                        }
 
index dbd8f651a0da10b2b3c1922a83a7d72fc2b29d9f..1454a501298fa316b4983027be15add3fe801a84 100644 (file)
@@ -119,7 +119,7 @@ void W_Devastator_Explode(void)
        remove(self);
 }
 
-void W_Devastator_DoRemoteExplode(int slot)
+void W_Devastator_DoRemoteExplode(.entity weaponentity)
 {SELFPARAM();
        W_Devastator_Unregister();
 
@@ -191,6 +191,7 @@ void W_Devastator_DoRemoteExplode(int slot)
                if(!(self.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        self.realowner.cnt = WEP_DEVASTATOR.m_id;
+                       int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(self.realowner, slot) = time;
                        self.realowner.switchweapon = w_getbestweapon(self.realowner);
                }
@@ -198,7 +199,7 @@ void W_Devastator_DoRemoteExplode(int slot)
        remove(self);
 }
 
-void W_Devastator_RemoteExplode(int slot)
+void W_Devastator_RemoteExplode(.entity weaponentity)
 {SELFPARAM();
        if(self.realowner.deadflag == DEAD_NO)
        if(self.realowner.lastrocket)
@@ -208,7 +209,7 @@ void W_Devastator_RemoteExplode(int slot)
                        : (vlen(NearestPointOnBox(self.realowner, self.origin) - self.origin) > WEP_CVAR(devastator, remote_radius)) // safety device
                )
                {
-                       W_Devastator_DoRemoteExplode(slot);
+                       W_Devastator_DoRemoteExplode(weaponentity);
                }
        }
 }
@@ -305,9 +306,9 @@ void W_Devastator_Think(void)
                        }
                }
 
-               int slot = 0; // TODO: unhardcode
+               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                if(self.rl_detonate_later)
-                       W_Devastator_RemoteExplode(slot);
+                       W_Devastator_RemoteExplode(weaponentity);
        }
 
        if(self.csqcprojectile_clientanimate == 0)
@@ -522,7 +523,7 @@ void W_Devastator_Attack(Weapon thiswep)
                        }
                }
                #endif
-               METHOD(Devastator, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -531,10 +532,10 @@ void W_Devastator_Attack(Weapon thiswep)
                                if(fire & 1)
                                {
                                        if(actor.rl_release || WEP_CVAR(devastator, guidestop))
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(devastator, refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire)))
                                        {
                                                W_Devastator_Attack(thiswep);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
                                                actor.rl_release = 0;
                                        }
                                }
index 8ae3f3e3c02231730afe8eeb5bd87f1e46689c20..e9fb0f4e9ab4c1bfe84bf2e04041fed1a51e0902 100644 (file)
@@ -406,19 +406,19 @@ void W_Electro_Attack_Orb(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-void W_Electro_CheckAttack(Weapon thiswep, entity actor, int slot, int fire)
+void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {SELFPARAM();
        if(self.electro_count > 1)
        if(self.BUTTON_ATCK2)
-       if(weapon_prepareattack(thiswep, actor, slot, true, -1))
+       if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
        {
                W_Electro_Attack_Orb(WEP_ELECTRO);
                self.electro_count -= 1;
-               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                return;
        }
        // WEAPONTODO: when the player releases the button, cut down the length of refire2?
-       w_ready(thiswep, actor, slot, fire);
+       w_ready(thiswep, actor, weaponentity, fire);
 }
 
 .float bot_secondary_electromooth;
@@ -451,7 +451,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, int slot, int fire)
                                }
                        }
                }
-               METHOD(Electro, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
                        {
@@ -471,20 +471,20 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, int slot, int fire)
 
                        if(fire & 1)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(electro, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
                                {
                                                W_Electro_Attack_Bolt(thiswep);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
                                }
                        }
                        else if(fire & 2)
                        {
                                if(time >= actor.electro_secondarytime)
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(electro, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
                                {
                                        W_Electro_Attack_Orb(thiswep);
                                        actor.electro_count = WEP_CVAR_SEC(electro, count);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                                        actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
                                }
                        }
index a2ff0de5963b0476dc9b3e531a6786ebeab7b68e..ccd3bc32df6a05945bd1a456aef5baffb2cf5c45 100644 (file)
@@ -226,35 +226,35 @@ void W_Fireball_AttackEffect(float i, vector f_diff)
        Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 }
 
-void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, int slot, int fire)
+void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        W_Fireball_Attack1();
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
 }
 
-void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, int slot, int fire)
+void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
 }
 
-void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, int slot, int fire)
+void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
 }
 
-void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, int slot, int fire)
+void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
 }
 
-void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, int slot, int fire)
+void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {SELFPARAM();
        W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
        sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
 }
 
 void W_Fireball_Firemine_Think(void)
@@ -371,23 +371,23 @@ void W_Fireball_Attack2(void)
                                }
                        }
                }
-               METHOD(Fireball, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Fireball, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(fire & 1)
                        {
                                if(time >= actor.fireball_primarytime)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(fireball, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(fireball, refire)))
                                {
-                                       W_Fireball_Attack1_Frame0(thiswep, actor, slot, fire);
+                                       W_Fireball_Attack1_Frame0(thiswep, actor, weaponentity, fire);
                                        actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
                                }
                        }
                        else if(fire & 2)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(fireball, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(fireball, refire)))
                                {
                                        W_Fireball_Attack2();
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
                                }
                        }
                }
index e7621c241c9a9eac2a04d712f5588b2139725026..952788c989eaf7123e80e9561a6bf65783d389f2 100644 (file)
@@ -211,7 +211,7 @@ void W_Hagar_Attack2(Weapon thiswep)
 }
 
 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
-void W_Hagar_Attack2_Load_Release(int slot)
+void W_Hagar_Attack2_Load_Release(.entity weaponentity)
 {SELFPARAM();
        // time to release the rockets we've loaded
 
@@ -223,7 +223,7 @@ void W_Hagar_Attack2_Load_Release(int slot)
        if(!self.hagar_load)
                return;
 
-       weapon_prepareattack_do(self, true, WEP_CVAR_SEC(hagar, refire), slot);
+       weapon_prepareattack_do(self, weaponentity, true, WEP_CVAR_SEC(hagar, refire));
 
        W_SetupShot(self, false, 2, SND(HAGAR_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
        Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
@@ -286,12 +286,12 @@ void W_Hagar_Attack2_Load_Release(int slot)
                MUTATOR_CALLHOOK(EditProjectile, self, missile);
        }
 
-       weapon_thinkf(self, slot, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
+       weapon_thinkf(self, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
        self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
        self.hagar_load = 0;
 }
 
-void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
+void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
 {SELFPARAM();
        // loadable hagar secondary attack, must always run each frame
 
@@ -318,7 +318,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
                        if(self.hagar_load)
                        {
                                // if we pressed primary fire while loading, unload all rockets and abort
-                               self.weaponentity[slot].state = WS_READY;
+                               self.(weaponentity).state = WS_READY;
                                W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo
                                self.hagar_load = 0;
                                sound(self, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM);
@@ -338,7 +338,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
                                if(!self.hagar_loadblock && self.hagar_loadstep < time)
                                {
                                        W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo));
-                                       self.weaponentity[slot].state = WS_INUSE;
+                                       self.(weaponentity).state = WS_INUSE;
                                        self.hagar_load += 1;
                                        sound(self, CH_WEAPON_B, SND_HAGAR_LOAD, VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
 
@@ -379,8 +379,8 @@ void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
                // release if player let go of button or if they've held it in too long
                if(!self.BUTTON_ATCK2 || (stopped && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
                {
-                       self.weaponentity[slot].state = WS_READY;
-                       W_Hagar_Attack2_Load_Release(slot);
+                       self.(weaponentity).state = WS_READY;
+                       W_Hagar_Attack2_Load_Release(weaponentity);
                }
        }
        else
@@ -407,30 +407,30 @@ void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
                        else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
                                self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
                }
-               METHOD(Hagar, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        float loadable_secondary;
                        loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
 
                        if(loadable_secondary)
-                               W_Hagar_Attack2_Load(thiswep, slot); // must always run each frame
+                               W_Hagar_Attack2_Load(thiswep, weaponentity); // must always run each frame
                        if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
                                w.wr_reload(w);
                        } else if((fire & 1) && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(hagar, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hagar, refire)))
                                {
                                        W_Hagar_Attack(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
                                }
                        }
                        else if((fire & 2) && !loadable_secondary && WEP_CVAR(hagar, secondary))
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(hagar, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire)))
                                {
                                        W_Hagar_Attack2(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
                                }
                        }
                }
@@ -439,9 +439,9 @@ void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
                        // we lost the weapon and want to prepare switching away
                        if(self.hagar_load)
                        {
-                               int slot = 0; // TODO: unhardcode
-                               self.weaponentity[slot].state = WS_READY;
-                               W_Hagar_Attack2_Load_Release(slot);
+                               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+                               self.(weaponentity).state = WS_READY;
+                               W_Hagar_Attack2_Load_Release(weaponentity);
                        }
                }
                METHOD(Hagar, wr_init, void(entity thiswep))
@@ -480,10 +480,10 @@ void W_Hagar_Attack2_Load(Weapon thiswep, int slot)
                }
                METHOD(Hagar, wr_playerdeath, void(entity thiswep))
                {
-                       int slot = 0; // TODO: unhardcode
+                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                        // if we have any rockets loaded when we die, release them
                        if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
-                               W_Hagar_Attack2_Load_Release(slot);
+                               W_Hagar_Attack2_Load_Release(weaponentity);
                }
                METHOD(Hagar, wr_reload, void(entity thiswep))
                {
index 5a91976ff4ad7bc48576eb3b834727c94779f8ea..29f3a2130c05c2b815af9cad6a5a1b78935b7609 100644 (file)
@@ -161,11 +161,11 @@ void W_HLAC_Attack2(void)
 }
 
 // weapon frames
-void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, int slot, int fire)
+void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        if(actor.weapon != actor.switchweapon) // abort immediately if switching
        {
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -176,18 +176,19 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, int slot, int fire)
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-                       w_ready(thiswep, actor, slot, fire);
+                       w_ready(thiswep, actor, weaponentity, fire);
                        return;
                }
 
+               int slot = weaponslot(weaponentity);
                ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
                W_HLAC_Attack(WEP_HLAC);
                actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
-        weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
+        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
        }
        else
        {
-               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
        }
 }
 
@@ -211,27 +212,27 @@ void W_HLAC_Attack2_Frame(Weapon thiswep)
                {
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
                }
-               METHOD(HLAC, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_hlac_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
                                w.wr_reload(w);
                        } else if(fire & 1)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(hlac, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
                                {
                                        actor.misc_bulletcounter = 0;
                                        W_HLAC_Attack(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
                                }
                        }
 
                        else if((fire & 2) && WEP_CVAR(hlac, secondary))
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(hlac, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
                                {
                                        W_HLAC_Attack2_Frame(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
                                }
                        }
                }
index c7ae7d43b5aa84a7c9103c30c67b025dfb77db6f..a46f19eb0425265d51d865eff0d588fa188e34b1 100644 (file)
@@ -45,11 +45,11 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 
 spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(this, WEP_HMG); }
 
-void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int fire)
+void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        if (!actor.BUTTON_ATCK)
        {
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -58,7 +58,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -85,8 +85,9 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
        if (autocvar_g_casings >= 2) // casing code
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor);
 
+       int slot = weaponslot(weaponentity);
        ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor();
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
 }
 
                METHOD(HeavyMachineGun, wr_aim, void(entity thiswep))
@@ -96,7 +97,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
                        else
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
                }
-               METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -104,10 +105,10 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
                        } else
                        {
                                if (fire & 1)
-                               if (weapon_prepareattack(thiswep, actor, slot, false, 0))
+                               if (weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
                                {
                                        actor.misc_bulletcounter = 0;
-                                       W_HeavyMachineGun_Attack_Auto(thiswep, actor, slot, fire);
+                                       W_HeavyMachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
                                }
                        }
                }
index 315310b36e36a5a43f0df93569b63c1dcca28a88..f447a154256a006aeb427bdf58d06c87277e0ab8 100644 (file)
@@ -19,11 +19,14 @@ ENDCLASS(Hook)
 REGISTER_WEAPON(HOOK, NEW(Hook));
 
 CLASS(OffhandHook, OffhandWeapon)
+#ifdef SVQC
     METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed))
     {
        Weapon wep = WEP_HOOK;
-       wep.wr_think(wep, actor, 1, key_pressed ? 1 : 0);
+       .entity weaponentity = weaponentities[1];
+       wep.wr_think(wep, actor, weaponentity, key_pressed ? 1 : 0);
     }
+#endif
 ENDCLASS(OffhandHook)
 OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); }
 
@@ -174,18 +177,18 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
        MUTATOR_CALLHOOK(EditProjectile, actor, gren);
 }
 
-               METHOD(Hook, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if (fire & 1) {
                                if(!actor.hook)
                                if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE))
                                if(time > actor.hook_refire)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, -1))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, -1))
                                {
                                        W_DecreaseAmmo(thiswep, actor, thiswep.ammo_factor * WEP_CVAR_PRI(hook, ammo));
                                        actor.hook_state |= HOOK_FIRING;
                                        actor.hook_state |= HOOK_WAITING_FOR_RELEASE;
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready);
                                }
                        } else {
                                actor.hook_state |= HOOK_REMOVING;
@@ -194,10 +197,10 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
 
                        if(fire & 2)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(hook, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hook, refire)))
                                {
                                        W_Hook_Attack2(thiswep, actor);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready);
                                }
                        }
 
index f27e0916d8c580c1dc9c256cf81b84400118c05d..71f7ac3a85742fd31908d828221de7bda863aa99 100644 (file)
@@ -104,7 +104,7 @@ void W_MachineGun_MuzzleFlash(void)
        self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
 }
 
-void W_MachineGun_Attack(Weapon thiswep, int deathtype, int slot)
+void W_MachineGun_Attack(Weapon thiswep, int deathtype, .entity weaponentity)
 {SELFPARAM();
        W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
        if(!autocvar_g_norecoil)
@@ -112,7 +112,7 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, int slot)
                self.punchangle_x = random() - 0.5;
                self.punchangle_y = random() - 0.5;
        }
-
+       int slot = weaponslot(weaponentity);
        // this attack_finished just enforces a cooldown at the end of a burst
        ATTACK_FINISHED(self, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor();
 
@@ -137,11 +137,11 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, int slot)
 }
 
 // weapon frames
-void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, int slot, int fire)
+void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        if(actor.weapon != actor.switchweapon) // abort immediately if switching
        {
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
        if(actor.BUTTON_ATCK)
@@ -151,25 +151,25 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, int slot, int fire)
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-                       w_ready(thiswep, actor, slot, fire);
+                       w_ready(thiswep, actor, weaponentity, fire);
                        return;
                }
                actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
-               W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, slot);
-               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
+               W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, weaponentity);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
        }
        else
-               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), w_ready);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), w_ready);
 }
 
 
-void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int fire)
+void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        float machinegun_spread;
 
        if(!(fire & 1))
        {
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -178,7 +178,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int fire)
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -204,11 +204,12 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int fire)
        if(autocvar_g_casings >= 2) // casing code
                SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor);
 
+       int slot = weaponslot(weaponentity);
        ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor();
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
 }
 
-void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, int slot, int fire)
+void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        W_SetupShot(actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage));
        if(!autocvar_g_norecoil)
@@ -230,12 +231,13 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, int slot, int fire)
        actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
        if(actor.misc_bulletcounter == 0)
        {
+               int slot = weaponslot(weaponentity);
                ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor();
-               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready);
        }
        else
        {
-               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_refire), W_MachineGun_Attack_Burst);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_refire), W_MachineGun_Attack_Burst);
        }
 
 }
@@ -247,7 +249,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, int slot, int fire)
                        else
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
                }
-               METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(machinegun, reload_ammo) && actor.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -256,47 +258,47 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, int slot, int fire)
                        if(WEP_CVAR(machinegun, mode) == 1)
                        {
                                if(fire & 1)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, 0))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
                                {
                                        actor.misc_bulletcounter = 0;
-                                       W_MachineGun_Attack_Auto(thiswep, actor, slot, fire);
+                                       W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
                                }
 
                                if(fire & 2)
-                               if(weapon_prepareattack(thiswep, actor, slot, true, 0))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
                                {
                                        Weapon w = get_weaponinfo(actor.weapon);
                                        if(!w.wr_checkammo2(w))
                                        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                                        {
                                                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-                                               w_ready(thiswep, actor, slot, fire);
+                                               w_ready(thiswep, actor, weaponentity, fire);
                                                return;
                                        }
 
                                        W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo));
 
                                        actor.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1;
-                                       W_MachineGun_Attack_Burst(thiswep, actor, slot, fire);
+                                       W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
                                }
                        }
                        else
                        {
 
                                if(fire & 1)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, 0))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
                                {
                                        actor.misc_bulletcounter = 1;
-                                       W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, slot); // sets attack_finished
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
+                                       W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, weaponentity); // sets attack_finished
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
                                }
 
                                if((fire & 2) && WEP_CVAR(machinegun, first))
-                               if(weapon_prepareattack(thiswep, actor, slot, true, 0))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
                                {
                                        actor.misc_bulletcounter = 1;
-                                       W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, slot); // sets attack_finished
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
+                                       W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, weaponentity); // sets attack_finished
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
                                }
                        }
                }
index 938f20390b2a09964f072d9e86bcc541bbc88095..790465d501b016d99cfc2417b9a4034e1cade2aa 100644 (file)
@@ -501,7 +501,7 @@ float W_MineLayer_PlacedMines(float detonate)
                                if(self.BUTTON_ATCK2 == true) self.BUTTON_ATCK = false;
                        }
                }
-               METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
                        {
@@ -513,10 +513,10 @@ float W_MineLayer_PlacedMines(float detonate)
                        }
                        else if(fire & 1)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(minelayer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire)))
                                {
                                        W_MineLayer_Attack(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
                                }
                        }
 
index f2e2013d8b5b14501292ca15ffb5d0ec011607c5..05092139669df071ce5069cc411e8fccc8ab68ff 100644 (file)
@@ -334,17 +334,17 @@ void W_Mortar_Attack2(Weapon thiswep)
                        wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime))));
                        wepinfo_ter_dps = 0;
                        */
-               METHOD(Mortar, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
                                w.wr_reload(w);
                        } else if(fire & 1)
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(mortar, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire)))
                                {
                                        W_Mortar_Attack(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
                                }
                        }
                        else if(fire & 2)
@@ -364,10 +364,10 @@ void W_Mortar_Attack2(Weapon thiswep)
                                        if(nadefound)
                                                sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
                                }
-                               else if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(mortar, refire)))
+                               else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire)))
                                {
                                        W_Mortar_Attack2(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready);
                                }
                        }
                }
index 8987b28ab50f40d8c2902da376d952af9663b868..811327553514802e045c72583d99a66d6e833415 100644 (file)
@@ -306,26 +306,26 @@ void W_Porto_Attack(float type)
                {
                        PORTO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                }
-               METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(porto, secondary))
                        {
                                if(fire & 1)
                                if(!actor.porto_current)
                                if(!actor.porto_forbidden)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(porto, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
                                {
                                        W_Porto_Attack(0);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
                                }
 
                                if(fire & 2)
                                if(!actor.porto_current)
                                if(!actor.porto_forbidden)
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(porto, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(porto, refire)))
                                {
                                        W_Porto_Attack(1);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
                                }
                        }
                        else
@@ -355,10 +355,10 @@ void W_Porto_Attack(float type)
                                if(fire & 1)
                                if(!actor.porto_current)
                                if(!actor.porto_forbidden)
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(porto, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
                                {
                                        W_Porto_Attack(-1);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
                                }
                        }
                }
index 63d77d80fb4404d54d4cfc13c193be3f91c1c09c..5aed6a7d473fff31f1a2208c7061a78f66839365 100644 (file)
@@ -90,32 +90,33 @@ void W_Rifle_Attack2(void)
 .float rifle_bullethail_frame;
 .float rifle_bullethail_animtime;
 .float rifle_bullethail_refire;
-void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, int slot, int fire)
+void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        float r, sw, af;
 
        sw = actor.switchweapon; // make it not detect weapon changes as reason to abort firing
+       int slot = weaponslot(weaponentity);
        af = ATTACK_FINISHED(actor, slot);
        actor.switchweapon = actor.weapon;
        ATTACK_FINISHED(actor, slot) = time;
        LOG_INFO(ftos(actor.WEP_AMMO(RIFLE)), "\n");
-       r = weapon_prepareattack(thiswep, actor, slot, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
+       r = weapon_prepareattack(thiswep, actor, weaponentity, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
        if(actor.switchweapon == actor.weapon)
                actor.switchweapon = sw;
        if(r)
        {
                actor.rifle_bullethail_attackfunc();
-               weapon_thinkf(actor, slot, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue);
+               weapon_thinkf(actor, weaponentity, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue);
                LOG_INFO("thinkf set\n");
        }
        else
        {
                ATTACK_FINISHED(actor, slot) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
-               LOG_INFO("out of ammo... ", ftos(actor.weaponentity[slot].state), "\n");
+               LOG_INFO("out of ammo... ", ftos(actor.(weaponentity).state), "\n");
        }
 }
 
-void W_Rifle_BulletHail(int slot, float mode, void(void) AttackFunc, float fr, float animtime, float refire)
+void W_Rifle_BulletHail(.entity weaponentity, float mode, void(void) AttackFunc, float fr, float animtime, float refire)
 {SELFPARAM();
        // if we get here, we have at least one bullet to fire
        AttackFunc();
@@ -126,12 +127,12 @@ void W_Rifle_BulletHail(int slot, float mode, void(void) AttackFunc, float fr, f
                self.rifle_bullethail_frame = fr;
                self.rifle_bullethail_animtime = animtime;
                self.rifle_bullethail_refire = refire;
-               weapon_thinkf(self, slot, fr, animtime, W_Rifle_BulletHail_Continue);
+               weapon_thinkf(self, weaponentity, fr, animtime, W_Rifle_BulletHail_Continue);
        }
        else
        {
                // just one shot
-               weapon_thinkf(self, slot, fr, animtime, w_ready);
+               weapon_thinkf(self, weaponentity, fr, animtime, w_ready);
        }
 }
 
@@ -160,7 +161,7 @@ void W_Rifle_BulletHail(int slot, float mode, void(void) AttackFunc, float fr, f
                                }
                        }
                }
-               METHOD(Rifle, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -169,11 +170,11 @@ void W_Rifle_BulletHail(int slot, float mode, void(void) AttackFunc, float fr, f
                        {
                                actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
                                if(fire & 1)
-                               if(weapon_prepareattack_check(thiswep, actor, slot, false, WEP_CVAR_PRI(rifle, refire)))
+                               if(weapon_prepareattack_check(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(rifle, refire)))
                                if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
                                {
-                                       weapon_prepareattack_do(actor, slot, false, WEP_CVAR_PRI(rifle, refire));
-                                       W_Rifle_BulletHail(slot, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+                                       weapon_prepareattack_do(actor, weaponentity, false, WEP_CVAR_PRI(rifle, refire));
+                                       W_Rifle_BulletHail(weaponentity, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
                                        actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
                                }
                                if(fire & 2)
@@ -185,11 +186,11 @@ void W_Rifle_BulletHail(int slot, float mode, void(void) AttackFunc, float fr, f
                                                        w.wr_reload(w);
                                                } else
                                                {
-                                                       if(weapon_prepareattack_check(thiswep, actor, slot, true, WEP_CVAR_SEC(rifle, refire)))
+                                                       if(weapon_prepareattack_check(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire)))
                                                        if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
                                                        {
-                                                               weapon_prepareattack_do(actor, slot, true, WEP_CVAR_SEC(rifle, refire));
-                                                               W_Rifle_BulletHail(slot, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+                                                               weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire));
+                                                               W_Rifle_BulletHail(weaponentity, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
                                                                actor.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost);
                                                        }
                                                }
index f25bef42fb21778ae9b99d609aa5078a08c9e75a..fa037e00b0477d80eecfb301748cca20b1e8e05b 100644 (file)
@@ -153,7 +153,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
                {
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
                }
-               METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) {
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -162,10 +162,10 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
                        {
                                if (fire & 1)
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(rpc, refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(rpc, refire)))
                                        {
                                                W_RocketPropelledChainsaw_Attack(thiswep);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
                                        }
                                }
 
index 8fd7aa89678f596373ca2430dc9ec5cc5a48f0d3..cc484c3d795496e554d0ab5e9f9f7b771cd525ab 100644 (file)
@@ -608,7 +608,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        else
                                self.BUTTON_ATCK = bot_aim(WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
                }
-               METHOD(Seeker, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -617,18 +617,18 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        {
                                if(WEP_CVAR(seeker, type) == 1)
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(seeker, missile_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, missile_refire)))
                                        {
                                                W_Seeker_Attack();
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
                                        }
                                }
                                else
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(seeker, tag_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
                                        {
                                                W_Seeker_Fire_Tag(thiswep);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
                                        }
                                }
                        }
@@ -637,18 +637,18 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        {
                                if(WEP_CVAR(seeker, type) == 1)
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(seeker, tag_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
                                        {
                                                W_Seeker_Fire_Tag(thiswep);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
                                        }
                                }
                                else
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(seeker, flac_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, flac_refire)))
                                        {
                                                W_Seeker_Fire_Flac(thiswep);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
                                        }
                                }
                        }
index a16c2d68ba0c2f922990912972276c7e516b71b1..d7d27fcb90e45b17dfc952d8eba5e6ffb1b256f1 100644 (file)
@@ -229,10 +229,10 @@ void W_Shockwave_Melee_Think(void)
        }
 }
 
-void W_Shockwave_Melee(Weapon thiswep, entity actor, int slot, int fire)
+void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
-       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
 
        entity meleetemp;
        meleetemp = spawn();
@@ -675,17 +675,17 @@ void W_Shockwave_Attack(void)
                        else
                                { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
                }
-               METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(fire & 1)
                        {
                                if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(shockwave, blast_animtime)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime)))
                                        {
                                                W_Shockwave_Attack();
                                                actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
                                        }
                                }
                        }
@@ -693,10 +693,10 @@ void W_Shockwave_Attack(void)
                        {
                                //if(actor.clip_load >= 0) // we are not currently reloading
                                if(!actor.crouch) // no crouchmelee please
-                               if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR(shockwave, melee_refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(shockwave, melee_refire)))
                                {
                                        // attempt forcing playback of the anim by switching to another anim (that we never play) here...
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, W_Shockwave_Melee);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shockwave_Melee);
                                }
                        }
                }
index da08705eedc48a4d5a5a444226a65e077079c095..2de55865a4e3373e75bd05839d6324d12ed5a0cd 100644 (file)
@@ -181,10 +181,10 @@ void W_Shotgun_Melee_Think(void)
        }
 }
 
-void W_Shotgun_Attack2(Weapon thiswep, entity actor, int slot, int fire)
+void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM);
-       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
 
        entity meleetemp;
        meleetemp = spawn();
@@ -195,34 +195,34 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, int slot, int fire)
 }
 
 // alternate secondary weapon frames
-void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, int slot, int fire)
+void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        Weapon w = get_weaponinfo(actor.weapon);
        if (!w.wr_checkammo2(w))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
        sound(actor, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound
        W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
 }
-void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int slot, int fire)
+void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        Weapon w = get_weaponinfo(actor.weapon);
        if (!w.wr_checkammo2(w))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
        W_Shotgun_Attack(WEP_SHOTGUN, false);
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2);
 }
 
 .float shotgun_primarytime;
@@ -234,7 +234,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int slot, int fire)
                        else
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false);
                }
-               METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(shotgun, reload_ammo) && actor.clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload
                        {
@@ -250,11 +250,11 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int slot, int fire)
                                {
                                        if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
                                        {
-                                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(shotgun, animtime)))
+                                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime)))
                                                {
                                                        W_Shotgun_Attack(thiswep, true);
                                                        actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor();
-                                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready);
+                                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready);
                                                }
                                        }
                                }
@@ -262,11 +262,11 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int slot, int fire)
                                {
                                        if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
                                        {
-                                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
+                                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
                                                {
                                                        W_Shotgun_Attack(thiswep, false);
                                                        actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor();
-                                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1);
+                                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1);
                                                }
                                        }
                                }
@@ -275,10 +275,10 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int slot, int fire)
                        if(!actor.crouch) // no crouchmelee please
                        if(WEP_CVAR(shotgun, secondary) == 1)
                        if(((fire & 1) && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
-                       if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR_SEC(shotgun, refire)))
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire)))
                        {
                                // attempt forcing playback of the anim by switching to another anim (that we never play) here...
-                               weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
+                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
                        }
                }
                METHOD(Shotgun, wr_init, void(entity thiswep))
index ae7bbda979a0718cb6bf04ee0f1a119ebf07b589..130edaaf58bef62debd1a9dc3e66b9804b1c0e1d 100644 (file)
@@ -379,21 +379,21 @@ void W_Tuba_NoteOn(float hittype)
                                        self.BUTTON_ATCK2 = 1;
                        }
                }
-               METHOD(Tuba, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Tuba, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(fire & 1)
-                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(tuba, refire)))
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(0);
                                //weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
-                               weapon_thinkf(actor, slot, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
+                               weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
                        if(fire & 2)
-                       if(weapon_prepareattack(thiswep, actor, slot, true, WEP_CVAR(tuba, refire)))
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(HITTYPE_SECONDARY);
                                //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
-                               weapon_thinkf(actor, slot, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
+                               weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
                        if(actor.tuba_note)
                        {
@@ -414,9 +414,9 @@ void W_Tuba_NoteOn(float hittype)
                }
                METHOD(Tuba, wr_reload, void(entity thiswep))
                {
-                       int slot = 0; // TODO: unhardcode
+                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                        // switch to alternate instruments :)
-                       if(self.weaponentity[slot].state == WS_READY)
+                       if(self.(weaponentity).state == WS_READY)
                        {
                                switch(self.tuba_instrument)
                                {
@@ -435,8 +435,8 @@ void W_Tuba_NoteOn(float hittype)
                                }
                                W_SetupShot(self, false, 0, "", 0, 0);
                                Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
-                               self.weaponentity[slot].state = WS_INUSE;
-                               weapon_thinkf(self, slot, WFRAME_RELOAD, 0.5, w_ready);
+                               self.(weaponentity).state = WS_INUSE;
+                               weapon_thinkf(self, weaponentity, WFRAME_RELOAD, 0.5, w_ready);
                        }
                }
                METHOD(Tuba, wr_checkammo1, bool(entity thiswep))
index 6830c90016fa0acd5021af517e1a7702e8242111..750b5c5a4eac7f2b46c5c1a12f98f838339dba14 100644 (file)
@@ -244,7 +244,7 @@ void W_RocketMinsta_Attack3 (void)
                        else
                                self.BUTTON_ATCK2 = bot_aim(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, int slot, int fire))
+               METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
                        // if the laser uses load, we also consider its ammo for reloading
@@ -257,10 +257,10 @@ void W_RocketMinsta_Attack3 (void)
                        }
                        if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
                        {
-                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(vaporizer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
                                {
                                        W_Vaporizer_Attack(thiswep);
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
                                }
                        }
                        if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm))
@@ -314,7 +314,7 @@ void W_RocketMinsta_Attack3 (void)
                                        actor.weapon = oldwep;
 
                                        // now do normal refire
-                                       weapon_thinkf(actor, slot, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
                                }
                        }
                        else
index 790d5c2b8c084e5a5b82798159b479b5d5cbe8d5..5a64accc9c68899192a0b6a1ba3e051993c7113d 100644 (file)
@@ -143,7 +143,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                                        self.BUTTON_ATCK2 = true;
                        }
                }
-               METHOD(Vortex, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(vortex, charge) && actor.vortex_charge < WEP_CVAR(vortex, charge_limit))
                                actor.vortex_charge = min(1, actor.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME);
@@ -163,10 +163,10 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                        {
                                if(fire & 1)
                                {
-                                       if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_PRI(vortex, refire)))
+                                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vortex, refire)))
                                        {
                                                W_Vortex_Attack(thiswep, 0);
-                                               weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
                                        }
                                }
                                if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : (fire & 2))
@@ -235,10 +235,10 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                                        }
                                        else if(WEP_CVAR(vortex, secondary))
                                        {
-                                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR_SEC(vortex, refire)))
+                                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(vortex, refire)))
                                                {
                                                        W_Vortex_Attack(thiswep, 1);
-                                                       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
+                                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
                                                }
                                        }
                                }
index 9dfc26de75291ee2db9a82effd7c796603d5fb67..db677fcd06192db8c22497b7c7fcb1e1e87350cf 100644 (file)
@@ -1062,7 +1062,8 @@ float bot_cmd_debug_assert_canfire()
        float f = bot_cmd.bot_cmd_parm_float;
 
        int slot = 0;
-       if(self.weaponentity[slot].state != WS_READY)
+       .entity weaponentity = weaponentities[slot];
+       if(self.(weaponentity).state != WS_READY)
        {
                if(f)
                {
index dc6d63b0c863710396bb092f24dbf8211b428bcf..76b6ea053076c0afbf3b6d41410d20c9f8e795d8 100644 (file)
@@ -1025,9 +1025,9 @@ void Drag_Update(entity dragger)
        draggee.ltime = max(servertime + serverframetime, draggee.ltime); // fixes func_train breakage
 
        vector vecs = '0 0 0';
-       int slot = 0; // TODO: unhardcode
-       if(dragger.weaponentity[slot].movedir_x > 0)
-               vecs = dragger.weaponentity[slot].movedir;
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       if(dragger.(weaponentity).movedir.x > 0)
+               vecs = dragger.(weaponentity).movedir;
 
        vector dv = v_right * -vecs_y + v_up * vecs_z;
 
index 7a18231392b3216e6a596fe71b48048d012c3b60..e8c5d2cd3a5229fe2d45d6131f24c0d6df8cbf39 100644 (file)
@@ -306,7 +306,7 @@ void PutObserverInServer()
        self.weaponmodel = "";
        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               self.weaponentity[slot] = NULL;
+               self.weaponentities[slot] = NULL;
        }
        self.exteriorweaponentity = world;
        self.killcount = FRAGS_SPECTATOR;
@@ -573,7 +573,7 @@ void PutClientInServer()
 
                for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
-                       CL_SpawnWeaponentity(this, slot);
+                       CL_SpawnWeaponentity(this, weaponentities[slot]);
                }
                this.alpha = default_player_alpha;
                this.colormod = '1 1 1' * autocvar_g_player_brightness;
@@ -2435,8 +2435,8 @@ void PlayerPreThink (void)
 
                // WEAPONTODO: THIS SHIT NEEDS TO GO EVENTUALLY
                // It cannot be predicted by the engine!
-               int slot = 0; // TODO: unhardcode
-               if((self.weapon == WEP_SHOCKWAVE.m_id || self.weapon == WEP_SHOTGUN.m_id) && self.weaponentity[slot].wframe == WFRAME_FIRE2 && time < self.weapon_nextthink)
+               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+               if((self.weapon == WEP_SHOCKWAVE.m_id || self.weapon == WEP_SHOTGUN.m_id) && self.(weaponentity).wframe == WFRAME_FIRE2 && time < self.weapon_nextthink)
                        do_crouch = 0;
 
                if (do_crouch)
index 205c2a0358d4e9fe6c944fbb1013fec2bcaa9814..517656822303516ed6c9b2a174e65ad1cc2194ab 100644 (file)
@@ -168,13 +168,13 @@ void player_anim (void)
        animdecide_setstate(self, animbits, false);
        animdecide_setimplicitstate(self, (self.flags & FL_ONGROUND));
 
-       int slot = 0; // TODO: unhardcode
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
        {
-               if (self.weaponentity[slot])
+               if (self.(weaponentity))
                {
-                       updateanim(self.weaponentity[slot]);
-                       if (!self.weaponentity[slot].animstate_override)
-                               setanim(self.weaponentity[slot], self.weaponentity[slot].anim_idle, true, false, false);
+                       updateanim(self.(weaponentity));
+                       if (!self.(weaponentity).animstate_override)
+                               setanim(self.(weaponentity), self.(weaponentity).anim_idle, true, false, false);
                }
        }
 }
index 4b972f0dec76304030bde9eb74acafebe96b03a9..bfc0f96a03f0049ef1290323db53ab9dd6ee7ce7 100644 (file)
@@ -831,8 +831,8 @@ void GameCommand_gettaginfo(float request, float argc)
                                tmp_entity = spawn();
                                if (argv(1) == "w")
                                {
-                                       int slot = 0;
-                                       _setmodel(tmp_entity, (nextent(world)).weaponentity[slot].model);
+                                       .entity weaponentity = weaponentities[0];
+                                       _setmodel(tmp_entity, (nextent(world)).(weaponentity).model);
                                }
                                else
                                {
@@ -892,8 +892,8 @@ void GameCommand_animbench(float request, float argc)
                                tmp_entity = spawn();
                                if (argv(1) == "w")
                                {
-                                       int slot = 0;
-                                       _setmodel(tmp_entity, (nextent(world)).weaponentity[slot].model);
+                                       .entity weaponentity = weaponentities[0];
+                                       _setmodel(tmp_entity, (nextent(world)).(weaponentity).model);
                                }
                                else
                                {
index a8e45511ddca0779bb36666ae181e2d31e2f70ce..f8c5f1cfbb812c0fd48c7d2dbde6140b3f2d5f8e 100644 (file)
@@ -152,7 +152,6 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 
 // definitions for weaponsystem
 // more WEAPONTODO: move these to their proper files
-.entity weaponentity[MAX_WEAPONSLOTS];
 .entity exteriorweaponentity;
 .vector weaponentity_glowmod;
 
@@ -164,11 +163,11 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 // WEAPONTODO
 .float autoswitch;
 float client_hasweapon(entity cl, float wpn, float andammo, float complain);
-void w_clear(Weapon thiswep, entity actor, int slot, int fire);
-void w_ready(Weapon thiswep, entity actor, int slot, int fire);
+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)
 .float weapon_nextthink;
-.void(Weapon thiswep, entity actor, int slot, int fire) weapon_think;
+.void(Weapon thiswep, entity actor, .entity weaponentity, int fire) weapon_think;
 
 
 // weapon states (self.weaponentity.state)
index e6641947c28204415136b484150964db85c28bca..3039bc3ab33b9551fff7bd93ecebf4babb74aa0a 100644 (file)
@@ -1489,11 +1489,12 @@ void FixIntermissionClient(entity e)
                e.takedamage = DAMAGE_NO;
                for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
-                       if(e.weaponentity[slot])
+                   .entity weaponentity = weaponentities[slot];
+                       if(e.(weaponentity))
                        {
-                               e.weaponentity[slot].effects = EF_NODRAW;
-                               if (e.weaponentity[slot].weaponentity[slot])
-                                       e.weaponentity[slot].weaponentity[slot].effects = EF_NODRAW;
+                               e.(weaponentity).effects = EF_NODRAW;
+                               if (e.(weaponentity).(weaponentity))
+                                       e.(weaponentity).(weaponentity).effects = EF_NODRAW;
                        }
                }
                if(IS_REAL_CLIENT(e))
index c14ab12410de60bd73533fe4cebef99a9dd58e69..fa11894a469ef7b156edc94ac3583813c8db9114 100644 (file)
@@ -864,8 +864,8 @@ void nade_prime()
        n.projectiledeathtype = DEATH_NADE.m_id;
 
        setmodel(fn, MDL_NADE_VIEW);
-       int slot = 0; // TODO: unhardcode
-       setattachment(fn, self.weaponentity[slot], "");
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       setattachment(fn, self.(weaponentity), "");
        fn.realowner = fn.owner = self;
        fn.colormod = Nades_from(n.nade_type).m_color;
        fn.colormap = self.colormap;
index 0df6accdd3c25b7947fc52c3adefba0838642c97..4e4da230d3f7a687761ee673c469ba3194228928 100644 (file)
@@ -207,9 +207,9 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
                        play2(self, SND(DRYFIRE));
                }
                Weapon wpn = get_weaponinfo(self.weapon);
-               int slot = 0; // TODO: unhardcode
-               if(self.weaponentity[slot].state != WS_CLEAR)
-                       w_ready(wpn, self, slot, (self.BUTTON_ATCK ? 1 : 0) | (self.BUTTON_ATCK2 ? 2 : 0));
+               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+               if(self.(weaponentity).state != WS_CLEAR)
+                       w_ready(wpn, self, weaponentity, (self.BUTTON_ATCK ? 1 : 0) | (self.BUTTON_ATCK2 ? 2 : 0));
 
                self.weapon_blocked = true;
        }
index 676e3f5d57b8d6bba617c9387f05b3834f34a6ed..5ddecef59bf9606736ec95df31bd5cc99da33ca2 100644 (file)
@@ -172,8 +172,8 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
                return;
        if(!autocvar_g_weapon_throwable)
                return;
-       int slot = 0; // TODO: unhardcode
-       if(self.weaponentity[slot].state != WS_READY)
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       if(self.(weaponentity).state != WS_READY)
                return;
        if(!W_IsWeaponThrowable(w))
                return;
index 3f57a3bb39a7ae54368cb6609db387700949d38a..ea0faa845b3ad6974ae040e656286ec3a12a004f 100644 (file)
@@ -55,9 +55,10 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
 
        W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
 
-       int slot = 0; // TODO: unhardcode
-       if(ent.weaponentity[slot].movedir.x > 0)
-               vecs = ent.weaponentity[slot].movedir;
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       vector md = ent.(weaponentity).movedir;
+       if(md.x > 0)
+               vecs = md;
        else
                vecs = '0 0 0';
 
index e64391d83db1fe6d4bf7f29bf40ea1ef53f57d6e..94af849aceaaaffb6c3e0879d55e3c1093e6a5c4 100644 (file)
@@ -92,8 +92,8 @@ float W_WeaponSpeedFactor()
 }
 
 
-void weapon_thinkf(entity actor, int slot, float fr, float t,
-    void(Weapon thiswep, entity actor, int slot, int fire) func);
+void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t,
+    void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);
 
 bool CL_Weaponentity_CustomizeEntityForClient()
 {
@@ -154,12 +154,12 @@ bool CL_Weaponentity_CustomizeEntityForClient()
 // to free:
 //   call again with ""
 //   remove the ent
-void CL_WeaponEntity_SetModel(entity this, int slot, string name)
+void CL_WeaponEntity_SetModel(entity this, .entity weaponentity, string name)
 {
        if (name != "")
        {
                // if there is a child entity, hide it until we're sure we use it
-               if (this.weaponentity[slot]) this.weaponentity[slot].model = "";
+               if (this.(weaponentity)) this.(weaponentity).model = "";
                _setmodel(this, W_Model(strcat("v_", name, ".md3")));
                int v_shot_idx = gettagindex(this, "shot");  // used later
                if (!v_shot_idx) v_shot_idx = gettagindex(this, "tag_shot");
@@ -175,20 +175,20 @@ void CL_WeaponEntity_SetModel(entity this, int slot, string name)
                // if we don't, this is a "real" animated model
                if (gettagindex(this, "weapon"))
                {
-                       if (!this.weaponentity[slot]) this.weaponentity[slot] = spawn();
-                       _setmodel(this.weaponentity[slot], W_Model(strcat("v_", name, ".md3")));
-                       setattachment(this.weaponentity[slot], this, "weapon");
+                       if (!this.(weaponentity)) this.(weaponentity) = new(weaponentity);
+                       _setmodel(this.(weaponentity), W_Model(strcat("v_", name, ".md3")));
+                       setattachment(this.(weaponentity), this, "weapon");
                }
                else if (gettagindex(this, "tag_weapon"))
                {
-                       if (!this.weaponentity[slot]) this.weaponentity[slot] = spawn();
-                       _setmodel(this.weaponentity[slot], W_Model(strcat("v_", name, ".md3")));
-                       setattachment(this.weaponentity[slot], this, "tag_weapon");
+                       if (!this.(weaponentity)) this.(weaponentity) = new(weaponentity);
+                       _setmodel(this.(weaponentity), W_Model(strcat("v_", name, ".md3")));
+                       setattachment(this.(weaponentity), this, "tag_weapon");
                }
                else
                {
-                       if (this.weaponentity[slot]) remove(this.weaponentity[slot]);
-                       this.weaponentity[slot] = NULL;
+                       if (this.(weaponentity)) remove(this.(weaponentity));
+                       this.(weaponentity) = NULL;
                }
 
                setorigin(this, '0 0 0');
@@ -200,7 +200,7 @@ void CL_WeaponEntity_SetModel(entity this, int slot, string name)
 
                if (v_shot_idx)  // v_ model attached to invisible h_ model
                {
-                       this.movedir = gettaginfo(this.weaponentity[slot], v_shot_idx);
+                       this.movedir = gettaginfo(this.(weaponentity), v_shot_idx);
                }
                else
                {
@@ -218,11 +218,11 @@ void CL_WeaponEntity_SetModel(entity this, int slot, string name)
                        }
                }
 
-               if (this.weaponentity[slot])  // v_ model attached to invisible h_ model
+               if (this.(weaponentity))  // v_ model attached to invisible h_ model
                {
-                       idx = gettagindex(this.weaponentity[slot], "shell");
-                       if (!idx) idx = gettagindex(this.weaponentity[slot], "tag_shell");
-                       if (idx) this.spawnorigin = gettaginfo(this.weaponentity[slot], idx);
+                       idx = gettagindex(this.(weaponentity), "shell");
+                       if (!idx) idx = gettagindex(this.(weaponentity), "tag_shell");
+                       if (idx) this.spawnorigin = gettaginfo(this.(weaponentity), idx);
                }
                else
                {
@@ -250,7 +250,7 @@ void CL_WeaponEntity_SetModel(entity this, int slot, string name)
                }
                else
                {
-                       if (this.weaponentity[slot])
+                       if (this.(weaponentity))
                        {
                                idx = gettagindex(this, "weapon");
                                if (!idx) idx = gettagindex(this, "tag_weapon");
@@ -277,8 +277,8 @@ void CL_WeaponEntity_SetModel(entity this, int slot, string name)
        else
        {
                this.model = "";
-               if (this.weaponentity[slot]) remove(this.weaponentity[slot]);
-               this.weaponentity[slot] = NULL;
+               if (this.(weaponentity)) remove(this.(weaponentity));
+               this.(weaponentity) = NULL;
                this.movedir = '0 0 0';
                this.spawnorigin = '0 0 0';
                this.oldorigin = '0 0 0';
@@ -312,9 +312,10 @@ vector CL_Weapon_GetShotOrg(float wpn)
 {
        entity wi = get_weaponinfo(wpn);
        entity e = spawn();
-       CL_WeaponEntity_SetModel(e, 0, wi.mdl);
+       .entity weaponentity = weaponentities[0];
+       CL_WeaponEntity_SetModel(e, weaponentity, wi.mdl);
        vector ret = e.movedir;
-       CL_WeaponEntity_SetModel(e, 0, "");
+       CL_WeaponEntity_SetModel(e, weaponentity, "");
        remove(e);
        return ret;
 }
@@ -324,17 +325,17 @@ void CL_Weaponentity_Think()
        SELFPARAM();
        this.nextthink = time;
        if (intermission_running) this.frame = this.anim_idle.x;
-       int slot = 0; // TODO: unhardcode
-       if (this.owner.weaponentity[slot] != this)
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       if (this.owner.(weaponentity) != this)
        {
-               if (this.weaponentity[slot]) remove(this.weaponentity[slot]);
+               if (this.(weaponentity)) remove(this.(weaponentity));
                remove(this);
                return;
        }
        if (this.owner.deadflag != DEAD_NO)
        {
                this.model = "";
-               if (this.weaponentity[slot]) this.weaponentity[slot].model = "";
+               if (this.(weaponentity)) this.(weaponentity).model = "";
                return;
        }
        if (this.weaponname != this.owner.weaponname || this.dmg != this.owner.modelindex
@@ -344,7 +345,7 @@ void CL_Weaponentity_Think()
                this.dmg = this.owner.modelindex;
                this.deadflag = this.owner.deadflag;
 
-               CL_WeaponEntity_SetModel(this, slot, this.owner.weaponname);
+               CL_WeaponEntity_SetModel(this, weaponentity, this.owner.weaponname);
        }
 
        int tb = (this.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT));
@@ -361,12 +362,12 @@ void CL_Weaponentity_Think()
 
        this.glowmod = this.owner.weaponentity_glowmod;
        this.colormap = this.owner.colormap;
-       if (this.weaponentity[slot])
+       if (this.(weaponentity))
        {
-               this.weaponentity[slot].effects = this.effects;
-               this.weaponentity[slot].alpha = this.alpha;
-               this.weaponentity[slot].colormap = this.colormap;
-               this.weaponentity[slot].glowmod = this.glowmod;
+               this.(weaponentity).effects = this.effects;
+               this.(weaponentity).alpha = this.alpha;
+               this.(weaponentity).colormap = this.colormap;
+               this.(weaponentity).glowmod = this.glowmod;
        }
 
        this.angles = '0 0 0';
@@ -439,9 +440,9 @@ void CL_ExteriorWeaponentity_Think()
 }
 
 // spawning weaponentity for client
-void CL_SpawnWeaponentity(entity e, int slot)
+void CL_SpawnWeaponentity(entity e, .entity weaponentity)
 {
-       entity view = e.weaponentity[slot] = new(weaponentity);
+       entity view = e.(weaponentity) = new(weaponentity);
        view.solid = SOLID_NOT;
        view.owner = e;
        setmodel(view, MDL_Null);  // precision set when changed
@@ -453,7 +454,7 @@ void CL_SpawnWeaponentity(entity e, int slot)
        view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
        view.nextthink = time;
 
-       if (slot == 0)
+       if (weaponentity == weaponentities[0])
        {
                entity exterior = e.exteriorweaponentity = spawn();
                exterior.classname = "exteriorweaponentity";
@@ -470,24 +471,24 @@ void CL_SpawnWeaponentity(entity e, int slot)
 }
 
 // Weapon subs
-void w_clear(Weapon thiswep, entity actor, int slot, int fire)
+void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        if (actor.weapon != -1)
        {
                actor.weapon = 0;
                actor.switchingweapon = 0;
        }
-       if (actor.weaponentity[slot])
+       if (actor.(weaponentity))
        {
-               actor.weaponentity[slot].state = WS_CLEAR;
-               actor.weaponentity[slot].effects = 0;
+               actor.(weaponentity).state = WS_CLEAR;
+               actor.(weaponentity).effects = 0;
        }
 }
 
-void w_ready(Weapon thiswep, entity actor, int slot, int fire)
+void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       if (actor.weaponentity[slot]) actor.weaponentity[slot].state = WS_READY;
-       weapon_thinkf(actor, slot, WFRAME_IDLE, 1000000, w_ready);
+       if (actor.(weaponentity)) actor.(weaponentity).state = WS_READY;
+       weapon_thinkf(actor, weaponentity, WFRAME_IDLE, 1000000, w_ready);
 }
 
 .float prevdryfire;
@@ -542,7 +543,7 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary
 }
 
 .float race_penalty;
-bool weapon_prepareattack_check(Weapon thiswep, entity actor, int slot, bool secondary, float attacktime)
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
 {
        if (!weapon_prepareattack_checkammo(thiswep, actor, secondary)) return false;
 
@@ -558,23 +559,25 @@ bool weapon_prepareattack_check(Weapon thiswep, entity actor, int slot, bool sec
 
        if (attacktime >= 0)
        {
+               int slot = weaponslot(weaponentity);
                // don't fire if previous attack is not finished
                if (ATTACK_FINISHED(actor, slot) > time + actor.weapon_frametime * 0.5) return false;
                // don't fire while changing weapon
-               if (actor.weaponentity[slot].state != WS_READY) return false;
+               if (actor.(weaponentity).state != WS_READY) return false;
        }
        return true;
 }
 
-void weapon_prepareattack_do(entity actor, int slot, bool secondary, float attacktime)
+void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary, float attacktime)
 {
-       actor.weaponentity[slot].state = WS_INUSE;
+       actor.(weaponentity).state = WS_INUSE;
 
        actor.spawnshieldtime = min(actor.spawnshieldtime, time);  // kill spawn shield when you fire
 
        // if the weapon hasn't been firing continuously, reset the timer
        if (attacktime >= 0)
        {
+               int slot = weaponslot(weaponentity);
                if (ATTACK_FINISHED(actor, slot) < time - actor.weapon_frametime * 1.5)
                {
                        ATTACK_FINISHED(actor, slot) = time;
@@ -586,23 +589,23 @@ void weapon_prepareattack_do(entity actor, int slot, bool secondary, float attac
        // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
 }
 
-bool weapon_prepareattack(Weapon thiswep, entity actor, int slot, bool secondary, float attacktime)
+bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
 {
-       if (weapon_prepareattack_check(thiswep, actor, slot, secondary, attacktime))
+       if (weapon_prepareattack_check(thiswep, actor, weaponentity, secondary, attacktime))
        {
-               weapon_prepareattack_do(actor, slot, secondary, attacktime);
+               weapon_prepareattack_do(actor, weaponentity, secondary, attacktime);
                return true;
        }
        return false;
 }
 
-void weapon_thinkf(entity actor, int slot, float fr, float t,
-       void(Weapon thiswep, entity actor, int slot, int fire) func)
+void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t,
+       void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func)
 {
        bool restartanim;
        if (fr == WFRAME_DONTCHANGE)
        {
-               fr = actor.weaponentity[slot].wframe;
+               fr = actor.(weaponentity).wframe;
                restartanim = false;
        }
        else if (fr == WFRAME_IDLE)
@@ -618,24 +621,24 @@ void weapon_thinkf(entity actor, int slot, float fr, float t,
        vector or = v_right;
        vector ou = v_up;
 
-       if (actor.weaponentity[slot])
+       if (actor.(weaponentity))
        {
-               actor.weaponentity[slot].wframe = fr;
+               actor.(weaponentity).wframe = fr;
                vector a = '0 0 0';
-               if (fr == WFRAME_IDLE) a = actor.weaponentity[slot].anim_idle;
-               else if (fr == WFRAME_FIRE1) a = actor.weaponentity[slot].anim_fire1;
-               else if (fr == WFRAME_FIRE2) a = actor.weaponentity[slot].anim_fire2;
+               if (fr == WFRAME_IDLE) a = actor.(weaponentity).anim_idle;
+               else if (fr == WFRAME_FIRE1) a = actor.(weaponentity).anim_fire1;
+               else if (fr == WFRAME_FIRE2) a = actor.(weaponentity).anim_fire2;
                else  // if (fr == WFRAME_RELOAD)
-                       a = actor.weaponentity[slot].anim_reload;
+                       a = actor.(weaponentity).anim_reload;
                a.z *= g_weaponratefactor;
-               setanim(actor.weaponentity[slot], a, restartanim == false, restartanim, restartanim);
+               setanim(actor.(weaponentity), a, restartanim == false, restartanim, restartanim);
        }
 
        v_forward = of;
        v_right = or;
        v_up = ou;
 
-       if (actor.weapon_think == w_ready && func != w_ready && actor.weaponentity[slot].state == WS_RAISE) backtrace(
+       if (actor.weapon_think == w_ready && func != w_ready && actor.(weaponentity).state == WS_RAISE) backtrace(
                        "Tried to override initial weapon think function - should this really happen?");
 
        t *= W_WeaponRateFactor();
@@ -683,17 +686,17 @@ bool forbidWeaponUse(entity player)
 
 void W_WeaponFrame(entity actor)
 {
-       int slot = 0; // TODO: unhardcode
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
        if (frametime) actor.weapon_frametime = frametime;
 
-       if (!actor.weaponentity[slot] || actor.health < 1) return;  // Dead player can't use weapons and injure impulse commands
+       if (!actor.(weaponentity) || actor.health < 1) return;  // Dead player can't use weapons and injure impulse commands
 
        if (forbidWeaponUse(actor))
        {
-               if (actor.weaponentity[slot].state != WS_CLEAR)
+               if (actor.(weaponentity).state != WS_CLEAR)
                {
                        Weapon wpn = get_weaponinfo(actor.weapon);
-                       w_ready(wpn, actor, 0, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
+                       w_ready(wpn, actor, weaponentity, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
                        return;
                }
        }
@@ -702,7 +705,7 @@ void W_WeaponFrame(entity actor)
        {
                actor.weapon = 0;
                actor.switchingweapon = 0;
-               actor.weaponentity[slot].state = WS_CLEAR;
+               actor.(weaponentity).state = WS_CLEAR;
                actor.weaponname = "";
                // actor.items &= ~IT_AMMO;
                return;
@@ -716,7 +719,7 @@ void W_WeaponFrame(entity actor)
        // Change weapon
        if (actor.weapon != actor.switchweapon)
        {
-               if (actor.weaponentity[slot].state == WS_CLEAR)
+               if (actor.(weaponentity).state == WS_CLEAR)
                {
                        // end switching!
                        actor.switchingweapon = actor.switchweapon;
@@ -729,7 +732,7 @@ void W_WeaponFrame(entity actor)
                        actor.ammo_field = newwep.ammo_field;
                        Weapon w = get_weaponinfo(actor.switchweapon);
                        w.wr_setup(w);
-                       actor.weaponentity[slot].state = WS_RAISE;
+                       actor.(weaponentity).state = WS_RAISE;
 
                        // set our clip load to the load of the weapon we switched to, if it's reloadable
                        if (newwep.spawnflags & WEP_FLAG_RELOADABLE && newwep.reloading_ammo)  // prevent accessing undefined cvars
@@ -742,14 +745,14 @@ void W_WeaponFrame(entity actor)
                                actor.clip_load = actor.clip_size = 0;
                        }
 
-                       weapon_thinkf(actor, slot, WFRAME_IDLE, newwep.switchdelay_raise, w_ready);
+                       weapon_thinkf(actor, weaponentity, WFRAME_IDLE, newwep.switchdelay_raise, w_ready);
                }
-               else if (actor.weaponentity[slot].state == WS_DROP)
+               else if (actor.(weaponentity).state == WS_DROP)
                {
                        // in dropping phase we can switch at any time
                        actor.switchingweapon = actor.switchweapon;
                }
-               else if (actor.weaponentity[slot].state == WS_READY)
+               else if (actor.(weaponentity).state == WS_READY)
                {
                        // start switching!
                        actor.switchingweapon = actor.switchweapon;
@@ -765,8 +768,8 @@ void W_WeaponFrame(entity actor)
                           )
                        {
                                sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
-                               actor.weaponentity[slot].state = WS_DROP;
-                               weapon_thinkf(actor, slot, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
+                               actor.(weaponentity).state = WS_DROP;
+                               weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
                        }
                }
        }
@@ -809,16 +812,20 @@ void W_WeaponFrame(entity actor)
                                actor.hook_switchweapon = key_pressed;
                                Weapon h = WEP_HOOK;
                                block_weapon = (actor.weapon == h.m_id && (actor.BUTTON_ATCK || key_pressed));
-                               h.wr_think(h, actor, 0, block_weapon ? 1 : 0);
+                               h.wr_think(h, actor, weaponentity, block_weapon ? 1 : 0);
                        }
                }
 
+               v_forward = fo;
+               v_right = ri;
+               v_up = up;
+
                if (!block_weapon)
                {
                        if (w)
                        {
                                Weapon e = get_weaponinfo(actor.weapon);
-                               e.wr_think(e, actor, 0, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
+                               e.wr_think(e, actor, weaponentity, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
                        }
                        else
                        {
@@ -835,7 +842,7 @@ void W_WeaponFrame(entity actor)
                                v_right = ri;
                                v_up = up;
                                Weapon wpn = get_weaponinfo(actor.weapon);
-                               actor.weapon_think(wpn, actor, 0, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
+                               actor.weapon_think(wpn, actor, weaponentity, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
                        }
                        else
                        {
@@ -847,12 +854,12 @@ void W_WeaponFrame(entity actor)
 
 void W_AttachToShotorg(entity actor, entity flash, vector offset)
 {
-       int slot = 0;
+       .entity weaponentity = weaponentities[0];
        flash.owner = actor;
        flash.angles_z = random() * 360;
 
-       if (gettagindex(actor.weaponentity[slot], "shot")) setattachment(flash, actor.weaponentity[slot], "shot");
-       else setattachment(flash, actor.weaponentity[slot], "tag_shot");
+       if (gettagindex(actor.(weaponentity), "shot")) setattachment(flash, actor.(weaponentity), "shot");
+       else setattachment(flash, actor.(weaponentity), "tag_shot");
        setorigin(flash, offset);
 
        entity xflash = spawn();
@@ -860,10 +867,10 @@ void W_AttachToShotorg(entity actor, entity flash, vector offset)
 
        flash.viewmodelforclient = actor;
 
-       if (actor.weaponentity[slot].oldorigin.x > 0)
+       if (actor.(weaponentity).oldorigin.x > 0)
        {
                setattachment(xflash, actor.exteriorweaponentity, "");
-               setorigin(xflash, actor.weaponentity[slot].oldorigin + offset);
+               setorigin(xflash, actor.(weaponentity).oldorigin + offset);
        }
        else
        {
@@ -916,7 +923,7 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use)
 .float reload_complain;
 .string reload_sound;
 
-void W_ReloadedAndReady(Weapon thiswep, entity actor, int slot, int fire)
+void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        // finish the reloading process, and do the ammo transfer
 
@@ -943,12 +950,12 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, int slot, int fire)
        // ATTACK_FINISHED(actor, slot) -= actor.reload_time - 1;
 
        Weapon wpn = get_weaponinfo(actor.weapon);
-       w_ready(wpn, actor, slot, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
+       w_ready(wpn, actor, weaponentity, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
 }
 
 void W_Reload(entity actor, float sent_ammo_min, string sent_sound)
 {
-       int slot = 0;
+       .entity weaponentity = weaponentities[0];
        // set global values to work with
        entity e = get_weaponinfo(actor.weapon);
 
@@ -1000,12 +1007,12 @@ void W_Reload(entity actor, float sent_ammo_min, string sent_sound)
                }
        }
 
-       if (actor.weaponentity[slot])
+       if (actor.(weaponentity))
        {
-               if (actor.weaponentity[slot].wframe == WFRAME_RELOAD) return;
+               if (actor.(weaponentity).wframe == WFRAME_RELOAD) return;
 
                // allow switching away while reloading, but this will cause a new reload!
-               actor.weaponentity[slot].state = WS_READY;
+               actor.(weaponentity).state = WS_READY;
        }
 
        // now begin the reloading process
@@ -1018,7 +1025,7 @@ void W_Reload(entity actor, float sent_ammo_min, string sent_sound)
 
        // ATTACK_FINISHED(actor, slot) = max(time, ATTACK_FINISHED(actor, slot)) + actor.reload_time + 1;
 
-       weapon_thinkf(actor, slot, WFRAME_RELOAD, actor.reload_time, W_ReloadedAndReady);
+       weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, actor.reload_time, W_ReloadedAndReady);
 
        if (actor.clip_load < 0) actor.clip_load = 0;
        actor.old_clip_load = actor.clip_load;
index c5ee7abb6daf52e8220e5968c553d5e300d0c259..97e6c72b4be3698caee7cfca657bf4fd4858c4f2 100644 (file)
@@ -18,7 +18,7 @@ vector shotorg_adjust(vector vecs, bool y_is_right, bool visual, int algn);
 
 vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn);
 
-void CL_SpawnWeaponentity(entity e, int slot);
+void CL_SpawnWeaponentity(entity e, .entity weaponentity);
 
 vector CL_Weapon_GetShotOrg(float wpn);
 
@@ -38,12 +38,12 @@ float W_WeaponRateFactor();
 
 float W_WeaponSpeedFactor();
 
-bool weapon_prepareattack(Weapon thiswep, entity actor, int slot, bool secondary, float attacktime);
+bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime);
 
-bool weapon_prepareattack_check(Weapon thiswep, entity actor, int slot, float secondary, float attacktime);
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, float secondary, float attacktime);
 
-void weapon_prepareattack_do(entity actor, int slot, float secondary, float attacktime);
+void weapon_prepareattack_do(entity actor, .entity weaponentity, float secondary, float attacktime);
 
-void weapon_thinkf(entity actor, int slot, float fr, float t, void(Weapon thiswep, entity actor, int slot, int fire) func);
+void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);
 
 #endif