Jump to content

Recommended Posts

Hello again :)

You might want to use TheSim:FindEntities() with that one. These are the parameters:

TheSim:FindEntities(x, y, z, range, must_tags, cant_tags, must_one_of_tags)

The function returns a table; Tags are what just about anything in the game have. Wanna know which mob has which? Look into their prefab files and find AddTag.

Generally, though, if you don't care which mob takes the damage, passive or not, you can just pass {"_combat"} as must_tags and {"player", "INLIMBO"} as cant_tags.

Assign FindEntities to a variable using local something = TheSim:FindEntities(stuff). Then, you can use that something in a loop:

local x, y, z = SomeInst.Transform:GetWorldPosition()
local something = TheSim:FindEntities(x, y, z, ...)

for k, v in ipairs(something) do
if v.components.combat then
	--Obviously, you can do more than what this loop does. Ask around, or ask me!
	--This even means you can exclude further things using components.
	v.components.combat:GetAttacked(attacker, damage, weapon, stimuli, spdamage) --Pass things to this function.
    end
end

SomeInst could be you, the item user.

x, y, z is already set if you replace that with your instance.
range is pretty self-explanatory. Since you want an entire screen, though, experiment with ranges going from 10-15, I think.
must_tags are needed. Use what I left above if you want to.
cant_tags are optional but is crucial to exclude you from the hurt list.
must_one_of_tags are also optional.

Edited by Baguettes
typo...

Hello again! Could you please give me an example of what do i have to put at: " v.components.combat:GetAttacked(attacker, damage, weapon, stimuli, spdamage" because i only know what i have to replace the " damage " with. T0T 

attacker is the instance attacking the entire screen. Pass yourself (your player’s inst) to it if you wish. This’ll count as you actually killing/hurting them with your “hands”.

damage is simple enough, aye?

weapon is your weapon instance. Well, maybe your microphone item. Optional, however.

stimuli is a bit of an odd one. Gives your attack a special effect, but not even I know all of the known ones. Also optional.

spdamage is a table used to handle things like planar damage and usually gets through armor. Is optional and can be empty (e.g. {})

FYI, you can drag and drop to paste your Lua file here; The forums support file downloading.

Also, here's what you need to pass in GetAttacked:
(doer, 15, self.inst)

And here's the explanations:

doer is you, the person activating the honk.
15 is, well, your damage.
self.inst is your activated item's instance.

stimuli and spdamage were removed since those are optional and don't need anything filled in.

  • Sanity 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...