From c20583d0bf3bdb802b643d4f10e87e2e17badf36 Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 29 Aug 2008 12:55:20 +0000 Subject: [PATCH] hook: when something gets in the way, cut the hook off. Helps a bit with moving around. git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4234 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/g_hook.qc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/data/qcsrc/server/g_hook.qc b/data/qcsrc/server/g_hook.qc index 8710a4456..42ba15912 100644 --- a/data/qcsrc/server/g_hook.qc +++ b/data/qcsrc/server/g_hook.qc @@ -60,6 +60,12 @@ void SetMovetypeFollow(entity ent, entity e) ent.aiment_classname = strzone(e.classname); ent.aiment_deadflag = e.deadflag; } +void UnsetMovetypeFollow(entity ent) +{ + ent.movetype = MOVETYPE_FLY; + ent.solid = SOLID_BBOX; + ent.aiment = world; +} float LostMovetypeFollow(entity ent) { if(ent.aiment) @@ -109,6 +115,23 @@ void GrapplingHookThink() makevectors(self.owner.v_angle); org = self.owner.origin + self.owner.view_ofs + v_forward * 8 - v_right * 8 + v_up * -12; + tracebox(org, self.mins, self.maxs, self.origin, MOVE_NOMONSTERS, self.owner); + // do not hit players with this, as they tend to get in the way just too often + if(trace_fraction < 1 && !self.aiment || trace_ent != self.aiment) + { + // 1. detach the hook + if(self.aiment) + UnsetMovetypeFollow(self); + + // 2. cut it off + self.origin = trace_endpos; + + // 3. reattach the hook + if(trace_ent) + if(trace_ent.movetype != MOVETYPE_NONE) + SetMovetypeFollow(self, trace_ent); + } + if(self.rope_length < 0) self.rope_length = vlen(org - self.origin); -- 2.39.2