#include "g_hook.qh"
-#include "_all.qh"
#include "weapons/common.qh"
+#include "weapons/csqcprojectile.qh"
#include "weapons/weaponsystem.qh"
#include "weapons/selection.qh"
#include "weapons/tracing.qh"
#include "../common/constants.qh"
#include "../common/util.qh"
#include "../common/weapons/all.qh"
-#include "../warpzonelib/common.qh"
-#include "../warpzonelib/server.qh"
+#include "../lib/warpzone/common.qh"
+#include "../lib/warpzone/server.qh"
+
+.int state;
/*============================================
============================================*/
.float hook_length;
-.float hook_switchweapon;
void RemoveGrapplingHook(entity pl)
{
}
void GrapplingHookReset(void)
-{
+{SELFPARAM();
if(self.realowner.hook == self)
RemoveGrapplingHook(self.owner);
else // in any case:
void GrapplingHookThink();
void GrapplingHook_Stop()
-{
+{SELFPARAM();
Send_Effect(EFFECT_HOOK_IMPACT, self.origin, '0 0 0', 1);
- sound (self, CH_SHOTS, W_Sound("hook_impact"), VOL_BASE, ATTEN_NORM);
+ sound (self, CH_SHOTS, SND_HOOK_IMPACT, VOL_BASE, ATTEN_NORM);
self.state = 1;
self.think = GrapplingHookThink;
}
.vector hook_start, hook_end;
-float GrapplingHookSend(entity to, int sf)
+bool GrapplingHookSend(entity this, entity to, int sf)
{
WriteByte(MSG_ENTITY, ENT_CLIENT_HOOK);
sf = sf & 0x7F;
return true;
}
+int autocvar_g_grappling_hook_tarzan;
+
void GrapplingHookThink()
-{
+{SELFPARAM();
float spd, dist, minlength, pullspeed, ropestretch, ropeairfriction, rubberforce, newlength, rubberforce_overstretch;
vector dir, org, end, v0, dv, v, myorg, vs;
if(self.realowner.hook != self) // how did that happen?
self.nextthink = time;
- int s = self.realowner.cvar_cl_gunalign;
- if(s != 1 && s != 2 && s != 4)
- s = 3; // default value
- --s;
+ int s = W_GetGunAlignment(self.realowner);
vs = hook_shotorigin[s];
makevectors(self.realowner.v_angle);
}
void GrapplingHookTouch (void)
-{
+{SELFPARAM();
if(other.movetype == MOVETYPE_FOLLOW)
return;
PROJECTILE_TOUCH;
}
void GrapplingHook_Damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
if(self.health <= 0)
return;
}
void FireGrapplingHook (void)
-{
+{SELFPARAM();
entity missile;
vector org;
vector vs;
makevectors(self.v_angle);
- int s = self.cvar_cl_gunalign;
- if(s != 1 && s != 2 && s != 4)
- s = 3; // default value
- --s;
+ int s = W_GetGunAlignment(self);
vs = hook_shotorigin[s];
// UGLY WORKAROUND: play this on CH_WEAPON_B so it can't cut off fire sounds
- sound (self, CH_WEAPON_B, W_Sound("hook_fire"), VOL_BASE, ATTEN_NORM);
+ sound (self, CH_WEAPON_B, SND_HOOK_FIRE, VOL_BASE, ATTEN_NORM);
org = self.origin + self.view_ofs + v_forward * vs.x + v_right * -vs.y + v_up * vs.z;
tracebox(self.origin + self.view_ofs, '-3 -3 -3', '3 3 3', org, MOVE_NORMAL, self);
missile.movetype = ((autocvar_g_balance_grapplehook_gravity) ? MOVETYPE_TOSS : MOVETYPE_FLY);
PROJECTILE_MAKETRIGGER(missile);
- //setmodel (missile, "models/hook.md3"); // precision set below
+ //setmodel (missile, MDL_HOOK); // precision set below
setsize (missile, '-3 -3 -3', '3 3 3');
setorigin (missile, org);
Net_LinkEntity(missile, false, 0, GrapplingHookSend);
}
-// void GrapplingHookFrame()
-// {
-// // this function has been modified for Xonotic
-// - if (self.BUTTON_HOOK && g_grappling_hook)
-// {
-// - if (!self.hook && self.hook_time <= time && !self.button6_pressed_before)
-// - if (timeoutStatus != 2) //only allow the player to fire the grappling hook if the game is not paused (timeout)
-// - FireGrapplingHook();
-// }
-// - else
-// {
-// if (self.hook)
-// RemoveGrapplingHook(self);
-// }
-// - self.button6_pressed_before = self.BUTTON_HOOK;
-// /*
-// // if I have no hook or it's not pulling yet, make sure I'm not flying!
-// if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
-
-void GrapplingHookFrame()
-{
- if(g_grappling_hook && timeout_status != TIMEOUT_ACTIVE && self.weapon != WEP_HOOK.m_id && !self.vehicle)
- {
- // offhand hook controls
- if(self.BUTTON_HOOK)
- {
- if (!(self.hook || (self.hook_state & HOOK_WAITING_FOR_RELEASE)) && (time > self.hook_refire))
- {
- self.hook_state |= HOOK_FIRING;
- self.hook_state |= HOOK_WAITING_FOR_RELEASE;
- }
- }
- else
- {
- self.hook_state |= HOOK_REMOVING;
- self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
- }
-
- self.hook_state &= ~HOOK_RELEASING;
- if(self.BUTTON_CROUCH && autocvar_g_balance_grapplehook_crouchslide)
- {
- self.hook_state &= ~HOOK_PULLING;
- //self.hook_state |= HOOK_RELEASING;
- }
- else
- {
- self.hook_state |= HOOK_PULLING;
- //self.hook_state &= ~HOOK_RELEASING;
- }
- }
- else if(!g_grappling_hook && self.switchweapon != WEP_HOOK.m_id && !self.vehicle)
- {
- if(self.BUTTON_HOOK && !self.hook_switchweapon)
- W_SwitchWeapon(WEP_HOOK.m_id);
- }
- self.hook_switchweapon = self.BUTTON_HOOK;
-
- if(!g_grappling_hook && self.weapon != WEP_HOOK.m_id)
- {
- self.hook_state &= ~HOOK_FIRING;
- self.hook_state |= HOOK_REMOVING;
- }
-
- if (self.hook_state & HOOK_FIRING)
- {
- if (self.hook)
- RemoveGrapplingHook(self);
- FireGrapplingHook();
- self.hook_state &= ~HOOK_FIRING;
- self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor());
- }
- else if(self.hook_state & HOOK_REMOVING)
- {
- if (self.hook)
- RemoveGrapplingHook(self);
- self.hook_state &= ~HOOK_REMOVING;
- }
-
- /*
- // if I have no hook or it's not pulling yet, make sure I'm not flying!
- if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
- {
- self.movetype = MOVETYPE_WALK;
- }
- if(self.impulse == GRAPHOOK_FIRE && self.hook_time <= time && g_grappling_hook)
- {
- // fire hook
- FireGrapplingHook();
- return;
- }
- else if(self.hookimpulse == GRAPHOOK_RELEASE)
- {
- // remove hook, reset movement type
- RemoveGrapplingHook(self);
- return;
- }
- */
- /*else // make sure the player's movetype is correct
- {
- //if(self.hook == world && self.movetype == MOVETYPE_FLY)
- if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
- {
- self.movetype = MOVETYPE_WALK;
- }
- }*/
- // note: The hook entity does the actual pulling
-}
-
void GrappleHookInit()
{
if(g_grappling_hook)
}
else
{
- WEP_ACTION(WEP_HOOK.m_id, WR_INIT);
+ Weapon w = WEP_HOOK;
+ w.wr_init(w);
hook_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 1);
hook_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 2);
hook_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 3);
}
void SetGrappleHookBindings()
-{
+{SELFPARAM();
// this function has been modified for Xonotic
// don't remove these lines! old server or demos coud overwrite the new aliases
stuffcmd(self, "alias +hook +button6\n");