From d6de58f68d13bae39435390d524eb62022a7023b Mon Sep 17 00:00:00 2001 From: drjaska Date: Sat, 19 Aug 2023 04:56:23 +0300 Subject: [PATCH] dogshit proto --- bal-wep-mario.cfg | 1 + bal-wep-nexuiz25.cfg | 1 + bal-wep-samual.cfg | 1 + bal-wep-xdf.cfg | 1 + bal-wep-xonotic.cfg | 1 + qcsrc/common/weapons/weapon/hagar.qc | 194 ++++++++++++++++++++++++++- qcsrc/common/weapons/weapon/hagar.qh | 1 + 7 files changed, 198 insertions(+), 2 deletions(-) diff --git a/bal-wep-mario.cfg b/bal-wep-mario.cfg index 25293a947..a13f589c8 100644 --- a/bal-wep-mario.cfg +++ b/bal-wep-mario.cfg @@ -348,6 +348,7 @@ set g_balance_hagar_primary_damageforcescale 0 set g_balance_hagar_primary_edgedamage 12.5 set g_balance_hagar_primary_force 100 set g_balance_hagar_primary_health 15 +set g_balance_hagar_primary_homing_speed_turnrate 0 set g_balance_hagar_primary_lifetime 5 set g_balance_hagar_primary_radius 65 set g_balance_hagar_primary_refire 0.16667 diff --git a/bal-wep-nexuiz25.cfg b/bal-wep-nexuiz25.cfg index 17f5b31ca..4c2b12a3c 100644 --- a/bal-wep-nexuiz25.cfg +++ b/bal-wep-nexuiz25.cfg @@ -348,6 +348,7 @@ set g_balance_hagar_primary_damageforcescale 0 set g_balance_hagar_primary_edgedamage 15 set g_balance_hagar_primary_force 100 set g_balance_hagar_primary_health 0 +set g_balance_hagar_primary_homing_speed_turnrate 0 set g_balance_hagar_primary_lifetime 30 set g_balance_hagar_primary_radius 65 set g_balance_hagar_primary_refire 0.15 diff --git a/bal-wep-samual.cfg b/bal-wep-samual.cfg index 2799a2496..fafa6be49 100644 --- a/bal-wep-samual.cfg +++ b/bal-wep-samual.cfg @@ -348,6 +348,7 @@ set g_balance_hagar_primary_damageforcescale 0 set g_balance_hagar_primary_edgedamage 12.5 set g_balance_hagar_primary_force 100 set g_balance_hagar_primary_health 15 +set g_balance_hagar_primary_homing_speed_turnrate 0 set g_balance_hagar_primary_lifetime 5 set g_balance_hagar_primary_radius 65 set g_balance_hagar_primary_refire 0.16667 diff --git a/bal-wep-xdf.cfg b/bal-wep-xdf.cfg index 491f0db71..cf58bb043 100644 --- a/bal-wep-xdf.cfg +++ b/bal-wep-xdf.cfg @@ -348,6 +348,7 @@ set g_balance_hagar_primary_damageforcescale 0 set g_balance_hagar_primary_edgedamage 12.5 set g_balance_hagar_primary_force 92 set g_balance_hagar_primary_health 15 +set g_balance_hagar_primary_homing_speed_turnrate 0 set g_balance_hagar_primary_lifetime 5 set g_balance_hagar_primary_radius 25 set g_balance_hagar_primary_refire 0.11 diff --git a/bal-wep-xonotic.cfg b/bal-wep-xonotic.cfg index 29d73a424..5da611437 100644 --- a/bal-wep-xonotic.cfg +++ b/bal-wep-xonotic.cfg @@ -348,6 +348,7 @@ set g_balance_hagar_primary_damageforcescale 0 set g_balance_hagar_primary_edgedamage 12.5 set g_balance_hagar_primary_force 100 set g_balance_hagar_primary_health 15 +set g_balance_hagar_primary_homing_speed_turnrate 0 set g_balance_hagar_primary_lifetime 5 set g_balance_hagar_primary_radius 65 set g_balance_hagar_primary_refire 0.16667 diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index a8c12efcc..8071ef900 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -75,6 +75,189 @@ void W_Hagar_Touch2(entity this, entity toucher) } } +/***************************************/ +// LegendGuard writes homming missile part to test 02-02-2021 +// LegendGuard adds a copy from hk_weapon.qc functions and the EXPERIMENT of homing missile of this weapon worked successfully 07-02-2021 +bool validate_target(entity this, entity proj, entity targ) +{ + if (!targ) + return false; + + // we know for sure pure entities are bad targets + if (is_pure(targ)) + return false; + + // If only this was used more.. + if (targ.flags & FL_NOTARGET) + return false; + + // Cant touch this + if ((targ.takedamage == DAMAGE_NO) || (GetResource(targ, RES_HEALTH) < 0)) + return false; + + // player + if (IS_PLAYER(targ)) + { + if (this.target_select_playerbias < 0) + return false; + + if (IS_DEAD(targ)) + return false; + } + + // Missile + if ((targ.flags & FL_PROJECTILE) && (this.target_select_missilebias < 0)) + return false; + + // Team check + if (SAME_TEAM(this, targ) || SAME_TEAM(this, targ.owner)) + return false; + + return true; +} + +void Hagar_homing_Missile_Think(entity this) +{ + // Check if lifetime has expired + if (this.cnt < time) + W_Hagar_Explode(this, NULL); + + vector vu, vd, vf, vl, vr, ve; // Vector (direction) + float fu, fd, ff, fl, fr, fe; // Fraction to solid + vector olddir, wishdir, newdir; // Final direction + float lt_for; // Length of Trace FORwrad + float lt_seek; // Length of Trace SEEK (left, right, up down) + float pt_seek; // Pitch of Trace SEEK (How mutch to angele left, right up, down trace towards v_forward) + + //this.nextthink = time + this.ticrate; + this.nextthink = time + 0.25; + this.nextthink = time; + + if (IS_DEAD(this.enemy) || IS_SPEC(this.enemy) || IS_OBSERVER(this.enemy)) + this.enemy = NULL; + + // Pick the closest valid target missile can see. + if (!this.enemy) + { + // in this case, the lighter check is to validate it first, and check distance if it is valid + IL_EACH(g_damagedbycontents, validate_target(this.owner, this, it), + { + if(vdist((this.origin - it.origin), >, 1000)) + continue; + + WarpZone_TraceLine(this.origin, it.origin, true, this.enemy); + if (trace_fraction == 1 || trace_ent == it) + { + + if(!this.enemy) + this.enemy = it; + else if(vlen2(this.origin - it.origin) < vlen2(this.origin - this.enemy.origin)) + this.enemy = it; + } + }); + } + + this.angles = vectoangles(this.velocity); + this.angles_x = this.angles_x * -1; + makevectors(this.angles); + this.angles_x = this.angles_x * -1; + + if (this.enemy) + { + // Get data on enemy position + vector pre_pos = this.enemy.origin + this.enemy.velocity * min((vlen(this.enemy.origin - this.origin) / vlen(this.velocity)), 0.5); + + WarpZone_TraceLine(this.origin, pre_pos, true, this.enemy); + ve = normalize(pre_pos - this.origin); + fe = trace_fraction; + } + else + { + ve = '0 0 0'; + fe = 0; + } + + if ((fe != 1) || (this.enemy == NULL) || vdist(this.origin - this.enemy.origin, >, 1000)) + { + float myspeed = vlen(this.velocity); + + lt_for = myspeed * 3; + lt_seek = myspeed * 2.95; + + // Trace forward + traceline(this.origin, this.origin + v_forward * lt_for, false, this); + vf = trace_endpos; + ff = trace_fraction; + + // Setup trace pitch + pt_seek = 1 - ff; + pt_seek = bound(0.15, pt_seek, 0.8); + if (ff < 0.5) pt_seek = 1; + + // Trace left + traceline(this.origin, this.origin + (-1 * (v_right * pt_seek) + (v_forward * ff)) * lt_seek, false, this); + vl = trace_endpos; + fl = trace_fraction; + + // Trace right + traceline(this.origin, this.origin + ((v_right * pt_seek) + (v_forward * ff)) * lt_seek, false, this); + vr = trace_endpos; + fr = trace_fraction; + + // Trace up + traceline(this.origin, this.origin + ((v_up * pt_seek) + (v_forward * ff)) * lt_seek, false, this); + vu = trace_endpos; + fu = trace_fraction; + + // Trace down + traceline(this.origin, this.origin + (-1 * (v_up * pt_seek) + (v_forward * ff)) * lt_seek, false, this); + vd = trace_endpos; + fd = trace_fraction; + + vl = normalize(vl - this.origin); + vr = normalize(vr - this.origin); + vu = normalize(vu - this.origin); + vd = normalize(vd - this.origin); + + // Panic tresh passed, find a single direction and turn as hard as we can + if (pt_seek == 1) + { + wishdir = v_right; + if (fl > fr) wishdir = -1 * v_right; + if (fu > fl) wishdir = v_up; + if (fd > fu) wishdir = -1 * v_up; + } + else + { + // Normalize our trace vectors to make a smooth path + wishdir = normalize( (vl * fl) + (vr * fr) + (vu * fu) + (vd * fd) ); + } + + if (this.enemy) + { + if (fe < 0.1) fe = 0.1; // Make sure we always try to move sligtly towards our target + wishdir = (wishdir * (1 - fe)) + (ve * fe); + } + } + else + { + wishdir = ve; + } + + // Calculate new heading + olddir = normalize(this.velocity); + newdir = normalize(olddir + wishdir * WEP_CVAR_PRI(hagar, homing_speed_turnrate)); + + // Set heading & speed + this.velocity = newdir * vlen(this.velocity); + + // Align model with new heading + this.angles = vectoangles(this.velocity); + + UpdateCSQCProjectile(this); +} +/********************************/ + void W_Hagar_Attack(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; @@ -99,8 +282,15 @@ void W_Hagar_Attack(Weapon thiswep, entity actor, .entity weaponentity) settouch(missile, W_Hagar_Touch); missile.use = W_Hagar_Explode_use; - setthink(missile, adaptor_think2use_hittype_splash); - missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime); + if (WEP_CVAR_PRI(hagar, homing_speed_turnrate) == 0) { + setthink(missile, adaptor_think2use_hittype_splash); + missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime); + } else { + setthink(missile, Hagar_homing_Missile_Think); + missile.nextthink = time + 0.5; // when to start homing + missile.nextthink = time; // when to start homing + missile.cnt = time + WEP_CVAR_PRI(hagar, lifetime); + } PROJECTILE_MAKETRIGGER(missile); missile.projectiledeathtype = thiswep.m_id; missile.weaponentity_fld = weaponentity; diff --git a/qcsrc/common/weapons/weapon/hagar.qh b/qcsrc/common/weapons/weapon/hagar.qh index 5a43d84ef..4d3e926a7 100644 --- a/qcsrc/common/weapons/weapon/hagar.qh +++ b/qcsrc/common/weapons/weapon/hagar.qh @@ -27,6 +27,7 @@ CLASS(Hagar, Weapon) P(class, prefix, edgedamage, float, BOTH) \ P(class, prefix, force, float, BOTH) \ P(class, prefix, health, float, BOTH) \ + P(class, prefix, homing_speed_turnrate, float, PRI) \ P(class, prefix, lifetime, float, PRI) \ P(class, prefix, lifetime_min, float, SEC) \ P(class, prefix, lifetime_rand, float, SEC) \ -- 2.39.2