From 8ff736708c9ba8cd4efab3632dfc8fd07374411b Mon Sep 17 00:00:00 2001 From: Samual Date: Mon, 21 May 2012 23:23:16 -0400 Subject: [PATCH] Working on new laser primary attack -- now has no projectile and works with its own tracing method --- balanceXonotic.cfg | 4 +- qcsrc/server/autocvars.qh | 2 + qcsrc/server/g_damage.qc | 23 ++++---- qcsrc/server/w_laser.qc | 109 ++++++++++++++++++++++++++------------ 4 files changed, 92 insertions(+), 46 deletions(-) diff --git a/balanceXonotic.cfg b/balanceXonotic.cfg index b7dbd3db8..108ed3aa8 100644 --- a/balanceXonotic.cfg +++ b/balanceXonotic.cfg @@ -230,9 +230,9 @@ set g_balance_grapplehook_damagedbycontents 1 set g_balance_laser_primary_damage 25 set g_balance_laser_primary_edgedamage 12.5 set g_balance_laser_primary_force 300 -set g_balance_laser_primary_radius 70 +set g_balance_laser_primary_radius 4000 set g_balance_laser_primary_speed 6000 -set g_balance_laser_primary_spread 0 +set g_balance_laser_primary_spread 0.12 set g_balance_laser_primary_refire 0.7 set g_balance_laser_primary_animtime 0.2 set g_balance_laser_primary_lifetime 5 diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 5e1c65f79..a56449816 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -435,11 +435,13 @@ float autocvar_g_balance_laser_primary_force; float autocvar_g_balance_laser_primary_force_other_scale; float autocvar_g_balance_laser_primary_force_velocitybias; float autocvar_g_balance_laser_primary_force_zscale; +var float autocvar_g_balance_laser_primary_jumpradius = 150; float autocvar_g_balance_laser_primary_lifetime; float autocvar_g_balance_laser_primary_radius; float autocvar_g_balance_laser_primary_refire; float autocvar_g_balance_laser_primary_shotangle; float autocvar_g_balance_laser_primary_speed; +var float autocvar_g_balance_laser_primary_spread = 0.15; float autocvar_g_balance_laser_secondary; float autocvar_g_balance_laser_secondary_animtime; float autocvar_g_balance_laser_secondary_damage; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index a49aad27b..afb6cf3f0 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -986,11 +986,10 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float } float RadiusDamage_running; -float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity) +float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector inflictorvelocity, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float inflictorselfdamage, float forceintensity, float deathtype, entity directhitentity) // Returns total damage applies to creatures { entity targ; - vector blastorigin; vector force; float total_damage_to_creatures; entity next; @@ -1010,30 +1009,29 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e tfloordmg = autocvar_g_throughfloor_damage; tfloorforce = autocvar_g_throughfloor_force; - blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5); total_damage_to_creatures = 0; if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once if(DEATH_WEAPONOF(deathtype) != WEP_TUBA) // do not send tuba damage (bandwidth hog) { - force = inflictor.velocity; + force = inflictorvelocity; if(vlen(force) == 0) force = '0 0 -1'; else force = normalize(force); if(forceintensity >= 0) - Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, 0, attacker); + Damage_DamageInfo(inflictororigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, 0, attacker); else - Damage_DamageInfo(blastorigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, 0, attacker); + Damage_DamageInfo(inflictororigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, 0, attacker); } stat_damagedone = 0; - targ = WarpZone_FindRadius (blastorigin, rad + MAX_DAMAGEEXTRARADIUS, FALSE); + targ = WarpZone_FindRadius (inflictororigin, rad + MAX_DAMAGEEXTRARADIUS, FALSE); while (targ) { next = targ.chain; - if (targ != inflictor) + if ((targ != inflictor) || inflictorselfdamage) if (ignore != targ) if(targ.takedamage) { vector nearest; @@ -1065,7 +1063,7 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e vector myblastorigin; vector center; - myblastorigin = WarpZone_TransformOrigin(targ, blastorigin); + myblastorigin = WarpZone_TransformOrigin(targ, inflictororigin); // if it's a player, use the view origin as reference if (targ.classname == "player") @@ -1114,7 +1112,7 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e for(c = 0; c < total; ++c) { //traceline(targ.WarpZone_findradius_findorigin, nearest, MOVE_NOMONSTERS, inflictor); - WarpZone_TraceLine(blastorigin, WarpZone_UnTransformOrigin(targ, nearest), MOVE_NOMONSTERS, inflictor); + WarpZone_TraceLine(inflictororigin, WarpZone_UnTransformOrigin(targ, nearest), MOVE_NOMONSTERS, inflictor); if (trace_fraction == 1 || trace_ent == targ) { ++hits; @@ -1220,6 +1218,11 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e return total_damage_to_creatures; } +float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity) +{ + return RadiusDamageForSource (inflictor, (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5), inflictor.velocity, attacker, coredamage, edgedamage, rad, ignore, FALSE, forceintensity, deathtype, directhitentity); +} + .float fire_damagepersec; .float fire_endtime; .float fire_deathtype; diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index 656d2be84..a05af2fa7 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -31,40 +31,81 @@ void W_Laser_Think() void W_Laser_Shockwave (void) { - float sc; - float ammoamount; - float bullets; - float d; - float f; - float spread; - float bulletspeed; - float bulletconstant; - entity flash; - - ammoamount = autocvar_g_balance_shotgun_primary_ammo; - bullets = autocvar_g_balance_shotgun_primary_bullets; - d = autocvar_g_balance_shotgun_primary_damage; - f = autocvar_g_balance_shotgun_primary_force; - spread = autocvar_g_balance_shotgun_primary_spread; - bulletspeed = autocvar_g_balance_shotgun_primary_speed; - bulletconstant = autocvar_g_balance_shotgun_primary_bulletconstant; - - W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shotgun_reload_ammo); - - W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/lasergun_fire.wav", CH_WEAPON_A, d * bullets); - for (sc = 0;sc < bullets;sc = sc + 1) - fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_LASER, 0, 1, bulletconstant); - endFireBallisticBullet(); - - pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); - - // muzzle flash for 1st person view - /*flash = spawn(); - setmodel(flash, "models/uziflash.md3"); // precision set below - flash.think = SUB_Remove; - flash.nextthink = time + 0.06; - flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(flash, '5 0 0');*/ + // declarations + float final_damage, final_spread; + entity head, next; + vector nearest, attack_endpos, angle_to_head, angle_to_attack, final_force; + + // set up the shot direction + vector wanted_shot_direction = (v_forward * cos(autocvar_g_balance_laser_primary_shotangle * DEG2RAD) + v_up * sin(autocvar_g_balance_laser_primary_shotangle * DEG2RAD)); + W_SetupShot_Dir(self, wanted_shot_direction, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, autocvar_g_balance_laser_primary_damage); + vector targpos = (w_shotorg + (w_shotdir * autocvar_g_balance_laser_primary_jumpradius)); + + // trace to see if this is a self jump + WarpZone_TraceLine(w_shotorg, targpos, FALSE, self); + //te_lightning2(world, targpos, w_shotorg); + + if(trace_fraction < 1) // Yes, it is a close range jump + { + RadiusDamageForSource(self, trace_endpos, '0 0 0', self, autocvar_g_balance_laser_primary_damage, autocvar_g_balance_laser_primary_edgedamage, autocvar_g_balance_laser_primary_jumpradius, world, TRUE, autocvar_g_balance_laser_primary_force, WEP_LASER, world); + pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); + } + else // No, it's a mid range attack + { + // find out what i'm pointing at + targpos = (w_shotorg + (w_shotdir * autocvar_g_balance_laser_primary_radius)); + WarpZone_TraceLine(w_shotorg, targpos, MOVE_WORLDONLY, self); + + te_lightning2(world, trace_endpos, w_shotorg); + + attack_endpos = trace_endpos; + //total_attack_range = vlen(w_shotorg - trace_endpos); + + // now figure out if I hit anything... + head = WarpZone_FindRadius(attack_endpos, vlen(w_shotorg - trace_endpos) + MAX_DAMAGEEXTRARADIUS, FALSE); + while(head) + { + next = head.chain; + + if((head != self) && (head.takedamage)) + { + // is it in range of the attack? + nearest = WarpZoneLib_NearestPointOnBox(head.origin + head.mins, head.origin + head.maxs, w_shotorg); + if(vlen(w_shotorg - nearest) <= autocvar_g_balance_laser_primary_radius) + { + // is it within the limit of the spread? + nearest = head.WarpZone_findradius_nearest; + angle_to_head = normalize(nearest - w_shotorg); + angle_to_attack = w_shotdir; + final_spread = vlen(angle_to_head - angle_to_attack); + if(final_spread <= autocvar_g_balance_laser_primary_spread) + { + // is it visible to the weapon? + //WarpZone_TraceLine(w_shotorg, nearest, MOVE_WORLDONLY, self); + //if(trace_fraction == 1) + //{ + // finally lets do some damage bitches! + if(autocvar_g_balance_laser_primary_spread) + final_damage = (final_spread / autocvar_g_balance_laser_primary_spread); + else + final_damage = 1; + + final_force = (normalize(nearest - w_shotorg) * autocvar_g_balance_laser_primary_force); + final_damage = (autocvar_g_balance_laser_primary_damage * final_damage + autocvar_g_balance_laser_primary_edgedamage * (1 - final_damage)); + + Damage(head, self, self, final_damage, WEP_LASER, w_shotorg, final_force); + + print(strcat(vtos(angle_to_head), " - ", vtos(angle_to_attack), ": ", ftos(vlen(angle_to_head - angle_to_attack)), ".\n")); + te_lightning2(world, nearest, w_shotorg); + //} + } + } + } + + head = next; + } + pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); + } } void W_Laser_Attack (float issecondary) -- 2.39.2