Jump to content

Recommended Posts

I wanna give a modded character basically a sniper rifle. I figure a good way to make the player play like a sniper is to make the weapon do damage based on how far away the player is from the target, up close would deal pitiful damage while as far as possible would deal the most damage. I can't even begin to think of anything similar to this that exists in the game, so if it can't be done, it won't be a big deal.

Link to comment
https://forums.kleientertainment.com/forums/topic/134707-damage-based-on-distance/
Share on other sites

The easiest way is probably to set your damage as a function of the distance to the target.

local function DistanceDamage(inst,attacker,target)
	local distsq = attacker:GetDistanceSqToInst(target) --get distance to target
	return 1 * distsq --return a value for the damage done
end

inst.components.weapon:SetDamage(DistanceDamage)

This is just an example, change it to your liking.

Edited by Monti18
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...