1 REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
6 // TODO: check if this is what is causing the glitchiness when switching between them
7 float dt = time - self.move_time;
9 if(dt <= 0) { return; }
13 // set myself as current conveyor where possible
14 for(e = world; (e = findentity(e, conveyor, self)); )
19 for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
23 vector emin = e.absmin;
24 vector emax = e.absmax;
25 if(self.solid == SOLID_BSP)
30 if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
31 if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
35 for(e = world; (e = findentity(e, conveyor, self)); )
37 if(IS_CLIENT(e)) // doing it via velocity has quite some advantages
38 continue; // done in SV_PlayerPhysics continue;
40 setorigin(e, e.origin + self.movedir * PHYS_INPUT_FRAMETIME);
43 UpdateCSQCProjectile(e);
46 // stupid conveyor code
47 tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
48 if(trace_fraction > 0)
49 setorigin(e, trace_endpos);
55 self.nextthink = time;
61 void conveyor_use(entity this, entity actor, entity trigger)
63 this.state = !this.state;
68 void conveyor_reset(entity this)
70 this.state = (this.spawnflags & 1);
75 bool conveyor_send(entity this, entity to, int sf)
77 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
78 WriteByte(MSG_ENTITY, sf);
82 WriteByte(MSG_ENTITY, self.warpzone_isboxy);
83 WriteCoord(MSG_ENTITY, self.origin_x);
84 WriteCoord(MSG_ENTITY, self.origin_y);
85 WriteCoord(MSG_ENTITY, self.origin_z);
87 WriteCoord(MSG_ENTITY, self.mins_x);
88 WriteCoord(MSG_ENTITY, self.mins_y);
89 WriteCoord(MSG_ENTITY, self.mins_z);
90 WriteCoord(MSG_ENTITY, self.maxs_x);
91 WriteCoord(MSG_ENTITY, self.maxs_y);
92 WriteCoord(MSG_ENTITY, self.maxs_z);
94 WriteCoord(MSG_ENTITY, self.movedir_x);
95 WriteCoord(MSG_ENTITY, self.movedir_y);
96 WriteCoord(MSG_ENTITY, self.movedir_z);
98 WriteByte(MSG_ENTITY, self.speed);
99 WriteByte(MSG_ENTITY, self.state);
101 WriteString(MSG_ENTITY, self.targetname);
102 WriteString(MSG_ENTITY, self.target);
106 WriteByte(MSG_ENTITY, self.state);
113 if (!this.speed) this.speed = 200;
114 this.movedir *= this.speed;
115 this.think = conveyor_think;
116 this.nextthink = time;
119 this.use = conveyor_use;
120 this.reset = conveyor_reset;
128 Net_LinkEntity(this, 0, false, conveyor_send);
133 spawnfunc(trigger_conveyor)
140 spawnfunc(func_conveyor)
143 InitMovingBrushTrigger();
144 self.movetype = MOVETYPE_NONE;
150 void conveyor_draw(entity this) { WITHSELF(this, conveyor_think()); }
154 self.draw = conveyor_draw;
155 self.drawmask = MASK_NORMAL;
157 self.movetype = MOVETYPE_NONE;
159 self.solid = SOLID_TRIGGER;
160 self.move_origin = self.origin;
161 self.move_time = time;
164 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
166 float sf = ReadByte();
170 self.warpzone_isboxy = ReadByte();
171 self.origin_x = ReadCoord();
172 self.origin_y = ReadCoord();
173 self.origin_z = ReadCoord();
174 setorigin(self, self.origin);
176 self.mins_x = ReadCoord();
177 self.mins_y = ReadCoord();
178 self.mins_z = ReadCoord();
179 self.maxs_x = ReadCoord();
180 self.maxs_y = ReadCoord();
181 self.maxs_z = ReadCoord();
182 setsize(self, self.mins, self.maxs);
184 self.movedir_x = ReadCoord();
185 self.movedir_y = ReadCoord();
186 self.movedir_z = ReadCoord();
188 self.speed = ReadByte();
189 self.state = ReadByte();
191 self.targetname = strzone(ReadString());
192 self.target = strzone(ReadString());
198 self.state = ReadByte();