-#ifdef IMPLEMENTATION
+#include "modeleffects.qh"
REGISTER_NET_LINKED(ENT_CLIENT_MODELEFFECT)
WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
f = 0;
- if(self.velocity != '0 0 0')
+ if(this.velocity != '0 0 0')
f |= 1;
- if(self.angles != '0 0 0')
+ if(this.angles != '0 0 0')
f |= 2;
- if(self.avelocity != '0 0 0')
+ if(this.avelocity != '0 0 0')
f |= 4;
WriteByte(MSG_ENTITY, f);
- WriteShort(MSG_ENTITY, self.modelindex);
- WriteByte(MSG_ENTITY, self.skin);
- WriteByte(MSG_ENTITY, self.frame);
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteShort(MSG_ENTITY, this.modelindex);
+ WriteByte(MSG_ENTITY, this.skin);
+ WriteByte(MSG_ENTITY, this.frame);
+ WriteVector(MSG_ENTITY, this.origin);
if(f & 1)
{
- WriteCoord(MSG_ENTITY, self.velocity.x);
- WriteCoord(MSG_ENTITY, self.velocity.y);
- WriteCoord(MSG_ENTITY, self.velocity.z);
+ WriteVector(MSG_ENTITY, this.velocity);
}
if(f & 2)
{
- WriteCoord(MSG_ENTITY, self.angles.x);
- WriteCoord(MSG_ENTITY, self.angles.y);
- WriteCoord(MSG_ENTITY, self.angles.z);
+ WriteCoord(MSG_ENTITY, this.angles.x);
+ WriteCoord(MSG_ENTITY, this.angles.y);
+ WriteCoord(MSG_ENTITY, this.angles.z);
}
if(f & 4)
{
- WriteCoord(MSG_ENTITY, self.avelocity.x);
- WriteCoord(MSG_ENTITY, self.avelocity.y);
- WriteCoord(MSG_ENTITY, self.avelocity.z);
+ WriteCoord(MSG_ENTITY, this.avelocity.x);
+ WriteCoord(MSG_ENTITY, this.avelocity.y);
+ WriteCoord(MSG_ENTITY, this.avelocity.z);
}
- WriteShort(MSG_ENTITY, self.scale * 256.0);
- WriteShort(MSG_ENTITY, self.scale2 * 256.0);
- WriteByte(MSG_ENTITY, self.teleport_time * 100.0);
- WriteByte(MSG_ENTITY, self.fade_time * 100.0);
- WriteByte(MSG_ENTITY, self.alpha * 255.0);
+ WriteShort(MSG_ENTITY, this.scale * 256.0);
+ WriteShort(MSG_ENTITY, this.scale2 * 256.0);
+ WriteByte(MSG_ENTITY, this.teleport_time * 100.0);
+ WriteByte(MSG_ENTITY, this.fade_time * 100.0);
+ WriteByte(MSG_ENTITY, this.alpha * 255.0);
return true;
}
#ifdef CSQC
entityclass(ModelEffect);
-class(ModelEffect) .float frame1time;
-class(ModelEffect) .float lifetime, fadetime;
-class(ModelEffect) .float teleport_time;
-class(ModelEffect) .float scale1, scale2;
+classfield(ModelEffect) .float frame1time;
+classfield(ModelEffect) .float lifetime, fadetime;
+classfield(ModelEffect) .float teleport_time;
+classfield(ModelEffect) .float scale1, scale2;
.float cnt;
.float scale;
void ModelEffect_Draw(entity this)
{
- self.angles = self.angles + frametime * self.avelocity;
- setorigin(self, self.origin + frametime * self.velocity);
- self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
- self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
- if(self.alpha < ALPHA_MIN_VISIBLE)
+ this.angles = this.angles + frametime * this.avelocity;
+ setorigin(this, this.origin + frametime * this.velocity);
+ this.scale = this.scale1 + (this.scale2 - this.scale1) * (time - this.teleport_time) / (this.lifetime + this.fadetime - this.teleport_time);
+ this.alpha = this.cnt * bound(0, 1 - (time - this.lifetime) / this.fadetime, 1);
+ if(this.alpha < ALPHA_MIN_VISIBLE)
{
- remove(self);
+ delete(this);
return;
}
- self.drawmask = MASK_NORMAL;
- if(self.scale <= 0)
+ this.drawmask = MASK_NORMAL;
+ if(this.scale <= 0)
{
- self.drawmask = 0;
+ this.drawmask = 0;
return;
}
}
NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew)
{
- make_pure(self);
+ make_pure(this);
int f = ReadByte();
e.skin = ReadByte();
e.frame = ReadByte();
e.frame1time = time;
- e.origin_x = ReadCoord();
- e.origin_y = ReadCoord();
- e.origin_z = ReadCoord();
+ e.origin = ReadVector();
setorigin(e, e.origin);
if(f & 1)
{
- e.velocity_x = ReadCoord();
- e.velocity_y = ReadCoord();
- e.velocity_z = ReadCoord();
+ e.velocity = ReadVector();
}
if(f & 2)
{
e.cnt = ReadByte() / 255.0; // actually alpha
e.draw = ModelEffect_Draw;
+ if (isnew) IL_PUSH(g_drawables, e);
- if (!isnew) remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
+ if (!isnew) delete(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
return true;
}
#endif
-
-#endif