]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/devastator.qc
Merge branch 'master' into TimePath/items
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / devastator.qc
index c52693a6558af65aeef571c43d58f80fd8525d51..f5aed7b40d6914d2c1db8a9267bbddb34e82a7ea 100644 (file)
@@ -13,7 +13,7 @@ CLASS(Devastator, Weapon)
 /* crosshair */ ATTRIB(Devastator, w_crosshair_size, float, 0.7);
 /* wepimg    */ ATTRIB(Devastator, model2, string, "weaponrocketlauncher");
 /* refname   */ ATTRIB(Devastator, netname, string, "devastator");
-/* wepname   */ ATTRIB(Devastator, message, string, _("Devastator"));
+/* wepname   */ ATTRIB(Devastator, m_name, string, _("Devastator"));
 ENDCLASS(Devastator)
 REGISTER_WEAPON(DEVASTATOR, NEW(Devastator));
 
@@ -64,8 +64,10 @@ DEVASTATOR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_devastator(void) { weapon_defaultspawnfunc(WEP_DEVASTATOR.m_id); }
-void spawnfunc_weapon_rocketlauncher(void) { spawnfunc_weapon_devastator(); }
+spawnfunc(weapon_devastator) { weapon_defaultspawnfunc(this, WEP_DEVASTATOR); }
+spawnfunc(weapon_rocketlauncher) { spawnfunc_weapon_devastator(this); }
+
+.entity lastrocket;
 
 void W_Devastator_Unregister(void)
 {SELFPARAM();
@@ -337,12 +339,12 @@ void W_Devastator_Damage(entity inflictor, entity attacker, float damage, int de
                W_PrepareExplosionByDamage(attacker, W_Devastator_Explode);
 }
 
-void W_Devastator_Attack(void)
+void W_Devastator_Attack(Weapon thiswep)
 {SELFPARAM();
        entity missile;
        entity flash;
 
-       W_DecreaseAmmo(WEP_CVAR(devastator, ammo));
+       W_DecreaseAmmo(thiswep, self, WEP_CVAR(devastator, ammo));
 
        W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 5, SND(ROCKET_FIRE), CH_WEAPON_A, WEP_CVAR(devastator, damage));
        Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
@@ -388,14 +390,14 @@ void W_Devastator_Attack(void)
        setmodel(flash, MDL_DEVASTATOR_MUZZLEFLASH); // precision set below
        SUB_SetFade(flash, time, 0.1);
        flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
-       W_AttachToShotorg(flash, '5 0 0');
+       W_AttachToShotorg(self, flash, '5 0 0');
 
        // common properties
        MUTATOR_CALLHOOK(EditProjectile, self, missile);
 }
 
                #if 0
-               METHOD(Devastator, wr_aim, bool(entity thiswep))
+               METHOD(Devastator, wr_aim, void(entity thiswep))
                {
                        // aim and decide to fire if appropriate
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
@@ -420,11 +422,9 @@ void W_Devastator_Attack(void)
 
                                if(self.BUTTON_ATCK2) self.BUTTON_ATCK = false;
                        }
-
-                       return true;
                }
                #else
-               METHOD(Devastator, wr_aim, bool(entity thiswep))
+               METHOD(Devastator, wr_aim, void(entity thiswep))
                {
                        // aim and decide to fire if appropriate
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
@@ -518,35 +518,33 @@ void W_Devastator_Attack(void)
                                //      dprint(ftos(desirabledamage),"\n");
                                if(self.BUTTON_ATCK2 == true) self.BUTTON_ATCK = false;
                        }
-
-                       return true;
                }
                #endif
-               METHOD(Devastator, wr_think, bool(entity thiswep, bool fire1, bool fire2))
+               METHOD(Devastator, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
                {
-                       if(WEP_CVAR(devastator, reload_ammo) && self.clip_load < WEP_CVAR(devastator, ammo)) // forced reload
-                               _WEP_ACTION(self.weapon, WR_RELOAD);
-                       else
-                       {
+                       if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
+                               Weapon w = get_weaponinfo(actor.weapon);
+                               w.wr_reload(w);
+                       } else {
                                if(fire1)
                                {
-                                       if(self.rl_release || WEP_CVAR(devastator, guidestop))
-                                       if(weapon_prepareattack(0, WEP_CVAR(devastator, refire)))
+                                       if(actor.rl_release || WEP_CVAR(devastator, guidestop))
+                                       if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(devastator, refire)))
                                        {
-                                               W_Devastator_Attack();
-                                               weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
-                                               self.rl_release = 0;
+                                               W_Devastator_Attack(thiswep);
+                                               weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
+                                               actor.rl_release = 0;
                                        }
                                }
                                else
-                                       self.rl_release = 1;
+                                       actor.rl_release = 1;
 
                                if(fire2)
-                               if(self.switchweapon == WEP_DEVASTATOR.m_id)
+                               if(actor.switchweapon == WEP_DEVASTATOR.m_id)
                                {
                                        entity rock;
                                        bool rockfound = false;
-                                       for(rock = world; (rock = find(rock, classname, "rocket")); ) if(rock.realowner == self)
+                                       for(rock = world; (rock = find(rock, classname, "rocket")); ) if(rock.realowner == actor)
                                        {
                                                if(!rock.rl_detonate_later)
                                                {
@@ -555,21 +553,17 @@ void W_Devastator_Attack(void)
                                                }
                                        }
                                        if(rockfound)
-                                               sound(self, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
+                                               sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
                                }
                        }
-
-                       return true;
                }
-               METHOD(Devastator, wr_init, bool(entity thiswep))
+               METHOD(Devastator, wr_init, void(entity thiswep))
                {
                        DEVASTATOR_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
-                       return true;
                }
-               METHOD(Devastator, wr_setup, bool(entity thiswep))
+               METHOD(Devastator, wr_setup, void(entity thiswep))
                {
                        self.rl_release = 1;
-                       return true;
                }
                METHOD(Devastator, wr_checkammo1, bool(entity thiswep))
                {
@@ -611,26 +605,24 @@ void W_Devastator_Attack(void)
                {
                        return false;
                }
-               METHOD(Devastator, wr_config, bool(entity thiswep))
+               METHOD(Devastator, wr_config, void(entity thiswep))
                {
                        DEVASTATOR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
-                       return true;
                }
-               METHOD(Devastator, wr_resetplayer, bool(entity thiswep))
+               METHOD(Devastator, wr_resetplayer, void(entity thiswep))
                {
+                       self.lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
                        self.rl_release = 0;
-                       return true;
                }
-               METHOD(Devastator, wr_reload, bool(entity thiswep))
+               METHOD(Devastator, wr_reload, void(entity thiswep))
                {
-                       W_Reload(WEP_CVAR(devastator, ammo), SND(RELOAD));
-                       return true;
+                       W_Reload(self, WEP_CVAR(devastator, ammo), SND(RELOAD));
                }
-               METHOD(Devastator, wr_suicidemessage, bool(entity thiswep))
+               METHOD(Devastator, wr_suicidemessage, int(entity thiswep))
                {
                        return WEAPON_DEVASTATOR_SUICIDE;
                }
-               METHOD(Devastator, wr_killmessage, bool(entity thiswep))
+               METHOD(Devastator, wr_killmessage, int(entity thiswep))
                {
                        if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
                                return WEAPON_DEVASTATOR_MURDER_SPLASH;
@@ -641,24 +633,13 @@ void W_Devastator_Attack(void)
 #endif
 #ifdef CSQC
 
-               METHOD(Devastator, wr_impacteffect, bool(entity thiswep))
+               METHOD(Devastator, wr_impacteffect, void(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 12;
                        pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), org2, '0 0 0', 1);
                        if(!w_issilent)
                                sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTN_NORM);
-
-                       return true;
-               }
-               METHOD(Devastator, wr_init, bool(entity thiswep))
-               {
-                       return true;
-               }
-               METHOD(Devastator, wr_zoomreticle, bool(entity thiswep))
-               {
-                       // no weapon specific image for this weapon
-                       return false;
                }
 
 #endif