Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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#include <client/view.qh>
9
10.float ltime;
11void orb_draw(entity this)
12{
13 float dt = time - this.move_time;
14 this.move_time = time;
15 if(dt <= 0)
16 return;
17
18 this.alpha = (this.ltime - time) / this.orb_lifetime;
19 this.scale = min((1 - this.alpha)*this.orb_lifetime*4,1)*this.orb_radius;
20 this.angles = this.angles + dt * this.avelocity;
21}
22
23float orb_drawtime; // global storage of last drawn orb frame, to counter overlapping orbs
25{
26 if(time <= orb_drawtime)
27 return;
28
29 if(boxesoverlap(view_origin - '1 1 1', view_origin + '1 1 1', this.absmin, this.absmax))
30 {
31 orb_drawtime = time; // prevent rendering more than one of these per frame!
32 float orb_alpha = 0.65 * (this.ltime - time) / this.orb_lifetime;
34 }
35}
36
38{
39 setmodel(e, MDL_NADE_ORB);
40 e.skin = 1;
41
42 setorigin(e, e.origin);
43
44 float model_radius = e.maxs.x;
45 vector size = '.5 .5 .5' * e.orb_radius;
46 setsize(e,-size,size);
47 e.orb_radius = e.orb_radius/model_radius*0.6;
48
49 e.draw = orb_draw;
50 e.draw2d = orb_draw2d;
53 SetResourceExplicit(e, RES_HEALTH, 255);
55 e.solid = SOLID_NOT;
56 e.drawmask = MASK_NORMAL;
57 e.scale = 0.01;
58 e.avelocity = '7 0 11';
59 e.renderflags |= RF_ADDITIVE;
60}
61#endif
62
63REGISTER_NET_LINKED(Nade_Orb)
64
65#ifdef CSQC
66NET_HANDLE(Nade_Orb, bool isNew)
67{
68 Net_Accept(Nade_Orb);
69 int sf = ReadByte();
70 if (sf & 1) {
71 this.origin = ReadVector();
72 setorigin(this, this.origin);
73 this.colormod = ReadVector();
74 this.orb_lifetime = ReadByte();
75 this.orb_radius = ReadShort();
76 this.ltime = time + ReadByte()/10.0;
77 // this.ltime = time + this.orb_lifetime;
78 orb_setup(this);
79 }
80 return true;
81}
82#endif
83
84#ifdef SVQC
85bool orb_send(entity this, entity to, int sf)
86{
87 int channel = MSG_ENTITY;
88 WriteHeader(channel, Nade_Orb);
89 WriteByte(channel, sf);
90 if (sf & 1) {
91 WriteVector(channel, this.origin);
92
93 WriteVector(channel, this.colormod);
94
95 WriteByte(channel, this.orb_lifetime);
96 //WriteByte(MSG_ENTITY, this.ltime - time + 1);
97 WriteShort(channel, this.orb_radius);
98 // round time delta to a 1/10th of a second
99 WriteByte(channel, (this.ltime - time)*10.0+0.5);
100 }
101 return true;
102}
103#endif
104
105#endif
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
#define drawfill(position, size, rgb, alpha, flag)
Definition draw.qh:36
vector colormod
Definition powerups.qc:21
float alpha
Definition items.qc:13
IntrusiveList g_drawables
Definition main.qh:91
vector view_origin
Definition main.qh:109
IntrusiveList g_drawables_2d
Definition main.qh:92
#define setmodel(this, m)
Definition model.qh:26
const float RF_ADDITIVE
const float DRAWFLAG_ADDITIVE
vector avelocity
const float MASK_NORMAL
const float SOLID_NOT
float time
vector size
vector absmax
vector origin
vector absmin
ent angles
Definition ent_cs.qc:121
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
#define NET_HANDLE(id, param)
Definition net.qh:15
const int MSG_ENTITY
Definition net.qh:115
#define ReadVector()
Definition net.qh:367
#define Net_Accept(classname)
Definition net.qh:201
#define WriteHeader(to, id)
Definition net.qh:221
#define REGISTER_NET_LINKED(id)
Definition net.qh:55
int ReadByte()
void WriteShort(float data, float dest, float desto)
float min(float f,...)
void WriteByte(float data, float dest, float desto)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_NONE
Definition movetypes.qh:129
float move_time
Definition movetypes.qh:77
float orb_radius
Definition nades.qh:71
float orb_lifetime
Definition nades.qh:70
void orb_draw(entity this)
Definition net.qc:11
void orb_draw2d(entity this)
Definition net.qc:24
void orb_setup(entity e)
Definition net.qc:37
float orb_drawtime
Definition net.qc:23
bool orb_send(entity this, entity to, int sf)
Definition net.qc:85
float ltime
Definition net.qc:10
float scale
Definition projectile.qc:14
vector
Definition self.qh:92
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
requires that m2>m1 in all coordinates, and that m4>m3
Definition vector.qh:73
#define vec2(...)
Definition vector.qh:90
float autocvar_hud_colorflash_alpha
Definition view.qh:39