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