Jump to content

[solved] Modding Character's Starvation Mechanic


Recommended Posts

I got it working!~ thanks again <3

 

I am making a ghost-like player. Less in the traditional sense of the game's ghosts, more in the fashion of the character's lore. And we all know that ghosts do not eat. So what I have been trying to do over the last few days is remove her hunger. Ideally the stat, but if nothing else at least the starvation fx.

My working modifications are as follows:


local master_postinit = function(inst)

-- Hunger
	inst.components.hunger:SetMax(1)
	inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE
	inst.components.hunger.hurtrate = 0
	
end

It's a nice little band-aid, I mean the decay is not only nil but also her hunger regens at the normal rate of decay... but the slurpers can still cause the fx and that bothers me. the hurtrate means I do not take damage from 0 hunger, although the arrow still shows on my health stat.

I have already put into place a set of balancing aspects to have this character's main drawbacks and what have you be based around her sanity.

Basically this: 

-- Ecto Conversion
local function ieat(inst, data)
	if data.food.components.edible then 
	local x, y, z = inst.Transform:GetWorldPosition()	
	inst.ectoconversion = true
	inst.components.sanity:DoDelta(-10)
	inst:DoTaskInTime(.8, function() 
		SpawnPrefab("nightmarefuel").Transform:SetPosition(x, y, z)
		end) 
	end
end 

local master_postinit = function(inst)
	inst:ListenForEvent("oneat", ieat)
end

Which works great. edible item + 10 sanity = nightmarefuel!

However, having to get back that 1 hunger point can be a bit annoying just to remove the starvation overlay. True I could wait for the regen to kick in, but I would prefer not to get the annoying fx at all.

Edited by Castael
solved it
Link to comment
Share on other sites

I don't know if this works, but this is from defaults character mod animsparrow. I just flipped the hunger and sanity stuff.

Spoiler

----------------------------------ANIMSPARROW'S STUFF!----------------------------------goes in modmain
-- Hide Sanity Badge now hides stomach instead
local function StatusDisplaysPostInit( self )
	if self.owner:HasTag( "animsparrow" ) then --change to your character's tag
	-- compatibility with Always On Status mod
		if KnownModIndex:IsModEnabled("workshop-376333686") then
			self.brain:SetPosition( 0, 35, 0 ) --I swapped the sanity to be visible and made the stomach invisible.
			self.stomach:SetPosition( -62, -52, 0 )
		else	
			self.moisturemeter:SetPosition( self.stomach:GetPosition() )
			self.stomach:SetPosition( self.moisturemeter:GetPosition() )
		end
		self.owner:DoTaskInTime(0, function(inst) self.stomach:Hide() end )
		self._SetGhostMode = self.SetGhostMode
		function self:SetGhostMode( ghostmode )
			self._SetGhostMode( self, ghostmode )
			if not ghostmode then
				self.stomach:Hide()
			end
		end
	end
	return self
end
AddClassPostConstruct( "widgets/statusdisplays", StatusDisplaysPostInit)

 

In his mod character animsparrow he also made his character's sanity a really large number and made some things in the character to remove sanity loss. You can check it out to mimic more of those cool features.

For example:

Upon revival he has full sanity to prevent the insane effects, ignores sanity penalties from food etc.
For hunger I think you can pause the hunger rate or just make the hunger max and regen a larger number now that the widget is hidden.

Edited by IronHunter
Link to comment
Share on other sites

Thank you for that helpful information IronHunter! Sadly it spat out some errors on boot about the "

	if KnownModIndex:IsModEnabled

being a nil value." but this will surely give me a place to start and work from outside of spinning my wheels in the databundles.(and subbed to the mod you mentioned just to get a better look at the entire code)

either way, im far too tired tonight to work on this but fully intend to explore it tomorrow ^.^

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