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