GreggZumbari1 Posted June 18, 2017 Share Posted June 18, 2017 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 More sharing options...
GreggZumbari1 Posted June 18, 2017 Author Share Posted June 18, 2017 I'm probably missing something really obvious. Link to comment Share on other sites More sharing options...
alainmcd Posted June 18, 2017 Share Posted June 18, 2017 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 More sharing options...
GreggZumbari1 Posted June 19, 2017 Author Share Posted June 19, 2017 Yup! Thank you, @alainmcd. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now