]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_vaporizer.qc
Send effects to client, allows mismatching effectinfo.txt
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_vaporizer.qc
index 2b754395ee3f68dd6c7dc44b0be3c38d05aa83e3..43ede987cef13a040df5bda4d023e66cb408da35 100644 (file)
@@ -7,12 +7,11 @@ REGISTER_WEAPON(
 /* flags     */ WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN,
 /* rating    */ BOT_PICKUP_RATING_HIGH,
 /* color     */ '0.5 1 1',
-/* firstpmdl */ "models/weapons/h_minstanex.iqm",
-/* thirdpmdl */ "models/weapons/v_minstanex.md3",
-/* pickupmdl */ "models/weapons/g_minstanex.md3",
+/* modelname */ "minstanex",
 /* simplemdl */ "foobar",
-/* crosshair */ "gfx/crosshairminstanex 0.4",
-/* refname   */ "minstanex",
+/* crosshair */ "gfx/crosshairminstanex 0.6",
+/* wepimg    */ "weaponminstanex",
+/* refname   */ "vaporizer",
 /* wepname   */ _("Vaporizer")
 );
 
@@ -39,7 +38,8 @@ REGISTER_WEAPON(
        w_prop(id, sn, float,  switchdelay_drop, switchdelay_drop) \
        w_prop(id, sn, string, weaponreplace, weaponreplace) \
        w_prop(id, sn, float,  weaponstart, weaponstart) \
-       w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride)
+       w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride) \
+       w_prop(id, sn, float,  weaponthrowable, weaponthrowable)
 
 #ifdef SVQC
 VAPORIZER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
@@ -48,19 +48,22 @@ VAPORIZER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #else
 #ifdef SVQC
-void spawnfunc_weapon_vaporizer (void) { weapon_defaultspawnfunc(WEP_VAPORIZER); }
-void spawnfunc_weapon_minstanex () { spawnfunc_weapon_vaporizer(); }
+void spawnfunc_weapon_vaporizer(void) { weapon_defaultspawnfunc(WEP_VAPORIZER); }
+void spawnfunc_weapon_minstanex(void) { spawnfunc_weapon_vaporizer(); }
 
-void W_Vaporizer_Attack (void)
+void W_Vaporizer_Attack(void)
 {
        float flying;
        flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
 
-       W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", CH_WEAPON_A, 10000);
+       W_SetupShot(self, true, 0, "", CH_WEAPON_A, 10000);
+       // handle sound separately so we can change the volume
+       // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway)
+       sound (self, CH_WEAPON_A, "weapons/minstanexfire.wav", VOL_BASE * 0.8, ATTEN_NORM);
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_VAPORIZER);
+       FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_VAPORIZER);
 
        if(yoda && flying)
                Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
@@ -72,7 +75,7 @@ void W_Vaporizer_Attack (void)
 
        self.vaporizer_lasthit = damage_goodhits;
 
-       pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+       Send_Effect("nex_muzzleflash", w_shotorg, w_shotdir * 1000, 1);
 
        // teamcolor / hit beam effect
        vector v;
@@ -81,37 +84,37 @@ void W_Vaporizer_Attack (void)
        {
                case NUM_TEAM_1:   // Red
                        if(damage_goodhits)
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3RED_HIT", w_shotorg, v, 1);
                        else
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3RED", w_shotorg, v, 1);
                        break;
                case NUM_TEAM_2:   // Blue
                        if(damage_goodhits)
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3BLUE_HIT", w_shotorg, v, 1);
                        else
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3BLUE", w_shotorg, v, 1);
                        break;
                case NUM_TEAM_3:   // Yellow
                        if(damage_goodhits)
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3YELLOW_HIT", w_shotorg, v, 1);
                        else
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3YELLOW", w_shotorg, v, 1);
                        break;
                case NUM_TEAM_4:   // Pink
                        if(damage_goodhits)
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3PINK_HIT", w_shotorg, v, 1);
                        else
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3PINK", w_shotorg, v, 1);
                        break;
                default:
                        if(damage_goodhits)
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3_HIT"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3_HIT", w_shotorg, v, 1);
                        else
-                               WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, v);
+                               Send_Effect("TE_TEI_G3", w_shotorg, v, 1);
                        break;
        }
-       
-       W_DecreaseAmmo(((g_minstagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
+
+       W_DecreaseAmmo(((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
 }
 
 float W_Vaporizer(float req)
@@ -120,18 +123,18 @@ float W_Vaporizer(float req)
        float vaporizer_ammo;
 
        // now multiple WR_s use this
-       vaporizer_ammo = ((g_minstagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
+       vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
 
        switch(req)
        {
                case WR_AIM:
                {
                        if(self.WEP_AMMO(VAPORIZER) > 0)
-                               self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
+                               self.BUTTON_ATCK = bot_aim(1000000, 0, 1, false);
                        else
-                               self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), FALSE); // WEAPONTODO: replace with proper vaporizer cvars
-                               
-                       return TRUE;
+                               self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
+
+                       return true;
                }
                case WR_THINK:
                {
@@ -140,31 +143,31 @@ float W_Vaporizer(float req)
                                WEP_ACTION(self.weapon, WR_RELOAD);
                        else if(WEP_CVAR(vaporizer, reload_ammo) && self.clip_load < vaporizer_ammo) // forced reload
                                WEP_ACTION(self.weapon, WR_RELOAD);
-                       else if (self.BUTTON_ATCK)
+                       else if(self.BUTTON_ATCK)
                        {
-                               if (weapon_prepareattack(0, WEP_CVAR_PRI(vaporizer, refire)))
+                               if(weapon_prepareattack(0, WEP_CVAR_PRI(vaporizer, refire)))
                                {
                                        W_Vaporizer_Attack();
                                        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
                                }
                        }
-                       else if (self.BUTTON_ATCK2)
+                       else if(self.BUTTON_ATCK2)
                        {
-                               if (self.jump_interval <= time)
-                               if (weapon_prepareattack(1, -1))
+                               if(self.jump_interval <= time)
+                               if(weapon_prepareattack(1, -1))
                                {
-                                       // handle refire manually, so that primary and secondary can be fired without conflictions (important for minstagib)
+                                       // 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();
-                                       
+
                                        // decrease ammo for the laser?
                                        if(WEP_CVAR_SEC(vaporizer, ammo))
                                                W_DecreaseAmmo(WEP_CVAR_SEC(vaporizer, ammo));
 
-                                       // ugly minstagib hack to reuse the fire mode of the laser
-                                       float w;
-                                       w = self.weapon;
+                                       // ugly instagib hack to reuse the fire mode of the laser
+                                       int oldwep = self.weapon; // we can't avoid this hack
                                        self.weapon = WEP_BLASTER;
                                        W_Blaster_Attack(
+                                               WEP_BLASTER | HITTYPE_SECONDARY,
                                                WEP_CVAR_SEC(vaporizer, shotangle),
                                                WEP_CVAR_SEC(vaporizer, damage),
                                                WEP_CVAR_SEC(vaporizer, edgedamage),
@@ -175,14 +178,14 @@ float W_Vaporizer(float req)
                                                WEP_CVAR_SEC(vaporizer, delay),
                                                WEP_CVAR_SEC(vaporizer, lifetime)
                                        );
-                                       self.weapon = w;
-                                       
+                                       self.weapon = oldwep;
+
                                        // now do normal refire
                                        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
                                }
                        }
-                       
-                       return TRUE;
+
+                       return true;
                }
                case WR_INIT:
                {
@@ -195,14 +198,14 @@ float W_Vaporizer(float req)
                        precache_sound("weapons/nexwhoosh2.wav");
                        precache_sound("weapons/nexwhoosh3.wav");
                        //W_Blaster(WR_INIT); // Samual: Is this really the proper thing to do? Didn't we already run this previously?
-                       VAPORIZER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
-                       return TRUE;
+                       VAPORIZER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
+                       return true;
                }
                case WR_SETUP:
                {
                        self.ammo_field = WEP_AMMO(VAPORIZER);
                        self.vaporizer_lasthit = 0;
-                       return TRUE;
+                       return true;
                }
                case WR_CHECKAMMO1:
                {
@@ -213,20 +216,20 @@ float W_Vaporizer(float req)
                case WR_CHECKAMMO2:
                {
                        if(!WEP_CVAR_SEC(vaporizer, ammo))
-                               return TRUE;
+                               return true;
                        ammo_amount = self.WEP_AMMO(VAPORIZER) >= WEP_CVAR_SEC(vaporizer, ammo);
                        ammo_amount += self.(weapon_load[WEP_VAPORIZER]) >= WEP_CVAR_SEC(vaporizer, ammo);
                        return ammo_amount;
                }
                case WR_CONFIG:
                {
-                       VAPORIZER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
-                       return TRUE;
+                       VAPORIZER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
+                       return true;
                }
                case WR_RESETPLAYER:
                {
                        self.vaporizer_lasthit = 0;
-                       return TRUE;
+                       return true;
                }
                case WR_RELOAD:
                {
@@ -237,7 +240,7 @@ float W_Vaporizer(float req)
                                used_ammo = vaporizer_ammo;
 
                        W_Reload(used_ammo, "weapons/reload.wav");
-                       return TRUE;
+                       return true;
                }
                case WR_SUICIDEMESSAGE:
                {
@@ -248,7 +251,7 @@ float W_Vaporizer(float req)
                        return WEAPON_VAPORIZER_MURDER;
                }
        }
-       return TRUE;
+       return false;
 }
 #endif
 #ifdef CSQC
@@ -260,36 +263,43 @@ float W_Vaporizer(float req)
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
-                       pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
-                       if(!w_issilent)
-                               sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
-                               
-                       return TRUE;
+                       if(w_deathtype & HITTYPE_SECONDARY)
+                       {
+                               pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
+                               if(!w_issilent) { sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); }
+                       }
+                       else
+                       {
+                               pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
+                               if(!w_issilent) { sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM); }
+                       }
+                       return true;
                }
                case WR_INIT:
                {
+                       precache_sound("weapons/laserimpact.wav");
                        precache_sound("weapons/neximpact.wav");
                        if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
                        {
                                precache_pic("gfx/reticle_nex");
                        }
-                       return TRUE;
+                       return true;
                }
                case WR_ZOOMRETICLE:
                {
                        if(button_zoom || zoomscript_caught)
                        {
                                reticle_image = "gfx/reticle_nex";
-                               return TRUE;
+                               return true;
                        }
                        else
                        {
                                // no weapon specific image for this weapon
-                               return FALSE;
+                               return false;
                        }
                }
        }
-       return TRUE;
+       return false;
 }
 #endif
 #endif