better CTF indicators
[divverent/nexuiz.git] / data / qcsrc / client / modeleffects.qc
1 .float frame1time;
2 .float lifetime, fadetime;
3 .float teleport_time;
4 .float scale1, scale2;
5
6 void ModelEffect_Draw()
7 {
8         self.angles = self.angles + frametime * self.avelocity;
9         self.origin = self.origin + frametime * self.velocity;
10         self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
11         self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
12         if(self.alpha < ALPHA_MIN_VISIBLE)
13         {
14                 remove(self);
15                 return;
16         }
17         if(self.scale <= 0)
18                 return;
19         R_AddEntity(self);
20 }
21
22 void Ent_ModelEffect(float isNew)
23 {
24         float f;
25         entity e;
26
27         self.classname = "modeleffect_spawner";
28
29         f = ReadByte();
30
31         e = spawn();
32         e.classname = "modeleffect";
33         e.model = "from network";
34         e.modelindex = ReadShort();
35         e.skin = ReadByte();
36         e.frame = ReadByte();
37         e.frame1time = time;
38         e.origin_x = ReadCoord();
39         e.origin_y = ReadCoord();
40         e.origin_z = ReadCoord();
41         if(f & 1)
42         {
43                 e.velocity_x = ReadCoord();
44                 e.velocity_y = ReadCoord();
45                 e.velocity_z = ReadCoord();
46         }
47         if(f & 2)
48         {
49                 e.angles_x = ReadAngle();
50                 e.angles_y = ReadAngle();
51                 e.angles_z = ReadAngle();
52         }
53         if(f & 4)
54         {
55                 e.avelocity_x = ReadAngle();
56                 e.avelocity_y = ReadAngle();
57                 e.avelocity_z = ReadAngle();
58         }
59         e.scale1 = ReadShort() / 256.0;
60         e.scale2 = ReadShort() / 256.0;
61         e.lifetime = time + ReadByte() * 0.01;
62         e.fadetime = ReadByte() * 0.01;
63         e.teleport_time = time;
64         e.cnt = ReadByte() / 255.0; // actually alpha
65
66         e.draw = ModelEffect_Draw;
67
68         if(!isNew)
69                 remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
70 }