Schulliya Posted July 6, 2022 Share Posted July 6, 2022 I added the tag "notarget" to it, so other mobs won't attack it for nothing. But when my mob attacks other mobs, they will still hit my mob. Is it possible to make them ignore my mob completely? I tried making a combat component postinit but I have no idea of what am I doing. Thank you! Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/ Share on other sites More sharing options...
. . . Posted July 6, 2022 Share Posted July 6, 2022 you can make it that when your mob attacks a target the target loses aggro target.components.combat:DropTarget() target.components.combat:SetTarget(nil) Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582344 Share on other sites More sharing options...
Schulliya Posted July 6, 2022 Author Share Posted July 6, 2022 15 minutes ago, . . . said: you can make it that when your mob attacks a target the target loses aggro target.components.combat:DropTarget() target.components.combat:SetTarget(nil) Where should I put this? I made it like this and did not work :c This code is from frog.lua, and I made some modifications. local RESTARGET_MUST_TAGS = {"_combat","_health"} local function retargetfn(inst) if not inst.components.health:IsDead() then return FindEntity(inst, TUNING.FROG_TARGET_DIST, function(guy) if not guy.components.health:IsDead() and not guy:HasTag("player") then guy.components.combat:DropTarget() guy.components.combat:SetTarget(nil) return true end end, RESTARGET_MUST_TAGS ) end end Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582349 Share on other sites More sharing options...
. . . Posted July 6, 2022 Share Posted July 6, 2022 you would put this code inside your entity -- Put this above the fn thing local function AttackEnemy(inst, data) if data.target ~= nil then data.target.components.combat:DropTarget() data.target.components.combat:SetTarget(nil) end end -- Put this inside its fn, where all the addcomponent and stuff liek that is (not the place where tags are added) inst:ListenForEvent("onattackother", AttackEnemy) Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582350 Share on other sites More sharing options...
Schulliya Posted July 6, 2022 Author Share Posted July 6, 2022 4 minutes ago, . . . said: you would put this code inside your entity -- Put this above the fn thing local function AttackEnemy(inst, data) if data.target ~= nil then data.target.components.combat:DropTarget() data.target.components.combat:SetTarget(nil) end end -- Put this inside its fn, where all the addcomponent and stuff liek that is (not the place where tags are added) inst:ListenForEvent("onattackother", AttackEnemy) This didn't work too. Maybe I have done something wrong...? Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582352 Share on other sites More sharing options...
. . . Posted July 6, 2022 Share Posted July 6, 2022 (edited) 2 minutes ago, Schulliya said: This didn't work too. Maybe I have done something wrong...? it crashed the game or the enemy still attacks? maybe it needs a taskintime for this function local function AttackEnemy(inst, data) if data.target ~= nil then data.target:DoTaskInTime(0, function() data.target.components.combat:DropTarget() data.target.components.combat:SetTarget(nil) data.target.components.combat:CancelAttack() end) end end Edited July 6, 2022 by . . . Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582353 Share on other sites More sharing options...
Schulliya Posted July 6, 2022 Author Share Posted July 6, 2022 (edited) 11 minutes ago, . . . said: it crashed the game or the enemy still attacks? maybe it needs a taskintime for this function local function AttackEnemy(inst, data) if data.target ~= nil then data.target:DoTaskInTime(0, function() data.target.components.combat:DropTarget() data.target.components.combat:SetTarget(nil) data.target.components.combat:CancelAttack() end) end end no, still doesn't work. it doesn't crashes well, it kinda works. The other mob won't attack my mob sometimes, but sometimes it will edit: ok I am testing this for a while now, and it only failed the first times. Now it works perfectly. Thank you so much! Edited July 6, 2022 by Schulliya Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582356 Share on other sites More sharing options...
. . . Posted July 6, 2022 Share Posted July 6, 2022 dang, unfortunately i wouldn't know how to do it then Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582357 Share on other sites More sharing options...
Schulliya Posted July 6, 2022 Author Share Posted July 6, 2022 (edited) I just edited the comment above, now it works, I don't understand though... why would it not work the first time? maybe i'm just crazy, and it worked fine all time long hahahahahahaha and thank you much! Edited July 6, 2022 by Schulliya Link to comment https://forums.kleientertainment.com/forums/topic/141507-i-want-my-mob-to-freely-attack-others-without-being-attacked-back/#findComment-1582359 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