r4192 - in trunk/data/qcsrc: client common server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Aug 26 07:58:52 EDT 2008
Author: div0
Date: 2008-08-26 07:58:51 -0400 (Tue, 26 Aug 2008)
New Revision: 4192
Modified:
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/client/View.qc
trunk/data/qcsrc/client/hook.qc
trunk/data/qcsrc/client/main.qh
trunk/data/qcsrc/client/particles.qc
trunk/data/qcsrc/client/progs.src
trunk/data/qcsrc/common/constants.qh
trunk/data/qcsrc/server/g_triggers.qc
Log:
misc_laser is now client side too (untested too)
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/client/Main.qc 2008-08-26 11:58:51 UTC (rev 4192)
@@ -439,6 +439,8 @@
Ent_PointParticles();
else if(self.enttype == ENT_CLIENT_RAINSNOW)
Ent_RainOrSnow();
+ else if(self.enttype == ENT_CLIENT_LASER)
+ Ent_Laser();
else
error("unknown entity type in CSQC_Ent_Update\n");
@@ -482,6 +484,9 @@
*/
// we don't NEED to remove them... they won't display anyway
// plus, svqc never does this anyway
+ } else if(self.enttype == ENT_CLIENT_POINTPARTICLES)
+ {
+ Ent_PointParticles_Remove();
}
self.enttype = 0;
Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/client/View.qc 2008-08-26 11:58:51 UTC (rev 4192)
@@ -60,6 +60,13 @@
// Render the Scene
+ view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
+ view_angles = input_angles;
+ makevectors(view_angles);
+ view_forward = v_forward;
+ view_right = v_right;
+ view_up = v_up;
+
e = self;
for(self = world; (self = nextent(self)); )
if(self.draw)
Modified: trunk/data/qcsrc/client/hook.qc
===================================================================
--- trunk/data/qcsrc/client/hook.qc 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/client/hook.qc 2008-08-26 11:58:51 UTC (rev 4192)
@@ -2,7 +2,7 @@
.vector HookEnd;
.float HookKillTime;
-void Draw_GrapplingHookLine(vector from, vector to, float thickness, vector org, vector view_forward, string texture, float aspect, vector rgb)
+void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, vector rgb, float drawflag)
{
// I want to draw a quad...
// from and to are MIDPOINTS.
@@ -18,14 +18,14 @@
length_tex = aspect * vlen(to - from) / thickness;
// direction is perpendicular to the view normal, and perpendicular to the axis
- thickdir = normalize(cross(axis, org - from));
+ thickdir = normalize(cross(axis, view_origin - from));
A = from - thickdir * (thickness / 2);
B = from + thickdir * (thickness / 2);
C = to + thickdir * (thickness / 2);
D = to - thickdir * (thickness / 2);
- R_BeginPolygon(texture, 0);
+ R_BeginPolygon(texture, drawflag);
R_PolygonVertex(A, '0 0 0' + t * '1 0 0', rgb, 1);
R_PolygonVertex(B, '0 1 0' + t * '1 0 0', rgb, 1);
R_PolygonVertex(C, '0 1 0' + (t + length_tex) * '1 0 0', rgb, 1);
@@ -39,13 +39,10 @@
string tex;
vector rgb;
- o = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
- makevectors(input_angles);
-
if(time >= self.HookKillTime)
return;
if(self.sv_entnum == player_localentnum - 1)
- a = o + v_forward * 8 - v_right * 8 + v_up * -12;
+ a = view_origin + view_forward * 8 - view_right * 8 + view_up * -12;
else
a = self.HookStart;
b = self.HookEnd;
@@ -75,9 +72,9 @@
rgb = '.3 1 .3';
}
if(checkextension("DP_SV_WRITEPICTURE"))
- Draw_GrapplingHookLine(b, a, 8, o, v_forward, tex, 0.25, '1 1 1');
+ Draw_CylindricLine(b, a, 8, tex, 0.25, '1 1 1', DRAWFLAG_NORMAL);
else
- Draw_GrapplingHookLine(b, a, 1, o, v_forward, "", 0.25, rgb);
+ Draw_CylindricLine(b, a, 1, "", 0.25, rgb, DRAWFLAG_NORMAL);
}
void Net_GrapplingHook()
Modified: trunk/data/qcsrc/client/main.qh
===================================================================
--- trunk/data/qcsrc/client/main.qh 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/client/main.qh 2008-08-26 11:58:51 UTC (rev 4192)
@@ -1,3 +1,5 @@
+const string string_null;
+
// --------------------------------------------------------------------------
// MENU Functionality
@@ -110,3 +112,4 @@
.void(void) draw;
float drawframetime;
+vector view_origin, view_angles, view_forward, view_right, view_up;
Modified: trunk/data/qcsrc/client/particles.qc
===================================================================
--- trunk/data/qcsrc/client/particles.qc 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/client/particles.qc 2008-08-26 11:58:51 UTC (rev 4192)
@@ -88,40 +88,56 @@
void Ent_PointParticles()
{
- self.modelindex = ReadShort();
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
- self.cnt = ReadShort(); // effect number
- self.impulse = ReadCoord(); // density (<0: point, >0: volume)
- if(self.impulse == 0)
- self.impulse = 1; // one per sec
- self.velocity = decompressShortVector(ReadShort());
- self.movedir = decompressShortVector(ReadShort());
- self.waterlevel = ReadCoord();
- self.count = ReadCoord();
- self.glow_color = ReadByte();
- if(self.noise)
- strunzone(self.noise);
- self.noise = strzone(ReadString());
+ float f;
+ f = ReadByte();
+ if(f & 2)
+ {
+ self.impulse = ReadCoord(); // density (<0: point, >0: volume)
+ if(self.impulse == 0)
+ self.impulse = 1; // one per sec
+ self.absolute = (self.impulse >= 0);
+ if(!self.absolute)
+ self.impulse *= -self.maxs_x * self.maxs_y * self.maxs_z / 262144; // relative: particles per 64^3 cube
+ }
+ if(f & 1)
+ {
+ self.modelindex = ReadShort();
+ self.origin_x = ReadCoord();
+ self.origin_y = ReadCoord();
+ self.origin_z = ReadCoord();
+ self.maxs_x = ReadCoord();
+ self.maxs_y = ReadCoord();
+ self.maxs_z = ReadCoord();
- self.absolute = (self.impulse >= 0);
- if(!self.absolute)
- self.impulse *= -self.maxs_x * self.maxs_y * self.maxs_z / 262144; // relative: particles per 64^3 cube
+ self.mins = -0.5 * self.maxs;
+ self.maxs = 0.5 * self.maxs;
+ self.origin = self.origin - self.mins;
- self.mins = -0.5 * self.maxs;
- self.maxs = 0.5 * self.maxs;
- self.origin = self.origin - self.mins;
+ self.cnt = ReadShort(); // effect number
+ self.velocity = decompressShortVector(ReadShort());
+ self.movedir = decompressShortVector(ReadShort());
+ self.waterlevel = ReadCoord();
+ self.count = ReadCoord();
+ self.glow_color = ReadByte();
+ if(self.noise)
+ strunzone(self.noise);
+ self.noise = strzone(ReadString());
+ }
+
setorigin(self, self.origin);
setsize(self, self.mins, self.maxs);
self.solid = SOLID_NOT;
self.draw = Draw_PointParticles;
}
+void Ent_PointParticles_Remove()
+{
+ if(self.noise)
+ strunzone(self.noise);
+ self.noise = string_null;
+}
+
void Draw_Rain()
{
te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color);
Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/client/progs.src 2008-08-26 11:58:51 UTC (rev 4192)
@@ -23,6 +23,7 @@
hook.qc
particles.qc
+laser.qc
Main.qc
View.qc
Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/common/constants.qh 2008-08-26 11:58:51 UTC (rev 4192)
@@ -11,8 +11,9 @@
// Revision 10: scoreboard force
// Revision 11: scoreboard unforce; spectator support beginning
// Revision 12: smaller scores updates (SERVER: requires new engine)
-// Revision 12: pointparticles
-#define CSQC_REVISION 13
+// Revision 13: pointparticles
+// Revision 14: laser
+#define CSQC_REVISION 14
// probably put these in common/
// so server/ and client/ can be synced better
@@ -41,6 +42,7 @@
const float ENT_CLIENT_TEAMSCORES = 5;
const float ENT_CLIENT_POINTPARTICLES = 6;
const float ENT_CLIENT_RAINSNOW = 7;
+const float ENT_CLIENT_LASER = 8;
///////////////////////////
// key constants
Modified: trunk/data/qcsrc/server/g_triggers.qc
===================================================================
--- trunk/data/qcsrc/server/g_triggers.qc 2008-08-26 11:28:13 UTC (rev 4191)
+++ trunk/data/qcsrc/server/g_triggers.qc 2008-08-26 11:58:51 UTC (rev 4192)
@@ -485,30 +485,37 @@
self.effects = EF_STARDUST;
}
-float pointparticles_SendEntity(entity to)
+float pointparticles_SendEntity(entity to, float fl)
{
WriteByte(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
- if(self.modelindex != 4.2)
- WriteShort(MSG_ENTITY, self.modelindex);
- else
- WriteShort(MSG_ENTITY, 0);
- WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
- WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y);
- WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z);
- WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x);
- WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y);
- WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z);
- WriteShort(MSG_ENTITY, self.cnt);
- if(self.state)
- WriteCoord(MSG_ENTITY, self.impulse);
- else
- WriteCoord(MSG_ENTITY, 0); // off
- WriteShort(MSG_ENTITY, compressShortVector(self.velocity));
- WriteShort(MSG_ENTITY, compressShortVector(self.movedir));
- WriteCoord(MSG_ENTITY, self.waterlevel);
- WriteCoord(MSG_ENTITY, self.count);
- WriteByte(MSG_ENTITY, self.glow_color);
- WriteString(MSG_ENTITY, self.noise);
+ WriteByte(MSG_ENTITY, fl);
+ if(fl & 2)
+ {
+ if(self.state)
+ WriteCoord(MSG_ENTITY, self.impulse);
+ else
+ WriteCoord(MSG_ENTITY, 0); // off
+ }
+ if(fl & 1)
+ {
+ if(self.modelindex != 4.2)
+ WriteShort(MSG_ENTITY, self.modelindex);
+ else
+ WriteShort(MSG_ENTITY, 0);
+ WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
+ WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y);
+ WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z);
+ WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x);
+ WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y);
+ WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z);
+ WriteShort(MSG_ENTITY, self.cnt);
+ WriteShort(MSG_ENTITY, compressShortVector(self.velocity));
+ WriteShort(MSG_ENTITY, compressShortVector(self.movedir));
+ WriteCoord(MSG_ENTITY, self.waterlevel);
+ WriteCoord(MSG_ENTITY, self.count);
+ WriteByte(MSG_ENTITY, self.glow_color);
+ WriteString(MSG_ENTITY, self.noise);
+ }
return 1;
}
@@ -523,13 +530,13 @@
if(self.wait)
self.nextthink = time + self.wait; // toggle back after a delay
self.state = !self.state;
- self.Version += 1;
+ self.SendFlags |= 2;
}
void pointparticles_think()
{
self.state = !self.state;
- self.Version += 1;
+ self.SendFlags |= 2;
}
void spawnfunc_func_pointparticles()
@@ -541,7 +548,7 @@
self.effects = EF_NODEPTHTEST;
self.SendEntity = pointparticles_SendEntity;
- self.Version = 1;
+ self.SendFlags = 3;
if(!self.modelindex)
self.modelindex = 4.2;
self.model = "net_entity";
@@ -691,7 +698,7 @@
void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float deathtype);
void misc_laser_think()
{
- vector o;
+ vector o, a;
if(!self.state)
{
self.enemy = find(world, targetname, self.target);
@@ -700,6 +707,12 @@
if(self.enemy)
{
o = self.enemy.origin;
+ a = vectoangles(o - self.origin);
+ if(a != self.angles)
+ {
+ self.angles = a;
+ self.Version += 1;
+ }
}
else
{
@@ -714,46 +727,66 @@
else
FireRailgunBullet(self.origin, o, self.dmg * frametime, 0, DEATH_HURTTRIGGER);
}
-
- if(time > self.ltime)
+}
+float laser_SendEntity(entity to, float fl)
+{
+ WriteByte(MSG_ENTITY, ENT_CLIENT_LASER);
+ WriteByte(MSG_ENTITY, fl);
+ if(fl & 1)
{
- traceline(self.origin, o, MOVE_WORLDONLY, self);
- trailparticles(self, self.cnt, self.origin, trace_endpos);
- pointparticles(self.lip, trace_endpos, trace_plane_normal, 256 * frametime);
- self.ltime = time + self.wait;
+ WriteCoord(MSG_ENTITY, self.origin_x);
+ WriteCoord(MSG_ENTITY, self.origin_y);
+ WriteCoord(MSG_ENTITY, self.origin_z);
+ WriteByte(MSG_ENTITY, self.colormod_x * 255.0);
+ WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
+ WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
+ WriteShort(MSG_ENTITY, self.cnt);
}
- self.nextthink = time;
+ if(fl & 2)
+ {
+ WriteCoord(MSG_ENTITY, self.velocity_x);
+ WriteCoord(MSG_ENTITY, self.velocity_y);
+ WriteCoord(MSG_ENTITY, self.velocity_z);
+ }
+ return 1;
}
+
/*QUAKED spawnfunc_misc_laser (.5 .5 .5) ?
Any object touching the beam will be hurt
Keys:
"target"
spawnfunc_target_position where the laser ends
"mdl"
- name of beam effect to use
+ name of beam end effect to use
+"colormod"
+ color of the beam (default: red)
"dmg"
damage per second (-1 for a laser that kills immediately)
-"wait"
- delay between sending the particle effect
*/
void spawnfunc_misc_laser()
{
if(self.mdl)
{
- self.cnt = particleeffectnum(self.mdl);
- self.lip = particleeffectnum(strcat(self.mdl, "_end"));
+ self.cnt = particleeffectnum(strcat(self.mdl, "_end"));
+ if(self.cnt < 0)
+ self.cnt = particleeffectnum(self.mdl);
}
else
{
- self.cnt = particleeffectnum("misc_laser_beam");
- self.lip = particleeffectnum("misc_laser_beam_end");
+ self.cnt = particleeffectnum("misc_laser_beam_end");
}
- if(!self.wait)
- self.wait = 1;
+ if(self.colormod == '0 0 0')
+ self.colormod = '1 0 0';
if(!self.message)
self.message = "saw the light";
self.think = misc_laser_think;
self.nextthink = time;
+
+ self.effects = EF_NODEPTHTEST;
+ self.SendEntity = laser_SendEntity;
+ self.SendFlags = 3;
+ self.modelindex = 1;
+ self.model = "net_entity";
}
// tZorks trigger impulse / gravity
More information about the nexuiz-commits
mailing list