Jump to content

How do I change the damage of a character when near others?


Recommended Posts

I'm currently trying to make a character who when near other people, does more damage. I already have the code for detecting if someone is near, i'm just not sure as to the command for adding damage, then taking it away when the other player leaves.

Here is my code, ending at the "then" statement:

local function damagefn(inst)
    local x, y, z = inst.Transform:GetWorldPosition()
    local delta = 0
    local ents = TheSim:FindEntities(x, y, z, 30, {"player"})
    for k, v in pairs(ents) do
        if v ~= inst then
          

Link to comment
Share on other sites

Hi @GreggZumbari1, welcome to the forums!

Perhaps this is what you're looking for?

local function damagefn(inst)
	local x, y, z = inst.Transform:GetWorldPosition()
	local ents = TheSim:FindEntities(x, y, z, 30, {"player"})
	inst.components.combat.damagemultiplier = 1 + (#ents - 1) * TUNING.YOURCHARACTERBONUS
end

 

Link to comment
Share on other sites

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
 Share

×
  • Create New...