DeadlyFox Posted April 9, 2025 Share Posted April 9, 2025 I need help giving a custom item that i made the ability to damage all entities on screen and also make a sound when used. If anyone could help that would be great!^^ Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/ Share on other sites More sharing options...
Baguettes Posted April 11, 2025 Share Posted April 11, 2025 (edited) 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 April 11, 2025 by Baguettes typo... Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1811791 Share on other sites More sharing options...
DeadlyFox Posted April 11, 2025 Author Share Posted April 11, 2025 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 Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1811830 Share on other sites More sharing options...
Baguettes Posted April 12, 2025 Share Posted April 12, 2025 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. {}) Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1811923 Share on other sites More sharing options...
DeadlyFox Posted April 13, 2025 Author Share Posted April 13, 2025 Could you please help me find the players inst because i dont seem to find it anywhere. T0T Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812081 Share on other sites More sharing options...
Baguettes Posted April 13, 2025 Share Posted April 13, 2025 Where are you calling this from? Is it your performable component? Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812082 Share on other sites More sharing options...
DeadlyFox Posted April 13, 2025 Author Share Posted April 13, 2025 No, but it is a similar component named honkable. Should I send you the file? Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812083 Share on other sites More sharing options...
Baguettes Posted April 13, 2025 Share Posted April 13, 2025 Yeah. Do that, I'll see if I can use any variables passed in the component. Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812084 Share on other sites More sharing options...
DeadlyFox Posted April 13, 2025 Author Share Posted April 13, 2025 Okay, thanks! Here is the file : https://www.mediafire.com/file/o2xx37crbgereyg/honkable.lua/file Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812085 Share on other sites More sharing options...
Baguettes Posted April 13, 2025 Share Posted April 13, 2025 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. 1 Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812086 Share on other sites More sharing options...
DeadlyFox Posted April 13, 2025 Author Share Posted April 13, 2025 Thanks a lot, now it works! and alright. 1 Link to comment https://forums.kleientertainment.com/forums/topic/165266-need-help-coding-i-want-to-make-a-custom-item-that-when-used-deals-damage-to-all-entities-on-the-screen/#findComment-1812088 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