Jump to content

How to make a transformation dependent on sanity


Recommended Posts

So I made a character that can transform by pressing a key on the keyboard and it looks good so far. But I'm having problems with the scripts. Let me explain, I want him to be able to transform only if he has at least 100 sanity or more, and his hunger bar still doesn't hit 0. How could i make that? 

Link to comment
Share on other sites

I don't know how to do exactly this one, but there's a mod called samurai jack and jack's appearence differs according to his sanity like when his sanity is lower than 75% his hair looks a bit more messy and so on. Maybe its codes can help you somehow.

Link to comment
Share on other sites

local function ChangeOnLowSanity(inst)
  if inst:HasTag("playerghost") then return
  if inst.components.sanity.current > 100 then
      inst.AnimState:SetBuild("character_preferance")--change that with your character look thing
      inst.components.hunger:DoDelta(-1000)--im sure there is better way to set your hunger 0 but this will work too
  end
end
ChangeOnLowSanity(inst)

and put it under master_postinits

 

and if you already have the code and you just want to add sanity and hunger thing

local function yourcode
if inst.components.sanity.current > 100 then -- this will check if your character has more than 100 sanity if not then the code bellow will not being executed
--your code
    if yourcode then --this part is when your character changes his preference when you press a key
      yourcode
      inst.components.hunger:DoDelta(-1000)--im sure there is better way to set your hunger 0 but this will work too
  end
  end

lemme know if there is any problem

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