]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/vaporizer.qc
Merge branch 'terencehill/strzone_fixes' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / vaporizer.qc
index aeb9125108a9b4a74c8e9f5db13258c9b0a9b6d2..a3c4c1f97db9db76f1710982eeb4e204ac4dee0a 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));
 
@@ -56,9 +56,112 @@ VAPORIZER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #endif
 #ifdef IMPLEMENTATION
+
+REGISTER_NET_TEMP(TE_CSQC_VAPORBEAMPARTICLE)
+
+#if defined(SVQC)
+void SendCSQCVaporizerBeamParticle(entity player, int hit) {
+       vector v;
+       v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
+       WriteHeader(MSG_BROADCAST, TE_CSQC_VAPORBEAMPARTICLE);
+       WriteCoord(MSG_BROADCAST, w_shotorg.x);
+       WriteCoord(MSG_BROADCAST, w_shotorg.y);
+       WriteCoord(MSG_BROADCAST, w_shotorg.z);
+       WriteCoord(MSG_BROADCAST, v.x);
+       WriteCoord(MSG_BROADCAST, v.y);
+       WriteCoord(MSG_BROADCAST, v.z);
+       WriteByte(MSG_BROADCAST, hit);
+       WriteByte(MSG_BROADCAST, num_for_edict(player));
+       WriteByte(MSG_BROADCAST, player.team);
+}
+#elif defined(CSQC)
+bool autocvar_cl_vaporizerbeam_particle = false;
+float autocvar_cl_vaporizerbeam_lifetime = 0.8;
+float autocvar_cl_vaporizerbeam_colorboost = 0.7;
+
+string Draw_VaporizerBeam_trace_callback_tex;
+float Draw_VaporizerBeam_trace_callback_rnd;
+vector Draw_VaporizerBeam_trace_callback_rgb;
+float Draw_VaporizerBeam_trace_callback_a;
+void Draw_VaporizerBeam_trace_callback(vector start, vector hit, vector end)
+{
+       float i;
+       vector vorg;
+       vorg = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin);
+       for(i = 0; i < Draw_VaporizerBeam_trace_callback_a; ++i)
+               Draw_CylindricLine(hit, start, 8, Draw_VaporizerBeam_trace_callback_tex, 0.25, Draw_VaporizerBeam_trace_callback_rnd, Draw_VaporizerBeam_trace_callback_rgb, min(1, Draw_VaporizerBeam_trace_callback_a - i), DRAWFLAG_NORMAL, vorg);
+       Draw_VaporizerBeam_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
+}
+
+.vector vorg1, vorg2;
+.float spawn_time;
+void VaporizerBeam_Draw(entity this)
+{
+       //draw either the old v2.3 beam or the new beam
+       particles_alphamin = particles_alphamax = particles_fade = 1;
+
+       string tex = "particles/lgbeam";
+       if(this.cnt)
+               tex = "particles/gauntletbeam";
+       vector rgb;
+       //entity e = CSQCModel_server2csqc(this.sv_entnum - 1);
+       //if (e == NULL)
+       //{
+               rgb = colormapPaletteColor(stof(getplayerkeyvalue(this.sv_entnum - 1, "colors")) & 0x0F, true);
+               //rgb = '1 1 1';
+       //}
+       //else
+       //      rgb = e.glowmod;
+       rgb *= (1 + autocvar_cl_vaporizerbeam_colorboost);
+
+       float fail = (self.nextthink - time);
+
+       Draw_VaporizerBeam_trace_callback_tex = tex;
+       Draw_VaporizerBeam_trace_callback_rnd = 0;
+       Draw_VaporizerBeam_trace_callback_rgb = rgb;
+       Draw_VaporizerBeam_trace_callback_a = bound(0, fail, 1);
+       WarpZone_TraceBox_ThroughZone(this.vorg1, '0 0 0', '0 0 0', this.vorg2, MOVE_NOTHING, world, world, Draw_VaporizerBeam_trace_callback);
+       Draw_VaporizerBeam_trace_callback_tex = string_null;
+
+       /*if(!MUTATOR_CALLHOOK(Particles_VaporizerBeam, this.vorg1, this.vorg2))
+       if(autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
+               WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
+       else
+               WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);*/
+}
+
+NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
+{
+       Net_Accept(vortex_beam);
+       this.think = SUB_Remove_self;
+       this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10);
+       this.draw = VaporizerBeam_Draw;
+       this.drawmask = MASK_NORMAL;
+
+       this.vorg1_x = ReadCoord(); this.vorg1_y = ReadCoord(); this.vorg1_z = ReadCoord();
+       this.vorg2_x = ReadCoord(); this.vorg2_y = ReadCoord(); this.vorg2_z = ReadCoord();
+       this.cnt = ReadByte();
+       int myowner = ReadByte();
+       this.owner = playerslots[myowner - 1];
+       this.sv_entnum = myowner;
+       this.team = ReadByte() - 1;
+
+       if(autocvar_cl_vaporizerbeam_particle)
+       {
+               WarpZone_TrailParticles(world, particleeffectnum(((this.cnt) ? EFFECT_VAPORIZER_HIT(this.team) : EFFECT_VAPORIZER(this.team))), this.vorg1, this.vorg2);
+               this.draw = func_null;
+               this.drawmask = MASK_NORMAL;
+               remove(this);
+       }
+
+       pointparticles(EFFECT_VORTEX_MUZZLEFLASH, this.vorg1, normalize(this.vorg2 - this.vorg1) * 1000, 1);
+       return true;
+}
+#endif
+
 #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();
@@ -85,6 +188,9 @@ void W_Vaporizer_Attack(Weapon thiswep)
        damage_goodhits = 0;
        FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
 
+       // do this now, as goodhits is disabled below
+       SendCSQCVaporizerBeamParticle(self, damage_goodhits);
+
        if(yoda && flying)
                Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
        if(damage_goodhits && self.vaporizer_lasthit)
@@ -95,20 +201,14 @@ void W_Vaporizer_Attack(Weapon thiswep)
 
        self.vaporizer_lasthit = damage_goodhits;
 
-       Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
-
-       // teamcolor / hit beam effect
-       vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
-       Send_Effect((damage_goodhits ? EFFECT_VAPORIZER_HIT(self.team) : EFFECT_VAPORIZER(self.team)), w_shotorg, v, 1);
-
        if(autocvar_g_rm)
        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 +223,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 +231,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 +250,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 +285,7 @@ void W_RocketMinsta_Attack2(void)
     }
 }
 
-void W_RocketMinsta_Attack3 (void)
+void W_RocketMinsta_Attack3 ()
 {SELFPARAM();
        makevectors(self.v_angle);
 
@@ -203,8 +302,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;
@@ -237,70 +335,69 @@ void W_RocketMinsta_Attack3 (void)
     }
 }
 
-               METHOD(Vaporizer, wr_aim, bool(entity thiswep))
+               METHOD(Vaporizer, wr_aim, void(entity thiswep))
                {
                        if(self.WEP_AMMO(VAPORIZER) > 0)
                                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;
                }
-               METHOD(Vaporizer, wr_think, bool(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),
@@ -312,28 +409,24 @@ 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;
-
-                       return true;
+                               actor.held_down = false;
                }
-               METHOD(Vaporizer, wr_init, bool(entity thiswep))
+               METHOD(Vaporizer, wr_init, void(entity thiswep))
                {
                        //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;
                }
-               METHOD(Vaporizer, wr_setup, bool(entity thiswep))
+               METHOD(Vaporizer, wr_setup, void(entity thiswep))
                {
                        self.ammo_field = WEP_AMMO(VAPORIZER);
                        self.vaporizer_lasthit = 0;
-                       return true;
                }
                METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
                {
@@ -350,17 +443,15 @@ void W_RocketMinsta_Attack3 (void)
                        ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
                        return ammo_amount;
                }
-               METHOD(Vaporizer, wr_config, bool(entity thiswep))
+               METHOD(Vaporizer, wr_config, void(entity thiswep))
                {
                        VAPORIZER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
-                       return true;
                }
-               METHOD(Vaporizer, wr_resetplayer, bool(entity thiswep))
+               METHOD(Vaporizer, wr_resetplayer, void(entity thiswep))
                {
                        self.vaporizer_lasthit = 0;
-                       return true;
                }
-               METHOD(Vaporizer, wr_reload, bool(entity thiswep))
+               METHOD(Vaporizer, wr_reload, void(entity thiswep))
                {
                        float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
                        float used_ammo;
@@ -369,14 +460,13 @@ void W_RocketMinsta_Attack3 (void)
                        else
                                used_ammo = vaporizer_ammo;
 
-                       W_Reload(used_ammo, SND(RELOAD));
-                       return true;
+                       W_Reload(self, used_ammo, SND(RELOAD));
                }
-               METHOD(Vaporizer, wr_suicidemessage, bool(entity thiswep))
+               METHOD(Vaporizer, wr_suicidemessage, int(entity thiswep))
                {
                        return WEAPON_THINKING_WITH_PORTALS;
                }
-               METHOD(Vaporizer, wr_killmessage, bool(entity thiswep))
+               METHOD(Vaporizer, wr_killmessage, int(entity thiswep))
                {
                        return WEAPON_VAPORIZER_MURDER;
                }
@@ -384,28 +474,26 @@ void W_RocketMinsta_Attack3 (void)
 #endif
 #ifdef CSQC
 
-               METHOD(Vaporizer, wr_impacteffect, bool(entity thiswep))
+               METHOD(Vaporizer, wr_impacteffect, void(entity thiswep))
                {
                        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); }
                        }
-                       return true;
                }
-               METHOD(Vaporizer, wr_init, bool(entity thiswep))
+               METHOD(Vaporizer, wr_init, void(entity thiswep))
                {
                        if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
                        {
                                precache_pic("gfx/reticle_nex");
                        }
-                       return true;
                }
                METHOD(Vaporizer, wr_zoomreticle, bool(entity thiswep))
                {