Jump to content

Sanity based on proximity to other players


Recommended Posts

I have a character that excels at winter hunting, but is afraid to be alone, ensuring that the character doesn't wander off from the group.  I think I've managed to tag entities as "bestfriend" and generate a positive sanity aura based on time since a friend was nearby, but am having trouble testing it..  A lot of my conditional stats aren't activating, and the same goes for this one.  I think this code activates for all pig mobs, but I want it to tag followers and players.  I might rework it, to relate to players with low sanity, but I have no idea how to check for that.
----------------------------------------------------------------------------------------------
local function FindFriend(inst)
    local x, y, z = inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x, y, z, 3, {"pig"}, {"player","werepig","guard","bestfriend"})
    for k, v in pairs(ents) do
        if not v:IsAsleep() and not v.components.sleeper:IsAsleep() then
            if inst.components.leader:CountFollowers() >= 1 then return end
            if v.components.health and not v.components.health:IsDead() then
                inst:PushEvent("makefriend")
                inst.components.leader:AddFollower(v)
                v.components.follower:AddLoyaltyTime(240)
                v:AddTag("bestfriend")
                v:DoTaskInTime(480,function()
                    v:RemoveTag("bestfriend")
                    end)
            end
        end
    end
end

furryeskimo.lua

Link to comment
Share on other sites

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
 Share

×
  • Create New...