swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
}
- // conveyors: check if we still convey stuff
- float conveyor_broken = FALSE;
- if(self.groundentity.classname == "func_conveyor")
- if(self.groundentity.nextthink)
- {
- if(!WarpZoneLib_BoxTouchesBrush(self.absmin + '0 0 -1', self.absmax + '0 0 -1', self.groundentity, self))
- self.groundentity = world;
- }
- if(!self.groundentity)
- {
- tracebox(self.origin + '0 0 -1', self.mins, self.maxs, self.origin + '0 0 -1', MOVE_NORMAL, self);
- if(trace_ent.classname == "func_conveyor")
- self.groundentity = trace_ent;
- }
-
// conveyors: first fix velocity
- if(self.groundentity.classname == "func_conveyor")
- if(self.groundentity.nextthink)
- self.velocity -= self.groundentity.movedir;
+ if(self.conveyor.state)
+ self.velocity -= self.conveyor.movedir;
if(self.classname != "player")
{
self.lastground = time;
// conveyors: then break velocity again
- if(self.groundentity.classname == "func_conveyor")
- if(self.groundentity.nextthink)
- self.velocity += self.groundentity.movedir;
+ if(self.conveyor.state)
+ self.velocity += self.conveyor.movedir;
self.lastflags = self.flags;
self.lastclassname = self.classname;
void conveyor_think()
{
- for(other = world; (other = findentity(other, groundentity, self)); )
+ entity e;
+
+ // set myself as current conveyor where possible
+ for(e = world; (e = findentity(e, conveyor, self)); )
+ e.conveyor = world;
+
+ if(self.state)
{
- if(other.flags & FL_CLIENT) // doing it via velocity has quite some advantages
- continue; // done in SV_PlayerPhysics
+ for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5); e; e = e.chain)
+ if(!e.conveyor.state)
+ {
+ vector emin = e.absmin - '1 1 1';
+ vector emax = e.absmax + '1 1 1';
+ if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
+ if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
+ e.conveyor = self;
+ }
+
+ for(e = world; (e = findentity(e, conveyor, self)); )
+ {
+ if(e.flags & FL_CLIENT) // doing it via velocity has quite some advantages
+ continue; // done in SV_PlayerPhysics
- // stupid conveyor code
- tracebox(other.origin, other.mins, other.maxs, other.origin + self.movedir * sys_frametime, MOVE_NORMAL, other);
- if(trace_fraction > 0)
- setorigin(other, trace_endpos);
+ // stupid conveyor code
+ tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
+ if(trace_fraction > 0)
+ setorigin(e, trace_endpos);
+ }
}
+
self.nextthink = time;
}
void conveyor_use()
{
- if(self.nextthink)
- self.nextthink = 0;
- else
- self.nextthink = time;
+ self.state = !self.state;
}
void conveyor_reset()
{
- if(self.spawnflags & 1)
- self.nextthink = time;
- else
- self.nextthink = 0;
+ self.state = (self.spawnflags & 1);
}
-void spawnfunc_func_conveyor()
+void conveyor_init()
{
- SetMovedir ();
- if not(InitMovingBrushTrigger())
- return;
- self.movetype = MOVETYPE_NONE;
if (!self.speed)
self.speed = 200;
self.movedir = self.movedir * self.speed;
self.think = conveyor_think;
+ self.nextthink = time;
IFTARGETED
{
self.use = conveyor_use;
conveyor_reset();
}
else
- self.nextthink = time;
+ self.state = 1;
+}
+
+void spawnfunc_trigger_conveyor()
+{
+ EXACTTRIGGER_INIT;
+ conveyor_init();
+}
+
+void spawnfunc_func_conveyor()
+{
+ SetMovedir();
+ InitMovingBrushTrigger();
+ self.movetype = MOVETYPE_NONE;
+ conveyor_init();
}