]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/overkill/hmg.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / hmg.qc
index 28ce4604ac5a58420158b185db96e722519cd227..347e76d4be1a8036e6a4ea76e6407026ba2be306 100644 (file)
@@ -10,8 +10,6 @@ MUTATOR_HOOKFUNCTION(hmg_nadesupport, Nade_Damage)
        M_ARGV(3, float) /* damage */ = (M_ARGV(0, entity)).max_health * 0.1;
 }
 
-spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(this, WEP_HMG); }
-
 void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        if (!PHYS_INPUT_BUTTON_ATCK(actor))
@@ -29,7 +27,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
 
        W_DecreaseAmmo(WEP_HMG, actor, WEP_CVAR_PRI(hmg, ammo), weaponentity);
 
-       W_SetupShot (actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hmg, damage));
+       W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hmg, damage), WEP_HMG.m_id);
 
        if(!autocvar_g_norecoil)
        {
@@ -72,25 +70,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(hmg, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
-               actor.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(hmg, shotangle),
-                       WEP_CVAR_SEC(hmg, damage),
-                       WEP_CVAR_SEC(hmg, edgedamage),
-                       WEP_CVAR_SEC(hmg, radius),
-                       WEP_CVAR_SEC(hmg, force),
-                       WEP_CVAR_SEC(hmg, speed),
-                       WEP_CVAR_SEC(hmg, spread),
-                       WEP_CVAR_SEC(hmg, delay),
-                       WEP_CVAR_SEC(hmg, lifetime)
-               );
-               actor.(weaponentity).m_weapon = oldwep;
+               BLASTER_SECONDARY_ATTACK(hmg, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -130,47 +110,29 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea
                {
                        return;
                }
-               // ugly instagib hack to reuse the fire mode of the laser
-               makevectors(actor.v_angle);
-               Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
-               actor.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(hmg, shotangle),
-                       WEP_CVAR_SEC(hmg, damage),
-                       WEP_CVAR_SEC(hmg, edgedamage),
-                       WEP_CVAR_SEC(hmg, radius),
-                       WEP_CVAR_SEC(hmg, force),
-                       WEP_CVAR_SEC(hmg, speed),
-                       WEP_CVAR_SEC(hmg, spread),
-                       WEP_CVAR_SEC(hmg, delay),
-                       WEP_CVAR_SEC(hmg, lifetime)
-               );
-               actor.(weaponentity).m_weapon = oldwep;
+               BLASTER_SECONDARY_ATTACK(hmg, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hmg, animtime), w_ready);
        }
 }
 
 METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
-    float ammo_amount = actor.ammo_nails >= WEP_CVAR_PRI(hmg, ammo);
-
-    if(autocvar_g_balance_hmg_reload_ammo)
-        ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR_PRI(hmg, ammo);
-
-    return ammo_amount;
+       float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hmg, ammo);
+       if (autocvar_g_balance_hmg_reload_ammo)
+       {
+               ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR_PRI(hmg, ammo);
+       }
+       return ammo_amount;
 }
 
 METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
-    float ammo_amount = actor.ammo_nails >= WEP_CVAR_SEC(hmg, ammo);
-
-    if(autocvar_g_balance_hmg_reload_ammo)
-        ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR_SEC(hmg, ammo);
-
-    return ammo_amount;
+       float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hmg, ammo);
+       if (autocvar_g_balance_hmg_reload_ammo)
+       {
+               ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR_SEC(hmg, ammo);
+       }
+       return ammo_amount;
 }
 
 METHOD(HeavyMachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))