Jump to content

Character perk help!!

Recommended Posts

Im making a custom character and i want to make him have very specific stats which are:

really slow sanity drain and two custom characters gaining sanity from him while everyone else loses sanity when around him

i may or may not have put the codes in wrong since ive been looking at multiple tutorials and other people having the same problem but i cant quite get it right :o(


silly file.txt

Link to comment
Share on other sites

local GOOD_REQUIRED_SANITY_TAGS = { "kurloz" }
local GOOD_EXCLUDE_SANITY_TAGS = { "burnt", "stump", "fire" }
local BAD_REQUIRED_SANITY_TAGS = { "kurloz" }

local function UpdateExtraSanityGain(inst)
    local x, y, z = inst.Transform:GetWorldPosition()
    --local num_good_entities = #TheSim:FindEntities(x, y, z, 10, GOOD_REQUIRED_SANITY_TAGS, GOOD_EXCLUDE_SANITY_TAGS)
    local num_bad_entities = #TheSim:FindEntities(x, y, z, 10, BAD_REQUIRED_SANITY_TAGS, BAD_EXCLUDE_SANITY_TAGS)
    --------(x,y,z,a range to find what effect your san,what inclued,what excluded)
    --here we look for tree that is not on fire
    inst._extra_sanity_gain =  - num_bad_entities--num_good_entities

local function CustomSanityFn(inst, dt)
    return inst._extra_sanity_gain
local master_postinit = function(inst)
    inst._extra_sanity_gain = 0
    inst._update_extra_sanity_task = inst:DoPeriodicTask(1, UpdateExtraSanityGain)

--Add this to custom character fn or


inst._extra_sanity_gain = 0
inst._update_extra_sanity_task = inst:DoPeriodicTask(1, UpdateExtraSanityGain)


--this in your own mod main

Link to comment
Share on other sites

local function aurafn(inst, observer)
    return -25--or any num you want

local function aurafallofffn(inst, observer, distsq)
    distsq = aurafn(inst, observer) + math.sqrt(math.max(1, distsq))
    return distsq
local master_postinit = function(inst)
    inst.components.sanityaura.max_distsq = 4--distance that will effected by you
    inst.components.sanityaura.aurafn = aurafn
    inst.components.sanityaura.fallofffn = aurafallofffn

--And this in your charater file will make your character decrease character sanity nearby

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

  • Create New...