X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_hook.qc;h=1b5e22bee56ed4e0ccd44c6f86847be5f46557b9;hb=74cebbb48d9481bb83eccb4438283f319352cb74;hp=7a77d4aff695a0a1fbfdb50ef10a838223c6d77c;hpb=289dc834837712c152d42d7755992e8e5ed09deb;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 7a77d4aff..1b5e22bee 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -8,6 +8,8 @@ #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" @@ -80,24 +82,24 @@ 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(); +void GrapplingHookThink(entity this); void GrapplingHook_Stop() {SELFPARAM(); Send_Effect(EFFECT_HOOK_IMPACT, self.origin, '0 0 0', 1); sound (self, CH_SHOTS, SND_HOOK_IMPACT, VOL_BASE, ATTEN_NORM); self.state = 1; - self.think = GrapplingHookThink; + setthink(self, GrapplingHookThink); self.nextthink = time; - self.touch = func_null; + settouch(self, func_null); self.velocity = '0 0 0'; self.movetype = MOVETYPE_NONE; self.hook_length = -1; @@ -106,14 +108,14 @@ void GrapplingHook_Stop() .vector hook_start, hook_end; bool GrapplingHookSend(entity this, entity to, int sf) { - WriteByte(MSG_ENTITY, ENT_CLIENT_HOOK); + 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) { @@ -132,8 +134,8 @@ bool GrapplingHookSend(entity this, entity to, int sf) int autocvar_g_grappling_hook_tarzan; -void GrapplingHookThink() -{SELFPARAM(); +void GrapplingHookThink(entity this) +{ 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? @@ -151,10 +153,7 @@ void GrapplingHookThink() 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); @@ -243,10 +242,10 @@ void GrapplingHookThink() { 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); } @@ -254,17 +253,17 @@ void GrapplingHookThink() 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; @@ -283,7 +282,7 @@ void GrapplingHookThink() self.realowner.velocity = dir*spd; self.realowner.movetype = MOVETYPE_FLY; - self.realowner.flags &= ~FL_ONGROUND; + UNSET_ONGROUND(self.realowner); } } @@ -302,11 +301,11 @@ void GrapplingHookThink() } } -void GrapplingHookTouch (void) -{SELFPARAM(); +void GrapplingHookTouch (entity this) +{ if(other.movetype == MOVETYPE_FOLLOW) return; - PROJECTILE_TOUCH; + PROJECTILE_TOUCH(this); GrapplingHook_Stop(); @@ -320,29 +319,29 @@ void GrapplingHookTouch (void) //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; @@ -353,10 +352,7 @@ void FireGrapplingHook (void) 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 @@ -389,8 +385,8 @@ void FireGrapplingHook (void) missile.angles = vectoangles (missile.velocity); //missile.glow_color = 250; // 244, 250 //missile.glow_size = 120; - missile.touch = GrapplingHookTouch; - missile.think = GrapplingHookThink; + settouch(missile, GrapplingHookTouch); + setthink(missile, GrapplingHookThink); missile.nextthink = time; missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION; @@ -425,11 +421,3 @@ void GrappleHookInit() 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"); -}