SSM Steve Posted November 19, 2020 Share Posted November 19, 2020 Hi, everyone, I've been making my first Don't Starve Together character mod. One of the "perks" she has is that when she's starving, she does not lose any health. Instead she loses sanity at double the rate that other characters lose health. I've messed around with a few things, but I couldn't get anything that works the way I want it to. Can anyone help me, or at least give me an idea of how I start working on this? Any help you can give would be much appreciated! I might be able to get the sanity part working on my own with enough work, but I am completely lost when it comes to removing the hunger damage. (reposting this because I accidently put it in tutorials and guides. I am a forum dumbo) Link to comment Share on other sites More sharing options...
penguin0616 Posted November 19, 2020 Share Posted November 19, 2020 (edited) something.components.hunger:SetOverrideStarveFn(function(inst) -- insert sanity loss here end) Edited November 19, 2020 by penguin0616 1 Link to comment Share on other sites More sharing options...
SSM Steve Posted November 20, 2020 Author Share Posted November 20, 2020 First of all, it works! When my character is at 0 hunger, she doesn't take damage! However, I still have a few issues. 1. Whenever I recover hunger and stop starving, my character still keeps losing sanity until I leave the game. 2. The health icon has a large down arrow on it which would make the player think they are losing health. I want to get rid of that arrow. I remember I found a way to change the arrow on the sanity icon, but I could not get it to work for health. 3. Is there any way to replace the red screen effect when a character starves? It's fine if there isn't, but I just feel like it sends the wrong message to players. This is what I added into master_postinit --Weave loses sanity instead of health when starving inst.components.hunger:SetOverrideStarveFn(function(inst) -- insert sanity loss here inst.components.sanity.dapperness = -2.5 end) Link to comment Share on other sites More sharing options...
penguin0616 Posted November 20, 2020 Share Posted November 20, 2020 1) That's because you're setting the player's dapperness, you'll want to manually handle their sanity with :DoDelta 2, 3) Unfortunately, I don't know the answers to these questions. 1 Link to comment Share on other sites More sharing options...
SSM Steve Posted November 20, 2020 Author Share Posted November 20, 2020 I got the sanity function working perfectly (aside from the whole down arrow business), and I'm sure I'll figure out the visual stuff later on. Thank you so much for your help! Link to comment Share on other sites More sharing options...
Ziro2k Posted November 27, 2020 Share Posted November 27, 2020 On 11/19/2020 at 11:36 PM, SSM Steve said: 2. The health icon has a large down arrow on it which would make the player think they are losing health. I want to get rid of that arrow. I remember I found a way to change the arrow on the sanity icon, but I could not get it to work for health. 3. Is there any way to replace the red screen effect when a character starves? It's fine if there isn't, but I just feel like it sends the wrong message to players. The black down arrow is handled in widgets\healthbadge.lua in the OnUpdate function, and the red onscreen effect is handled in widgets\bloodover.lua in the UpdateState function. Unfortunately, as you can see these are hardcoded to trigger when starving (replica.hunger:IsStarving() returns true when hunger <= 0). Unlike with something like fire for example, where the client has access to networked variables that describe how much damage the player is taking, there is no way for the client to actually determine if they are taking starvation damage or not (which, to be honest, seems kind of strange given that SetOverrideStarveFn is a thing, though I guess maybe it was never meant to be used for players). Anyway, you have a couple of options at this point. You could override the above functions with your desired functionality (note that they are widgets, so they should only be modified with client-side code), or you could modify replica.hunger:IsStarving() to always return false for your character. The latter method seems less messy in my opinion, so I went with that. AddClassPostConstruct("components/hunger_replica", function(self) local _IsStarving = self.IsStarving function self:IsStarving() if self.inst:HasTag("nostarvedamage") then return false else return _IsStarving(self) end end end) As you can see above, I used a tag "nostarvedamage" to make this reusable for other characters or situations, so you'll need to add that tag to your character. If you don't care about reusability though, then you can replace that tag check with self.inst.prefab == "your character name here". 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