]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/hmg.qc
Merge branch 'master' into TimePath/unified_weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / hmg.qc
index 5e48c2840999f6f814349ab64d7678bd523bc584..bcbefbf82efa10882b7f41a856dae9d58404ea36 100644 (file)
@@ -43,80 +43,77 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #ifdef IMPLEMENTATION
 #ifdef SVQC
 
-void spawnfunc_weapon_hmg() { weapon_defaultspawnfunc(WEP_HMG.m_id); }
+spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(WEP_HMG.m_id); }
 
-void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
-{SELFPARAM();
-       if (!self.BUTTON_ATCK)
+void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2)
+{
+       if (!actor.BUTTON_ATCK)
        {
-               w_ready(thiswep, fire1, fire2);
+               w_ready(thiswep, actor, fire1, fire2);
                return;
        }
 
-       if(!_WEP_ACTION(self.weapon, WR_CHECKAMMO1))
-       if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
+       Weapon w = get_weaponinfo(actor.weapon);
+       if(!w.wr_checkammo1(w))
+       if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
-               W_SwitchWeapon_Force(self, w_getbestweapon(self));
-               w_ready(thiswep, fire1, fire2);
+               W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
+               w_ready(thiswep, actor, fire1, fire2);
                return;
        }
 
-       W_DecreaseAmmo(WEP_HMG, WEP_CVAR(hmg, ammo));
+       W_DecreaseAmmo(WEP_HMG, self, WEP_CVAR(hmg, ammo));
 
-       W_SetupShot (self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(hmg, damage));
+       W_SetupShot (actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(hmg, damage));
 
        if(!autocvar_g_norecoil)
        {
-               self.punchangle_x = random () - 0.5;
-               self.punchangle_y = random () - 0.5;
+               actor.punchangle_x = random () - 0.5;
+               actor.punchangle_y = random () - 0.5;
        }
 
-       float hmg_spread = bound(WEP_CVAR(hmg, spread_min), WEP_CVAR(hmg, spread_min) + (WEP_CVAR(hmg, spread_add) * self.misc_bulletcounter), WEP_CVAR(hmg, spread_max));
+       float hmg_spread = bound(WEP_CVAR(hmg, spread_min), WEP_CVAR(hmg, spread_min) + (WEP_CVAR(hmg, spread_add) * actor.misc_bulletcounter), WEP_CVAR(hmg, spread_max));
        fireBullet(w_shotorg, w_shotdir, hmg_spread, WEP_CVAR(hmg, solidpenetration), WEP_CVAR(hmg, damage), WEP_CVAR(hmg, force), WEP_HMG.m_id, 0);
 
-       self.misc_bulletcounter = self.misc_bulletcounter + 1;
+       actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
 
        Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        W_MachineGun_MuzzleFlash();
-       W_AttachToShotorg(self.muzzle_flash, '5 0 0');
+       W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
 
        if (autocvar_g_casings >= 2) // casing code
-               SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
+               SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor);
 
-       ATTACK_FINISHED(self) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor();
-       weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
+       ATTACK_FINISHED(actor) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor();
+       weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
 }
 
-               METHOD(HeavyMachineGun, wr_aim, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_aim, void(entity thiswep))
                {
                        if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false);
                        else
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
-
-                       return true;
                }
-               METHOD(HeavyMachineGun, wr_think, bool(entity thiswep, bool fire1, bool fire2))
+               METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
                {
-                       if(WEP_CVAR(hmg, reload_ammo) && self.clip_load < WEP_CVAR(hmg, ammo)) // forced reload
-                               _WEP_ACTION(self.weapon, WR_RELOAD);
-                       else
+                       if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload
+                               Weapon w = get_weaponinfo(actor.weapon);
+                               w.wr_reload(w);
+                       } else
                        {
                                if (fire1)
-                               if (weapon_prepareattack(0, 0))
+                               if (weapon_prepareattack(actor, false, 0))
                                {
-                                       self.misc_bulletcounter = 0;
-                                       W_HeavyMachineGun_Attack_Auto(thiswep, fire1, fire2);
+                                       actor.misc_bulletcounter = 0;
+                                       W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
                                }
                        }
-
-                       return true;
                }
-               METHOD(HeavyMachineGun, wr_init, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_init, void(entity thiswep))
                {
                        HMG_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
-                       return true;
                }
                METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep))
                {
@@ -136,21 +133,19 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
 
                        return ammo_amount;
                }
-               METHOD(HeavyMachineGun, wr_config, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_config, void(entity thiswep))
                {
                        HMG_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
-                       return true;
                }
-               METHOD(HeavyMachineGun, wr_reload, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_reload, void(entity thiswep))
                {
-                       W_Reload(WEP_CVAR(hmg, ammo), SND(RELOAD));
-                       return true;
+                       W_Reload(self, WEP_CVAR(hmg, ammo), SND(RELOAD));
                }
-               METHOD(HeavyMachineGun, wr_suicidemessage, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_suicidemessage, int(entity thiswep))
                {
                        return WEAPON_THINKING_WITH_PORTALS;
                }
-               METHOD(HeavyMachineGun, wr_killmessage, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_killmessage, int(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                                return WEAPON_HMG_MURDER_SNIPE;
@@ -161,7 +156,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
 #endif
 #ifdef CSQC
 
-               METHOD(HeavyMachineGun, wr_impacteffect, bool(entity thiswep))
+               METHOD(HeavyMachineGun, wr_impacteffect, void(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 2;
@@ -173,17 +168,6 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
                                        sound(self, CH_SHOTS, SND_RIC2, VOL_BASE, ATTEN_NORM);
                                else if(w_random < 0.2)
                                        sound(self, CH_SHOTS, SND_RIC3, VOL_BASE, ATTEN_NORM);
-
-                       return true;
-               }
-               METHOD(HeavyMachineGun, wr_init, bool(entity thiswep))
-               {
-                       return true;
-               }
-               METHOD(HeavyMachineGun, wr_zoomreticle, bool(entity thiswep))
-               {
-                       // no weapon specific image for this weapon
-                       return false;
                }
 
 #endif