Sign in to follow this  
An Actual Ghoul

How do I make my character have a sanity aura?

Recommended Posts

Hi, I would like some help with creating a sanity aura for a character that I am currently making but, I think I screwed the order wrong or something. I'm not entirely the best at coding so yeah (it's gonna look a bit ugly).

-- This initializes for both the server and client. Tags can be added here.
local common_postinit = function(inst) 
    -- Minimap icon
    inst.MiniMapEntity:SetIcon( "mizukii.tex" )
end

local function OnSanityDelta(inst, data)
    CurrentSanity = inst.components.sanity:GetPercent()
    if inst.sleepingbag == nil then
        if CurrentSanity <= 0.15 then
            inst.components.sanityaura.aura = TUNING.MIZUKII_AURARATE * 0
        elseif CurrentSanity <= 0.5 then
            inst.components.sanityaura.aura = TUNING.MIZUKII_AURARATE * 0.5
        else
            inst.components.sanityaura.aura = TUNING.MIZUKII_AURARATE
        end
    else
        inst.components.sanityaura.aura = TUNING.MIZUKII_AURARATE * 2
    end
end

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
    -- Set starting inventory
    inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default
    
    --Sanity Aura
    inst:AddComponent("sanityaura")
    inst.components.sanityaura.max_distsq = TUNING.MIZUKII_AURASIZE
    inst.components.sanityaura.aura = TUNING.MIZUKII_AURARATE
    inst.components.sanityaura.fallofffn = Mizukii_aurafallofffn
    
    -- choose which sounds this character will play
    inst.soundsname = "willow"
    
    -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
    
    -- Stats    
    inst.components.health:SetMaxHealth(135)
    inst.components.hunger:SetMax(155)
    inst.components.sanity:SetMax(200)
    
    -- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = .75
    
    -- Hunger rate (optional)
    inst.components.hunger.hungerrate = 1.15 * TUNING.WILSON_HUNGER_RATE
    
    inst.OnLoad = onload
    inst.OnNewSpawn = onload
    
end

return MakePlayerCharacter("mizukii", prefabs, assets, common_postinit, master_postinit, prefabs)
 

Whenever I try and test this character in-game, the game won't load at all so yeah, i definitely scrwed something up lol. Any help with this coding mess I have created would be much appreciated.

Share this post


Link to post
Share on other sites

No, I haven't. Would that be the problem? There is an error when I left the code like this though, it was taking an insanely long time for me to load into the game after I selected my character when I still had the sanity aura code.

Share this post


Link to post
Share on other sites
decduck3    26

That usually means something is wrong with the character. There may be an error in the log? That may show us the issue.

 

How to get logs:

Open DST, go to the world that you were testing in. Above the delete button, there is an 'Open Cluster_X' button, click that. Then go into Master, and then open the log. Check for any errors

Share this post


Link to post
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
Sign in to follow this