X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_hook.qc;h=68aa7154ecdc3928261ea584bd251be2c86d2c03;hb=32190d3dc9786c24001a66dc8e2a07f41b6cc0a6;hp=32cce331a50776da625ffa35df7544f86afbcc5f;hpb=f4c77946d2b388b2ef4fae1057d1a636d9850923;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 32cce331a..68aa7154e 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -1,5 +1,8 @@ #include "g_hook.qh" +#include +#include +#include #include "weapons/common.qh" #include "weapons/csqcprojectile.qh" #include "weapons/weaponsystem.qh" @@ -13,6 +16,7 @@ #include "../common/vehicles/all.qh" #include "../common/constants.qh" #include "../common/util.qh" +#include #include #include "../lib/warpzone/common.qh" #include "../lib/warpzone/server.qh" @@ -78,11 +82,11 @@ void RemoveGrapplingHooks(entity pl) for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; + if(!pl.(weaponentity)) + continue; // continue incase other slots exist? if(pl.(weaponentity).hook) - { delete(pl.(weaponentity).hook); - pl.(weaponentity).hook = NULL; - } + pl.(weaponentity).hook = NULL; } //pl.disableclientprediction = false; @@ -90,15 +94,14 @@ void RemoveGrapplingHooks(entity pl) void RemoveHook(entity this) { - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - { - .entity weaponentity = weaponentities[slot]; - if(this.realowner.(weaponentity).hook == this) - this.realowner.(weaponentity).hook = NULL; - } + entity player = this.realowner; + .entity weaponentity = this.weaponentity_fld; + + if(player.(weaponentity).hook == this) + player.(weaponentity).hook = NULL; - if(this.realowner.move_movetype == MOVETYPE_FLY) - set_movetype(this.realowner, MOVETYPE_WALK); + if(player.move_movetype == MOVETYPE_FLY) + set_movetype(player, MOVETYPE_WALK); delete(this); } @@ -107,7 +110,6 @@ void GrapplingHookReset(entity this) RemoveHook(this); } -void GrapplingHookThink(entity this); void GrapplingHook_Stop(entity this) { Send_Effect(EFFECT_HOOK_IMPACT, this.origin, '0 0 0', 1); @@ -137,15 +139,11 @@ bool GrapplingHookSend(entity this, entity to, int sf) } if(sf & 2) { - WriteCoord(MSG_ENTITY, this.hook_start.x); - WriteCoord(MSG_ENTITY, this.hook_start.y); - WriteCoord(MSG_ENTITY, this.hook_start.z); + WriteVector(MSG_ENTITY, this.hook_start); } if(sf & 4) { - WriteCoord(MSG_ENTITY, this.hook_end.x); - WriteCoord(MSG_ENTITY, this.hook_end.y); - WriteCoord(MSG_ENTITY, this.hook_end.z); + WriteVector(MSG_ENTITY, this.hook_end); } return true; } @@ -162,7 +160,7 @@ void GrapplingHookThink(entity this) error("Owner lost the hook!\n"); return; } - if(LostMovetypeFollow(this) || intermission_running || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || ((this.aiment.flags & FL_PROJECTILE) && this.aiment.classname != "nade")) + if(LostMovetypeFollow(this) || game_stopped || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || ((this.aiment.flags & FL_PROJECTILE) && this.aiment.classname != "nade")) { RemoveHook(this); return; @@ -329,7 +327,7 @@ void GrapplingHookTouch(entity this, entity toucher) GrapplingHook_Stop(this); if(toucher) - if(toucher.move_movetype != MOVETYPE_NONE) + //if(toucher.move_movetype != MOVETYPE_NONE) { SetMovetypeFollow(this, toucher); WarpZone_RefSys_BeginAddingIncrementally(this, this.aiment); @@ -338,17 +336,17 @@ void GrapplingHookTouch(entity this, entity toucher) //this.realowner.disableclientprediction = true; } -void GrapplingHook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void GrapplingHook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(this.health <= 0) + if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) return; if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions return; // g_balance_projectiledamage says to halt - this.health = this.health - damage; + TakeResource(this, RESOURCE_HEALTH, damage); - if (this.health <= 0) + if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0) { if(attacker != this.realowner) { @@ -365,19 +363,9 @@ void FireGrapplingHook(entity actor, .entity weaponentity) if(forbidWeaponUse(actor)) return; if(actor.vehicle) return; - makevectors(actor.v_angle); - - int s = W_GunAlign(actor.(weaponentity), STAT(GUNALIGN, actor)) - 1; - vector vs = hook_shotorigin[s]; - - // UGLY WORKAROUND: play this on CH_WEAPON_B so it can't cut off fire sounds - sound (actor, CH_WEAPON_B, SND_HOOK_FIRE, VOL_BASE, ATTEN_NORM); - vector org = actor.origin + actor.view_ofs + v_forward * vs.x + v_right * -vs.y + v_up * vs.z; - - 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); + // TODO: offhand hook shoots from eye + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', true, 0, SND_HOOK_FIRE, CH_WEAPON_B, 0, WEP_HOOK.m_id); + Send_Effect(EFFECT_HOOK_MUZZLEFLASH, w_shotorg, '0 0 0', 1); entity missile = WarpZone_RefSys_SpawnSameRefSys(actor); missile.owner = missile.realowner = actor; @@ -394,11 +382,11 @@ void FireGrapplingHook(entity actor, .entity weaponentity) //setmodel (missile, MDL_HOOK); // precision set below setsize (missile, '-3 -3 -3', '3 3 3'); - setorigin(missile, org); + setorigin(missile, w_shotorg); missile.state = 0; // not latched onto anything - W_SetupProjVelocity_Explicit(missile, v_forward, v_up, autocvar_g_balance_grapplehook_speed_fly, 0, 0, 0, false); + W_SetupProjVelocity_Explicit(missile, w_shotdir, v_up, autocvar_g_balance_grapplehook_speed_fly, 0, 0, 0, false); missile.angles = vectoangles (missile.velocity); //missile.glow_color = 250; // 244, 250 @@ -409,11 +397,13 @@ void FireGrapplingHook(entity actor, .entity weaponentity) missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION; - missile.health = autocvar_g_balance_grapplehook_health;//120 + SetResourceAmountExplicit(missile, RESOURCE_HEALTH, autocvar_g_balance_grapplehook_health); missile.event_damage = GrapplingHook_Damage; missile.takedamage = DAMAGE_AIM; missile.damageforcescale = 0; missile.damagedbycontents = (autocvar_g_balance_grapplehook_damagedbycontents); + if(missile.damagedbycontents) + IL_PUSH(g_damagedbycontents, missile); missile.hook_start = missile.hook_end = missile.origin;