- make the grapple set the player's gravity to 0 when it's active,

then to 1 again when it's released.  stops that annoying bobbing
  effect.
- also reindent one of the functions, since it annoyed me so much
This commit is contained in:
Adam Olsen 2001-10-14 00:57:50 +00:00
parent 55500b87d6
commit 1171a6ffe4

20
hook.qc
View file

@ -44,6 +44,7 @@ void (entity rhook) Reset_Grapple =
rhook.owner.hook_out = FALSE; rhook.owner.hook_out = FALSE;
rhook.owner.fire_held_down = FALSE; rhook.owner.fire_held_down = FALSE;
rhook.owner.weaponframe = 0; rhook.owner.weaponframe = 0;
rhook.owner.gravity = 1; // FIXME: interferes with other gravity stuff
rhook.think = SUB_Remove; rhook.think = SUB_Remove;
rhook.nextthink = time; rhook.nextthink = time;
@ -58,21 +59,18 @@ void (entity rhook) Reset_Grapple =
void () Grapple_Track = void () Grapple_Track =
{ {
// drop the hook if owner is dead or has released the button // drop the hook if owner is dead or has released the button
if (!self.owner.on_hook || self.owner.health <= 0) if (!self.owner.on_hook || self.owner.health <= 0) {
{
Reset_Grapple (self); Reset_Grapple (self);
return; return;
} }
if (self.owner.health <= 0 || self.owner.has_disconnected) //CH does a real check if dead
{ if (self.owner.health <= 0 || self.owner.has_disconnected) { //CH does a real check if dead
self.think = SUB_Remove; self.think = SUB_Remove;
self.nextthink = time; self.nextthink = time;
if (self.goalentity) if (self.goalentity) {
{
self.goalentity.think = SUB_Remove; self.goalentity.think = SUB_Remove;
self.goalentity.nextthink = time; self.goalentity.nextthink = time;
if (self.goalentity.goalentity) if (self.goalentity.goalentity) {
{
self.goalentity.goalentity.think = SUB_Remove; self.goalentity.goalentity.think = SUB_Remove;
self.goalentity.goalentity.nextthink = time; self.goalentity.goalentity.nextthink = time;
} }
@ -95,6 +93,7 @@ void () Grapple_Track =
return; return;
} }
} }
// If the hook is not attached to the player, constantly // If the hook is not attached to the player, constantly
// copy the target's velocity. Velocity copying DOES NOT work properly // copy the target's velocity. Velocity copying DOES NOT work properly
// for a hooked client. // for a hooked client.
@ -390,6 +389,8 @@ void () Service_Grapple =
{ {
local vector hook_dir; local vector hook_dir;
self.gravity = 0;
// drop the hook if player lets go of button // drop the hook if player lets go of button
if (!self.button0) if (!self.button0)
{ {
@ -402,13 +403,14 @@ void () Service_Grapple =
if (self.hook.enemy.classname == "player") if (self.hook.enemy.classname == "player")
hook_dir = (self.hook.enemy.origin - self.origin); hook_dir = (self.hook.enemy.origin - self.origin);
// else, track to hook // else, track to hook
else if (self.hook.enemy.classname != "player") else
hook_dir = (self.hook.origin - self.origin); hook_dir = (self.hook.origin - self.origin);
// set the facing of the grapple // set the facing of the grapple
// self.hook.angles = vectoangles(self.hook.velocity); // self.hook.angles = vectoangles(self.hook.velocity);
self.velocity = normalize(hook_dir) * self.maxspeed * 1.5; self.velocity = normalize(hook_dir) * self.maxspeed * 1.5;
if ( vlen(hook_dir) <= 100 && self.lefty) // cancel chain sound if ( vlen(hook_dir) <= 100 && self.lefty) // cancel chain sound
{ {
// If there is a chain, ditch it now. We're // If there is a chain, ditch it now. We're