Jump to content

Cheers for sanity?


Recommended Posts

So I have a character who whenever she does an emote she loses 25 hunger and gains 25 sanity.

But I dont know how to set it to a specific emote and make it so that everyone gains sanity around a certain proximity(Like the firepits light range). RIght now I have this thanks to browsing through these fourms:

	-- Emote for Sanity
	inst:ListenForEvent("emote", function(inst, data)
	if inst:HasTag("cheery") then
		inst.components.sanity:DoDelta(25)
		inst.components.hunger:DoDelta(-25)
	end
	end)

Any ideas? I appreciate the help!

Link to comment
Share on other sites

    -- Emote for Sanity
    inst:ListenForEvent("emote", function(inst, data)
        if inst:HasTag("cheery") then
            inst.components.sanity:DoDelta(25)
            inst.components.hunger:DoDelta(-25)

            for k, v in pairs(AllPlayers) do
                if v ~= inst and v:IsNear(inst, 16) and v.components.sanity then
                    v.components.sanity:DoDelta(10)
                end
            end
        end
    end)

You can use TheSim:FindEntities and loop through the result, too. But this isn't as expensive.

The 16 is the range in units (1 turf = 4 units).

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