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