]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/nades/net.qc
Implement intrusive lists
[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 orb_draw(entity this)
8 {
9         float dt = time - this.move_time;
10         this.move_time = time;
11         if(dt <= 0)
12                 return;
13
14         this.alpha = (this.ltime - time) / this.orb_lifetime;
15         this.scale = min((1 - this.alpha)*this.orb_lifetime*4,1)*this.orb_radius;
16         this.angles = this.angles + dt * this.avelocity;
17 }
18
19 void orb_setup(entity e)
20 {
21         setmodel(e, MDL_NADE_ORB);
22         e.skin = 1;
23
24         setorigin(e, e.origin);
25
26         float model_radius = e.maxs.x;
27         vector size = '1 1 1' * e.orb_radius / 2;
28         setsize(e,-size,size);
29         e.orb_radius = e.orb_radius/model_radius*0.6;
30
31         e.draw = orb_draw;
32         IL_PUSH(g_drawables, e);
33         e.health = 255;
34         e.move_movetype = MOVETYPE_NONE;
35         e.solid = SOLID_NOT;
36         e.drawmask = MASK_NORMAL;
37         e.scale = 0.01;
38         e.avelocity = '7 0 11';
39         e.renderflags |= RF_ADDITIVE;
40 }
41 #endif
42
43 REGISTER_NET_LINKED(Nade_Orb)
44
45 #ifdef CSQC
46 NET_HANDLE(Nade_Orb, bool isNew)
47 {
48         Net_Accept(Nade_Orb);
49         int sf = ReadByte();
50         if (sf & 1) {
51                 this.origin_x = ReadCoord();
52                 this.origin_y = ReadCoord();
53                 this.origin_z = ReadCoord();
54                 setorigin(this, this.origin);
55                 this.colormod_x = ReadCoord();
56                 this.colormod_y = ReadCoord();
57                 this.colormod_z = ReadCoord();
58                 this.orb_lifetime = ReadByte();
59                 this.orb_radius = ReadShort();
60                 this.ltime = time + ReadByte()/10.0;
61                 // this.ltime = time + this.orb_lifetime;
62                 orb_setup(this);
63         }
64         return true;
65 }
66 #endif
67
68 #ifdef SVQC
69 bool orb_send(entity this, entity to, int sf)
70 {
71         int channel = MSG_ENTITY;
72         WriteHeader(channel, Nade_Orb);
73         WriteByte(channel, sf);
74         if (sf & 1) {
75                 WriteCoord(channel, this.origin.x);
76                 WriteCoord(channel, this.origin.y);
77                 WriteCoord(channel, this.origin.z);
78
79                 WriteCoord(channel, this.colormod.x);
80                 WriteCoord(channel, this.colormod.y);
81                 WriteCoord(channel, this.colormod.z);
82
83                 WriteByte(channel, this.orb_lifetime);
84                 //WriteByte(MSG_ENTITY, this.ltime - time + 1);
85                 WriteShort(channel, this.orb_radius);
86                 // round time delta to a 1/10th of a second
87                 WriteByte(channel, (this.ltime - time)*10.0+0.5);
88         }
89         return true;
90 }
91 #endif
92
93 #endif