]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 54d17d934e33030ba55c4f956a0fd66a9a2f025a..9952063f60133e5fe4845ffd5f76e66ae7065d30 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 e262ca87dbb9593d47a72162df73ef4f54bf4b00..35a320b9d50908b6209927e604db3f6004f57397 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 c901e3ae3e669ad0a0ab69cd1439b0ff4b0474d1..102fd6a5c1fdfb1aa4a58bcc320c195f645ce03f 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 2e8e8dc29d1ae87ec6a11a97a38e63483d5f53e9..86444bb486a5c972faf03c8fc3d38b807a09c026 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 31bc7cb7b3d663c2964ac319c2386fbc23c8c0ae..4c60805d266c77d19b3e71df6d3a31e30d6cc456 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 0503cbd90a03d4275e0961e6f18103b75cc2c516..491fa734ed61b750172cdb8d00954c9cdef27221 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 51ce0d98304f0928cf29c1b596949c1be76df138..9fe73f830631a8d1353b02e7fbf2422899dcbffa 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 264053fb61374147f6e71d2ff4eee9c742d6ac55..9b14898298b6c2202c667d83f1ad77e045c5313f 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 f2d442df8c251ebacd84bd7ea097ba3f214c6349..3b420f32916fac2297d1031a49bd695fbd5d2e2d 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 aa71a47d008c08eac2cb62139a4c7170c566936c..2cb036bc557582cc1dca9ef80da2c21f0f7f5d77 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 83c205026315af710dd41af4a89b3e1504a1d5c4..65a663057402da9b8fcf7162d25c5a4800544809 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 8a4f55ed8b4c4b2740df5516d4375ec793ab6a7c..3a8eb1d52bb84426527f695af313bf261c8ac835 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 676bf896e59ae76059142cca0c99058a58537e58..9a54f810f55237cb95bc3b16dcc700234be2c47f 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 094d1251471743c481d1e9202ea873bc63bec313..d5a4c1231089ae846c2fe06be2ee4f5ed5646421 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 62d8c12e567901bdb41627abcc091bb949bcb8ef..ebc73787ce1b8df2d100b8addfe261b9abaa290c 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 0ec1d7a09c4a005bb99b482df3524d5d7dd7d141..e1796bdf235a4d6bee4873a3e53d9e95c1357048 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 5d636674d0419fa28ecbaaa12ba4c483c8899618..d7792fac4aef157ea91a93f6a8b72a54c0facb8b 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 d72320cf2d131b3ffcef7fa9d7fd1aa199577991..75d8146de4eb67b1d4fcf18b3241dc7632eaea41 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 3d0b46dcdad5788b6e2f380160ece453658ea354..8c080862db500649b02d61508b1c1ae90b0c4a8d 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 8b643e57c0c6517df230eb70b9891b44bceef2fd..7321d38f2aed1fcd60b90b1552783013e8e59a27 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 dd5d8c241bd48efd50e2ca1ca6c1b1f8e836316d..b0761b2c2ad1006623ab473ca9b7cbe912476c99 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 c7712bf2f608d97ea5d776a6fbbff67312373799..37f6875b5595118009cace956d568318439194b8 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 fb1d9fcdbe1cc2749464d35b1f9b78075db318df..616939d1e80abd1a83c259d626f91d699ff931ed 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 bcbefbf82efa10882b7f41a856dae9d58404ea36..6707a7c32e960cc0eac5c9a01c68eb8bc42f0dd7 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 48fdb6508e9f427ca2608a646b5e2f83918c2384..e279b798a98489bd47a8b0de58364f849fef9fd8 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 688600cd74f2e7b4cde3c98384507c963c952cf6..90a4471f17bbf6110bca905b19da7b0883821c20 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 75cc7e4d706a2ef5b5e85ec647549f07d6f630fc..548ede96606e08d786ca252624c4d0353e89e737 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 34d64f004eadb5ef53ed16942a90aaea6f54604d..c1995745816ba1d7059743728ab81244d8f06309 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 cf802ac7f42deb61d9e3fc169e1887095cfc1c70..b17476632b9681f5c0cc0bc6ed229d4d3a60bbd0 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 73590a5d565dc56a31291d1c992858cb665faa9a..49b3931566fd829e61e31a77253d5f5a8bfa2f25 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 700e66be259c1a4b64059f7ec1003afd37ee25ff..71ddaa6b58acd7f77bde45fbca2cb917c70123bf 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 365061ec26c3b320de02bb2b285189e070f7afc1..645bd9eb9b4475ec31156c64cf358614ec59cf13 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 a99c5192fdf35b74b225053e148e431cb46fd2ea..30ffaca327ee2b40449964b0cdd0355cb1382a55 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 813fce32807b0e123838c2bf2ced2c68b2a3452f..a5cb397737267127c620db7a4e7269fb31a7f7d1 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 e6bd46cffeffae3a5068e14e7f981847b3744c2f..d1c86de307e208ffd216f4d74d0c39a2880919cb 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 012bd852d1dbe21407f6096a39cf9d9d91e66855..f7aceee20f3f531f0519610d3a1de5e511ad2b17 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 d09746724c8d9020bf7dfc882639ca9deba5952f..c51028b620b82eafe98006f14786b3662715ba1a 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 7914804b9df976219bf2b6112365fd0abc0151f8..eedecf87b96ced564b4a0daf7d87d5d1e355617e 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 95b8c7ba3e245af29096f3eedbdd40dc99e3d916..87d7e0e529c986f340043a59ee732890de1b7ce0 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 26189143cf2aa4680c07350e77ec31d7b6280d15..140a93cfdf02bafe87d983aba29479ee16a94a7c 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 2e152bb6822755adfca1046bd0c16f5cd83d9ff7..f65e058433ec146ec9799b5d77d672c1bb68c49b 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 208948f2866e8637f36766ccc3368cc905479a61..0929d8bc687796a35dc8b4fb66fcac69e69c8c11 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 d3d9f14fa756fc175c832e0baf804fa6b27adbb4..e1fc0922d62f53d50ce4b99fbe436b82b1bd20e7 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);