X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_hook.qc;h=04766c155dd89ed8cbbfc862f423217c8d6994fe;hb=92c61bba87835a1bfd152c4cbb40764647a83656;hp=4a32779289d12c54f10da05bb6e357b4c8266a89;hpb=068324d293df795dbc41de75f38256b8c6c35607;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 4a3277928..04766c155 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" @@ -88,19 +90,19 @@ void GrapplingHookReset(entity this) remove(this); } -void GrapplingHookThink(); -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; - self.nextthink = time; - self.touch = func_null; - self.velocity = '0 0 0'; - self.movetype = MOVETYPE_NONE; - self.hook_length = -1; +void GrapplingHookThink(entity this); +void GrapplingHook_Stop(entity this) +{ + Send_Effect(EFFECT_HOOK_IMPACT, this.origin, '0 0 0', 1); + sound (this, CH_SHOTS, SND_HOOK_IMPACT, VOL_BASE, ATTEN_NORM); + + this.state = 1; + setthink(this, GrapplingHookThink); + this.nextthink = time; + settouch(this, func_null); + this.velocity = '0 0 0'; + this.movetype = MOVETYPE_NONE; + this.hook_length = -1; } .vector hook_start, hook_end; @@ -108,32 +110,32 @@ bool GrapplingHookSend(entity this, entity to, int sf) { WriteHeader(MSG_ENTITY, ENT_CLIENT_HOOK); sf = sf & 0x7F; - if(sound_allowed(MSG_BROADCAST, self.realowner)) + if(sound_allowed(MSG_BROADCAST, this.realowner)) sf |= 0x80; WriteByte(MSG_ENTITY, sf); if(sf & 1) { - WriteByte(MSG_ENTITY, etof(self.realowner)); + WriteByte(MSG_ENTITY, etof(this.realowner)); } if(sf & 2) { - WriteCoord(MSG_ENTITY, self.hook_start.x); - WriteCoord(MSG_ENTITY, self.hook_start.y); - WriteCoord(MSG_ENTITY, self.hook_start.z); + WriteCoord(MSG_ENTITY, this.hook_start.x); + WriteCoord(MSG_ENTITY, this.hook_start.y); + WriteCoord(MSG_ENTITY, this.hook_start.z); } if(sf & 4) { - WriteCoord(MSG_ENTITY, self.hook_end.x); - WriteCoord(MSG_ENTITY, self.hook_end.y); - WriteCoord(MSG_ENTITY, self.hook_end.z); + WriteCoord(MSG_ENTITY, this.hook_end.x); + WriteCoord(MSG_ENTITY, this.hook_end.y); + WriteCoord(MSG_ENTITY, this.hook_end.z); } return true; } 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? @@ -165,9 +167,9 @@ void GrapplingHookThink() entity pull_entity = self.realowner; float velocity_multiplier = 1; MUTATOR_CALLHOOK(GrappleHookThink, self, tarzan, pull_entity, velocity_multiplier); - tarzan = hook_tarzan; - pull_entity = hook_pullentity; - velocity_multiplier = hook_velmultiplier; + tarzan = M_ARGV(1, int); + pull_entity = M_ARGV(2, entity); + velocity_multiplier = M_ARGV(3, float); if(self.state == 1) { @@ -251,7 +253,7 @@ 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); } } @@ -299,13 +301,13 @@ void GrapplingHookThink() } } -void GrapplingHookTouch () -{SELFPARAM(); +void GrapplingHookTouch (entity this) +{ if(other.movetype == MOVETYPE_FOLLOW) return; - PROJECTILE_TOUCH; + PROJECTILE_TOUCH(this); - GrapplingHook_Stop(); + GrapplingHook_Stop(this); if(other) if(other.movetype != MOVETYPE_NONE) @@ -333,38 +335,38 @@ void GrapplingHook_Damage(entity this, entity inflictor, entity attacker, float { this.realowner.pusher = attacker; this.realowner.pushltime = time + autocvar_g_maxpushtime; - this.realowner.istypefrag = this.realowner.BUTTON_CHAT; + this.realowner.istypefrag = PHYS_INPUT_BUTTON_CHAT(this.realowner); } RemoveGrapplingHook(this.realowner); } } -void FireGrapplingHook () -{SELFPARAM(); +void FireGrapplingHook(entity actor) +{ entity missile; vector org; vector vs; - if(forbidWeaponUse(self)) return; - if(self.vehicle) return; + if(forbidWeaponUse(actor)) return; + if(actor.vehicle) return; - makevectors(self.v_angle); + makevectors(actor.v_angle); - int s = W_GetGunAlignment(self); + int s = W_GetGunAlignment(actor); 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, 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; + sound (actor, CH_WEAPON_B, SND_HOOK_FIRE, VOL_BASE, ATTEN_NORM); + org = actor.origin + actor.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); + tracebox(actor.origin + actor.view_ofs, '-3 -3 -3', '3 3 3', org, MOVE_NORMAL, actor); org = trace_endpos; Send_Effect(EFFECT_HOOK_MUZZLEFLASH, org, '0 0 0', 1); - missile = WarpZone_RefSys_SpawnSameRefSys(self); - missile.owner = missile.realowner = self; - self.hook = missile; + missile = WarpZone_RefSys_SpawnSameRefSys(actor); + missile.owner = missile.realowner = actor; + actor.hook = missile; missile.reset = GrapplingHookReset; missile.classname = "grapplinghook"; missile.flags = FL_PROJECTILE; @@ -383,8 +385,8 @@ void FireGrapplingHook () 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;