]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/weapons/projectile.qc
#include this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / weapons / projectile.qc
index de45141a136c1bb71aba06fafa4de21ad7fa027b..ba8846277e38e16a84021596bab74c6308609edd 100644 (file)
@@ -1,3 +1,22 @@
+#if defined(CSQC)
+       #include "../../dpdefs/csprogsdefs.qc"
+    #include "../Defs.qc"
+    #include "../../common/constants.qh"
+    #include "../../warpzonelib/anglestransform.qh"
+    #include "../../common/util.qh"
+    #include "../../common/nades.qh"
+    #include "../../common/buffs.qh"
+    #include "../autocvars.qh"
+    #include "../../csqcmodellib/interpolate.qh"
+    #include "../movetypes.qh"
+    #include "../main.qh"
+    #include "../../csqcmodellib/cl_model.qh"
+    #include "projectile.qh"
+    #include "../../server/t_items.qh"
+#elif defined(MENUQC)
+#elif defined(SVQC)
+#endif
+
 .vector iorigin1, iorigin2;
 .float spawntime;
 .vector trail_oldorigin;
@@ -11,11 +30,11 @@ void SUB_Stop()
 }
 
 .float alphamod;
-.float count; // set if clientside projectile
-.float cnt; // sound index
+.int count; // set if clientside projectile
+.int cnt; // sound index
 .float gravity;
-.float snd_looping;
-.float silent;
+.int snd_looping;
+.bool silent;
 
 void Projectile_ResetTrail(vector to)
 {
@@ -36,7 +55,7 @@ void Projectile_DrawTrail(vector to)
        // force the effect even for stationary firemine
        if(self.cnt == PROJECTILE_FIREMINE)
                if(from == to)
-                       from_z += 1;
+                       from.z += 1;
 
        if (self.traileffect)
        {
@@ -49,8 +68,8 @@ void Projectile_Draw()
 {
        vector rot;
        vector trailorigin;
-       float f;
-       float drawn;
+       int f;
+       bool drawn;
        float t;
        float a;
 
@@ -58,7 +77,7 @@ void Projectile_Draw()
 
        if(self.count & 0x80)
        {
-               //self.move_flags &~= FL_ONGROUND;
+               //self.move_flags &= ~FL_ONGROUND;
                if(self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
                        Movetype_Physics_NoMatchServer();
                        // the trivial movetypes do not have to match the
@@ -101,30 +120,22 @@ void Projectile_Draw()
                        case PROJECTILE_GRENADE_BOUNCING:
                                rot = '0 -1000 0'; // sideways
                                break;
-                       case PROJECTILE_NADE_RED_BURN:
-                       case PROJECTILE_NADE_RED:
-                       case PROJECTILE_NADE_BLUE_BURN:
-                       case PROJECTILE_NADE_BLUE:
-                       case PROJECTILE_NADE_YELLOW_BURN:
-                       case PROJECTILE_NADE_YELLOW:
-                       case PROJECTILE_NADE_PINK_BURN:
-                       case PROJECTILE_NADE_PINK:
-                       case PROJECTILE_NADE_BURN:
-                       case PROJECTILE_NADE:
-                               rot = self.avelocity; 
-                               break;
                        case PROJECTILE_HOOKBOMB:
                                rot = '1000 0 0'; // forward
                                break;
                        default:
                                break;
                }
+
+               if(Nade_IDFromProjectile(self.cnt) != 0)
+                       rot = self.avelocity;
+
                self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
        }
 
        vector ang;
        ang = self.angles;
-       ang_x = -ang_x;
+       ang_x = -ang.x;
        makevectors(ang);
 
        a = 1 - (time - self.fade_time) * self.fade_rate;
@@ -136,18 +147,6 @@ void Projectile_Draw()
        trailorigin = self.origin;
        switch(self.cnt)
        {
-           case PROJECTILE_NADE_RED_BURN:
-               case PROJECTILE_NADE_RED:
-               case PROJECTILE_NADE_BLUE_BURN:
-               case PROJECTILE_NADE_BLUE:
-               case PROJECTILE_NADE_YELLOW_BURN:
-               case PROJECTILE_NADE_YELLOW:
-               case PROJECTILE_NADE_PINK_BURN:
-               case PROJECTILE_NADE_PINK:
-               case PROJECTILE_NADE_BURN:
-               case PROJECTILE_NADE:
-                       trailorigin += v_up * 4;
-                       break;
                case PROJECTILE_GRENADE:
                case PROJECTILE_GRENADE_BOUNCING:
                        trailorigin += v_right * 1 + v_forward * -10;
@@ -155,6 +154,10 @@ void Projectile_Draw()
                default:
                        break;
        }
+
+       if(Nade_IDFromProjectile(self.cnt) != 0)
+               trailorigin += v_up * 4;
+
        if(drawn)
                Projectile_DrawTrail(trailorigin);
        else
@@ -167,10 +170,7 @@ void Projectile_Draw()
 
        switch(self.cnt)
        {
-               case PROJECTILE_BULLET_GLOWING:
-               case PROJECTILE_BULLET_GLOWING_TRACER:
-                       adddynamiclight(self.origin, 50 * a, '1 1 0');
-                       break;
+               // Possibly add dlights here.
                default:
                        break;
        }
@@ -178,7 +178,7 @@ void Projectile_Draw()
        self.drawmask = MASK_NORMAL;
 }
 
-void loopsound(entity e, float ch, string samp, float vol, float attn)
+void loopsound(entity e, int ch, string samp, float vol, float attn)
 {
        if(self.silent)
                return;
@@ -198,7 +198,7 @@ void Ent_RemoveProjectile()
 
 void Ent_Projectile()
 {
-       float f;
+       int f;
 
        // projectile properties:
        //   kind (interpolated, or clientside)
@@ -226,7 +226,7 @@ void Ent_Projectile()
        if(f & 0x40)
                self.move_flags |= FL_ONGROUND;
        else
-               self.move_flags &~= FL_ONGROUND;
+               self.move_flags &= ~FL_ONGROUND;
 
        if(!self.move_time)
        {
@@ -277,6 +277,8 @@ void Ent_Projectile()
                        self.fade_time = 0;
                        self.fade_rate = 0;
                }
+
+               self.team = ReadByte() - 1;
        }
 
        if(f & 2)
@@ -292,28 +294,29 @@ void Ent_Projectile()
                {
                        case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
                        case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
-                       case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
-                       case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle_weak"); break;
-                       case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
                        case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
                        case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
                        case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
                        case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
                        case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
                        case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
-                       case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
+                       case PROJECTILE_BLASTER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
                        case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
                        case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
                        case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
                        case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
                        case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
                        case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
+                       case PROJECTILE_NAPALM_FOUNTAIN: //self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("torch_small"); break;
                        case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
                        case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
                        case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
                        case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
                        case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
 
+                       case PROJECTILE_MAGE_SPIKE: setmodel(self, "models/ebomb.mdl"); self.traileffect = particleeffectnum("TR_VORESPIKE"); break;
+                       case PROJECTILE_SHAMBLER_LIGHTNING: setmodel(self, "models/ebomb.mdl"); self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
+
                        case PROJECTILE_RAPTORBOMB:    setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
                        case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3");     self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
                        case PROJECTILE_RAPTORCANNON:  setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
@@ -324,19 +327,11 @@ void Ent_Projectile()
 
                        case PROJECTILE_BUMBLE_GUN: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
                        case PROJECTILE_BUMBLE_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
-                       
-                       case PROJECTILE_NADE_RED: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_red"); break;
-                       case PROJECTILE_NADE_RED_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_red_burn"); break;
-                       case PROJECTILE_NADE_BLUE: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_blue"); break;
-                       case PROJECTILE_NADE_BLUE_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_blue_burn"); break;
-                       case PROJECTILE_NADE_YELLOW: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_yellow"); break;
-                       case PROJECTILE_NADE_YELLOW_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_yellow_burn"); break;
-                       case PROJECTILE_NADE_PINK: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_pink"); break;
-                       case PROJECTILE_NADE_PINK_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_pink_burn"); break;
-                       case PROJECTILE_NADE: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade"); break;
-                       case PROJECTILE_NADE_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_burn"); break;
+
+                       case PROJECTILE_RPC: setmodel(self, "models/weapons/ok_rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); break;
 
                        default:
+                               if(Nade_IDFromProjectile(self.cnt) != 0) { setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum(Nade_TrailEffect(self.cnt, self.team)); break; }
                                error("Received invalid CSQC projectile, can't work with this!");
                                break;
                }
@@ -352,7 +347,7 @@ void Ent_Projectile()
                {
                        case PROJECTILE_ELECTRO:
                                // only new engines support sound moving with object
-                               loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTEN_NORM);
                                self.mins = '0 0 -4';
                                self.maxs = '0 0 -4';
                                self.move_movetype = MOVETYPE_BOUNCE;
@@ -360,8 +355,9 @@ void Ent_Projectile()
                                self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
                                self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
                                break;
+                       case PROJECTILE_RPC:
                        case PROJECTILE_ROCKET:
-                               loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTEN_NORM);
                                self.mins = '-3 -3 -3';
                                self.maxs = '3 3 3';
                                break;
@@ -369,40 +365,18 @@ void Ent_Projectile()
                                self.mins = '-3 -3 -3';
                                self.maxs = '3 3 3';
                                break;
-                       case PROJECTILE_NADE_RED_BURN:
-                       case PROJECTILE_NADE_RED:
-                       case PROJECTILE_NADE_BLUE_BURN:
-                       case PROJECTILE_NADE_BLUE:
-                               self.mins = '-3 -3 -3';
-                               self.maxs = '3 3 3';
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
-                               self.scale = 1.5;
-                               self.avelocity = randomvec() * 720;
-                               break;
                        case PROJECTILE_GRENADE_BOUNCING:
                                self.mins = '-3 -3 -3';
                                self.maxs = '3 3 3';
                                self.move_movetype = MOVETYPE_BOUNCE;
                                self.move_touch = func_null;
-                               self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
-                               self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
+                               self.move_bounce_factor = g_balance_mortar_bouncefactor;
+                               self.move_bounce_stopspeed = g_balance_mortar_bouncestop;
                                break;
-                       case PROJECTILE_NADE_RED_BURN:
-                       case PROJECTILE_NADE_RED:
-                       case PROJECTILE_NADE_BLUE_BURN:
-                       case PROJECTILE_NADE_BLUE:
-                       case PROJECTILE_NADE_YELLOW_BURN:
-                       case PROJECTILE_NADE_YELLOW:
-                       case PROJECTILE_NADE_PINK_BURN:
-                       case PROJECTILE_NADE_PINK:
-                       case PROJECTILE_NADE_BURN:
-                       case PROJECTILE_NADE:
-                               self.mins = '-16 -16 -16';
-                               self.maxs = '16 16 16';
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
-                               self.scale = 1.5;
+                       case PROJECTILE_SHAMBLER_LIGHTNING:
+                               self.mins = '-8 -8 -8';
+                               self.maxs = '8 8 8';
+                               self.scale = 2.5;
                                self.avelocity = randomvec() * 720;
                                break;
                        case PROJECTILE_MINE:
@@ -429,13 +403,14 @@ void Ent_Projectile()
                                self.move_movetype = MOVETYPE_BOUNCE;
                                self.move_touch = func_null;
                                break;
+                       case PROJECTILE_NAPALM_FOUNTAIN:
                        case PROJECTILE_FIREBALL:
-                               loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTEN_NORM);
                                self.mins = '-16 -16 -16';
                                self.maxs = '16 16 16';
                                break;
                        case PROJECTILE_FIREMINE:
-                               loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTEN_NORM);
                                self.move_movetype = MOVETYPE_BOUNCE;
                                self.move_touch = func_null;
                                self.mins = '-4 -4 -4';
@@ -450,7 +425,7 @@ void Ent_Projectile()
                                self.maxs = '2 2 2';
                                break;
                        case PROJECTILE_SEEKER:
-                               loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
                                self.mins = '-4 -4 -4';
                                self.maxs = '4 4 4';
                                break;
@@ -463,17 +438,17 @@ void Ent_Projectile()
             case PROJECTILE_RAPTORCANNON:
                                break;
             case PROJECTILE_SPIDERROCKET:
-                loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
+                loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
                                break;
             case PROJECTILE_WAKIROCKET:
-                loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
-                               break;            
+                loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
+                               break;
             /*
             case PROJECTILE_WAKICANNON:
                                break;
                        case PROJECTILE_BUMBLE_GUN:
                                // only new engines support sound moving with object
-                               loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTEN_NORM);
                                self.mins = '0 0 -4';
                                self.maxs = '0 0 -4';
                                self.move_movetype = MOVETYPE_BOUNCE;
@@ -485,6 +460,24 @@ void Ent_Projectile()
                        default:
                                break;
                }
+
+               if(Nade_IDFromProjectile(self.cnt) != 0)
+               {
+                       int nade_type = Nade_IDFromProjectile(self.cnt);
+                       self.mins = '-16 -16 -16';
+                       self.maxs = '16 16 16';
+                       self.colormod = Nade_Color(nade_type);
+                       self.move_movetype = MOVETYPE_BOUNCE;
+                       self.move_touch = func_null;
+                       self.scale = 1.5;
+                       self.avelocity = randomvec() * 720;
+
+                       if(nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
+                               self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+                       else
+                               self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
+               }
+
                setsize(self, self.mins, self.maxs);
        }
 
@@ -523,8 +516,10 @@ void Projectile_Precache()
        precache_model("models/rocket.md3");
        precache_model("models/tagrocket.md3");
        precache_model("models/tracer.mdl");
-       
+       precache_model("models/sphere/sphere.md3");
+
        precache_model("models/weapons/v_ok_grenade.md3");
+       precache_model("models/weapons/ok_rocket.md3");
 
        precache_sound("weapons/electro_fly.wav");
        precache_sound("weapons/rocket_fly.wav");