dahl Posted March 3, 2019 Share Posted March 3, 2019 Hello! I seek for function that would work like DropTarget() in DST that allow to force entity to drop its target if you want. I've tried three ways like > SetTarget(nil) > GiveUp() and setting fields of combat component itself but none of them has the same effect. Is there any way in vanilla to force mobs to lose their targets for awhile? Force them to attack each other? It seems that it is not that easy like it possible in dst. Any help would be great! Link to comment Share on other sites More sharing options...
dahl Posted March 7, 2019 Author Share Posted March 7, 2019 Does anyone know what could help? Link to comment Share on other sites More sharing options...
Ultroman Posted March 7, 2019 Share Posted March 7, 2019 In DST most mobs retarget every tick, so if something attackable is in range, they start attacking and don't stop until something stops them (usually when they get out of range of the target or too far from "home"). Some mobs only start attacking if you attack them. You get the idea. So, when you make them drop their target, unless it's a Pigman or some other mob that isn't hostile until you attack them, the mob will just retarget a valid player on the next tick, effectively cancelling your "command". You need a system to keep track of which players the mob cannot attack (individual ignore-list per mob), and then extend the IsValidTarget function for both the combat-component and the combat_replica-component, so you do a check for whether the target is in your ignore-list, and if so, you return false, otherwise return whatever the original function would do. I'm too tired to write it out now, but I think this is the best and least intrusive way. Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted March 8, 2019 Share Posted March 8, 2019 Usually I use something like this to force enemies to drop the targets (works on both dst and ds): target.components.combat:ShareTarget(nil, 50, function(dude) --it might need some altering depending where you put it return dude.components.combat:SetTarget(nil) end, 30) a advance way is: local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, 10) for k,v in pairs(ents) do if v.components.combat and v.components.combat.target == inst then v.components.combat.target = nil end end but the advance way requires you to know your code to make it work as I don't know how you want to call these codes. To set them to attack each other you'd probably have to use either a mix of both codes. As for the list the mobs can't attack the players, some of the mobs target player components that you most likely can't include in their exclude list or remove those components without some unexpected results. Link to comment Share on other sites More sharing options...
dahl Posted March 10, 2019 Author Share Posted March 10, 2019 Hmm... Thank you dearly for such a good and helpful answers! I'll try to do my best. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.