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