Well shame on me, I just realized I read this page that I had loaded a day ago and BL00DB4TH’s post wasn’t there :b
[lua]function GM:EntityTakeDamage(victim, weapon, killer, ammount, dmginfo)
–Killer as in attacker, just easier to type for me.
if (ammount > 0) then --No point trying anything if the damage is 0 or less
if (weapon == "your_weapon_here") then --If the source of damage is the weapon in question
local distance = victim:GetPos():Distance(killer:GetPos()) --Get the distance between victim and killer
local factor = distance*0.01 --Get 0.01 per unit of distance
dmginfo:ScaleDamage( 1-factor ) -- Substract that to 1
--This formula reduces 1% of the damage per unit of distance (Probably waaay too much)
Thats a gamemode script function, if you want to use it in a weapon script, add it as a serverside hook.
If you want to say, reduce 1% damage after the distance is 1000 units just add an IF condition.
Also, important, “ammount” wont scale down but the actual damage will, so if you try printing out the amount damage of a dmginfo:ScaleDamage(0) it will show the damage before scaling. Use dmginfo:getDamage() for that.
killer:PrintMessage( HUD_PRINTCENTER, math.floor(dmginfo:GetDamage()*10)/10 )[/lua]