From 77cbd6e6637f0ecc3be76f2c72e76e5dfb25abca Mon Sep 17 00:00:00 2001 From: cypress Date: Mon, 30 Oct 2023 18:43:09 -0400 Subject: [PATCH] SERVER: Fix Ray Gun splash damage --- source/server/damage.qc | 32 +++++++++++++++++++------------- source/server/weapons/ray_gun.qc | 1 + 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/source/server/damage.qc b/source/server/damage.qc index df4a7df..2858081 100644 --- a/source/server/damage.qc +++ b/source/server/damage.qc @@ -439,19 +439,6 @@ void(entity victim,entity attacker, float damage, float d_style) DamageHandler = makeCrawler(victim); GiveAchievement(3, attacker); } - // if (victim.health < z_health*0.5) - // { - // if (victim.crawling != TRUE && !(victim.health <= 0) && crawler_num < 5 && victim.classname != "ai_dog") - // { - // makeCrawler(victim); - // GiveAchievement(3, attacker); - // } - // else - // { - // if (attacker.classname == "player" && (victim.health - damage) > 0) - // addmoney(attacker, 10, 1); - // } - // } if (victim.health <= 0) addmoney(attacker, 60, 1); @@ -573,6 +560,21 @@ float(entity targ, entity inflictor) CanDamage = return FALSE; }; +float(float min, float max, vector org1, vector org2, float radius) calculate_proximity_value = +{ + float proximity_value; + float distance = fabs(vlen(org1 - org2)); + + if (distance <= radius) { + float normalized_distance = distance / radius; + proximity_value = min + (max - min) * (1 - normalized_distance); + } else { + proximity_value = min; + } + + return proximity_value; +}; + void(entity inflictor, entity attacker, float damage2, float mindamage, float radius) DamgageExplode = { float final_damage; @@ -692,6 +694,10 @@ void(entity inflictor, entity attacker, float damage2, float mindamage, float ra // as i can get and i'm not super confident.. // (rounds * (rand 0-100) * weapon_damage/500). final_damage = (rounds * rint(random() * 100)) * damage2/500; + } else if (inflictor.classname == "projectile_raybeam") { + //final_damage = calculate_proximity_value(mindamage, damage2, inflictor.origin, ent.origin, radius); + //bprint(PRINT_HIGH, strcat("damage: ", ftos(final_damage), "\n")); + final_damage = damage2; } else { r = rounds; multi = 1.07; diff --git a/source/server/weapons/ray_gun.qc b/source/server/weapons/ray_gun.qc index 3f60d3d..5e4b089 100644 --- a/source/server/weapons/ray_gun.qc +++ b/source/server/weapons/ray_gun.qc @@ -137,6 +137,7 @@ void() W_FireRay = porter.movetype = MOVETYPE_FLY; porter.weapon = self.weapon; porter.solid = SOLID_BBOX; + porter.classname = "projectile_raybeam"; // Start initial velocity projection. makevectors(self.v_angle);