From: Rudolf Polzer Date: Thu, 29 Dec 2011 22:10:50 +0000 (+0100) Subject: also add trigger_conveyor; new behaviour X-Git-Tag: xonotic-v0.6.0~74^2~21^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=534459c2ae3b244e8e4f0ac8413cba60c560a76a;p=xonotic%2Fxonotic-data.pk3dir.git also add trigger_conveyor; new behaviour --- diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 9364d7294..79087eb8a 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -882,25 +882,9 @@ void SV_PlayerPhysics() 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") { @@ -1382,9 +1366,8 @@ void SV_PlayerPhysics() 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; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 4b2684c51..68c1fb058 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -671,3 +671,5 @@ void PlayerUseKey(); typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t; .spawn_evalfunc_t spawn_evalfunc; + +.entity conveyor; diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index 8af076ce2..6b85d209c 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -2058,45 +2058,56 @@ void spawnfunc_func_vectormamamam() 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; @@ -2104,5 +2115,19 @@ void spawnfunc_func_conveyor() 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(); }