#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 "cl_player.qh"
#include "command/common.qh"
#include "round_handler.qh"
+#include "../common/state.qh"
+#include "../common/physics/player.qh"
#include "../common/vehicles/all.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)
{
//pl.disableclientprediction = false;
}
-void GrapplingHookReset(void)
-{SELFPARAM();
- if(self.realowner.hook == self)
- RemoveGrapplingHook(self.owner);
+void GrapplingHookReset(entity this)
+{
+ if(this.realowner.hook == this)
+ RemoveGrapplingHook(this.owner);
else // in any case:
- remove(self);
+ remove(this);
}
void GrapplingHookThink();
}
.vector hook_start, hook_end;
-float GrapplingHookSend(entity to, int sf)
-{SELFPARAM();
- WriteByte(MSG_ENTITY, ENT_CLIENT_HOOK);
+bool GrapplingHookSend(entity this, entity to, int sf)
+{
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_HOOK);
sf = sf & 0x7F;
if(sound_allowed(MSG_BROADCAST, self.realowner))
sf |= 0x80;
WriteByte(MSG_ENTITY, sf);
if(sf & 1)
{
- WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
+ WriteByte(MSG_ENTITY, etof(self.realowner));
}
if(sf & 2)
{
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);
{
entity aim_ent = ((IS_VEHICLE(self.aiment) && self.aiment.owner) ? self.aiment.owner : self.aiment);
v = v - dv * 0.5;
- if((frozen_pulling && self.aiment.frozen) || !frozen_pulling)
+ if((frozen_pulling && STAT(FROZEN, self.aiment)) || !frozen_pulling)
{
self.aiment.velocity = self.aiment.velocity - dv * 0.5;
- self.aiment.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self.aiment);
if(self.aiment.flags & FL_PROJECTILE)
UpdateCSQCProjectile(self.aiment);
}
self.aiment.nextthink = time + autocvar_g_balance_grapplehook_nade_time; // set time after letting go?
aim_ent.pusher = self.realowner;
aim_ent.pushltime = time + autocvar_g_maxpushtime;
- aim_ent.istypefrag = aim_ent.BUTTON_CHAT;
+ aim_ent.istypefrag = PHYS_INPUT_BUTTON_CHAT(aim_ent);
}
}
- pull_entity.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(pull_entity);
}
if(!frozen_pulling && !(self.aiment.flags & FL_PROJECTILE))
pull_entity.velocity = WarpZone_RefSys_TransformVelocity(self, pull_entity, v * velocity_multiplier);
- if(frozen_pulling && autocvar_g_balance_grapplehook_pull_frozen == 2 && !self.aiment.frozen)
+ if(frozen_pulling && autocvar_g_balance_grapplehook_pull_frozen == 2 && !STAT(FROZEN, self.aiment))
{
RemoveGrapplingHook(self.realowner);
return;
self.realowner.velocity = dir*spd;
self.realowner.movetype = MOVETYPE_FLY;
- self.realowner.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self.realowner);
}
}
}
}
-void GrapplingHookTouch (void)
+void GrapplingHookTouch ()
{SELFPARAM();
if(other.movetype == MOVETYPE_FOLLOW)
return;
//self.realowner.disableclientprediction = true;
}
-void GrapplingHook_Damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
- if(self.health <= 0)
+void GrapplingHook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
+ if(this.health <= 0)
return;
- if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
+ if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_balance_projectiledamage says to halt
- self.health = self.health - damage;
+ this.health = this.health - damage;
- if (self.health <= 0)
+ if (this.health <= 0)
{
- if(attacker != self.realowner)
+ if(attacker != this.realowner)
{
- self.realowner.pusher = attacker;
- self.realowner.pushltime = time + autocvar_g_maxpushtime;
- self.realowner.istypefrag = self.realowner.BUTTON_CHAT;
+ this.realowner.pusher = attacker;
+ this.realowner.pushltime = time + autocvar_g_maxpushtime;
+ this.realowner.istypefrag = PHYS_INPUT_BUTTON_CHAT(this.realowner);
}
- RemoveGrapplingHook(self.realowner);
+ RemoveGrapplingHook(this.realowner);
}
}
-void FireGrapplingHook (void)
+void FireGrapplingHook ()
{SELFPARAM();
entity missile;
vector org;
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
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();
-void GrapplingHookFrame()
-{SELFPARAM();
- if (self.offhand == OFFHAND_HOOK) {
- if (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 (self.switchweapon != WEP_HOOK.m_id && !self.vehicle) {
- if (self.BUTTON_HOOK && !self.hook_switchweapon)
- W_SwitchWeapon(WEP_HOOK.m_id);
- }
- if (self.weapon != WEP_HOOK.m_id && self.offhand != OFFHAND_HOOK) {
- self.hook_state &= ~HOOK_FIRING;
- self.hook_state |= HOOK_REMOVING;
- }
- }
- self.hook_switchweapon = self.BUTTON_HOOK;
- _GrapplingHookFrame();
-}
-
-void _GrapplingHookFrame()
-{
- 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)
hook_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 4);
}
}
-
-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");
- stuffcmd(self, "alias -hook -button6\n");
-}