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