Jump to content

Recommended Posts

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!

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.

Edited by Ultroman

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.

Edited by K1NGT1GER609

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