flipwix Posted September 15, 2022 Share Posted September 15, 2022 (edited) I'm still pretty new to modding Don't Starve Together, so I apologize for the clunkiness of this, but I figured it was worth asking for help or pointers on what I could look into. I'm trying to make a mod that rebalances Willow; for this reason, I'm trying to put everything into the modmain.lua file if I can, rather than using a prefab or patch of any kind, because I read that putting it in the modmain reduces the risk of conflicts with other mods when it comes to modifying base game things. The intention is to make Willow totally immune to fire and more heat resistant but also give her some nerfs to compensate. Her max health, max sanity, and max hunger are all slightly lower (by 10 points), she loses sanity at a slightly faster rate, she is slowed by rain and has a higher sanity penalty from it, and... the last idea is the one I'm really struggling with, though it's also fully possible I've actually failed at coding the previous nerfs, as I haven't tested them yet. The last idea would be for Willow to have a random chance to burn up items in her inventory when at low sanity, instead of DS's original 'starting fires when low sanity' drawback. I struggled for a while to figure out how to do this, before settling on this only applying to equipped items she is currently in the process of using (such as tools) as I'm not sure how I would go about doing anything else. This is the entirety of the modmain.lua file as it is currently. local TUNING = GLOBAL.TUNING local STRINGS = GLOBAL.STRINGS TUNING.WILLOW_FIRE_DAMAGE = 0.0 GLOBAL.STRINGS.CHARACTERS.WILLOW.ANNOUNCE_BURNTITEMINV = "Whoops. I was really itching to burn something." GLOBAL.STRINGS.CHARACTERS.WILLOW.ANNOUNCE_BURNTITEMOOPS = "Oops. Something needed to go up in flames." GLOBAL.STRINGS.CHARACTERS.WILLOW.ANNOUNCE_BURNTITEMJOY = "Well, it's not my fault I love watching things burn." AddPrefabPostInit("willow", function(inst) inst.components.sanity.night_drain_mult = 1.1 inst.components.sanity.neg_aura_mult = 1.1 inst.components.temperature.inherentinsulation = -TUNING.INSULATION_SMALL inst.components.temperature.inherentsummerinsulation = TUNING.INSULATION_MEDIUM inst.components.sanity:SetMax(0.916667*TUNING.WILLOW_SANITY) inst.components.health:SetMaxHealth(0.93334*TUNING.WILLOW_HEALTH) inst.components.hunger:SetMax(0.93334*TUNING.WILLOW_HUNGER) inst.components.health.fire_damage_scale = 0.0 local rain_mitigation = false for k,v in pairs (inst.components.inventory.equipslots) do if v:HasTag("waterproofer") then rain_mitigation = true end end local function slowedbyrain(inst, israining) if israining and not rain_mitigation then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "rain_speed_debuff", 0.8) else inst.components.locomotor:SetExternalSpeedMultiplier(inst, "rain_speed_debuff", 1) end end local function extraraindebuff(inst, israining) if israining and not rain_mitigation then inst.components.sanity.neg_aura_mult = 1.3 else inst.components.sanity.neg_aura_mult = 1.1 end end local low_sanity_item_burn_risk = false if inst.components.sanity.currentsanity:GetPercent() < 0.25 then low_sanity_item_burn_risk = true end end local function accidentalitemburn(inst, low_sanity_item_burn_risk) if low_sanity_item_burn_risk then inst.ListenForEvent("working", function(inst, data) local tool local randomchance = math.random(1,50) local tool_burn = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) tool = tool_burn and tool_burn if tool and randomchance == 1 then inst.components.talker:Say(GLOBAL.GetString("ANNOUNCE_BURNTITEMINV" or "ANNOUNCE_BURNTITEMOOPS" or "ANNOUNCE_BURNTITEMJOY")) --this is where i'd put the 'burn item' code if i knew how to do that... end end) end end end) GLOBAL.STRINGS.CHARACTER_DESCRIPTIONS.willow = "*Immune to fire damage \n*Can craft a cuddly bear and sweet lighter \n*Burns things up when nervous" if not GLOBAL.TheNet:GetIsServer() then return end Does this look even close to right so far? If not, what do I need to change and where have I gone wrong? If so... does anyone have any direction they can point me to figure out how to make equipped tools 'burn'? If all that can be is the item disappearing while the burning sound effect plays, that's fine by me; it would be even better if I could make ash fall onto the ground, but I'm new to this and trying to be realistic. Any help or feedback is very much appreciated! Edited September 17, 2022 by flipwix Link to comment https://forums.kleientertainment.com/forums/topic/143191-burning-items-in-inventory-when-low-sanity-more/ Share on other sites More sharing options...
hhh2 Posted September 15, 2022 Share Posted September 15, 2022 Seems fine. In general and for all programming, you should avoid burying `magic numbers' like 1.1, 1.3, 0.25. It's a terrible habit to pick up and will haunt you in bigger programs. That's all I have to comment; you seem to know what you are doing. Link to comment https://forums.kleientertainment.com/forums/topic/143191-burning-items-in-inventory-when-low-sanity-more/#findComment-1598314 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