1 REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
3 void conveyor_think(entity this)
6 // TODO: check if this is what is causing the glitchiness when switching between them
7 float dt = time - this.move_time;
9 if(dt <= 0) { return; }
12 // set mythis as current conveyor where possible
13 FOREACH_ENTITY_ENT(conveyor, this,
20 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.state && isPushable(it),
22 vector emin = it.absmin;
23 vector emax = it.absmax;
24 if(this.solid == SOLID_BSP)
29 if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
30 if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
34 FOREACH_ENTITY_ENT(conveyor, this,
36 if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
37 continue; // done in SV_PlayerPhysics continue;
39 setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
40 move_out_of_solid(it);
42 UpdateCSQCProjectile(it);
45 // stupid conveyor code
46 tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
47 if(trace_fraction > 0)
48 setorigin(it, trace_endpos);
54 this.nextthink = time;
60 void conveyor_use(entity this, entity actor, entity trigger)
62 this.state = !this.state;
67 void conveyor_reset(entity this)
69 this.state = (this.spawnflags & 1);
74 bool conveyor_send(entity this, entity to, int sf)
76 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
77 WriteByte(MSG_ENTITY, sf);
81 WriteByte(MSG_ENTITY, this.warpzone_isboxy);
82 WriteCoord(MSG_ENTITY, this.origin_x);
83 WriteCoord(MSG_ENTITY, this.origin_y);
84 WriteCoord(MSG_ENTITY, this.origin_z);
86 WriteCoord(MSG_ENTITY, this.mins_x);
87 WriteCoord(MSG_ENTITY, this.mins_y);
88 WriteCoord(MSG_ENTITY, this.mins_z);
89 WriteCoord(MSG_ENTITY, this.maxs_x);
90 WriteCoord(MSG_ENTITY, this.maxs_y);
91 WriteCoord(MSG_ENTITY, this.maxs_z);
93 WriteCoord(MSG_ENTITY, this.movedir_x);
94 WriteCoord(MSG_ENTITY, this.movedir_y);
95 WriteCoord(MSG_ENTITY, this.movedir_z);
97 WriteByte(MSG_ENTITY, this.speed);
98 WriteByte(MSG_ENTITY, this.state);
100 WriteString(MSG_ENTITY, this.targetname);
101 WriteString(MSG_ENTITY, this.target);
105 WriteByte(MSG_ENTITY, this.state);
110 void conveyor_init(entity this)
112 if (!this.speed) this.speed = 200;
113 this.movedir *= this.speed;
114 setthink(this, conveyor_think);
115 this.nextthink = time;
118 this.use = conveyor_use;
119 this.reset = conveyor_reset;
127 Net_LinkEntity(this, 0, false, conveyor_send);
132 spawnfunc(trigger_conveyor)
139 spawnfunc(func_conveyor)
142 InitMovingBrushTrigger(this);
143 set_movetype(this, MOVETYPE_NONE);
149 void conveyor_draw(entity this) { conveyor_think(this); }
151 void conveyor_init(entity this)
153 this.draw = conveyor_draw;
154 IL_PUSH(g_drawables, this);
155 this.drawmask = MASK_NORMAL;
157 this.move_movetype = MOVETYPE_NONE;
159 this.solid = SOLID_TRIGGER;
160 this.move_time = time;
163 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
169 this.warpzone_isboxy = ReadByte();
170 this.origin_x = ReadCoord();
171 this.origin_y = ReadCoord();
172 this.origin_z = ReadCoord();
173 setorigin(this, this.origin);
175 this.mins_x = ReadCoord();
176 this.mins_y = ReadCoord();
177 this.mins_z = ReadCoord();
178 this.maxs_x = ReadCoord();
179 this.maxs_y = ReadCoord();
180 this.maxs_z = ReadCoord();
181 setsize(this, this.mins, this.maxs);
183 this.movedir_x = ReadCoord();
184 this.movedir_y = ReadCoord();
185 this.movedir_z = ReadCoord();
187 this.speed = ReadByte();
188 this.state = ReadByte();
190 this.targetname = strzone(ReadString());
191 this.target = strzone(ReadString());
197 this.state = ReadByte();