Jump to content

Need help setting my character's stats.


Recommended Posts

I'm trying to set my character's max sanity very low (80) as well as make it so that his sanity declines faster than normal. I've edited the character.lua file and it won't take effect in the game, despite other edits working.

Here's the character.lua (andy.lua) code:

local MakePlayerCharacter = require "prefabs/player_common"

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
}

-- Your character's stats
TUNING.ANDY_HEALTH = 150
TUNING.ANDY_HUNGER = 100
TUNING.ANDY_SANITY = 80

-- Custom starting inventory
TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.ANDY = {

	"fishsticks",
	
}

local start_inv = {}
for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do
    start_inv[string.lower(k)] = v.ANDY
end
local prefabs = FlattenTree(start_inv, true)

-- When the character is revived from human
local function onbecamehuman(inst)
	-- Set speed when not a ghost (optional)
	inst.components.locomotor:SetExternalSpeedMultiplier(inst, "andy_speed_mod", 1)
end

local function onbecameghost(inst)
	-- Remove speed modifier when becoming a ghost
   inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "andy_speed_mod")
end

-- When loading or spawning the character
local function onload(inst)
    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
    inst:ListenForEvent("ms_becameghost", onbecameghost)

    if inst:HasTag("playerghost") then
        onbecameghost(inst)
    else
        onbecamehuman(inst)
    end
end


-- This initializes for both the server and client. Tags can be added here.
local common_postinit = function(inst) 
	-- Minimap icon
	inst.MiniMapEntity:SetIcon( "andy.tex" )
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
	
	-- choose which sounds this character will play
	inst.soundsname = "wortox"
	
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(TUNING.ANDY_HEALTH)
	inst.components.hunger:SetMax(TUNING.ANDY_HUNGER)
	inst.components.sanity:SetMax(TUNING.ANDY_SANITY)
	
	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
	-- Sanity rate
	inst.components.sanity:SetMax(TUNING.WOLFGANG_SANITY)
	inst.components.sanity.night_drain_mult = 1.5 -- This one is a night sanity drain multiplier
	inst.components.sanity.neg_aura_mult = 1.1 -- This one is a regular sanity drain multiplier (from any source)
	
end

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

(I found another post that provided Wolfgang's sanity drain effect, so I added that. If that has something to do with this... :[ )  (I'm also using Dragon Wolf Leo's Extended Sample Character DST template, if that changes anything.)  (also the character's name is Blueberry, ignore that all of the code says andy lol)

While I'm new to DST modding, I've modded another character into the game and never ran into this problem. I've tried to find tutorials on how to do this but I've found none that work. Please help.......................

Link to comment
Share on other sites

Hey hey!

It looks like under your sanity rate section, you appear to have accidentally re-set your character's max sanity stat to be equal to Wolfgang's max sanity here:

Quote
inst.components.sanity:SetMax(TUNING.WOLFGANG_SANITY)

Removing this should fix things I believe.

Edited by Chesed
  • Like 1
Link to comment
Share on other sites

10 hours ago, Chesed said:

Hey hey!

It looks like under your sanity rate section, you appear to have accidentally re-set your character's max sanity stat to be equal to Wolfgang's max sanity here:

Removing this should fix things I believe.

It worked, thank you!

  • Like 1
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...