]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/modeleffects.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / 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         setorigin(self, 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         self.drawmask = MASK_NORMAL;
18         if(self.scale <= 0)
19         {
20                 self.drawmask = 0;
21                 return;
22         }
23 }
24
25 void Ent_ModelEffect(float isNew)
26 {
27         float f;
28         entity e;
29
30         self.classname = "modeleffect_spawner";
31
32         f = ReadByte();
33
34         e = spawn();
35         e.classname = "modeleffect";
36         e.model = "from network";
37         e.modelindex = ReadShort();
38         e.skin = ReadByte();
39         e.frame = ReadByte();
40         e.frame1time = time;
41         e.origin_x = ReadCoord();
42         e.origin_y = ReadCoord();
43         e.origin_z = ReadCoord();
44         setorigin(e, e.origin);
45         if(f & 1)
46         {
47                 e.velocity_x = ReadCoord();
48                 e.velocity_y = ReadCoord();
49                 e.velocity_z = ReadCoord();
50         }
51         if(f & 2)
52         {
53                 e.angles_x = ReadAngle();
54                 e.angles_y = ReadAngle();
55                 e.angles_z = ReadAngle();
56         }
57         if(f & 4)
58         {
59                 e.avelocity_x = ReadAngle();
60                 e.avelocity_y = ReadAngle();
61                 e.avelocity_z = ReadAngle();
62         }
63         e.scale1 = ReadShort() / 256.0;
64         e.scale2 = ReadShort() / 256.0;
65         e.lifetime = time + ReadByte() * 0.01;
66         e.fadetime = ReadByte() * 0.01;
67         e.teleport_time = time;
68         e.cnt = ReadByte() / 255.0; // actually alpha
69
70         e.draw = ModelEffect_Draw;
71
72         if(!isNew)
73                 remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
74 }