]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/nades/all.qc
Net: tempentity support
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / nades / all.qc
1 #if defined(CSQC)
2         #include "../../dpdefs/csprogsdefs.qh"
3         #include "../../client/defs.qh"
4         #include "all.qh"
5         #include "../buffs/all.qh"
6         #include "../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 "../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_NET_LINKED(Nade_Heal, bool isNew)
55 #ifdef CSQC
56 {
57         Net_Accept();
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 }
71 #endif
72
73 #ifdef SVQC
74 bool healer_send(entity to, int sf)
75 {
76         SELFPARAM();
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