]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/nades/net.qc
Manually rotate it
[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
23         setorigin(e, e.origin);
24
25         float model_radius = e.maxs.x;
26         vector size = '1 1 1' * e.orb_radius / 2;
27         setsize(e,-size,size);
28         e.orb_radius = e.orb_radius/model_radius*0.6;
29
30         e.draw = orb_draw;
31         e.health = 255;
32         e.movetype = MOVETYPE_NONE;
33         e.solid = SOLID_NOT;
34         e.drawmask = MASK_NORMAL;
35         e.scale = 0.01;
36         e.avelocity = e.move_avelocity = '7 0 11';
37         e.renderflags |= RF_ADDITIVE;
38 }
39 #endif
40
41 REGISTER_NET_LINKED(Nade_Orb)
42
43 #ifdef CSQC
44 NET_HANDLE(Nade_Orb, bool isNew)
45 {
46         Net_Accept(Nade_Orb);
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.colormod_x = ReadCoord();
54                 this.colormod_y = ReadCoord();
55                 this.colormod_z = ReadCoord();
56                 this.orb_lifetime = ReadByte();
57                 this.orb_radius = ReadShort();
58                 this.ltime = time + ReadByte()/10.0;
59                 // this.ltime = time + this.orb_lifetime;
60                 orb_setup(this);
61         }
62         return true;
63 }
64 #endif
65
66 #ifdef SVQC
67 bool orb_send(entity this, entity to, int sf)
68 {
69         int channel = MSG_ENTITY;
70         WriteHeader(channel, Nade_Orb);
71         WriteByte(channel, sf);
72         if (sf & 1) {
73                 WriteCoord(channel, this.origin.x);
74                 WriteCoord(channel, this.origin.y);
75                 WriteCoord(channel, this.origin.z);
76
77                 WriteCoord(channel, this.colormod.x);
78                 WriteCoord(channel, this.colormod.y);
79                 WriteCoord(channel, this.colormod.z);
80
81                 WriteByte(channel, this.orb_lifetime);
82                 //WriteByte(MSG_ENTITY, this.ltime - time + 1);
83                 WriteShort(channel, this.orb_radius);
84                 // round time delta to a 1/10th of a second
85                 WriteByte(channel, (this.ltime - time)*10.0+0.5);
86         }
87         return true;
88 }
89 #endif
90
91 #endif