Jump to content

Help with sanity based character


Recommended Posts

Well, im new to modding in DST, and im trying to make a mod now, since i really like this game, i would like to make a character with these perks:

A character with very low sanity (75)

  • When sanity is over 65, he generates light (just a little bit)
  • Also, the more sanity he has, the less dame he does, and viceversa, id like to do something around... 75 sanity = 0.5 damage, 60 sanity 1 damage, 50 sanity, 1.5 damage, 35 sanity, 2 damage, and from 10 to 0, 3 damage multiplier
  • In summer, he gets 50+ health, in winter he gets 50- health (Base health 150)
  • Inmune to summer heat

I've been reading several guides, and several google searches, but i cant seem to figure out how to get the mod working, i've got the art and everything, if possible, id like to know what's the difference between "modmain" and "scripts" , because looking at some other mods, there's lots of code in modmain, but in most of the guides ive seen, they put it at "charactername.lua" 

Ps. Im using Extended sample character guide, and as it has the health, sanity and etc in scripts, some other mods have that in "modmain" which makes me confused, thanks for any help with this!

Link to comment
Share on other sites

So all of these will be done inside of your character's file, AKA charactername.lua. I won't know everything off hand since I'm away from the game files, but most of the information you need is in the game files.

 

For you sanity light you need to setup an event listener inside the master_postinit function.

inst:ListenForEvent("sanitydelta", sanitylight)

Then you need to add a function that will enable the light if your sanity hits 65, or turn it off if it's below 65.

local function sanitylight(inst)

if inst.components.sanity.current >= 65 then

--turn on light

else

--turn off light

end

end

For the light portion I would look at the fireflies.lua inside the prefab folder for the game.

 

The damage based on sanity would be a very similar setup.

inst:ListenForEvent("sanitydelta", sanitydamage)

 

local function sanitydamage(inst)

if inst.components.sanity.current > 60 then

     inst.components.combat.damagemultiplier = 1 - .5

else if inst.components.sanity.current > 50 then

     inst.components.combat.damagemultiplier = 1

else if inst.components.sanity.current > 35 then

     inst.components.combat.damagemultiplier = 1 + 1

else if inst.components.sanity.current <=10 then

     inst.components.combat.damagemultiplier = 1 + 2

end

end

 

I would need to look at the game files to help out any furhter.

Edited by RedHairedHero
Link to comment
Share on other sites

Okay, so, it's all working now (thanks a lot RedHaired), but there's something else id like to know if its possible to make, im trying to make my character to get +25 max health on summer and -25 health on winter (base health 150)

I have tried many things, like putting the code in another block, and setting up a listener, but maybe i didnt use the correct thing (i used API.GetSeasonManager, idk if that's the right thing)

I'll add the code, hoping that someone can explain to me what's wrong and what's not

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