2 REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
4 void conveyor_think(entity this)
7 // TODO: check if this is what is causing the glitchiness when switching between them
8 float dt = time - this.move_time;
10 if(dt <= 0) { return; }
13 // set myself as current conveyor where possible
14 IL_EACH(g_conveyed, it.conveyor == this,
17 IL_REMOVE(g_conveyed, it);
22 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.state && isPushable(it),
24 vector emin = it.absmin;
25 vector emax = it.absmax;
26 if(this.solid == SOLID_BSP)
31 if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
32 if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
35 IL_PUSH(g_conveyed, it);
40 IL_EACH(g_conveyed, it.conveyor == this,
42 if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
43 continue; // done in SV_PlayerPhysics continue;
45 setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
46 move_out_of_solid(it);
48 UpdateCSQCProjectile(it);
51 // stupid conveyor code
52 tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
53 if(trace_fraction > 0)
54 setorigin(it, trace_endpos);
60 this.nextthink = time;
66 void conveyor_use(entity this, entity actor, entity trigger)
68 this.state = !this.state;
73 void conveyor_reset(entity this)
75 this.state = (this.spawnflags & 1);
80 bool conveyor_send(entity this, entity to, int sf)
82 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
83 WriteByte(MSG_ENTITY, sf);
87 WriteByte(MSG_ENTITY, this.warpzone_isboxy);
88 WriteVector(MSG_ENTITY, this.origin);
90 WriteVector(MSG_ENTITY, this.mins);
91 WriteVector(MSG_ENTITY, this.maxs);
93 WriteVector(MSG_ENTITY, this.movedir);
95 WriteByte(MSG_ENTITY, this.speed);
96 WriteByte(MSG_ENTITY, this.state);
98 WriteString(MSG_ENTITY, this.targetname);
99 WriteString(MSG_ENTITY, this.target);
103 WriteByte(MSG_ENTITY, this.state);
108 void conveyor_init(entity this)
110 if (!this.speed) this.speed = 200;
111 this.movedir *= this.speed;
112 setthink(this, conveyor_think);
113 this.nextthink = time;
116 this.use = conveyor_use;
117 this.reset = conveyor_reset;
125 Net_LinkEntity(this, 0, false, conveyor_send);
130 spawnfunc(trigger_conveyor)
137 spawnfunc(func_conveyor)
140 InitMovingBrushTrigger(this);
141 set_movetype(this, MOVETYPE_NONE);
147 void conveyor_draw(entity this) { conveyor_think(this); }
149 void conveyor_init(entity this, bool isnew)
152 IL_PUSH(g_drawables, this);
153 this.draw = conveyor_draw;
154 this.drawmask = MASK_NORMAL;
156 set_movetype(this, MOVETYPE_NONE);
158 this.solid = SOLID_TRIGGER;
159 this.move_time = time;
162 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
168 this.warpzone_isboxy = ReadByte();
169 this.origin = ReadVector();
170 setorigin(this, this.origin);
172 this.mins = ReadVector();
173 this.maxs = ReadVector();
174 setsize(this, this.mins, this.maxs);
176 this.movedir = ReadVector();
178 this.speed = ReadByte();
179 this.state = ReadByte();
181 this.targetname = strzone(ReadString());
182 this.target = strzone(ReadString());
184 conveyor_init(this, isnew);
188 this.state = ReadByte();