Jump to content

Recommended Posts

In my mod, I set the pig follower stop leashing and stop run after me. So it can be far away from me.

And when I join the game or come back from cave, the leadership is not resume unless they are nearby.

I already rewrite the cached_player_join_fn, I guess the reason is that the pig is not loaded, thus the "ms_playerjoined" is not listened. 

anyway to achieve this? I think there are no creature in DST have this feature, when the creature is allow to be far away, they can only follow a things instead of player, like chest, beefalo.

Can I achieve it by follower components' onLoad()? is onLoad() run when I come close to the pig or when I join the world?

seems I made it, in the load of pigman, do this
 

    inst:RemoveEventCallback("ms_playerjoined", inst.components.follower.cached_player_join_fn, TheWorld)
    inst.components.follower.CAN_old_cached_player_join_fn = inst.components.follower.cached_player_join_fn

    inst.components.follower.cached_player_join_fn = function(world, player) 
        dprint("cached_player_join_fn")
        dprint(player.userid)
        dprint(inst.components.follower.cached_player_leader_userid)
        if inst.components.follower.cached_player_leader_userid == player.userid then
            inst.components.follower:SetLeader(player)
        end
    end
    inst:ListenForEvent("ms_playerjoined", inst.components.follower.cached_player_join_fn, TheWorld)

 

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