From: Mario Date: Thu, 29 Sep 2016 02:10:47 +0000 (+1000) Subject: Begin reintroducing old gun alignment hack X-Git-Tag: xonotic-v0.8.2~326^2~90 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cd1792a49bf2a7ddeedd29520421731d49ac255f;p=xonotic%2Fxonotic-data.pk3dir.git Begin reintroducing old gun alignment hack --- diff --git a/qcsrc/common/weapons/calculations.qc b/qcsrc/common/weapons/calculations.qc index c35b1930c..a8587b1ab 100644 --- a/qcsrc/common/weapons/calculations.qc +++ b/qcsrc/common/weapons/calculations.qc @@ -144,6 +144,54 @@ vector findperpendicular(vector v) return normalize(cliptoplane(p, v)); } +#ifdef SVQC + int W_GunAlign(entity this, int preferred_align) + { + entity own = this.owner; + // using wasfreed, as we don't actually clear .gunaligns yet + if(!own.gunaligns[preferred_align] || wasfreed(own.gunaligns[preferred_align]) || own.gunaligns[preferred_align] == this) + { + own.gunaligns[preferred_align] = this; + return preferred_align; // fall back if the good one is already choosable + } + + for(int j = 4; j > 0; --j) // start from left and try the others + { + if(!own.gunaligns[j] || wasfreed(own.gunaligns[j]) || own.gunaligns[j] == this) + { + own.gunaligns[j] = this; + return j; + } + } + + own.gunaligns[preferred_align] = this; + return preferred_align; // no other choice + } +#else + int W_GunAlign(entity this, int preferred_align) + { + // using wasfreed, as we don't actually clear gunaligns yet + if(!gunaligns[preferred_align] || wasfreed(gunaligns[preferred_align]) || gunaligns[preferred_align] == this) + { + gunaligns[preferred_align] = this; + return preferred_align; // fall back if the good one is already choosable + } + + for(int j = 4; j > 0; --j) + { + if(!gunaligns[j] || wasfreed(gunaligns[j]) || gunaligns[j] == this) + { + gunaligns[j] = this; + return j; + } + } + + gunaligns[preferred_align] = this; + return preferred_align; // no other choice + } +#endif + +#if 0 int W_GetGunAlignment(entity player) { int gunalign = STAT(GUNALIGN, player); @@ -153,6 +201,7 @@ int W_GetGunAlignment(entity player) return gunalign; } +#endif vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle) { diff --git a/qcsrc/common/weapons/calculations.qh b/qcsrc/common/weapons/calculations.qh index c349eeca4..d749cc15e 100644 --- a/qcsrc/common/weapons/calculations.qh +++ b/qcsrc/common/weapons/calculations.qh @@ -2,5 +2,6 @@ vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor); vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle); -int W_GetGunAlignment(entity player); +int W_GunAlign(entity this, int preferred_align); +//int W_GetGunAlignment(entity player); float explosion_calcpush_getmultiplier(vector explosion_v, vector target_v); diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 5d2e9e240..0a2754f06 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -1301,7 +1301,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) if(isnew) { - int gunalign = W_GetGunAlignment(NULL); + int gunalign = W_GunAlign(NULL, STAT(GUNALIGN)); this.beam_shotorigin = arc_shotorigin[gunalign]; diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 38a416383..2b322f760 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -370,7 +370,7 @@ void Draw_GrapplingHook(entity this) InterpolateOrigin_Do(this); - int s = W_GetGunAlignment(NULL); + int s = W_GunAlign(NULL, STAT(GUNALIGN)); switch(this.HookType) { diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index ccb658e73..ddb23f0b1 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -695,10 +695,10 @@ void PutClientInServer(entity this) for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; - if(slot == 0) + //if(slot == 0) this.(weaponentity).m_switchweapon = w_getbestweapon(this); - else - this.(weaponentity).m_switchweapon = WEP_Null; + //else + //this.(weaponentity).m_switchweapon = WEP_Null; this.(weaponentity).weaponname = ""; this.(weaponentity).m_switchingweapon = WEP_Null; this.cnt = -1; diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 90266189b..92d6ccac4 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -153,7 +153,7 @@ void GrapplingHookThink(entity this) this.nextthink = time; - int s = W_GetGunAlignment(this.realowner); + int s = W_GunAlign(this.realowner, STAT(GUNALIGN, this.realowner)); vs = hook_shotorigin[s]; makevectors(this.realowner.v_angle); @@ -352,7 +352,7 @@ void FireGrapplingHook(entity actor) makevectors(actor.v_angle); - int s = W_GetGunAlignment(actor); + int s = W_GunAlign(actor, STAT(GUNALIGN, actor)); vs = hook_shotorigin[s]; // UGLY WORKAROUND: play this on CH_WEAPON_B so it can't cut off fire sounds