]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/nades/net.qc
Merge branch 'master' into Mario/entrap_nade
[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 }
17
18 void orb_setup(entity e)
19 {
20         setmodel(e, MDL_NADE_ORB);
21
22         setorigin(e, e.origin);
23
24         float model_radius = e.maxs.x;
25         vector size = '1 1 1' * e.orb_radius / 2;
26         setsize(e,-size,size);
27         e.orb_radius = e.orb_radius/model_radius*0.6;
28
29         e.draw = orb_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.renderflags |= RF_ADDITIVE;
37 }
38 #endif
39
40 REGISTER_NET_LINKED(Nade_Orb)
41
42 #ifdef CSQC
43 NET_HANDLE(Nade_Orb, bool isNew)
44 {
45         Net_Accept(Nade_Orb);
46         int sf = ReadByte();
47         if (sf & 1) {
48                 this.origin_x = ReadCoord();
49                 this.origin_y = ReadCoord();
50                 this.origin_z = ReadCoord();
51                 setorigin(this, this.origin);
52                 this.colormod_x = ReadCoord();
53                 this.colormod_y = ReadCoord();
54                 this.colormod_z = ReadCoord();
55                 this.orb_lifetime = ReadByte();
56                 this.orb_radius = ReadShort();
57                 this.ltime = time + ReadByte()/10.0;
58                 // this.ltime = time + this.orb_lifetime;
59                 orb_setup(this);
60         }
61         return true;
62 }
63 #endif
64
65 #ifdef SVQC
66 bool orb_send(entity this, entity to, int sf)
67 {
68         int channel = MSG_ENTITY;
69         WriteHeader(channel, Nade_Orb);
70         WriteByte(channel, sf);
71         if (sf & 1) {
72                 WriteCoord(channel, this.origin.x);
73                 WriteCoord(channel, this.origin.y);
74                 WriteCoord(channel, this.origin.z);
75
76                 WriteCoord(channel, this.colormod.x);
77                 WriteCoord(channel, this.colormod.y);
78                 WriteCoord(channel, this.colormod.z);
79
80                 WriteByte(channel, this.orb_lifetime);
81                 //WriteByte(MSG_ENTITY, this.ltime - time + 1);
82                 WriteShort(channel, this.orb_radius);
83                 // round time delta to a 1/10th of a second
84                 WriteByte(channel, (this.ltime - time)*10.0+0.5);
85         }
86         return true;
87 }
88 #endif
89
90 #endif