Hook: merge offhand and weapon behaviour
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 6 Oct 2015 00:00:09 +0000 (11:00 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 6 Oct 2015 00:00:09 +0000 (11:00 +1100)
Fixes offhand with nades
Fixes ammo

43 files changed:
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/monster/wyvern.qc
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_weapon.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
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/cl_client.qc
qcsrc/server/g_hook.qc
qcsrc/server/g_hook.qh
qcsrc/server/mutators/gamemode_nexball.qc
qcsrc/server/weapons/weaponsystem.qc
qcsrc/server/weapons/weaponsystem.qh

index 54d17d9..9952063 100644 (file)
@@ -42,7 +42,7 @@ void M_Mage_Attack_Spike(vector dir);
 void M_Mage_Attack_Push();
 METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bool fire2)) {
     if (fire1)
-    if (!IS_PLAYER(actor) || weapon_prepareattack(actor, false, 0.2)) {
+    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, 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);
@@ -51,7 +51,7 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bo
         weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
     }
     if (fire2)
-    if (!IS_PLAYER(actor) || weapon_prepareattack(actor, true, 0.5)) {
+    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, true, 0.5)) {
         M_Mage_Attack_Push();
         weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
     }
index e262ca8..35a320b 100644 (file)
@@ -53,7 +53,7 @@ void M_Spider_Attack_Web();
 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(actor, false, autocvar_g_monster_spider_attack_web_delay)) {
+    if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, false, autocvar_g_monster_spider_attack_web_delay)) {
                if (!isPlayer) {
                        actor.spider_web_delay = time + 3;
                        setanim(actor, actor.anim_shoot, true, true, true);
@@ -68,7 +68,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fir
         return;
     }
     if (fire2)
-    if (!isPlayer || weapon_prepareattack(actor, true, 0.5)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, true, 0.5)) {
        if (isPlayer) {
                actor.enemy = Monster_FindTarget(actor);
                actor.attack_range = 60;
index c901e3a..102fd6a 100644 (file)
@@ -50,7 +50,7 @@ void M_Wyvern_Attack_Fireball_Touch();
 
 METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, bool fire1, bool fire2)) {
     if (fire1)
-    if (time > actor.attack_finished_single || weapon_prepareattack(actor, false, 1.2)) {
+    if (time > actor.attack_finished_single || weapon_prepareattack(thiswep, actor, 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 = time + 1.2;
index 2e8e8dc..86444bb 100644 (file)
@@ -19,7 +19,7 @@ void turret_initparams(entity);
 METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 31bc7cb..4c60805 100644 (file)
@@ -19,7 +19,7 @@ void turret_flac_projectile_think_explode();
 METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 0503cbd..491fa73 100644 (file)
@@ -22,7 +22,7 @@ void turret_hellion_missile_think();
 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 51ce0d9..9fe73f8 100644 (file)
@@ -27,7 +27,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, bool fir
 {
        bool isPlayer = IS_PLAYER(actor);
        if (fire1)
-       if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+       if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 264053f..9b14898 100644 (file)
@@ -21,7 +21,7 @@ METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, bool
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR(machinegun, sustained_refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index f2d442d..3b420f3 100644 (file)
@@ -19,7 +19,7 @@ METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR(machinegun, sustained_refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index aa71a47..2cb036b 100644 (file)
@@ -22,7 +22,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fir
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 83c2050..65a6630 100644 (file)
@@ -18,7 +18,7 @@ REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
 METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
        bool isPlayer = IS_PLAYER(actor);
        if (fire1)
-       if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+       if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 8a4f55e..3a8eb1d 100644 (file)
@@ -19,7 +19,7 @@ entity toast(entity from, float range, float damage);
 METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 676bf89..9a54f81 100644 (file)
@@ -18,7 +18,7 @@ REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack));
 METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, 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);
index 094d125..d5a4c12 100644 (file)
@@ -48,7 +48,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, boo
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     if (fire1)
-    if (weapon_prepareattack(player, false, autocvar_g_vehicle_racer_cannon_refire)) {
+    if (weapon_prepareattack(thiswep, player, false, autocvar_g_vehicle_racer_cannon_refire)) {
         if (veh) {
             veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost;
             veh.wait = time;
@@ -64,7 +64,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, boo
         weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready);
     }
     if (fire2)
-    if (!isPlayer || weapon_prepareattack(actor, false, 0.2)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, false, 0.2)) {
         if (isPlayer) W_SetupShot_Dir(actor, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0);
         racer_fire_rocket(w_shotorg, w_shotdir, NULL);
         weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
index 62d8c12..ebc7378 100644 (file)
@@ -58,7 +58,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bo
     // 1 [wait] 1 [wait] 2 [wait] 2 [wait] [wait]
     float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4);
     if (fire1)
-    if (weapon_prepareattack(player, false, t)) {
+    if (weapon_prepareattack(thiswep, player, 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;
@@ -93,7 +93,7 @@ METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, bool fire1, bool
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     if (fire2)
-    if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_bombs_refire)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_bombs_refire)) {
         if (veh) setself(veh);
         raptor_bombdrop();
         weapon_thinkf(player, WFRAME_FIRE2, 0, w_ready);
@@ -114,7 +114,7 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, boo
     entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     if (fire2)
-    if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_flare_refire)) {
+    if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_flare_refire)) {
         for(int i = 0; i < 3; ++i) {
             entity _flare = spawn();
             setmodel(_flare, MDL_VEH_RAPTOR_FLARE);
index 0ec1d7a..e1796bd 100644 (file)
@@ -677,7 +677,7 @@ void Arc_Smoke()
 
                                if((!actor.arc_beam) || wasfreed(actor.arc_beam))
                                {
-                                       if(weapon_prepareattack(actor, fire2, 0))
+                                       if(weapon_prepareattack(thiswep, actor, fire2, 0))
                                        {
                                                W_Arc_Beam(fire2);
 
@@ -702,7 +702,7 @@ void Arc_Smoke()
 
                        #if 0
                        if(fire2)
-                       if(weapon_prepareattack(actor, true, autocvar_g_balance_arc_secondary_refire))
+                       if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_arc_secondary_refire))
                        {
                                W_Arc_Attack2();
                                actor.arc_count = autocvar_g_balance_arc_secondary_count;
index 5d63667..d7792fa 100644 (file)
@@ -165,7 +165,7 @@ void W_Blaster_Attack(
                {
                        if(fire1)
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(blaster, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(blaster, refire)))
                                {
                                        W_Blaster_Attack(
                                                actor,
@@ -196,7 +196,7 @@ void W_Blaster_Attack(
 
                                        case 1: // normal projectile secondary
                                        {
-                                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(blaster, refire)))
+                                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(blaster, refire)))
                                                {
                                                        W_Blaster_Attack(
                                                                actor,
index d72320c..75d8146 100644 (file)
@@ -584,7 +584,7 @@ void W_Crylink_Attack2(Weapon thiswep)
                        if(fire1)
                        {
                                if(actor.crylink_waitrelease != 1)
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(crylink, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(crylink, refire)))
                                {
                                        W_Crylink_Attack(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
@@ -594,7 +594,7 @@ void W_Crylink_Attack2(Weapon thiswep)
                        if(fire2 && autocvar_g_balance_crylink_secondary)
                        {
                                if(actor.crylink_waitrelease != 2)
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(crylink, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(crylink, refire)))
                                {
                                        W_Crylink_Attack2(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
index 3d0b46d..8c08086 100644 (file)
@@ -527,7 +527,7 @@ void W_Devastator_Attack(Weapon thiswep)
                                if(fire1)
                                {
                                        if(actor.rl_release || WEP_CVAR(devastator, guidestop))
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(devastator, refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(devastator, refire)))
                                        {
                                                W_Devastator_Attack(thiswep);
                                                weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
index 8b643e5..7321d38 100644 (file)
@@ -410,7 +410,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2)
 {SELFPARAM();
        if(self.electro_count > 1)
        if(self.BUTTON_ATCK2)
-       if(weapon_prepareattack(actor, true, -1))
+       if(weapon_prepareattack(thiswep, actor, true, -1))
        {
                W_Electro_Attack_Orb(WEP_ELECTRO);
                self.electro_count -= 1;
@@ -471,7 +471,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2)
 
                        if(fire1)
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire)))
                                {
                                                W_Electro_Attack_Bolt(thiswep);
                                                weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
@@ -480,7 +480,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2)
                        else if(fire2)
                        {
                                if(time >= actor.electro_secondarytime)
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(electro, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(electro, refire)))
                                {
                                        W_Electro_Attack_Orb(thiswep);
                                        actor.electro_count = WEP_CVAR_SEC(electro, count);
index dd5d8c2..b0761b2 100644 (file)
@@ -376,7 +376,7 @@ void W_Fireball_Attack2(void)
                        if(fire1)
                        {
                                if(time >= actor.fireball_primarytime)
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(fireball, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(fireball, refire)))
                                {
                                        W_Fireball_Attack1_Frame0(thiswep, actor, fire1, fire2);
                                        actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
@@ -384,7 +384,7 @@ void W_Fireball_Attack2(void)
                        }
                        else if(fire2)
                        {
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(fireball, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(fireball, refire)))
                                {
                                        W_Fireball_Attack2();
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
index c7712bf..37f6875 100644 (file)
@@ -419,7 +419,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep)
                                w.wr_reload(w);
                        } else if(fire1 && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(hagar, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hagar, refire)))
                                {
                                        W_Hagar_Attack(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
@@ -427,7 +427,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep)
                        }
                        else if(fire2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
                        {
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hagar, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hagar, refire)))
                                {
                                        W_Hagar_Attack2(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
index fb1d9fc..616939d 100644 (file)
@@ -218,7 +218,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep)
                                w.wr_reload(w);
                        } else if(fire1)
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(hlac, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hlac, refire)))
                                {
                                        actor.misc_bulletcounter = 0;
                                        W_HLAC_Attack(thiswep);
@@ -228,7 +228,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep)
 
                        else if(fire2 && WEP_CVAR(hlac, secondary))
                        {
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hlac, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hlac, refire)))
                                {
                                        W_HLAC_Attack2_Frame(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
index bcbefbf..6707a7c 100644 (file)
@@ -104,7 +104,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, boo
                        } else
                        {
                                if (fire1)
-                               if (weapon_prepareattack(actor, false, 0))
+                               if (weapon_prepareattack(thiswep, actor, false, 0))
                                {
                                        actor.misc_bulletcounter = 0;
                                        W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
index 48fdb65..e279b79 100644 (file)
@@ -18,10 +18,10 @@ ENDCLASS(Hook)
 REGISTER_WEAPON(HOOK, NEW(Hook));
 
 CLASS(OffhandHook, OffhandWeapon)
-    METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity player, bool key_pressed))
+    METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed))
     {
        Weapon wep = WEP_HOOK;
-       WITH(entity, self, player, wep.wr_think(wep, self, key_pressed, false));
+       wep.wr_think(wep, actor, key_pressed, false);
     }
 ENDCLASS(OffhandHook)
 OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); }
@@ -175,23 +175,25 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
 
                METHOD(Hook, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
                {
-                       if(fire1 || actor.BUTTON_HOOK)
-                       {
+                       if (fire1) {
                                if(!actor.hook)
                                if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE))
-                               if(!(actor.hook_state & HOOK_FIRING))
                                if(time > actor.hook_refire)
-                               if(weapon_prepareattack(actor, false, -1))
+                               if(weapon_prepareattack(thiswep, actor, false, -1))
                                {
                                        W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hook, ammo));
                                        actor.hook_state |= HOOK_FIRING;
+                                       actor.hook_state |= HOOK_WAITING_FOR_RELEASE;
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready);
                                }
+                       } else {
+                               actor.hook_state |= HOOK_REMOVING;
+                               actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
                        }
 
                        if(fire2)
                        {
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hook, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hook, refire)))
                                {
                                        W_Hook_Attack2(thiswep, actor);
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready);
@@ -246,33 +248,22 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
                                actor.hook_time_fueldecrease = time + WEP_CVAR_PRI(hook, hooked_time_free);
                        }
 
-                       if(actor.BUTTON_CROUCH)
+                       actor.hook_state = BITSET(actor.hook_state, HOOK_PULLING, (!actor.BUTTON_CROUCH || !autocvar_g_balance_grapplehook_crouchslide));
+
+                       if (actor.hook_state & HOOK_FIRING)
                        {
-                               actor.hook_state &= ~HOOK_PULLING;
-                               if(fire1 || actor.BUTTON_HOOK)
-                                       actor.hook_state &= ~HOOK_RELEASING;
-                               else
-                                       actor.hook_state |= HOOK_RELEASING;
+                               if (actor.hook)
+                                       RemoveGrapplingHook(actor);
+                               WITH(entity, self, actor, FireGrapplingHook());
+                               actor.hook_state &= ~HOOK_FIRING;
+                               actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor());
                        }
-                       else
+                       else if (actor.hook_state & HOOK_REMOVING)
                        {
-                               actor.hook_state |= HOOK_PULLING;
-                               actor.hook_state &= ~HOOK_RELEASING;
-
-                               if(fire1 || actor.BUTTON_HOOK)
-                               {
-                                       // already fired
-                                       if(actor.hook)
-                                               actor.hook_state |= HOOK_WAITING_FOR_RELEASE;
-                               }
-                               else
-                               {
-                                       actor.hook_state |= HOOK_REMOVING;
-                                       actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
-                               }
+                               if (actor.hook)
+                                       RemoveGrapplingHook(actor);
+                               actor.hook_state &= ~HOOK_REMOVING;
                        }
-
-                       _GrapplingHookFrame();
                }
                METHOD(Hook, wr_init, void(entity thiswep))
                {
index 688600c..90a4471 100644 (file)
@@ -256,14 +256,14 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi
                        if(WEP_CVAR(machinegun, mode) == 1)
                        {
                                if(fire1)
-                               if(weapon_prepareattack(actor, false, 0))
+                               if(weapon_prepareattack(thiswep, actor, false, 0))
                                {
                                        actor.misc_bulletcounter = 0;
                                        W_MachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
                                }
 
                                if(fire2)
-                               if(weapon_prepareattack(actor, true, 0))
+                               if(weapon_prepareattack(thiswep, actor, true, 0))
                                {
                                        Weapon w = get_weaponinfo(actor.weapon);
                                        if(!w.wr_checkammo2(w))
@@ -284,7 +284,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi
                        {
 
                                if(fire1)
-                               if(weapon_prepareattack(actor, false, 0))
+                               if(weapon_prepareattack(thiswep, actor, false, 0))
                                {
                                        actor.misc_bulletcounter = 1;
                                        W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); // sets attack_finished
@@ -292,7 +292,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi
                                }
 
                                if(fire2 && WEP_CVAR(machinegun, first))
-                               if(weapon_prepareattack(actor, true, 0))
+                               if(weapon_prepareattack(thiswep, actor, true, 0))
                                {
                                        actor.misc_bulletcounter = 1;
                                        W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished
index 75cc7e4..548ede9 100644 (file)
@@ -511,7 +511,7 @@ float W_MineLayer_PlacedMines(float detonate)
                        }
                        else if(fire1)
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR(minelayer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(minelayer, refire)))
                                {
                                        W_MineLayer_Attack(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
index 34d64f0..c199574 100644 (file)
@@ -341,7 +341,7 @@ void W_Mortar_Attack2(Weapon thiswep)
                                w.wr_reload(w);
                        } else if(fire1)
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(mortar, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(mortar, refire)))
                                {
                                        W_Mortar_Attack(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
@@ -364,7 +364,7 @@ void W_Mortar_Attack2(Weapon thiswep)
                                        if(nadefound)
                                                sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
                                }
-                               else if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(mortar, refire)))
+                               else if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(mortar, refire)))
                                {
                                        W_Mortar_Attack2(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready);
index cf802ac..b174766 100644 (file)
@@ -305,7 +305,7 @@ void W_Porto_Attack(float type)
                                if(fire1)
                                if(!actor.porto_current)
                                if(!actor.porto_forbidden)
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(porto, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire)))
                                {
                                        W_Porto_Attack(0);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
@@ -314,7 +314,7 @@ void W_Porto_Attack(float type)
                                if(fire2)
                                if(!actor.porto_current)
                                if(!actor.porto_forbidden)
-                               if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(porto, refire)))
+                               if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(porto, refire)))
                                {
                                        W_Porto_Attack(1);
                                        weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
@@ -347,7 +347,7 @@ void W_Porto_Attack(float type)
                                if(fire1)
                                if(!actor.porto_current)
                                if(!actor.porto_forbidden)
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(porto, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire)))
                                {
                                        W_Porto_Attack(-1);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
index 73590a5..49b3931 100644 (file)
@@ -99,7 +99,7 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, bool fire1, bool
        actor.switchweapon = actor.weapon;
        ATTACK_FINISHED(actor) = time;
        LOG_INFO(ftos(actor.WEP_AMMO(RIFLE)), "\n");
-       r = weapon_prepareattack(actor, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
+       r = weapon_prepareattack(thiswep, actor, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
        if(actor.switchweapon == actor.weapon)
                actor.switchweapon = sw;
        if(r)
@@ -169,7 +169,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt
                        {
                                actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
                                if(fire1)
-                               if(weapon_prepareattack_check(actor, false, WEP_CVAR_PRI(rifle, refire)))
+                               if(weapon_prepareattack_check(thiswep, actor, false, WEP_CVAR_PRI(rifle, refire)))
                                if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
                                {
                                        weapon_prepareattack_do(actor, false, WEP_CVAR_PRI(rifle, refire));
@@ -185,7 +185,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt
                                                        w.wr_reload(w);
                                                } else
                                                {
-                                                       if(weapon_prepareattack_check(actor, true, WEP_CVAR_SEC(rifle, refire)))
+                                                       if(weapon_prepareattack_check(thiswep, actor, true, WEP_CVAR_SEC(rifle, refire)))
                                                        if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
                                                        {
                                                                weapon_prepareattack_do(actor, true, WEP_CVAR_SEC(rifle, refire));
index 700e66b..71ddaa6 100644 (file)
@@ -162,7 +162,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
                        {
                                if (fire1)
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(rpc, refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(rpc, refire)))
                                        {
                                                W_RocketPropelledChainsaw_Attack(thiswep);
                                                weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
index 365061e..645bd9e 100644 (file)
@@ -617,7 +617,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        {
                                if(WEP_CVAR(seeker, type) == 1)
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, missile_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, missile_refire)))
                                        {
                                                W_Seeker_Attack();
                                                weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
@@ -625,7 +625,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                                }
                                else
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, tag_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, tag_refire)))
                                        {
                                                W_Seeker_Fire_Tag(thiswep);
                                                weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
@@ -637,7 +637,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        {
                                if(WEP_CVAR(seeker, type) == 1)
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, tag_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, tag_refire)))
                                        {
                                                W_Seeker_Fire_Tag(thiswep);
                                                weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
@@ -645,7 +645,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                                }
                                else
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, flac_refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, flac_refire)))
                                        {
                                                W_Seeker_Fire_Flac(thiswep);
                                                weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
index a99c519..30ffaca 100644 (file)
@@ -681,7 +681,7 @@ void W_Shockwave_Attack(void)
                        {
                                if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR(shockwave, blast_animtime)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(shockwave, blast_animtime)))
                                        {
                                                W_Shockwave_Attack();
                                                actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
@@ -693,7 +693,7 @@ void W_Shockwave_Attack(void)
                        {
                                //if(actor.clip_load >= 0) // we are not currently reloading
                                if(!actor.crouch) // no crouchmelee please
-                               if(weapon_prepareattack(actor, true, WEP_CVAR(shockwave, melee_refire)))
+                               if(weapon_prepareattack(thiswep, actor, 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, WFRAME_FIRE1, 0, W_Shockwave_Melee);
index 813fce3..a5cb397 100644 (file)
@@ -250,7 +250,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir
                                {
                                        if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
                                        {
-                                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(shotgun, animtime)))
+                                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(shotgun, animtime)))
                                                {
                                                        W_Shotgun_Attack(thiswep, true);
                                                        actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor();
@@ -262,7 +262,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir
                                {
                                        if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
                                        {
-                                               if(weapon_prepareattack(actor, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
+                                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
                                                {
                                                        W_Shotgun_Attack(thiswep, false);
                                                        actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor();
@@ -275,7 +275,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir
                        if(!actor.crouch) // no crouchmelee please
                        if(WEP_CVAR(shotgun, secondary) == 1)
                        if((fire1 && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || fire2)
-                       if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(shotgun, refire)))
+                       if(weapon_prepareattack(thiswep, actor, 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, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
index e6bd46c..d1c86de 100644 (file)
@@ -382,14 +382,14 @@ void W_Tuba_NoteOn(float hittype)
                METHOD(Tuba, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
                {
                        if(fire1)
-                       if(weapon_prepareattack(actor, false, WEP_CVAR(tuba, refire)))
+                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(0);
                                //weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
                                weapon_thinkf(actor, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
                        if(fire2)
-                       if(weapon_prepareattack(actor, true, WEP_CVAR(tuba, refire)))
+                       if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(HITTYPE_SECONDARY);
                                //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
index 012bd85..f7aceee 100644 (file)
@@ -257,7 +257,7 @@ void W_RocketMinsta_Attack3 (void)
                        }
                        if(fire1 && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
                        {
-                               if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(vaporizer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vaporizer, refire)))
                                {
                                        W_Vaporizer_Attack(thiswep);
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
index d097467..c51028b 100644 (file)
@@ -163,7 +163,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                        {
                                if(fire1)
                                {
-                                       if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(vortex, refire)))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vortex, refire)))
                                        {
                                                W_Vortex_Attack(thiswep, 0);
                                                weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
@@ -235,7 +235,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                                        }
                                        else if(WEP_CVAR(vortex, secondary))
                                        {
-                                               if(weapon_prepareattack(actor, false, WEP_CVAR_SEC(vortex, refire)))
+                                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_SEC(vortex, refire)))
                                                {
                                                        W_Vortex_Attack(thiswep, 1);
                                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
index 7914804..eedecf8 100644 (file)
@@ -2546,8 +2546,6 @@ void PlayerPreThink (void)
 
                FixPlayermodel();
 
-               GrapplingHookFrame();
-
                // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
                //if(frametime)
                {
index 95b8c7b..87d7e0e 100644 (file)
@@ -65,7 +65,6 @@ And you should be done!
 ============================================*/
 
 .float hook_length;
-.float hook_switchweapon;
 
 void RemoveGrapplingHook(entity pl)
 {
@@ -405,111 +404,6 @@ void FireGrapplingHook (void)
        Net_LinkEntity(missile, false, 0, GrapplingHookSend);
 }
 
-//  void GrapplingHookFrame()
-//  {
-//         // this function has been modified for Xonotic
-// -       if (self.BUTTON_HOOK && g_grappling_hook)
-//         {
-// -               if (!self.hook && self.hook_time <= time && !self.button6_pressed_before)
-// -                       if (timeoutStatus != 2) //only allow the player to fire the grappling hook if the game is not paused (timeout)
-// -                               FireGrapplingHook();
-//         }
-// -       else
-//         {
-//                 if (self.hook)
-//                         RemoveGrapplingHook(self);
-//         }
-// -       self.button6_pressed_before = self.BUTTON_HOOK;
-//         /*
-//         // if I have no hook or it's not pulling yet, make sure I'm not flying!
-//         if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
-
-void _GrapplingHookFrame();
-void GrapplingHookFrame()
-{SELFPARAM();
-       if (self.offhand == OFFHAND_HOOK) {
-        if (timeout_status != TIMEOUT_ACTIVE && self.weapon != WEP_HOOK.m_id && !self.vehicle) {
-            // offhand hook controls
-            if (self.BUTTON_HOOK) {
-                if (!(self.hook || (self.hook_state & HOOK_WAITING_FOR_RELEASE)) && (time > self.hook_refire)) {
-                    self.hook_state |= HOOK_FIRING;
-                    self.hook_state |= HOOK_WAITING_FOR_RELEASE;
-                }
-            } else {
-                self.hook_state |= HOOK_REMOVING;
-                self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
-            }
-
-            self.hook_state &= ~HOOK_RELEASING;
-            if (self.BUTTON_CROUCH && autocvar_g_balance_grapplehook_crouchslide) {
-                self.hook_state &= ~HOOK_PULLING;
-                //self.hook_state |= HOOK_RELEASING;
-            } else {
-                self.hook_state |= HOOK_PULLING;
-                //self.hook_state &= ~HOOK_RELEASING;
-            }
-        }
-       } else {
-               if (self.switchweapon != WEP_HOOK.m_id && !self.vehicle) {
-                       if (self.BUTTON_HOOK && !self.hook_switchweapon)
-                               W_SwitchWeapon(WEP_HOOK.m_id);
-               }
-               if (self.weapon != WEP_HOOK.m_id && self.offhand != OFFHAND_HOOK) {
-                       self.hook_state &= ~HOOK_FIRING;
-                       self.hook_state |= HOOK_REMOVING;
-               }
-       }
-       self.hook_switchweapon = self.BUTTON_HOOK;
-       _GrapplingHookFrame();
-}
-
-void _GrapplingHookFrame()
-{
-       if (self.hook_state & HOOK_FIRING)
-       {
-               if (self.hook)
-                       RemoveGrapplingHook(self);
-               FireGrapplingHook();
-               self.hook_state &= ~HOOK_FIRING;
-               self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor());
-       }
-       else if(self.hook_state & HOOK_REMOVING)
-       {
-               if (self.hook)
-                       RemoveGrapplingHook(self);
-               self.hook_state &= ~HOOK_REMOVING;
-       }
-
-       /*
-       // if I have no hook or it's not pulling yet, make sure I'm not flying!
-       if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
-       {
-               self.movetype = MOVETYPE_WALK;
-       }
-       if(self.impulse == GRAPHOOK_FIRE && self.hook_time <= time && g_grappling_hook)
-       {
-               // fire hook
-               FireGrapplingHook();
-               return;
-       }
-       else if(self.hookimpulse == GRAPHOOK_RELEASE)
-       {
-               // remove hook, reset movement type
-               RemoveGrapplingHook(self);
-               return;
-       }
-       */
-       /*else // make sure the player's movetype is correct
-       {
-               //if(self.hook == world && self.movetype == MOVETYPE_FLY)
-               if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
-               {
-                       self.movetype = MOVETYPE_WALK;
-               }
-       }*/
-       // note: The hook entity does the actual pulling
-}
-
 void GrappleHookInit()
 {
        if(g_grappling_hook)
index 2618914..140a93c 100644 (file)
@@ -3,8 +3,6 @@
 
 // Wazat's grappling hook
 .entity                hook;
-void GrapplingHookFrame();
-void _GrapplingHookFrame();
 void RemoveGrapplingHook(entity pl);
 void SetGrappleHookBindings();
 // (note: you can change the hook impulse #'s to whatever you please)
index 2e152bb..f65e058 100644 (file)
@@ -842,7 +842,7 @@ float ball_customize()
        METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2))
        {
                if(fire1)
-                       if(weapon_prepareattack(actor, false, autocvar_g_balance_nexball_primary_refire))
+                       if(weapon_prepareattack(thiswep, actor, false, autocvar_g_balance_nexball_primary_refire))
                                if(autocvar_g_nexball_basketball_meter)
                                {
                                        if(self.ballcarried && !self.metertime)
@@ -856,7 +856,7 @@ float ball_customize()
                                        weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                                }
                if(fire2)
-                       if(weapon_prepareattack(actor, true, autocvar_g_balance_nexball_secondary_refire))
+                       if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_nexball_secondary_refire))
                        {
                                W_Nexball_Attack2();
                                weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
index 208948f..0929d8b 100644 (file)
@@ -457,57 +457,66 @@ void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2)
 
 .float prevdryfire;
 .float prevwarntime;
-bool weapon_prepareattack_checkammo(entity actor, float secondary)
+bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondary)
 {
-       Weapon w = get_weaponinfo(actor.weapon);
-       if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
-       if (!w.(secondary ? wr_checkammo2 : wr_checkammo1)(w))
-       {
-               // always keep the Mine Layer if we placed mines, so that we can detonate them
-               entity mine;
-               if(actor.weapon == WEP_MINE_LAYER.m_id)
-               for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == actor)
-                       return false;
+       if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
+       bool ammo = false;
+       if (secondary) {
+               WITH(entity, self, actor, ammo = thiswep.wr_checkammo2(thiswep));
+       } else {
+               WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
+       }
+       if (ammo) return true;
+       // always keep the Mine Layer if we placed mines, so that we can detonate them
+       entity mine;
+       if(actor.weapon == WEP_MINE_LAYER.m_id)
+       for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == actor)
+               return false;
 
-               if(actor.weapon == WEP_SHOTGUN.m_id)
-               if(!secondary && WEP_CVAR(shotgun, secondary) == 1)
-                       return false; // no clicking, just allow
+       if(actor.weapon == WEP_SHOTGUN.m_id)
+       if(!secondary && WEP_CVAR(shotgun, secondary) == 1)
+               return false; // no clicking, just allow
 
-               if(actor.weapon == actor.switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
-               {
-                       sound (actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
-                       actor.prevdryfire = time;
-               }
+       if(actor.weapon == actor.switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
+       {
+               sound (actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
+               actor.prevdryfire = time;
+       }
 
-               if(w.(secondary ? wr_checkammo1 : wr_checkammo2)(w)) // check if the other firing mode has enough ammo
-               {
-                       if(time - actor.prevwarntime > 1)
-                       {
-                               Send_Notification(
-                                       NOTIF_ONE,
-                                       actor,
-                                       MSG_MULTI,
-                                       ITEM_WEAPON_PRIMORSEC,
-                                       actor.weapon,
-                                       secondary,
-                                       (1 - secondary)
-                               );
-                       }
-                       actor.prevwarntime = time;
-               }
-               else // this weapon is totally unable to fire, switch to another one
+       // check if the other firing mode has enough ammo
+       bool ammo_other = false;
+       if (secondary) {
+               WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
+       } else {
+               WITH(entity, self, actor, ammo = thiswep.wr_checkammo2(thiswep));
+       }
+       if (ammo_other)
+       {
+               if (time - actor.prevwarntime > 1)
                {
-                       W_SwitchToOtherWeapon(actor);
+                       Send_Notification(
+                               NOTIF_ONE,
+                               actor,
+                               MSG_MULTI,
+                               ITEM_WEAPON_PRIMORSEC,
+                               actor.weapon,
+                               secondary,
+                               (1 - secondary)
+                       );
                }
-
-               return false;
+               actor.prevwarntime = time;
        }
-       return true;
+       else // this weapon is totally unable to fire, switch to another one
+       {
+               W_SwitchToOtherWeapon(actor);
+       }
+
+       return false;
 }
 .float race_penalty;
-bool weapon_prepareattack_check(entity actor, bool secondary, float attacktime)
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, bool secondary, float attacktime)
 {
-       if(!weapon_prepareattack_checkammo(actor, secondary))
+       if(!weapon_prepareattack_checkammo(thiswep, actor, secondary))
                return false;
 
        //if sv_ready_restart_after_countdown is set, don't allow the player to shoot
@@ -553,9 +562,9 @@ void weapon_prepareattack_do(entity actor, bool secondary, float attacktime)
        actor.bulletcounter += 1;
        //dprint("attack finished ", ftos(ATTACK_FINISHED(actor)), "\n");
 }
-bool weapon_prepareattack(entity actor, bool secondary, float attacktime)
+bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime)
 {
-       if (weapon_prepareattack_check(actor, secondary, attacktime)) {
+       if (weapon_prepareattack_check(thiswep, actor, secondary, attacktime)) {
                weapon_prepareattack_do(actor, secondary, attacktime);
                return true;
        }
@@ -653,6 +662,8 @@ float forbidWeaponUse(entity player)
        return 0;
 }
 
+.bool hook_switchweapon;
+
 void W_WeaponFrame(entity actor)
 {
        vector fo, ri, up;
@@ -766,12 +777,24 @@ void W_WeaponFrame(entity actor)
                v_right = ri;
                v_up = up;
 
+               bool block_weapon = false;
                {
-                       bool key_pressed = actor.BUTTON_HOOK;
-               Weapon wpn = actor.offhand;
-               if (wpn.offhand_think) wpn.offhand_think(wpn, actor, key_pressed);
+                       bool key_pressed = actor.BUTTON_HOOK && !actor.vehicle;
+               Weapon off = actor.offhand;
+               if (off) {
+                       if (off.offhand_think) off.offhand_think(off, actor, key_pressed);
+               } else {
+                       if (key_pressed && actor.switchweapon != WEP_HOOK.m_id && !actor.hook_switchweapon) {
+                                       W_SwitchWeapon(WEP_HOOK.m_id);
+                               }
+                               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, block_weapon, false);
+               }
         }
 
+               if (!block_weapon)
                if (w) {
                        Weapon e = get_weaponinfo(actor.weapon);
                        e.wr_think(e, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2);
index d3d9f14..e1fc092 100644 (file)
@@ -34,9 +34,9 @@ float W_WeaponRateFactor();
 
 float W_WeaponSpeedFactor();
 
-bool weapon_prepareattack(entity actor, bool secondary, float attacktime);
+bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime);
 
-bool weapon_prepareattack_check(entity actor, float secondary, float attacktime);
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, float secondary, float attacktime);
 
 void weapon_prepareattack_do(entity actor, float secondary, float attacktime);