Jump to content

Beard heating abillity


Recommended Posts

how can i make this work :
  inst.components.beard:AddCallback(BEARD_DAYS[1], inst.components.sanity:SetMax(200))
  inst.components.beard:AddCallback(BEARD_DAYS[2], inst.components.sanity:SetMax(220))                
  inst.components.beard:AddCallback(BEARD_DAYS[3], inst.components.sanity:SetMax(225))

Edited by DarivenCZ
Link to comment
Share on other sites

Sorry, you mean you want your character's maximum sanity to change according to his beard length, right? If so, look in the spoiler. If not, let me know.

Spoiler

I imagine you're copying from Wilson's or Webber's prefab. No need to change the arguments to AddCallback, instead add your new behaviour to the functions that are being passed. So keep this in your master_postinit (or similar, however it should look for your character):


    inst:AddComponent("beard")
    inst.components.beard.onreset = OnResetBeard
    inst.components.beard.prize = "beardhair"   -- change or remove if needed
    inst.components.beard:AddCallback(BEARD_DAYS[1], OnGrowShortBeard)
    inst.components.beard:AddCallback(BEARD_DAYS[2], OnGrowMediumBeard)
    inst.components.beard:AddCallback(BEARD_DAYS[3], OnGrowLongBeard)

Change the OnGrowXXBeard and OnResetBeard functions to this:


local function OnResetBeard(inst)
    inst.AnimState:ClearOverrideSymbol("beard")

    inst.components.sanity:SetMax(150)	-- I'm assuming 150, change if necessary
end

local function OnGrowShortBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_short")	-- arguments will probably be different, depending on your symbols
    inst.components.beard.bits = BEARD_BITS[1]

    inst.components.sanity:SetMax(200)
end

local function OnGrowMediumBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_medium")	-- same as above
    inst.components.beard.bits = BEARD_BITS[2]

    inst.components.sanity:SetMax(220)
end

local function OnGrowLongBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_long")	-- same as above
    inst.components.beard.bits = BEARD_BITS[3]

    inst.components.sanity:SetMax(225)
end

However, sanity:SetMax has a silly behaviour, it changes the maximum sanity and sets the player's sanity to that new maximum, which isn't ideal. Here's a workaround you can try:


-- sanity:SetMax() always sets the players sanity at max
-- this workaround changes the max value keeping the sanity percentage
-- untested
local function sanitymaxsamepct(sanitycmp, max)
    local pct = sanitycmp:GetPercent()
    sanitycmp:SetMax(max)
    sanitycmp:SetPercent(pct)
end

local function OnResetBeard(inst)
    inst.AnimState:ClearOverrideSymbol("beard")

    sanitymaxsamepct(inst.components.sanity, 150)
end

local function OnGrowShortBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_short")
    inst.components.beard.bits = BEARD_BITS[1]

    sanitymaxsamepct(inst.components.sanity, 200)
end

local function OnGrowMediumBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_medium")
    inst.components.beard.bits = BEARD_BITS[2]

    sanitymaxsamepct(inst.components.sanity, 220)
end

local function OnGrowLongBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_long")
    inst.components.beard.bits = BEARD_BITS[3]

    sanitymaxsamepct(inst.components.sanity, 225)
end

Keep in mind that shaving adds a certain sanity bonus to your character (depending on beard lenght and, as we discussed before, any changes you make to the shaving mechanics). The bonus is applied after the max sanity change, so if, say, you're at 100 sanity with a 200 max and shave, you keep that 50% with the new max (75/150) and then the bonus is applied.

Link to comment
Share on other sites

It does not show up the beard did i done anything wrong?
 


local MakePlayerCharacter = require "prefabs/player_common"


local assets = {         
                 Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
                 Asset( "ANIM", "anim/wintel_beard.zip" ),
}
local prefabs = 
{
"ice",
}

-- Custom starting items
local start_inv = {
}

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

local function onbecameghost(inst)
    -- Remove speed modifier when becoming a ghost
   inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "wintel_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( "wintel.tex" )
end

-- sanity:SetMax() always sets the players sanity at max
-- this workaround changes the max value keeping the sanity percentage
-- untested
local function sanitymaxsamepct(sanitycmp, max)
    local pct = sanitycmp:GetPercent()
    sanitycmp:SetMax(max)
    sanitycmp:SetPercent(pct)
end

local function OnResetBeard(inst)
    inst.AnimState:ClearOverrideSymbol("beard")

    sanitymaxsamepct(inst.components.sanity, 180)
end
--tune the beard economy...
local BEARD_DAYS = { 1, 2, 3 }
local BEARD_BITS = { 3, 4,  6 }

local function OnGrowShortBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "wintel_beard", "beard_short")
    inst.components.beard.bits = BEARD_BITS[1]

    sanitymaxsamepct(inst.components.sanity, 200)
end

local function OnGrowMediumBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "wintel_beard", "beard_medium")
    inst.components.beard.bits = BEARD_BITS[2]

    sanitymaxsamepct(inst.components.sanity, 220)
end

local function OnGrowLongBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "wintel_beard", "beard_long")
    inst.components.beard.bits = BEARD_BITS[3]

    sanitymaxsamepct(inst.components.sanity, 225)
end

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
        inst:AddComponent("beard")
        inst.components.beard.onreset = OnResetBeard
        inst.components.beard.prize = "ice"
        inst.components.beard:AddCallback(BEARD_DAYS[1], OnGrowShortBeard)
        inst.components.beard:AddCallback(BEARD_DAYS[2], OnGrowMediumBeard)
        inst.components.beard:AddCallback(BEARD_DAYS[3], OnGrowLongBeard)
              
        inst.components.beard.insulation_factor = -2
    -- choose which sounds this character will play
    inst.soundsname = "maxwell"
    
    -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
  -- inst.talker_path_override = "dontstarve_DLC001/characters/"
    
    -- Stats    
    inst.components.health:SetMaxHealth(80)
    inst.components.hunger:SetMax(150)
    inst.components.sanity:SetMax(180)
  inst.components.temperature.maxtemp = 100
  inst.components.temperature.inherentsummerinsulation = -2000
  inst.components.temperature.inherentinsulation = 100
  inst.components.beard:AddCallback(BEARD_DAYS[1], inst.components.sanity:SetMax(200))
  inst.components.beard:AddCallback(BEARD_DAYS[2], inst.components.sanity:SetMax(220))                
  inst.components.beard:AddCallback(BEARD_DAYS[3], inst.components.sanity:SetMax(225))  
    -- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = TUNING.WENDY_DAMAGE_MULT
    
    -- Hunger rate (optional)
    inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE
  
  inst.components.sanity.night_drain_mult = TUNING.WENDY_SANITY_MULT
  inst.components.sanity.neg_aura_mult = TUNING.WENDY_SANITY_MULT
    
      inst.OnLoad = onload
    inst.OnNewSpawn = onload
    end

return MakePlayerCharacter("wintel", prefabs, assets, common_postinit, master_postinit, start_inv)
 

Link to comment
Share on other sites

I'm not particularly savvy when it comes to animations. Does it work with the default beard? I.e.

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

local function OnGrowShortBeard(inst)
    inst.AnimState:OverrideSymbol("beard", "beard", "beard_short")
    inst.components.beard.bits = BEARD_BITS[1]
    
    sanitmaxsamepct(inst.components.sanity, 180)
end

--...

That might let you know if it's set up correctly, Other than that, I wouldn't know what could be going on.

Does the rest work correctly? Max sanity changes.

Link to comment
Share on other sites

It is okay i already figured it out i forot to change the part 

    -- Stats    
    inst.components.health:SetMaxHealth(80)
    inst.components.hunger:SetMax(150)
    inst.components.sanity:SetMax(180)
  inst.components.temperature.maxtemp = 100
  inst.components.temperature.inherentsummerinsulation = -2000
  inst.components.temperature.inherentinsulation = 100
  inst.components.beard:AddCallback(BEARD_DAYS[1], inst.components.sanity:SetMax(200))
  inst.components.beard:AddCallback(BEARD_DAYS[2], inst.components.sanity:SetMax(220))                
  inst.components.beard:AddCallback(BEARD_DAYS[3], inst.components.sanity:SetMax(225))  

to 

    -- Stats    
    inst.components.health:SetMaxHealth(80)
    inst.components.hunger:SetMax(150)
    inst.components.sanity:SetMax(180)
  inst.components.temperature.maxtemp = 100
  inst.components.temperature.inherentsummerinsulation = -2000
  inst.components.temperature.inherentinsulation = 100

Link to comment
Share on other sites

Yes. now im trying to make him able to "craft" ice from sanity, but... game crashed is there something i do wrong? Firs i just want to try if it works with rocks :

PrefabFiles = {
    "wintel",
    "wintel_none",
}

Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/wintel.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wintel.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wintel.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wintel.xml" ),
    
    Asset( "IMAGE", "images/selectscreen_portraits/wintel_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wintel_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wintel.tex" ),
    Asset( "ATLAS", "bigportraits/wintel.xml" ),
    
    Asset( "IMAGE", "images/map_icons/wintel.tex" ),
    Asset( "ATLAS", "images/map_icons/wintel.xml" ),
    
    Asset( "IMAGE", "images/avatars/avatar_wintel.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_wintel.xml" ),
    
    Asset( "IMAGE", "images/avatars/avatar_ghost_wintel.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_wintel.xml" ),
    
    Asset( "IMAGE", "images/avatars/self_inspect_wintel.tex" ),
    Asset( "ATLAS", "images/avatars/self_inspect_wintel.xml" ),
    
    Asset( "IMAGE", "images/names_wintel.tex" ),
    Asset( "ATLAS", "images/names_wintel.xml" ),
    
    Asset( "IMAGE", "bigportraits/wintel_none.tex" ),
    Asset( "ATLAS", "bigportraits/wintel_none.xml" ),

}

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH

-- The character select screen lines
STRINGS.CHARACTER_TITLES.wintel = "Winter wizard"
STRINGS.CHARACTER_NAMES.wintel = "Wintel"
STRINGS.CHARACTER_DESCRIPTIONS.wintel = "*Grows an icy beard\n*is not afraid of dark and monsters\n*Always hungry, doesnt hit very hard"
STRINGS.CHARACTER_QUOTES.wintel = "\"Cold, cold,...\""

-- Custom speech strings
STRINGS.CHARACTERS.WINTEL = require "speech_wintel"

-- The character's name as appears in-game 
STRINGS.NAMES.WINTEL = "Wintel"

AddMinimapAtlas("images/map_icons/wintel.xml")

-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.
AddModCharacter("wintel", "MALE")

STRINGS.RECIPE_DESC.ICE = "Look this is ot a rabbit" 

local RecipeCost = GetModConfigData("RecipeCost") then
    Recipe("ice", {Ingredient("rocks",1)}, RECIPETABS.MAGIC, TECH.NONE )
  end 

Link to comment
Share on other sites

Remove this:

local RecipeCost = GetModConfigData("RecipeCost") then
    Recipe("ice", {Ingredient("rocks",1)}, RECIPETABS.MAGIC, TECH.NONE )
end

and instead add this:

AddRecipe("ice", {Ingredient("rocks", 10), Ingredient(CHARACTER_INGREDIENT.SANITY), TUNING.SANITY_TINY}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, 5, "wintel")

Then add this to both master_postinit and common_postinit in your character lua file:

inst:AddTag("wintel")

I've set it up so it costs 10 rocks to craft, giving you 5 ice - change those to whatever you please. You can also change TUNING.SANITY_TINY.

Again, untested.

Link to comment
Share on other sites

 is this all right ? The game always crash : STRINGS.RECIPE_DESC.ICE = "Ice magic"
or I have done here some mistake? : 

local common_postinit = function(inst)

    -- Minimap icon
    inst.MiniMapEntity:SetIcon( "wintel.tex" )
end

  inst:AddTag("wintel")

or here ? :
local master_postinit = function(inst)
        inst:AddComponent("beard")
        inst.components.beard.onreset = OnResetBeard
        inst.components.beard.prize = "ice"
        inst.components.beard:AddCallback(BEARD_DAYS[1], OnGrowShortBeard)
        inst.components.beard:AddCallback(BEARD_DAYS[2], OnGrowMediumBeard)
        inst.components.beard:AddCallback(BEARD_DAYS[3], OnGrowLongBeard)
              
        inst.components.beard.insulation_factor = -2
    -- choose which sounds this character will play
    inst.soundsname = "maxwell"
    
    -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
  -- inst.talker_path_override = "dontstarve_DLC001/characters/"
    
    -- Stats    
    inst.components.health:SetMaxHealth(80)
    inst.components.hunger:SetMax(150)
    inst.components.sanity:SetMax(180)
  inst.components.temperature.maxtemp = 100
  inst.components.temperature.inherentsummerinsulation = -2000
  inst.components.temperature.inherentinsulation = 100
  inst:AddTag("wintel")                                                     --here is the AddTag
 

Thanks for help

Link to comment
Share on other sites

Seems to be in the common postinit. Willow for example :

 


local function common_postinit(inst)
    inst:AddTag("pyromaniac")
    inst:AddTag("expertchef")
end

Wickerbottom :


local function common_postinit(inst)
    inst:AddTag("insomniac")
    inst:AddTag("bookbuilder")

    --reader (from reader component) added to pristine state for optimization
    inst:AddTag("reader")
end

 

In your first example it's outside the postinit, in the second it's in the wrong postinit.

Edited by Lumina
Link to comment
Share on other sites

I think is in the : 

AddRecipe("ice", {Ingredient("rocks", 10), Ingredient(CHARACTER_INGREDIENT.SANITY), TUNING.SANITY_TINY}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, 5, "wintel")

becouse when I made this : 

AddRecipe("ice", {Ingredient("rocks", 10),}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, 5, "wintel")

It worked

 

Link to comment
Share on other sites

4 minutes ago, Lumina said:

You need a workaround to be able to have two recipes, one for the character, and another for everyone else. Otherwise, if you change the base recipe for ice staff, it will replace the current one.

That is what i want so it will replace the current one just for my character. Can i do it just like this ? 

AddRecipe("icestaff", {Ingredient("twigs", 2), Ingredient(icegem, 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, 5, "wintel")

 

Link to comment
Share on other sites

Just now, DarivenCZ said:

That is what i want so it will replace the current one just for my character. Can i do it just like this ? 

I don't think so, it will probably replace the recipe, and the others character will not be able to craft the item. I posted a link to a post explaining a way to do this without removing the recipe for others character. Just between my post and your.

Link to comment
Share on other sites

thank you but still not working 

local icestaff = AddRecipe("icestaff", {Ingredient("twigs", 2), Ingredient("bluegem", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "wintel")

icestaff.image = "icestaff.tex"
icestaff.product = "icestaff"

GLOBAL.STRINGS.RECIPE_DESC.ICESTAFF = "Ice staff."

GLOBAL.STRINGS.NAMES.ICESTAFF = "ice staff"

Link to comment
Share on other sites

3 minutes ago, DarivenCZ said:

thank you but still not working 

try giving the things a different name. Like i don't know

 



local coldstaff = AddRecipe("icestaff_alt", {Ingredient("twigs", 2), Ingredient("bluegem", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "wintel")

coldstaff.image = "icestaff.tex"
coldstaff.product = "icestaff" 

Because if you name everything icestaff i'm not sure it could work.

 

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