From: Mario Date: Sat, 27 Jul 2019 01:43:11 +0000 (+1000) Subject: Add a weapon flag for weapons that don't use truaim, and fix porto secondary held... X-Git-Tag: xonotic-v0.8.5~1448 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2af11cb55da57f55537b917cfce554e86eeea144;p=xonotic%2Fxonotic-data.pk3dir.git Add a weapon flag for weapons that don't use truaim, and fix porto secondary held angle mode --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 322abb87e..60ae3f18a 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -392,86 +392,6 @@ STATIC_INIT(fpscounter_init) showfps_prevfps_time = currentTime; // we must initialize it to avoid an instant low frame sending } -STATIC_INIT(Porto) -{ - entity e = new_pure(porto); - e.draw = Porto_Draw; - IL_PUSH(g_drawables, e); - e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP; -} - -const int polyline_length = 16; -.vector polyline[polyline_length]; -void Porto_Draw(entity this) -{ - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - { - entity wepent = viewmodels[slot]; - - if (wepent.activeweapon != WEP_PORTO) continue; - if (spectatee_status) continue; - if (WEP_CVAR(porto, secondary)) continue; - if (intermission == 1) continue; - if (intermission == 2) continue; - if (STAT(HEALTH) <= 0) continue; - - vector pos = view_origin; - vector dir = view_forward; - makevectors(((autocvar_chase_active) ? warpzone_save_view_angles : view_angles)); - pos += v_right * -wepent.movedir.y - + v_up * wepent.movedir.z; - - if (wepent.angles_held_status) - { - makevectors(wepent.angles_held); - dir = v_forward; - } - - wepent.polyline[0] = pos; - - int portal_number = 0, portal1_idx = 1, portal_max = 2; - int n = 1 + 2; // 2 lines == 3 points - for (int idx = 0; idx < n && idx < polyline_length - 1; ) - { - traceline(pos, pos + 65536 * dir, true, this); - dir = reflect(dir, trace_plane_normal); - pos = trace_endpos; - wepent.polyline[++idx] = pos; - if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP) - { - n += 1; - continue; - } - if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) - { - n = max(2, idx); - break; - } - // check size - { - vector ang = vectoangles2(trace_plane_normal, dir); - ang.x = -ang.x; - makevectors(ang); - if (!CheckWireframeBox(this, pos - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward)) - { - n = max(2, idx); - break; - } - } - portal_number += 1; - if (portal_number >= portal_max) break; - if (portal_number == 1) portal1_idx = idx; - } - for (int idx = 0; idx < n - 1; ++idx) - { - vector p = wepent.polyline[idx], q = wepent.polyline[idx + 1]; - if (idx == 0) p -= view_up * 16; // line from player - vector rgb = (idx < portal1_idx) ? '1 0 0' : '0 0 1'; - Draw_CylindricLine(p, q, 4, "", 1, 0, rgb, 0.5, DRAWFLAG_NORMAL, view_origin); - } - } -} - float drawtime; float avgspeed; vector GetCurrentFov(float fov) @@ -679,6 +599,9 @@ float EnemyHitCheck() float TrueAimCheck(entity wepent) { + if(wepent.activeweapon.spawnflags & WEP_FLAG_NOTRUEAIM) + return SHOTTYPE_HITWORLD; + float nudge = 1; // added to traceline target and subtracted from result TOOD(divVerent): do we still need this? Doesn't the engine do this now for us? vector vecs, trueaimpoint, w_shotorg; vector mi, ma, dv; @@ -692,12 +615,6 @@ float TrueAimCheck(entity wepent) switch(wepent.activeweapon) // WEAPONTODO { - case WEP_TUBA: // no aim - case WEP_PORTO: // shoots from eye - case WEP_NEXBALL: // shoots from eye - case WEP_HOOK: // no trueaim - case WEP_MORTAR: // toss curve - return SHOTTYPE_HITWORLD; case WEP_VORTEX: case WEP_OVERKILL_NEX: case WEP_VAPORIZER: diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 12fd6eb61..f3c1f4139 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -6,8 +6,6 @@ vector crosshair_getcolor(entity this, float health_stat); void calc_followmodel_ofs(entity view); -void Porto_Draw(entity this); - void CSQC_Demo_Camera(); void TrueAim_Init(); diff --git a/qcsrc/common/gamemodes/gamemode/nexball/weapon.qh b/qcsrc/common/gamemodes/gamemode/nexball/weapon.qh index 73b887260..7790663ac 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/weapon.qh +++ b/qcsrc/common/gamemodes/gamemode/nexball/weapon.qh @@ -1,7 +1,7 @@ #pragma once CLASS(BallStealer, PortoLaunch) -/* flags */ ATTRIB(BallStealer, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED); +/* flags */ ATTRIB(BallStealer, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_NOTRUEAIM); /* impulse */ ATTRIB(BallStealer, impulse, int, 0); /* refname */ ATTRIB(BallStealer, netname, string, "ballstealer"); /* wepname */ ATTRIB(BallStealer, m_name, string, _("Ball Stealer")); diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index a2623ca20..8c025cb19 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -198,6 +198,7 @@ const int WEP_FLAG_DUALWIELD = BIT(11); // weapon can be dual wielded const int WEP_FLAG_NODUAL = BIT(12); // weapon doesn't work well with dual wielding (fireball etc just explode on fire), doesn't currently prevent anything const int WEP_FLAG_PENETRATEWALLS = BIT(13); // weapon has high calibur bullets that can penetrate thick walls (WEAPONTODO) const int WEP_FLAG_BLEED = BIT(14); // weapon pierces and causes bleeding (used for damage effects) +const int WEP_FLAG_NOTRUEAIM = BIT(15); // weapon doesn't aim directly at targets // variables: string weaponorder_byid; diff --git a/qcsrc/common/weapons/weapon/hook.qh b/qcsrc/common/weapons/weapon/hook.qh index 1d15d448e..53bb38291 100644 --- a/qcsrc/common/weapons/weapon/hook.qh +++ b/qcsrc/common/weapons/weapon/hook.qh @@ -4,7 +4,7 @@ CLASS(Hook, Weapon) /* spawnfunc */ ATTRIB(Hook, m_canonical_spawnfunc, string, "weapon_hook"); /* ammotype */ ATTRIB(Hook, ammo_type, int, RES_FUEL); /* impulse */ ATTRIB(Hook, impulse, int, 0); -/* flags */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); +/* flags */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH | WEP_FLAG_NOTRUEAIM); /* rating */ ATTRIB(Hook, bot_pickupbasevalue, float, 0); /* color */ ATTRIB(Hook, wpcolor, vector, '0 0.5 0'); /* modelname */ ATTRIB(Hook, mdl, string, "hookgun"); diff --git a/qcsrc/common/weapons/weapon/mortar.qh b/qcsrc/common/weapons/weapon/mortar.qh index d83fe59dc..459344237 100644 --- a/qcsrc/common/weapons/weapon/mortar.qh +++ b/qcsrc/common/weapons/weapon/mortar.qh @@ -4,7 +4,7 @@ CLASS(Mortar, Weapon) /* spawnfunc */ ATTRIB(Mortar, m_canonical_spawnfunc, string, "weapon_mortar"); /* ammotype */ ATTRIB(Mortar, ammo_type, int, RES_ROCKETS); /* impulse */ ATTRIB(Mortar, impulse, int, 4); -/* flags */ ATTRIB(Mortar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); +/* flags */ ATTRIB(Mortar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH | WEP_FLAG_NOTRUEAIM); /* rating */ ATTRIB(Mortar, bot_pickupbasevalue, float, 7000); /* color */ ATTRIB(Mortar, wpcolor, vector, '1 0 0'); /* modelname */ ATTRIB(Mortar, mdl, string, "gl"); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 722171b95..0e482d8ae 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -1,5 +1,84 @@ #include "porto.qh" +#ifdef CSQC +STATIC_INIT(Porto) +{ + entity e = new_pure(porto); + e.draw = Porto_Draw; + IL_PUSH(g_drawables, e); + e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP; +} + +const int polyline_length = 16; +.vector polyline[polyline_length]; +void Porto_Draw(entity this) +{ + if (spectatee_status || intermission == 1 || intermission == 2 || STAT(HEALTH) <= 0 || WEP_CVAR(porto, secondary)) return; + + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + entity wepent = viewmodels[slot]; + + if (wepent.activeweapon != WEP_PORTO) continue; + + vector pos = view_origin; + vector dir = view_forward; + makevectors(((autocvar_chase_active) ? warpzone_save_view_angles : view_angles)); + pos += v_right * -wepent.movedir.y + + v_up * wepent.movedir.z; + + if (wepent.angles_held_status) + { + makevectors(wepent.angles_held); + dir = v_forward; + } + + wepent.polyline[0] = pos; + + int portal_number = 0, portal1_idx = 1, portal_max = 2; + int n = 1 + 2; // 2 lines == 3 points + for (int idx = 0; idx < n && idx < polyline_length - 1; ) + { + traceline(pos, pos + 65536 * dir, true, this); + dir = reflect(dir, trace_plane_normal); + pos = trace_endpos; + wepent.polyline[++idx] = pos; + if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP) + { + n += 1; + continue; + } + if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) + { + n = max(2, idx); + break; + } + // check size + { + vector ang = vectoangles2(trace_plane_normal, dir); + ang.x = -ang.x; + makevectors(ang); + if (!CheckWireframeBox(this, pos - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward)) + { + n = max(2, idx); + break; + } + } + portal_number += 1; + if (portal_number >= portal_max) break; + if (portal_number == 1) portal1_idx = idx; + } + for (int idx = 0; idx < n - 1; ++idx) + { + vector p = wepent.polyline[idx], q = wepent.polyline[idx + 1]; + if (idx == 0) p -= view_up * 16; // line from player + vector rgb = (idx < portal1_idx) ? '1 0 0' : '0 0 1'; + Draw_CylindricLine(p, q, 4, "", 1, 0, rgb, 0.5, DRAWFLAG_NORMAL, view_origin); + } + } +} +#endif + #ifdef SVQC #include #include diff --git a/qcsrc/common/weapons/weapon/porto.qh b/qcsrc/common/weapons/weapon/porto.qh index 735426feb..29820ef06 100644 --- a/qcsrc/common/weapons/weapon/porto.qh +++ b/qcsrc/common/weapons/weapon/porto.qh @@ -4,7 +4,7 @@ CLASS(PortoLaunch, Weapon) /* spawnfunc */ ATTRIB(PortoLaunch, m_canonical_spawnfunc, string, "weapon_porto"); /* ammotype */ ATTRIB(PortoLaunch, ammo_type, int, RES_NONE); /* impulse */ ATTRIB(PortoLaunch, impulse, int, 0); -/* flags */ ATTRIB(PortoLaunch, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON | WEP_FLAG_NODUAL); +/* flags */ ATTRIB(PortoLaunch, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON | WEP_FLAG_NODUAL | WEP_FLAG_NOTRUEAIM); /* rating */ ATTRIB(PortoLaunch, bot_pickupbasevalue, float, 0); /* color */ ATTRIB(PortoLaunch, wpcolor, vector, '0.5 0.5 0.5'); /* modelname */ ATTRIB(PortoLaunch, mdl, string, "porto"); @@ -38,6 +38,10 @@ REGISTER_WEAPON(PORTO, porto, NEW(PortoLaunch)); SPAWNFUNC_WEAPON(weapon_porto, WEP_PORTO) +#ifdef CSQC +void Porto_Draw(entity this); +#endif + #ifdef SVQC .entity porto_current; .vector porto_v_angle; // holds "held" view angles diff --git a/qcsrc/common/weapons/weapon/tuba.qh b/qcsrc/common/weapons/weapon/tuba.qh index d932d98bd..f0cb6d249 100644 --- a/qcsrc/common/weapons/weapon/tuba.qh +++ b/qcsrc/common/weapons/weapon/tuba.qh @@ -3,7 +3,7 @@ CLASS(Tuba, Weapon) /* spawnfunc */ ATTRIB(Tuba, m_canonical_spawnfunc, string, "weapon_tuba"); /* impulse */ ATTRIB(Tuba, impulse, int, 1); -/* flags */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH | WEP_FLAG_NODUAL); +/* flags */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH | WEP_FLAG_NODUAL | WEP_FLAG_NOTRUEAIM); /* rating */ ATTRIB(Tuba, bot_pickupbasevalue, float, 2000); /* color */ ATTRIB(Tuba, wpcolor, vector, '0 1 0'); /* modelname */ ATTRIB(Tuba, mdl, string, "tuba"); diff --git a/qcsrc/common/wepent.qc b/qcsrc/common/wepent.qc index 6b1797c66..9193c4ef1 100644 --- a/qcsrc/common/wepent.qc +++ b/qcsrc/common/wepent.qc @@ -36,10 +36,10 @@ MACRO_END \ PROP(false, porto_v_angle_held, WEPENT_SET_NORMAL, \ { WriteByte(chan, this.porto_v_angle_held); if(this.porto_v_angle_held) { \ - WriteAngle(chan, this.porto_v_angle.x); WriteAngle(chan, this.porto_v_angle.y); \ + WriteAngle(chan, this.owner.porto_v_angle.x); WriteAngle(chan, this.owner.porto_v_angle.y); \ } }, \ { (viewmodels[this.m_wepent_slot]).angles_held_status = ReadByte(); if((viewmodels[this.m_wepent_slot]).angles_held_status) { \ - (viewmodels[this.m_wepent_slot]).angles_held_x = ReadAngle(); (viewmodels[this.m_wepent_slot]).angles_held_y = ReadAngle(); (viewmodels[this.m_wepent_slot]).angles_held_z = 0; } \ + (viewmodels[this.m_wepent_slot]).angles_held = vec2(ReadAngle(), ReadAngle()); } \ else { (viewmodels[this.m_wepent_slot]).angles_held = '0 0 0'; } }) \ \ PROP(false, tuba_instrument, WEPENT_SET_NORMAL, \