. . . Posted February 10, 2017 Share Posted February 10, 2017 (edited) Hello, I need help ! This's the code I need help with Spoiler local function BatVeilAttack(inst) local x, y, z = inst.Transform:GetWorldPosition() local adam = TheSim:FindEntities(x, y, z, 1, nil, NON_ATTACK_TAGS, ATTACK_TAGS) local ents = TheSim:FindEntities(x, y, z, 1.75, nil, NON_ATTACK_TAGS, ATTACK_TAGS) for i, v in ipairs(ents) do if v:IsValid() and not v:IsInLimbo() then if v.components.combat ~= nil and not v.lord_mode == true and v.components.health and not v.components.health:IsDead() then v.components.combat:GetAttacked(inst, 1, nil) for i, v in ipairs(adam) do if v:IsValid() and not v:IsInLimbo() then if v.lord_mode == true and v.components.health and not v.components.health:IsDead() then v.components.health:DoDelta(1) end end end end end end end So, what I want to do is make a leeching attack for my character, where when an entity in range gets hit the health goes to my character! The problem right now's since I don't know a code to check how many entities are in 1.75 range then my character just heals 1 point of health even if their are 5 entities in range getting hit by the leeching attack.. Also, thanks very much for reading my problem & have like a wonderful day or night, peace !!! EDIT: So, I didn't figure out how to check how many entities are within range, but I learned that Ipairs already does the code for every single entity in range so my health draining thing was always working fine it's just I wasn't close enough when testing it, lol fail!! Anyways thanks for reading ! Edited February 10, 2017 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/73937-solved-how-to-check-how-many-entities-are-within-a-certain-range/ Share on other sites More sharing options...
HabdomeRaider Posted February 10, 2017 Share Posted February 10, 2017 (edited) I think you need to put the code for the second part inside the first part so it happens when there are entities in ents. Or save the number of entities in ents and use that in the second part. Edited February 10, 2017 by HabdomeRaider Link to comment https://forums.kleientertainment.com/forums/topic/73937-solved-how-to-check-how-many-entities-are-within-a-certain-range/#findComment-865276 Share on other sites More sharing options...
. . . Posted February 10, 2017 Author Share Posted February 10, 2017 (edited) 4 hours ago, HabdomeRaider said: I think you need to put the code for the second part inside the first part so it happens when there are entities in ents. Or save the number of entities in ents and use that in the second part. Thanks, I didn't think of that at all! It totally worked, now it only heals when their are entities in range !! Edited February 10, 2017 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/73937-solved-how-to-check-how-many-entities-are-within-a-certain-range/#findComment-865280 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