X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Ftriggers%2Fmisc%2Flaser.qc;h=f0aafc7c40e5d06238324f87b0eb6d14dec518bb;hb=aa14e2a0c66030cfde1c5d9d2c0882b5aa4816c1;hp=a7fb07815356973eee23bdee3c88a0878f312434;hpb=e4ac65ac2e770b795d1234ead3b2c25731f39bb3;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/misc/laser.qc b/qcsrc/common/triggers/misc/laser.qc index a7fb07815..f0aafc7c4 100644 --- a/qcsrc/common/triggers/misc/laser.qc +++ b/qcsrc/common/triggers/misc/laser.qc @@ -1,65 +1,64 @@ #if defined(CSQC) - #include "../../../client/_all.qh" - #include "../../buffs.qh" - #include "../../../csqcmodellib/interpolate.qh" - #include "../../../client/main.qh" - #include "../../../csqcmodellib/cl_model.qh" + #include + #include + #include #elif defined(MENUQC) #elif defined(SVQC) #endif +REGISTER_NET_LINKED(ENT_CLIENT_LASER) + #ifdef SVQC .float modelscale; -void misc_laser_aim() +void misc_laser_aim(entity this) { vector a; - if(self.enemy) + if(this.enemy) { - if(self.spawnflags & 2) + if(this.spawnflags & 2) { - if(self.enemy.origin != self.mangle) + if(this.enemy.origin != this.mangle) { - self.mangle = self.enemy.origin; - self.SendFlags |= 2; + this.mangle = this.enemy.origin; + this.SendFlags |= 2; } } else { - a = vectoangles(self.enemy.origin - self.origin); + a = vectoangles(this.enemy.origin - this.origin); a_x = -a_x; - if(a != self.mangle) + if(a != this.mangle) { - self.mangle = a; - self.SendFlags |= 2; + this.mangle = a; + this.SendFlags |= 2; } } } else { - if(self.angles != self.mangle) + if(this.angles != this.mangle) { - self.mangle = self.angles; - self.SendFlags |= 2; + this.mangle = this.angles; + this.SendFlags |= 2; } } - if(self.origin != self.oldorigin) + if(this.origin != this.oldorigin) { - self.SendFlags |= 1; - self.oldorigin = self.origin; + this.SendFlags |= 1; + this.oldorigin = this.origin; } } -void misc_laser_init() +void misc_laser_init(entity this) { if(self.target != "") self.enemy = find(world, targetname, self.target); } .entity pusher; -void misc_laser_think() +void misc_laser_think(entity this) { vector o; - entity oldself; entity hitent; vector hitloc; @@ -68,7 +67,7 @@ void misc_laser_think() if(!self.state) return; - misc_laser_aim(); + misc_laser_aim(this); if(self.enemy) { @@ -98,11 +97,7 @@ void misc_laser_think() { self.count = 1; - oldself = self; - self = self.enemy; - activator = self.pusher; - SUB_UseTargets(); - self = oldself; + SUB_UseTargets(self.enemy, self.enemy.pusher, NULL); } } else @@ -111,11 +106,7 @@ void misc_laser_think() { self.count = 0; - oldself = self; - self = self.enemy; - activator = self.pusher; - SUB_UseTargets(); - self = oldself; + SUB_UseTargets(self.enemy, self.enemy.pusher, NULL); } } } @@ -126,13 +117,13 @@ void misc_laser_think() if(((self.spawnflags & 8) == 0) == (self.team != hitent.team)) return; if(hitent.takedamage) - Damage(hitent, self, self, ((self.dmg < 0) ? 100000 : (self.dmg * frametime)), DEATH_HURTTRIGGER, hitloc, '0 0 0'); + Damage(hitent, self, self, ((self.dmg < 0) ? 100000 : (self.dmg * frametime)), DEATH_HURTTRIGGER.m_id, hitloc, '0 0 0'); } } -float laser_SendEntity(entity to, float fl) +bool laser_SendEntity(entity this, entity to, float fl) { - WriteByte(MSG_ENTITY, ENT_CLIENT_LASER); + WriteHeader(MSG_ENTITY, ENT_CLIENT_LASER); fl = fl - (fl & 0xF0); // use that bit to indicate finite length laser if(self.spawnflags & 2) fl |= 0x80; @@ -195,74 +186,68 @@ Keys: "dmg" damage per second (-1 for a laser that kills immediately) */ -void laser_use() +void laser_use(entity this, entity actor, entity trigger) { - self.state = !self.state; - self.SendFlags |= 4; - misc_laser_aim(); + this.state = !this.state; + this.SendFlags |= 4; + misc_laser_aim(this); } -void laser_reset() +void laser_reset(entity this) { - if(self.spawnflags & 1) - self.state = 1; + if(this.spawnflags & 1) + this.state = 1; else - self.state = 0; + this.state = 0; } -void spawnfunc_misc_laser() +spawnfunc(misc_laser) { - if(self.mdl) + if(this.mdl) { - if(self.mdl == "none") - self.cnt = -1; + if(this.mdl == "none") + this.cnt = -1; else { - self.cnt = _particleeffectnum(self.mdl); - if(self.cnt < 0) - if(self.dmg) - self.cnt = particleeffectnum(EFFECT_LASER_DEADLY); + this.cnt = _particleeffectnum(this.mdl); + if(this.cnt < 0 && this.dmg) + this.cnt = particleeffectnum(EFFECT_LASER_DEADLY); } } - else if(!self.cnt) + else if(!this.cnt) { - if(self.dmg) - self.cnt = particleeffectnum(EFFECT_LASER_DEADLY); + if(this.dmg) + this.cnt = particleeffectnum(EFFECT_LASER_DEADLY); else - self.cnt = -1; + this.cnt = -1; } - if(self.cnt < 0) - self.cnt = -1; + if(this.cnt < 0) + this.cnt = -1; - if(self.colormod == '0 0 0') - if(!self.alpha) - self.colormod = '1 0 0'; - if(self.message == "") - self.message = "saw the light"; - if (self.message2 == "") - self.message2 = "was pushed into a laser by"; - if(!self.scale) - self.scale = 1; - if(!self.modelscale) - self.modelscale = 1; - else if(self.modelscale < 0) - self.modelscale = 0; - self.think = misc_laser_think; - self.nextthink = time; - InitializeEntity(self, misc_laser_init, INITPRIO_FINDTARGET); + if(this.colormod == '0 0 0') + if(!this.alpha) + this.colormod = '1 0 0'; + if(this.message == "") this.message = "saw the light"; + if (this.message2 == "") this.message2 = "was pushed into a laser by"; + if(!this.scale) this.scale = 1; + if(!this.modelscale) this.modelscale = 1; + else if(this.modelscale < 0) this.modelscale = 0; + setthink(this, misc_laser_think); + this.nextthink = time; + InitializeEntity(this, misc_laser_init, INITPRIO_FINDTARGET); - self.mangle = self.angles; + this.mangle = this.angles; - Net_LinkEntity(self, false, 0, laser_SendEntity); + Net_LinkEntity(this, false, 0, laser_SendEntity); IFTARGETED { - self.reset = laser_reset; - laser_reset(); - self.use = laser_use; + this.reset = laser_reset; + this.reset(this); + this.use = laser_use; } else - self.state = 1; + this.state = 1; } #elif defined(CSQC) @@ -279,115 +264,118 @@ class(Laser) .float alpha; class(Laser) .float scale; // scaling factor of the thickness class(Laser) .float modelscale; // scaling factor of the dlight -void Draw_Laser() +void Draw_Laser(entity this) { - if(!self.state) + if(!this.state) return; - InterpolateOrigin_Do(); - if(self.count & 0x80) + InterpolateOrigin_Do(this); + if(this.count & 0x80) { - if(self.count & 0x10) + if(this.count & 0x10) { - trace_endpos = self.velocity; + trace_endpos = this.velocity; trace_dphitq3surfaceflags = 0; } else - traceline(self.origin, self.velocity, 0, self); + traceline(this.origin, this.velocity, 0, this); } else { - if(self.count & 0x10) + if(this.count & 0x10) { - makevectors(self.angles); - trace_endpos = self.origin + v_forward * 1048576; + makevectors(this.angles); + trace_endpos = this.origin + v_forward * 1048576; trace_dphitq3surfaceflags = Q3SURFACEFLAG_SKY; } else { - makevectors(self.angles); - traceline(self.origin, self.origin + v_forward * 32768, 0, self); + makevectors(this.angles); + traceline(this.origin, this.origin + v_forward * 32768, 0, this); if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) - trace_endpos = self.origin + v_forward * 1048576; + trace_endpos = this.origin + v_forward * 1048576; } } - if(self.scale != 0) + if(this.scale != 0) { - if(self.alpha) + if(this.alpha) { - Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL, view_origin); + Draw_CylindricLine(this.origin, trace_endpos, this.scale, "particles/laserbeam", 0, time * 3, this.colormod, this.alpha, DRAWFLAG_NORMAL, view_origin); } else { - Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin); + Draw_CylindricLine(this.origin, trace_endpos, this.scale, "particles/laserbeam", 0, time * 3, this.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin); } } if (!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT))) { - if(self.cnt >= 0) - pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000); - if(self.colormod != '0 0 0' && self.modelscale != 0) - adddynamiclight(trace_endpos + trace_plane_normal * 1, self.modelscale, self.colormod * 5); + if(this.cnt >= 0) + __pointparticles(this.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000); + if(this.colormod != '0 0 0' && this.modelscale != 0) + adddynamiclight(trace_endpos + trace_plane_normal * 1, this.modelscale, this.colormod * 5); } } -void Ent_Laser() +NET_HANDLE(ENT_CLIENT_LASER, bool isnew) { - InterpolateOrigin_Undo(); + InterpolateOrigin_Undo(this); // 30 bytes, or 13 bytes for just moving int f = ReadByte(); - self.count = (f & 0xF0); + this.count = (f & 0xF0); - if(self.count & 0x80) - self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; + if(this.count & 0x80) + this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; else - self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; + this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; if(f & 1) { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); + setorigin(this, this.origin); } if(f & 8) { - self.colormod_x = ReadByte() / 255.0; - self.colormod_y = ReadByte() / 255.0; - self.colormod_z = ReadByte() / 255.0; + this.colormod_x = ReadByte() / 255.0; + this.colormod_y = ReadByte() / 255.0; + this.colormod_z = ReadByte() / 255.0; if(f & 0x40) - self.alpha = ReadByte() / 255.0; + this.alpha = ReadByte() / 255.0; else - self.alpha = 0; - self.scale = 2; - self.modelscale = 50; + this.alpha = 0; + this.scale = 2; + this.modelscale = 50; if(f & 0x20) { - self.scale *= ReadByte() / 16.0; // beam radius - self.modelscale *= ReadByte() / 16.0; // dlight radius + this.scale *= ReadByte() / 16.0; // beam radius + this.modelscale *= ReadByte() / 16.0; // dlight radius } if((f & 0x80) || !(f & 0x10)) - self.cnt = ReadShort() - 1; // effect number + this.cnt = ReadShort() - 1; // effect number else - self.cnt = 0; + this.cnt = 0; } if(f & 2) { if(f & 0x80) { - self.velocity_x = ReadCoord(); - self.velocity_y = ReadCoord(); - self.velocity_z = ReadCoord(); + this.velocity_x = ReadCoord(); + this.velocity_y = ReadCoord(); + this.velocity_z = ReadCoord(); } else { - self.angles_x = ReadAngle(); - self.angles_y = ReadAngle(); + this.angles_x = ReadAngle(); + this.angles_y = ReadAngle(); } } if(f & 4) - self.state = ReadByte(); - InterpolateOrigin_Note(); - self.draw = Draw_Laser; + this.state = ReadByte(); + + return = true; + + InterpolateOrigin_Note(this); + this.draw = Draw_Laser; } #endif