]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/vaporizer.qc
Merge branch 'terencehill/menu_languages' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / vaporizer.qc
index bb0283c669e2ad65e917b4cf31ba57aa6329b8d8..5a6082134c58134d5df4b97889d029405f0b9772 100644 (file)
@@ -13,7 +13,7 @@ CLASS(Vaporizer, Weapon)
 /* crosshair */ ATTRIB(Vaporizer, w_crosshair_size, float, 0.6);
 /* wepimg    */ ATTRIB(Vaporizer, model2, string, "weaponminstanex");
 /* refname   */ ATTRIB(Vaporizer, netname, string, "vaporizer");
-/* wepname   */ ATTRIB(Vaporizer, message, string, _("Vaporizer"));
+/* wepname   */ ATTRIB(Vaporizer, m_name, string, _("Vaporizer"));
 ENDCLASS(Vaporizer)
 REGISTER_WEAPON(VAPORIZER, NEW(Vaporizer));
 
@@ -57,8 +57,8 @@ VAPORIZER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_vaporizer(void) { weapon_defaultspawnfunc(WEP_VAPORIZER.m_id); }
-void spawnfunc_weapon_minstanex(void) { spawnfunc_weapon_vaporizer(); }
+spawnfunc(weapon_vaporizer) { weapon_defaultspawnfunc(this, WEP_VAPORIZER); }
+spawnfunc(weapon_minstanex) { spawnfunc_weapon_vaporizer(this); }
 
 void W_RocketMinsta_Explosion(vector loc)
 {SELFPARAM();
@@ -105,10 +105,10 @@ void W_Vaporizer_Attack(Weapon thiswep)
        if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
                W_RocketMinsta_Explosion(trace_endpos);
 
-       W_DecreaseAmmo(thiswep, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
+       W_DecreaseAmmo(thiswep, self, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
 }
 
-void W_RocketMinsta_Laser_Explode (void)
+void W_RocketMinsta_Laser_Explode ()
 {SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
@@ -123,7 +123,7 @@ void W_RocketMinsta_Laser_Explode (void)
        remove(self);
 }
 
-void W_RocketMinsta_Laser_Touch (void)
+void W_RocketMinsta_Laser_Touch ()
 {SELFPARAM();
        PROJECTILE_TOUCH;
        //W_RocketMinsta_Laser_Explode ();
@@ -131,7 +131,7 @@ void W_RocketMinsta_Laser_Touch (void)
        remove(self);
 }
 
-void W_RocketMinsta_Attack2(void)
+void W_RocketMinsta_Attack2()
 {SELFPARAM();
        makevectors(self.v_angle);
 
@@ -150,8 +150,7 @@ void W_RocketMinsta_Attack2(void)
 
     while(counter < total)
        {
-        proj = spawn ();
-        proj.classname = "plasma_prim";
+        proj = new(plasma_prim);
         proj.owner = proj.realowner = self;
         proj.bot_dodge = true;
         proj.bot_dodgerating = autocvar_g_rm_laser_damage;
@@ -186,7 +185,7 @@ void W_RocketMinsta_Attack2(void)
     }
 }
 
-void W_RocketMinsta_Attack3 (void)
+void W_RocketMinsta_Attack3 ()
 {SELFPARAM();
        makevectors(self.v_angle);
 
@@ -203,8 +202,7 @@ void W_RocketMinsta_Attack3 (void)
 
     while(counter < total)
        {
-        proj = spawn ();
-        proj.classname = "plasma_prim";
+        proj = new(plasma_prim);
         proj.owner = proj.realowner = self;
         proj.bot_dodge = true;
         proj.bot_dodgerating = autocvar_g_rm_laser_damage;
@@ -244,61 +242,62 @@ void W_RocketMinsta_Attack3 (void)
                        else
                                self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
                }
-               METHOD(Vaporizer, wr_think, void(entity thiswep, bool fire1, bool fire2))
+               METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
                        // if the laser uses load, we also consider its ammo for reloading
-                       if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && self.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
-                               Weapon w = get_weaponinfo(self.weapon);
+                       if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
+                               Weapon w = get_weaponinfo(actor.weapon);
                                w.wr_reload(w);
-                       } else if(WEP_CVAR(vaporizer, reload_ammo) && self.clip_load < vaporizer_ammo) { // forced reload
-                               Weapon w = get_weaponinfo(self.weapon);
+                       } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload
+                               Weapon w = get_weaponinfo(actor.weapon);
                                w.wr_reload(w);
                        }
-                       if(fire1 && (self.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(self))
+                       if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
                        {
-                               if(weapon_prepareattack(false, WEP_CVAR_PRI(vaporizer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
                                {
                                        W_Vaporizer_Attack(thiswep);
-                                       weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
                                }
                        }
-                       if(fire2 || (fire1 && !self.ammo_cells && autocvar_g_rm))
+                       if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm))
                        {
                                if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
                                {
                                        bool rapid = autocvar_g_rm_laser_rapid;
-                                       if(self.jump_interval <= time && !self.held_down)
+                                       if(actor.jump_interval <= time && !actor.held_down)
                                        {
                                                if(rapid)
-                                                       self.held_down = true;
-                                               self.jump_interval = time + autocvar_g_rm_laser_refire;
-                                               self.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
+                                                       actor.held_down = true;
+                                               actor.jump_interval = time + autocvar_g_rm_laser_refire;
+                                               actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
                                                damage_goodhits = 0;
                                                W_RocketMinsta_Attack2();
                                        }
-                                       else if(rapid && self.jump_interval2 <= time && self.held_down)
+                                       else if(rapid && actor.jump_interval2 <= time && actor.held_down)
                                        {
-                                               self.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
+                                               actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
                                                damage_goodhits = 0;
                                                W_RocketMinsta_Attack3();
-                                               //weapon_thinkf(WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
+                                               //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
                                        }
                                }
-                               else if (self.jump_interval <= time)
+                               else if (actor.jump_interval <= time)
                                {
                                        // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib)
-                                       self.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor();
+                                       actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor();
 
                                        // decrease ammo for the laser?
                                        if(WEP_CVAR_SEC(vaporizer, ammo))
-                                               W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(vaporizer, ammo));
+                                               W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo));
 
                                        // ugly instagib hack to reuse the fire mode of the laser
-                                       makevectors(self.v_angle);
-                                       int oldwep = self.weapon; // we can't avoid this hack
-                                       self.weapon = WEP_BLASTER.m_id;
+                                       makevectors(actor.v_angle);
+                                       int oldwep = actor.weapon; // we can't avoid this hack
+                                       actor.weapon = WEP_BLASTER.m_id;
                                        W_Blaster_Attack(
+                                               actor,
                                                WEP_BLASTER.m_id | HITTYPE_SECONDARY,
                                                WEP_CVAR_SEC(vaporizer, shotangle),
                                                WEP_CVAR_SEC(vaporizer, damage),
@@ -310,14 +309,14 @@ void W_RocketMinsta_Attack3 (void)
                                                WEP_CVAR_SEC(vaporizer, delay),
                                                WEP_CVAR_SEC(vaporizer, lifetime)
                                        );
-                                       self.weapon = oldwep;
+                                       actor.weapon = oldwep;
 
                                        // now do normal refire
-                                       weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
                                }
                        }
                        else
-                               self.held_down = false;
+                               actor.held_down = false;
                }
                METHOD(Vaporizer, wr_init, void(entity thiswep))
                {
@@ -361,7 +360,7 @@ void W_RocketMinsta_Attack3 (void)
                        else
                                used_ammo = vaporizer_ammo;
 
-                       W_Reload(used_ammo, SND(RELOAD));
+                       W_Reload(self, used_ammo, SND(RELOAD));
                }
                METHOD(Vaporizer, wr_suicidemessage, int(entity thiswep))
                {
@@ -380,12 +379,12 @@ void W_RocketMinsta_Attack3 (void)
                        vector org2 = w_org + w_backoff * 6;
                        if(w_deathtype & HITTYPE_SECONDARY)
                        {
-                               pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
+                               pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
                                if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
                        }
                        else
                        {
-                               pointparticles(particleeffectnum(EFFECT_VORTEX_IMPACT), org2, '0 0 0', 1);
+                               pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
                                if(!w_issilent) { sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); }
                        }
                }