]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
laser secondary gauntlet, lots of improvements to code
authorFruitieX <rasse@rasse-lappy.localdomain>
Wed, 21 Jul 2010 11:13:43 +0000 (14:13 +0300)
committerFruitieX <rasse@rasse-lappy.localdomain>
Wed, 21 Jul 2010 11:13:43 +0000 (14:13 +0300)
12 files changed:
balanceFruit.cfg
particles/gauntletbeam.tga [new file with mode: 0644]
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/hook.qc
qcsrc/server/cl_client.qc
qcsrc/server/g_world.qc
qcsrc/server/progs.src
qcsrc/server/w_laser.qc
qcsrc/server/w_laser.qh [new file with mode: 0644]
sound/weapons/gauntlet_fire.ogg
sound/weapons/gauntletbeam_fly.ogg [new file with mode: 0644]

index ba90c56aa723c77c16dd24432bb267840ef31602..a2bfdfb4669f3d4455b7e50f698f635f2c9660f0 100644 (file)
@@ -219,10 +219,10 @@ set g_balance_laser_primary_shotangle 0
 set g_balance_laser_primary_delay 0
 set g_balance_laser_primary_gauntlet 0
 set g_balance_laser_secondary 1 // when 1, a secondary laser mode exists
-set g_balance_laser_secondary_damage 7
+set g_balance_laser_secondary_damage 110 // dps
 set g_balance_laser_secondary_edgedamage 0
-set g_balance_laser_secondary_force 75
-set g_balance_laser_secondary_radius 10
+set g_balance_laser_secondary_force 500
+set g_balance_laser_secondary_radius 45
 set g_balance_laser_secondary_speed 0
 set g_balance_laser_secondary_spread 0
 set g_balance_laser_secondary_refire 0.066
diff --git a/particles/gauntletbeam.tga b/particles/gauntletbeam.tga
new file mode 100644 (file)
index 0000000..20a6ee5
Binary files /dev/null and b/particles/gauntletbeam.tga differ
index b1c423b25bcd4833f4406f809b1705912787b7fd..1b019d5be89d63aa3caa0b0831fc5005a2b77d8a 100644 (file)
@@ -234,6 +234,7 @@ float tempdb;
 float ClientProgsDB;
 vector hook_shotorigin[4];
 vector electro_shotorigin[4];
+vector gauntlet_shotorigin[4];
 
 #ifdef BLURTEST
 float blurtest_time0, blurtest_time1, blurtest_radius, blurtest_power;
index 14a213ef2756f8a70dc91749f9fb19d1ce114fae..ed851b9c1ff3a08ed5662005a40c7f543375b5c2 100644 (file)
@@ -1031,6 +1031,10 @@ void Ent_Init()
        electro_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
        electro_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
        electro_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
+       gauntlet_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
+       gauntlet_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
+       gauntlet_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
+       gauntlet_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
 
        if(forcefog)
                strunzone(forcefog);
index 8644847b3f92efc78a38f75e5a7801359e153423..9f690d5bc884dc3692b1ebb172cdd6089e74775f 100644 (file)
@@ -6,6 +6,12 @@
 .float LGBeamKillTime;
 .float LGBeamSound;
 .float LGBeamSilent;
+.vector GauntletBeamStart;
+.vector GauntletBeamEnd;
+.float GauntletBeamKillTime;
+.float GauntletBeamSound;
+.float GauntletBeamSilent;
+
 
 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float alpha, float drawflag)
 {
@@ -138,6 +144,38 @@ void Draw_GrapplingHook()
                setorigin(self, a);
        }
 
+       if(time < self.GauntletBeamKillTime)
+       {
+               s = cvar("cl_gunalign");
+               if(s != 1 && s != 2 && s != 4)
+                       s = 3; // default value
+               --s;
+               vs = gauntlet_shotorigin[s];
+
+               if(self.sv_entnum == player_localentnum - 1)
+               {
+                       b = view_origin + view_forward * MAX_SHOT_DISTANCE;
+                       WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world);
+                       a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z;
+               }
+               else
+               {
+                       a = self.GauntletBeamStart;
+                       b = self.GauntletBeamEnd;
+               }
+
+               tex = "particles/gauntletbeam";
+               rgb = '1 1 1';
+
+               Draw_GrapplingHook_trace_callback_tex = tex;
+               Draw_GrapplingHook_trace_callback_rnd = random();
+               WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, MOVE_NORMAL, world, world, Draw_GrapplingHook_trace_callback);
+               Draw_GrapplingHook_trace_callback_tex = string_null;
+
+               // helps the sound
+               setorigin(self, a);
+       }
+
        if(time < self.LGBeamKillTime && !self.LGBeamSilent)
        {
                if(!self.LGBeamSound)
@@ -154,6 +192,23 @@ void Draw_GrapplingHook()
                        self.LGBeamSound = 0;
                }
        }
+
+       if(time < self.GauntletBeamKillTime && !self.GauntletBeamSilent)
+       {
+               if(!self.GauntletBeamSound)
+               {
+                       sound (self, CHAN_PROJECTILE, "weapons/gauntletbeam_fly.wav", VOL_BASE, ATTN_NORM);
+                       self.GauntletBeamSound = 1;
+               }
+       }
+       else
+       {
+               if(self.GauntletBeamSound)
+               {
+                       sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
+                       self.GauntletBeamSound = 0;
+               }
+       }
 }
 
 void Net_GrapplingHook()
@@ -201,10 +256,18 @@ void Net_GrapplingHook()
                        p.LGBeamSilent = 1;
                        p.draw = Draw_GrapplingHook;
                        break;
+               case 3: // gauntlet beam
+                       p.GauntletBeamKillTime = time + 0.1;
+                       p.GauntletBeamStart = start;
+                       p.GauntletBeamEnd = end;
+                       p.GauntletBeamSilent = 0;
+                       p.draw = Draw_GrapplingHook;
+                       break;
        }
 }
 
 void Hook_Precache()
 {
        precache_sound("weapons/lgbeam_fly.wav");
+       precache_sound("weapons/gauntletbeam_fly.wav");
 }
index f4b83c5d8d754f6a6dc2fdf7e6e1318702c004d8..fda3e902fa31649e8746faeaee0892a201755590 100644 (file)
@@ -1071,6 +1071,10 @@ float ClientInit_SendEntity(entity to, float sf)
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[1]));
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[2]));
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[3]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[0]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[1]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[2]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[3]));
        if(sv_foginterval && world.fog != "")
                WriteString(MSG_ENTITY, world.fog);
        else
index 020c24bb3df3bb4b4bcecde9e573771eb937be52..07898df16817501ada15cc655255c3cec5cf9f0e 100644 (file)
@@ -513,6 +513,7 @@ void spawnfunc_worldspawn (void)
        readlevelcvars();
        GrappleHookInit();
        ElectroInit();
+       LaserInit();
 
        player_count = 0;
        bot_waypoints_for_items = cvar("g_waypoints_for_items");
index 929b0df2091175973835016c8ddc531f965ad631..adf4b4a1d89545418734228dddc0b16345100f0a 100644 (file)
@@ -44,6 +44,7 @@ portals.qh
 
 g_hook.qh
 w_electro.qh
+w_laser.qh
 
 scores.qh
 
index c716ae1e6df6e72afe48d45eb02bd139d3273d3e..8633297a12d2c31bbbfe16d77b3b5d79a571322d 100644 (file)
@@ -101,32 +101,105 @@ void W_Laser_Attack (float issecondary)
        }
 }
 
-void W_Laser_Attack2 (float issecondary) // gauntlet
+.entity gauntletbeam;
+.float prevgauntletfire;
+void gauntletbeam_think()
 {
-       float damage, force, myradius;
-       if(issecondary)
+       float damage, myforce, myradius;
+       if(self.cnt)
        {
                damage = cvar("g_balance_laser_secondary_damage");
-               force = cvar("g_balance_laser_secondary_force");
+               myforce = cvar("g_balance_laser_secondary_force");
                myradius = cvar("g_balance_laser_secondary_radius");
        }
        else
        {
                damage = cvar("g_balance_laser_primary_damage");
-               force = cvar("g_balance_laser_primary_force");
+               myforce = cvar("g_balance_laser_primary_force");
                myradius = cvar("g_balance_laser_primary_radius");
        }
 
-       W_SetupShot (self, TRUE, 0, "weapons/gauntlet_fire.wav", damage);
+       self.owner.prevgauntletfire = time;
+       if (self.owner.weaponentity.state != WS_INUSE || self != self.owner.gauntletbeam || self.owner.deadflag != DEAD_NO || (!self.owner.BUTTON_ATCK2 && self.cnt) || (!self.owner.BUTTON_ATCK && !self.cnt))
+       {
+               remove(self);
+               return;
+       }
+
+       self.nextthink = time;
+
+       makevectors(self.owner.v_angle);
+       vector angle;
+       angle = v_forward;
+
+       WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * myradius, FALSE, self.owner, ANTILAG_LATENCY(self.owner));
+
+       // apply the damage
+       if(trace_fraction < 1)
+       {
+               vector force;
+               force = angle * myforce;
+               Damage (trace_ent, self.owner, self.owner, damage * frametime, WEP_ELECTRO, trace_endpos, force * frametime);
+       }
+
+       // draw effect
+       vector vecs, org;
+       if(self.owner.weaponentity.movedir_x > 0)
+       {
+               vecs = self.owner.weaponentity.movedir;
+               vecs_y = -vecs_y;
+       }
+       else
+               vecs = '0 0 0';
+       org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * vecs_y + v_up * vecs_z;
+       
+       // TODO turn into a csqc entity
+       WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
+       WriteByte(MSG_BROADCAST, TE_CSQC_BEAM);
+       WriteByte(MSG_BROADCAST, num_for_edict(self.owner));
+       WriteByte(MSG_BROADCAST, 3);
+       WriteCoord(MSG_BROADCAST, trace_endpos_x);
+       WriteCoord(MSG_BROADCAST, trace_endpos_y);
+       WriteCoord(MSG_BROADCAST, trace_endpos_z);
+       WriteCoord(MSG_BROADCAST, org_x);
+       WriteCoord(MSG_BROADCAST, org_y);
+       WriteCoord(MSG_BROADCAST, org_z);
+}
+
+// experimental gauntlet
+void W_Laser_Attack2 (float issecondary)
+{
+       // only play fire sound if 0.5 sec has passed since player let go the fire button
+       if(time - self.prevgauntletfire > 0.5)
+       {
+               sound (self, CHAN_WEAPON, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM);
+       }
 
-       WarpZone_traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * (myradius + vlen(eX * self.velocity_x + eY * self.velocity_y)/5), FALSE, self, ANTILAG_LATENCY(self));
+       entity beam, oldself;
 
-       pointparticles(particleeffectnum("laser_gauntletmuzzleflash"), w_shotorg, w_shotdir * 1000, 1);
-       pointparticles(particleeffectnum("laser_gauntlet"), w_shotorg + w_shotdir * (myradius + vlen(eX * self.velocity_x + eY * self.velocity_y)/5), w_shotdir * 1000, 1);
-       pointparticles(particleeffectnum("laser_gauntlet"), w_shotorg + w_shotdir * (myradius + vlen(eX * self.velocity_x + eY * self.velocity_y)/5) * 0.5, w_shotdir * 1000, 1);
+       self.gauntletbeam = beam = spawn();
+       beam.solid = SOLID_NOT;
+       beam.think = gauntletbeam_think;
+       beam.owner = self;
+       beam.movetype = MOVETYPE_NONE;
+       beam.shot_spread = 0;
+       beam.bot_dodge = TRUE;
+       beam.bot_dodgerating = cvar("g_balance_laser_primary_damage");
+       beam.cnt = issecondary;
 
-       if (trace_fraction < 1)
-               Damage(trace_ent, self, self, damage, WEP_LASER | HITTYPE_SECONDARY, trace_endpos, cvar("g_balance_laser_primary_force") * w_shotdir);
+       oldself = self;
+       self = beam;
+       self.think();
+       self = oldself;
+}
+
+void LaserInit()
+{
+       weapon_action(WEP_LASER, WR_PRECACHE);
+       gauntlet_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 1);
+       gauntlet_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 2);
+       gauntlet_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 3);
+       gauntlet_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 4);
 }
 
 void spawnfunc_weapon_laser (void)
diff --git a/qcsrc/server/w_laser.qh b/qcsrc/server/w_laser.qh
new file mode 100644 (file)
index 0000000..0f2c137
--- /dev/null
@@ -0,0 +1,2 @@
+void LaserInit();
+vector gauntlet_shotorigin[4];
index 01906932c7d4810b559c758fbb9a349345320967..03802f65d10547e699bf900878269346e311d095 100644 (file)
Binary files a/sound/weapons/gauntlet_fire.ogg and b/sound/weapons/gauntlet_fire.ogg differ
diff --git a/sound/weapons/gauntletbeam_fly.ogg b/sound/weapons/gauntletbeam_fly.ogg
new file mode 100644 (file)
index 0000000..874d246
Binary files /dev/null and b/sound/weapons/gauntletbeam_fly.ogg differ