Tesumoto Posted October 28, 2016 Share Posted October 28, 2016 (edited) Hello everybody! I want to make my character add a bonus heat it in winter is not freezing. What do I need to write in "character".lua? Also I would like to know which parameter is responsible for the rate of descent of the mind at night? inst.components.sanity.night_drain_mult it forces the mind to fall, but how to get the mind to recover at night? Edited December 25, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 1) Bonus heat in winter: Add in your "character".lua, inside of master_postinit(inst): inst:WatchWorldState("season", WatchSeason ) And add this function: local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation + value --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation - value --Remove the bonus if not winter end end 2) The parameter for lost sanity during night, inside of master_postinit(inst): inst.components.sanity.night_drain_mult = 1 --Default is 1 Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 4 minutes ago, kavaline said: 1) Bonus heat in winter: Add in your "character".lua, inside of master_postinit(inst): inst:WatchWorldState("season", WatchSeason ) And add this function: local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation + value --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation - value --Remove the bonus if not winter end end 2) The parameter for lost sanity during night, inside of master_postinit(inst): inst.components.sanity.night_drain_mult = 1 --Default is 1 Thank for help inst.components.sanity.night_drain_mult it forces the mind to fall, but how to get the mind to recover at night? Edited October 28, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 2 minutes ago, Tezumoto said: Thank for help inst.components.sanity.night_drain_mult it forces the mind to fall, but how to get the mind to recover at night? Just put a negative value: inst.components.sanity.night_drain_mult = -1 Instead of lose sanity, you will recover =] Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 2 minutes ago, kavaline said: Just put a negative value: inst.components.sanity.night_drain_mult = -1 Instead of lose sanity, you will recover =] Thank you) Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 8 minutes ago, kavaline said: Just put a negative value: inst.components.sanity.night_drain_mult = -1 Instead of lose sanity, you will recover =] Can make to decrease the mind in the daytime? inst.components.sanity.day_drain_mult = 1 or -1 don't work Link to comment Share on other sites More sharing options...
Arlesienne Posted October 28, 2016 Share Posted October 28, 2016 4 minutes ago, Tezumoto said: Can make to decrease the mind in the daytime? inst.components.sanity.day_drain_mult = 1 or -1 don't work Try upping it. Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 (edited) For the daytime, is: inst.components.sanity.dapperness = -TUNING.DAPPERNESS_SMALL --Also, change for _TINY, _MED, _LARGE, etc. Waxwell have _LARGE (positive) Edited October 28, 2016 by kavaline put a better example Link to comment Share on other sites More sharing options...
. . . Posted October 28, 2016 Share Posted October 28, 2016 (edited) local function drain_sanity_at_day(inst, phase) if phase == "day" then if inst:HasTag("playerghost") then return end inst.components.sanity.dapperness = -TUNING.DAPPERNESS_MED -- Instead of MED you can also use TINY , SMALL , LARGE , HUGE elseif phase == "night" then if inst:HasTag("playerghost") then return end inst.components.sanity.dapperness = 0 elseif phase == "dusk" then if inst:HasTag("playerghost") then return end inst.components.sanity.dapperness = 0 end end put code below in master_postinit put code above outside of master_postinit inst:WatchWorldState("phase", drain_sanity_at_day) Here this should make your character decrease mind in day . Edited October 28, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 24 minutes ago, kavaline said: For the daytime, is: inst.components.sanity.dapperness = -TUNING.DAPPERNESS_SMALL --Also, change for _TINY, _MED, _LARGE, etc. Waxwell have _LARGE (positive) inst.components.sanity.dapperness = -1It works, but the mind is empties too quickly. What value is the standard (evening and night)? My English is very bad. Therefore, I can miss something. Edited October 28, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 (edited) I edit my example, try the new code =] See data/scripts/tuning.lua for understand the TUNING values. This is the lines for dapperness values: DAPPERNESS_TINY = 100/(day_time*15) DAPPERNESS_SMALL = 100/(day_time*10) DAPPERNESS_MED = 100/(day_time*6) DAPPERNESS_MED_LARGE = 100/(day_time*4.5) DAPPERNESS_LARGE = 100/(day_time*3) DAPPERNESS_HUGE = 100/(day_time) Different of " day_drain_mult ", "dapperness" isn't a rate ("-1" don't mean "multiply the value for -1", is a value) @Edit Also, day_time = 300 Edited October 28, 2016 by kavaline Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 @SuperDavid This code will not conflict with character equipaments? '-' Change the lines with: inst.component.sanity.dapperness = value for: inst.component.sanity.dapperness = inst.component.sanity.dapperness * value isn't better, or it don't cause any issue? Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 8 minutes ago, kavaline said: I edit my example, try the new code =] See data/scripts/tuning.lua for understand the TUNING values. This is the lines for dapperness values: DAPPERNESS_TINY = 100/(day_time*15) DAPPERNESS_SMALL = 100/(day_time*10) DAPPERNESS_MED = 100/(day_time*6) DAPPERNESS_MED_LARGE = 100/(day_time*4.5) DAPPERNESS_LARGE = 100/(day_time*3) DAPPERNESS_HUGE = 100/(day_time) Different of " day_drain_mult ", "dapperness" isn't a rate ("-1" don't mean "multiply the value for -1", is a value) I'm a little confused in all this) I need to day mind is emptied at a rate in the evening. And in the evening the mind has not changed. Link to comment Share on other sites More sharing options...
. . . Posted October 28, 2016 Share Posted October 28, 2016 @kavaline I think your way is better . Link to comment Share on other sites More sharing options...
. . . Posted October 28, 2016 Share Posted October 28, 2016 (edited) @Tezumoto Here this code should decrease mind in daytime and mind no decrease in evening. Above master_postinit local function drain_sanity_at_day(inst, phase) if phase == "day" then if inst:HasTag("playerghost") then return end inst.components.sanity.night_drain_mult = -1 inst.component.sanity.dapperness = inst.component.sanity.dapperness * -TUNING.DAPPERNESS_SMALL elseif phase == "night" then if inst:HasTag("playerghost") then return end inst.components.sanity.night_drain_mult = -1 inst.component.sanity.dapperness = inst.component.sanity.dapperness * 0 elseif phase == "dusk" then if inst:HasTag("playerghost") then return end inst.components.sanity.night_drain_mult = 0 inst.component.sanity.dapperness = inst.component.sanity.dapperness * 0 end end Under master_postinit inst:WatchWorldState("phase", drain_sanity_at_day) Edited October 28, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 25 minutes ago, Tezumoto said: I'm a little confused in all this) I need to day mind is emptied at a rate in the evening. And in the evening the mind has not changed. Well, let's go: During the daytime, inst.component.sanity.dapperness will manage your sanity gain (or lost, if the value is negative). During dusktime and nighttime, is inst.components.sanity.night_drain_mult that will manage. So, when one is active, the other isn't active =] Also, inst.component.sanity.dapperness = -TUNING.DAPPERNESS_SMALL is the same as inst.component.sanity.dapperness = -100/(300*10). If you change for inst.component.sanity.dapperness = -TUNING.DAPPERNESS_TINY, is the same of inst.component.sanity.dapperness = -100/(300*15). Note, the only change is the divisor value, from (300*10) to (300*15). If you think this value drain a high sanity, change for inst.component.sanity.dapperness = -100/(300*20), for example, until you find the fine decrease =] (You can use a calculator for find the decimal values) Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 1 hour ago, kavaline said: 1) Bonus heat in winter: Add in your "character".lua, inside of master_postinit(inst): inst:WatchWorldState("season", WatchSeason ) And add this function: local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation + value --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation - value --Remove the bonus if not winter end end Bonus appears at the beginning of winter, and then immediately begins to fade. Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 (edited) 56 minutes ago, Tezumoto said: Bonus appears at the beginning of winter, and then immediately begins to fade. Yes, I grab the idea of "Bonus heat in Winter", and only in Winter xD If you want this bonus in all seasons, just put in master_postinit(inst) this: if inst.components.temperature.inherentinsulation ~= nil then inst.components.temperature.inherentinsulation = inst.components.temperature.inherentinsulation + VALUE else inst.components.temperature.inherentinsulation = VALUE end It will make the job =] For reference, the VALUE of some items (from dontstarve.wikia): Rabbit earmuffs = 60 Breezy vest = 60 Cat cap = 60 Winter hat = 120 Beefalo hat = 240 Puffy vest = 240 @edit I miss the "temperature" piece in the codes xD Edited October 28, 2016 by kavaline Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 37 minutes ago, kavaline said: Yes, I grab the idea of "Bonus heat in Winter", and only in Winter xD If you want this bonus in all seasons, just put in master_postinit(inst) this: if inst.components.inherentinsulation ~= nil then inst.components.inherentinsulation = inst.components.inherentinsulation + VALUE else inst.components.inherentinsulation = VALUE end It will make the job =] For reference, the VALUE of some items (from dontstarve.wikia): Rabbit earmuffs = 60 Breezy vest = 60 Cat cap = 60 Winter hat = 120 Beefalo hat = 240 Puffy vest = 240 On the first day of winter, there is a bonus. The character temperature of 15, and the ground of 5. But after a couple of seconds, the character becomes the same temperature as that of the ground. I want to character constantly in the winter was 10 degrees more than the ground. Edited October 28, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 2 minutes ago, Tezumoto said: On the first day of winter, there is a bonus. The character temperature of 15, and the ground 5 But after a couple of seconds, the character becomes the same temperature as that of the ground. In my last post, I put inst.components.inherentinsulation The right is inst.components.temperature.inherentinsulation I miss the temperature... So, put a high VALUE (like 400) and test if the temperature goes down quickly. If work, post here =] Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 8 minutes ago, kavaline said: In my last post, I put inst.components.inherentinsulation The right is inst.components.temperature.inherentinsulation I miss the temperature... So, put a high VALUE (like 400) and test if the temperature goes down quickly. If work, post here =] Oh... I thought there indicated temperature) I changed at 10 and 10 degrees always will be more) Edited October 28, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 22 minutes ago, Tezumoto said: On the first day of winter, there is a bonus. The character temperature of 15, and the ground of 5. But after a couple of seconds, the character becomes the same temperature as that of the ground. I want to character constantly in the winter was 10 degrees more than the ground. It is beyond of my actual knowledge... This code is for reduce the rate of temperature decrease; you will lose heat, but at reduced rate. Have a code for set minimum temperature, but I don't know how works (and don't remember the code...). Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 24 minutes ago, kavaline said: So, put a high VALUE (like 400) and test if the temperature goes down quickly. If work, post here =] local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = 960 --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = 0 --Remove the bonus if not winter end end I set the value of 960, but the character temperature still drops very quickly =( inst: WatchWorldState ( "season", Watch Season) also placed in the right place. This my full code: local MakePlayerCharacter = require "prefabs/player_common" local assets = {Asset("SCRIPT", "scripts/prefabs/player_common.lua")} local prefabs = {} local start_inv = {"sewing_kit", "bedroll_furry"} local function onbecamehuman(inst) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "kagerou_speed_mod", 1) end local function onbecameghost(inst) inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "kagerou_speed_mod") end 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 local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = 960 --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = 0 --Remove the bonus if not winter end end local common_postinit = function(inst) inst.MiniMapEntity:SetIcon( "kagerou.tex" ) end local master_postinit = function(inst) inst.soundsname = "willow" inst.components.health:SetMaxHealth(100) inst.components.hunger:SetMax(100) inst.components.sanity:SetMax(300) inst.components.locomotor.walkspeed = ( TUNING.WILSON_WALK_SPEED * 1.1 ) inst.components.locomotor.runspeed = ( TUNING.WILSON_RUN_SPEED * 1.1 ) inst.components.combat.damagemultiplier = 0.9 inst.components.hunger.hungerrate = ( TUNING.WILSON_HUNGER_RATE * 1.1 ) inst.OnLoad = onload inst.OnNewSpawn = onload inst.components.eater:SetCanEatRaw() inst.components.eater.strongstomach = true inst:WatchWorldState("season", WatchSeason ) end return MakePlayerCharacter("kagerou", prefabs, assets, common_postinit, master_postinit, start_inv) Edited October 28, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
kavaline Posted October 28, 2016 Share Posted October 28, 2016 (edited) 17 minutes ago, Tezumoto said: local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = 960 --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = 0 --Remove the bonus if not winter end end I set the value of 960, but the character temperature still drops very quickly =( inst: WatchWorldState ( "season", Watch Season) also placed in the right place. This my full code: local MakePlayerCharacter = require "prefabs/player_common" local assets = {Asset("SCRIPT", "scripts/prefabs/player_common.lua")} local prefabs = {} local start_inv = {"sewing_kit", "bedroll_furry"} local function onbecamehuman(inst) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "kagerou_speed_mod", 1) end local function onbecameghost(inst) inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "kagerou_speed_mod") end 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 local function WatchSeason(inst, season) if season == "winter" then inst.components.temperature.inherentinsulation = 960 --Default is 0, increase for add resistance else inst.components.temperature.inherentinsulation = 0 --Remove the bonus if not winter end end local common_postinit = function(inst) inst.MiniMapEntity:SetIcon( "kagerou.tex" ) end local master_postinit = function(inst) inst.soundsname = "willow" inst.components.health:SetMaxHealth(100) inst.components.hunger:SetMax(100) inst.components.sanity:SetMax(300) inst.components.locomotor.walkspeed = ( TUNING.WILSON_WALK_SPEED * 1.1 ) inst.components.locomotor.runspeed = ( TUNING.WILSON_RUN_SPEED * 1.1 ) inst.components.combat.damagemultiplier = 0.9 inst.components.hunger.hungerrate = ( TUNING.WILSON_HUNGER_RATE * 1.1 ) inst.OnLoad = onload inst.OnNewSpawn = onload inst.components.eater:SetCanEatRaw() inst.components.eater.strongstomach = true inst:WatchWorldState("season", WatchSeason ) end return MakePlayerCharacter("kagerou", prefabs, assets, common_postinit, master_postinit, start_inv) Unfortunelly I'm headed in other code here, but I have a trick for test my codes; inside of the if, above the lines that change the insulation, put this: inst.components.talker:Say("Winter Bonus ON"), and inst.components.talker:Say("Winter Bonus OFF"). Look if when the winters come, what he says. This will test if the insulation really is affected, or not. The code: local MakePlayerCharacter = require "prefabs/player_common" local assets = {Asset("SCRIPT", "scripts/prefabs/player_common.lua")} local prefabs = {} local start_inv = {"sewing_kit", "bedroll_furry"} local function onbecamehuman(inst) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "kagerou_speed_mod", 1) end local function onbecameghost(inst) inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "kagerou_speed_mod") end 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 local function WatchSeason(inst, season) if season == "winter" then inst.components.talker:Say("Winter Bonus ON") inst.components.temperature.inherentinsulation = 960 --Default is 0, increase for add resistance else inst.components.talker:Say("Winter Bonus OFF") inst.components.temperature.inherentinsulation = 0 --Remove the bonus if not winter end end local common_postinit = function(inst) inst.MiniMapEntity:SetIcon( "kagerou.tex" ) end local master_postinit = function(inst) inst.soundsname = "willow" inst.components.health:SetMaxHealth(100) inst.components.hunger:SetMax(100) inst.components.sanity:SetMax(300) inst.components.locomotor.walkspeed = ( TUNING.WILSON_WALK_SPEED * 1.1 ) inst.components.locomotor.runspeed = ( TUNING.WILSON_RUN_SPEED * 1.1 ) inst.components.combat.damagemultiplier = 0.9 inst.components.hunger.hungerrate = ( TUNING.WILSON_HUNGER_RATE * 1.1 ) inst.OnLoad = onload inst.OnNewSpawn = onload inst.components.eater:SetCanEatRaw() inst.components.eater.strongstomach = true inst:WatchWorldState("season", WatchSeason ) end return MakePlayerCharacter("kagerou", prefabs, assets, common_postinit, master_postinit, start_inv) Edited October 28, 2016 by kavaline Link to comment Share on other sites More sharing options...
Tesumoto Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 22 minutes ago, kavaline said: Unfortunelly I'm headed in other code here, but I have a trick for test my codes; inside of the if, above the lines that change the insulation, put this: inst.components.talker:Say("Winter Bonus ON"), and inst.components.talker:Say("Winter Bonus OFF"). Look if when the winters come, what he says. This will test if the insulation really is affected, or not. Somehow it at me does not work. But I found another way. inst.components.temperature.inherentinsulation = ( TUNING.INSULATION_PER_BEARD_BIT * 9 ) By increasing the number 9, I get a bigger bonus. But it will work for all seasons. Edited October 28, 2016 by Tezumoto Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now