]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/nades/all.qc
Mutators: self containment
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / nades / all.qc
1 #include "all.qh"
2
3 #if defined(CSQC)
4         #include "../../client/defs.qh"
5         #include "../buffs/all.qh"
6         #include "../movetypes/movetypes.qh"
7         #include "../../client/main.qh"
8         #include "../../lib/csqcmodel/cl_model.qh"
9 #elif defined(MENUQC)
10 #elif defined(SVQC)
11     #include "../constants.qh"
12     #include "../../server/constants.qh"
13         #include "../turrets/sv_turrets.qh"
14 #endif
15
16
17 #ifdef CSQC
18 .float ltime;
19 void healer_draw(entity this)
20 {
21         float dt = time - self.move_time;
22         self.move_time = time;
23         if(dt <= 0)
24                 return;
25
26         self.alpha = (self.ltime - time) / self.healer_lifetime;
27         self.scale = min((1 - self.alpha)*self.healer_lifetime*4,1)*self.healer_radius;
28 }
29
30 void healer_setup(entity e)
31 {
32         setmodel(e, MDL_NADE_HEAL);
33
34         setorigin(e, e.origin);
35
36         float model_radius = e.maxs.x;
37         vector size = '1 1 1' * e.healer_radius / 2;
38         setsize(e,-size,size);
39         e.healer_radius = e.healer_radius/model_radius*0.6;
40
41         e.draw = healer_draw;
42         e.health = 255;
43         e.movetype = MOVETYPE_NONE;
44         e.solid = SOLID_NOT;
45         e.drawmask = MASK_NORMAL;
46         e.scale = 0.01;
47         e.avelocity = e.move_avelocity = '7 0 11';
48         e.colormod = '1 0 0';
49         e.renderflags |= RF_ADDITIVE;
50 }
51 #endif // CSQC
52
53 REGISTER_NET_LINKED(Nade_Heal)
54 #ifdef CSQC
55 NET_HANDLE(Nade_Heal, bool isNew)
56 {
57         Net_Accept(Nade_Heal);
58         int sf = ReadByte();
59         if (sf & 1) {
60                 this.origin_x = ReadCoord();
61                 this.origin_y = ReadCoord();
62                 this.origin_z = ReadCoord();
63                 setorigin(this, this.origin);
64                 this.healer_lifetime = ReadByte();
65                 this.healer_radius = ReadShort();
66                 this.ltime = time + ReadByte()/10.0;
67                 // this.ltime = time + this.healer_lifetime;
68                 healer_setup(this);
69         }
70         return true;
71 }
72 #endif
73
74 #ifdef SVQC
75 bool healer_send(entity this, entity to, int sf)
76 {
77         int channel = MSG_ENTITY;
78         WriteHeader(channel, Nade_Heal);
79         WriteByte(channel, sf);
80         if (sf & 1) {
81                 WriteCoord(channel, this.origin.x);
82                 WriteCoord(channel, this.origin.y);
83                 WriteCoord(channel, this.origin.z);
84
85                 WriteByte(channel, this.healer_lifetime);
86                 //WriteByte(MSG_ENTITY, this.ltime - time + 1);
87                 WriteShort(channel, this.healer_radius);
88                 // round time delta to a 1/10th of a second
89                 WriteByte(channel, (this.ltime - time)*10.0+0.5);
90         }
91         return true;
92 }
93 #endif // SVQC