hall123 Posted May 7, 2025 Share Posted May 7, 2025 (edited) Hey folks I developed a building mod to attract monsters's aggro. During the test, I found it can't attract the aggro of shadow creature. related code local AGGRO_CANT_TAGS = { "INLIMBO", "player", "eyeturret", "engineering" } local function AttractAggro(inst) local x, y, z = inst.Transform:GetWorldPosition() local range = PAINMAGNET_RANGE or 15 local ents = TheSim:FindEntities(x, y, z, range, nil, AGGRO_CANT_TAGS) -- shadow creature for i, v in ipairs(ents) do if v:IsValid() and v:HasTag("shadowcreature") then print("found Shadow creature ",v.prefab) end end -- other monsters for i, v in ipairs(ents) do if v:IsValid() and v.components.combat and inst.components.combat:CanTarget(v) then if v:HasTag("_combat") then print("found target ",v.prefab) v.components.combat:GiveUp() v.components.combat:SetTarget(inst) -- v.components.health:DoDelta(-PAINMAGNET_DAMAGE, nil, "painmagnet") end end end end The key code don’t work. There is no record in the server logs. local ents = TheSim:FindEntities(x, y, z, range, nil, AGGRO_CANT_TAGS) -- shadow creature for i, v in ipairs(ents) do if v:IsValid() and v:HasTag("shadowcreature") then print("found Shadow creature ",v.prefab) end end Q1 how to find the shadow creature? Q2 how to change the shadow creature's attack target to buildings? The full mod source code is available in this repo: https://github.com/yanghao5/painmagnet/tree/dev Edited May 7, 2025 by hall123 Link to comment https://forums.kleientertainment.com/forums/topic/165622-how-to-attract-the-aggro-of-shadow-creature/ Share on other sites More sharing options...
hall123 Posted May 19, 2025 Author Share Posted May 19, 2025 Ultimately, I referred to bernite's code and perfectly solved this problem. scripts\prefabs\bernie_big.lua Link to comment https://forums.kleientertainment.com/forums/topic/165622-how-to-attract-the-aggro-of-shadow-creature/#findComment-1816423 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