4AcidStars4 Posted June 21 Share Posted June 21 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 More sharing options...
Glommer2 Posted July 16 Share Posted July 16 local GOOD_REQUIRED_SANITY_TAGS = { "kurloz" } local GOOD_EXCLUDE_SANITY_TAGS = { "burnt", "stump", "fire" } local BAD_REQUIRED_SANITY_TAGS = { "kurloz" } local BAD_EXCLUDE_SANITY_TAGS = { nil } 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 end local function CustomSanityFn(inst, dt) return inst._extra_sanity_gain end local master_postinit = function(inst) inst._extra_sanity_gain = 0 inst._update_extra_sanity_task = inst:DoPeriodicTask(1, UpdateExtraSanityGain) end --Add this to custom character fn or AddPrefabPostInit("customer_character",function(inst) inst._extra_sanity_gain = 0 inst._update_extra_sanity_task = inst:DoPeriodicTask(1, UpdateExtraSanityGain) end) --this in your own mod main Link to comment Share on other sites More sharing options...
Glommer2 Posted July 16 Share Posted July 16 will make cunstom character lose sanity near you Link to comment Share on other sites More sharing options...
Glommer2 Posted July 16 Share Posted July 16 local function aurafn(inst, observer) return -25--or any num you want end local function aurafallofffn(inst, observer, distsq) distsq = aurafn(inst, observer) + math.sqrt(math.max(1, distsq)) return distsq end local master_postinit = function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.max_distsq = 4--distance that will effected by you inst.components.sanityaura.aurafn = aurafn inst.components.sanityaura.fallofffn = aurafallofffn end --And this in your charater file will make your character decrease character sanity nearby Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now