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