Jump to content

Need help adding perks to character.


Recommended Posts

I'm new to modding. I want folowing perks for my character.

Gain sanity when near others.

Gain +10 to max sanity , hunger , health each time when revived

Turn invisible for 10 seconds (70% transparent) (Monsters lose track of you and cannot attack you unless you attack them first) when pressing E

If you can write it so I can understand how to make similar things next time I would be thankful.

Link to comment
Share on other sites

I think this would make your character gain sanity from being close to other players, put it in YOURCHARACTER.lua inside master_postinit

Spoiler

	-- Sanity gain from nearby players
local function sanityfn(inst)
local x,y,z = inst.Transform:GetWorldPosition()   
local delta = 0
local rad = 10
local rad_sq = rad*rad
for k,v in pairs(AllPlayers) do
if v ~= inst then
local distsq = inst:GetDistanceSqToInst(v)
if distsq < rad_sq then
local sz = TUNING.SANITYAURA_TINY * rad
delta = delta + sz/math.max(1, distsq)
end
end
end
 
return delta
end
inst.components.sanity.custom_rate_fn = sanityfn

 

The other ones Idk, sorry

Link to comment
Share on other sites

2 minutes ago, SuperDavid said:

I think this would make your character gain sanity from being close to other players, put it in YOURCHARACTER.lua inside master_postinit

  Hide contents


	-- Sanity gain from nearby players
local function sanityfn(inst)
local x,y,z = inst.Transform:GetWorldPosition()   
local delta = 0
local rad = 10
local rad_sq = rad*rad
for k,v in pairs(AllPlayers) do
if v ~= inst then
local distsq = inst:GetDistanceSqToInst(v)
if distsq < rad_sq then
local sz = TUNING.SANITYAURA_TINY * rad
delta = delta + sz/math.max(1, distsq)
end
end
end
 
return delta
end
inst.components.sanity.custom_rate_fn = sanityfn

 

The other ones Idk, sorry

I wished i had brains like that.

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