Xonotic
net.qc
Go to the documentation of this file.
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);
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 = ReadVector();
54  setorigin(this, this.origin);
55  this.colormod = ReadVector();
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  WriteVector(channel, this.origin);
74 
75  WriteVector(channel, this.colormod);
76 
77  WriteByte(channel, this.orb_lifetime);
78  //WriteByte(MSG_ENTITY, this.ltime - time + 1);
79  WriteShort(channel, this.orb_radius);
80  // round time delta to a 1/10th of a second
81  WriteByte(channel, (this.ltime - time)*10.0+0.5);
82  }
83  return true;
84 }
85 #endif
86 
87 #endif
const float SOLID_NOT
Definition: csprogsdefs.qc:244
float MOVETYPE_NONE
Definition: progsdefs.qc:246
float alpha
Definition: items.qc:14
#define REGISTER_NET_LINKED(id)
Definition: net.qh:67
vector colormod
Definition: powerups.qc:21
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
entity() spawn
#define NET_HANDLE(id, param)
Definition: net.qh:12
entity to
Definition: self.qh:96
origin
Definition: ent_cs.qc:114
vector avelocity
Definition: csprogsdefs.qc:105
vector size
Definition: csprogsdefs.qc:114
float ltime
Definition: progsdefs.qc:107
#define setmodel(this, m)
Definition: model.qh:26
RES_HEALTH
Definition: ent_cs.qc:126
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float orb_lifetime
Definition: nades.qh:129
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
const float RF_ADDITIVE
Definition: csprogsdefs.qc:169
float scale
Definition: projectile.qc:14
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float orb_radius
Definition: nades.qh:130
float move_time
Definition: movetypes.qh:77
setorigin(ent, v)
vector angles
Definition: csprogsdefs.qc:104
float time
Definition: csprogsdefs.qc:16
IntrusiveList g_drawables
Definition: main.qh:77
void set_movetype(entity this, int mt)