Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
conveyor.qc
Go to the documentation of this file.
1#include "conveyor.qh"
2REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
3
5{
6#ifdef CSQC
7 // TODO: check if this is what is causing the glitchiness when switching between them
8 float dt = time - this.move_time;
9 this.move_time = time;
10 if(dt <= 0) { return; }
11#endif
12
13 // set myself as current conveyor where possible
14 IL_EACH(g_conveyed, it.conveyor == this,
15 {
16 it.conveyor = NULL;
17 IL_REMOVE(g_conveyed, it);
18 });
19
20 if(this.active == ACTIVE_ACTIVE)
21 {
22 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, it.conveyor.active == ACTIVE_NOT && isPushable(it),
23 {
24 if (WarpZoneLib_ExactTrigger_Touch(this, it, false))
25 {
26 if(!it.conveyor)
28 it.conveyor = this;
29 }
30 });
31
32 IL_EACH(g_conveyed, it.conveyor == this,
33 {
34 if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
35 continue; // done in SV_PlayerPhysics continue;
36
37 setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
38 move_out_of_solid(it);
39#ifdef SVQC
40 UpdateCSQCProjectile(it);
41#endif
42 /*
43 // stupid conveyor code
44 tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
45 if(trace_fraction > 0)
46 setorigin(it, trace_endpos);
47 */
48 });
49 }
50
51#ifdef SVQC
52 this.nextthink = time;
53#endif
54}
55
56#ifdef SVQC
57
58bool conveyor_send(entity this, entity to, int sendflags)
59{
60 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
61 WriteByte(MSG_ENTITY, sendflags);
62
63 if(sendflags & SF_TRIGGER_INIT)
64 {
66 WriteVector(MSG_ENTITY, this.origin);
67
68 WriteVector(MSG_ENTITY, this.mins);
69 WriteVector(MSG_ENTITY, this.maxs);
70
71 WriteVector(MSG_ENTITY, this.movedir);
72
75
78 }
79
80 if(sendflags & SF_TRIGGER_UPDATE)
82
83 return true;
84}
85
87{
88 if (!this.speed) this.speed = 200;
89 this.movedir *= this.speed;
91 this.nextthink = time;
92 this.setactive = generic_netlinked_setactive;
93 if(this.targetname && this.targetname != "")
94 {
95 // backwards compatibility
97 }
98 this.reset = generic_netlinked_reset;
99 this.reset(this);
100
101 Net_LinkEntity(this, 0, false, conveyor_send);
102
104}
105
106spawnfunc(trigger_conveyor)
107{
108 SetMovedir(this);
110 conveyor_init(this);
111}
112
113spawnfunc(func_conveyor)
114{
115 SetMovedir(this);
118 conveyor_init(this);
119}
120
121#elif defined(CSQC)
122
123void conveyor_draw(entity this) { conveyor_think(this); }
124
125void conveyor_init(entity this, bool isnew)
126{
127 if(isnew)
128 IL_PUSH(g_drawables, this);
129 this.draw = conveyor_draw;
130 this.drawmask = MASK_NORMAL;
131
133 this.model = "";
134 this.solid = SOLID_TRIGGER;
135 this.move_time = time;
136}
137
138NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
139{
140 int sendflags = ReadByte();
141
142 if(sendflags & SF_TRIGGER_INIT)
143 {
144 this.warpzone_isboxy = ReadByte();
145 this.origin = ReadVector();
146 setorigin(this, this.origin);
147
148 this.mins = ReadVector();
149 this.maxs = ReadVector();
150 setsize(this, this.mins, this.maxs);
151
152 this.movedir = ReadVector();
153
154 this.speed = ReadByte();
155 this.active = ReadByte();
156
157 this.targetname = strzone(ReadString());
158 this.target = strzone(ReadString());
159
160 conveyor_init(this, isnew);
161 }
162
163 if(sendflags & SF_TRIGGER_UPDATE)
164 this.active = ReadByte();
165
166 return true;
167}
168#endif
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define ReadString
IntrusiveList g_drawables
Definition main.qh:91
void conveyor_init(entity this)
Definition conveyor.qc:86
bool conveyor_send(entity this, entity to, int sendflags)
Definition conveyor.qc:58
void conveyor_think(entity this)
Definition conveyor.qc:4
IntrusiveList g_conveyed
Definition conveyor.qh:4
float drawmask
const float SOLID_TRIGGER
const float MASK_NORMAL
vector mins
float time
vector maxs
float nextthink
vector absmax
vector origin
vector absmin
#define use
const int ACTIVE_NOT
Definition defs.qh:36
const int SF_TRIGGER_INIT
Definition defs.qh:22
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
const int SF_TRIGGER_UPDATE
Definition defs.qh:23
float speed
Definition dynlight.qc:9
model
Definition ent_cs.qc:139
solid
Definition ent_cs.qc:165
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
int SendFlags
Definition net.qh:118
#define NET_HANDLE(id, param)
Definition net.qh:15
const int MSG_ENTITY
Definition net.qh:115
#define ReadVector()
Definition net.qh:367
#define WriteHeader(to, id)
Definition net.qh:221
#define REGISTER_NET_LINKED(id)
Definition net.qh:55
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
int ReadByte()
bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher, bool touchfunc)
Definition common.qc:815
#define EXACTTRIGGER_INIT
Definition common.qh:116
float warpzone_isboxy
Definition common.qh:12
vector movedir
Definition viewloc.qh:18
void WriteString(string data, float dest, float desto)
float vlen(vector v)
void WriteByte(float data, float dest, float desto)
string strzone(string s)
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
#define setthink(e, f)
entity this
Definition self.qh:72
void
Definition self.qh:72
#define spawnfunc(id)
Definition spawnfunc.qh:96
void SetMovedir(entity this)
Definition subs.qc:540
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:577
void generic_netlinked_reset(entity this)
Definition triggers.qc:76
void generic_netlinked_legacy_use(entity this, entity actor, entity trigger)
Definition triggers.qc:98
bool isPushable(entity e)
Definition triggers.qc:3
void generic_netlinked_setactive(entity this, int act)
Definition triggers.qc:65
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55