Jump to content

Add sanity drain to prefabs when on fire?


Recommended Posts

So I have been trying to do this will little to no luck so far.  

 

Questions:

1. How do I make the torch drain sanity?

2. How can I make all things that are on fire produce a sanity aura?

 

1. 

I cannot get the torch to decrease sanity.

 

It seemed like the easiest one.  I should be able to just:

local function updatetorch(inst)    inst:AddComponent("dapperness")    inst.components.dapperness.dapperness = TUNING.CRAZINESS_MEDendAddPrefabPostInit("torch",updatetorch)

but it doesn't work.  I was looking at the nightsword as a reference.

 

2.

I want my character's sanity to drain when he is near a fire.

 

So far I have gotten the sanityaura on a firepit with:

local function CalcSanity(inst)    if inst.components.burnable and inst.components.burnable:IsBurning() then        return -TUNING.SANITYAURA_SMALL    end    return 0endlocal function updatefiresanityaura(inst)    inst:AddComponent("sanityaura")    inst.components.sanityaura.aurafn = CalcSanityendAddPrefabPostInit("firepit",updatefiresanityaura)

So how would I apply this logic to anything that is on fire or IsBurning()?

 

 

Also... just some DS SDK questions that I difficult for me to grasp.

When trying to add a sanityaura to the firepit it would only work in the way I have it above I tried editing aura directly instead of aurafn and the firepit would always drain sanity.  Also I tried an inline function and assigning it to aurafn but got the same results (always drain sanity).  Why is this the case?  Is it just that I am not understanding lua or is it something with DS

local function updatefiresanityaura(inst)    inst:AddComponent("sanityaura")    if inst.components.burnable and inst.components.burnable:IsBurning() then         inst.components.sanityaura.aurafn = function() return -TUNING.SANITYAURA_SMALL end    else        inst.components.sanityaura.aurafn = function() return 0 end    endend

not even sure how aurafn works really.

Link to comment
Share on other sites

For 1. if you have the DLC installed sanity drains have moved to a subset of the equippable component, like

 

inst.components.equippable.dapperness = TUNING.CRAZINESS_MED

 

If you intend to release the mod you'll need to write in an if-check so that people with and without the DLC can use it.

Link to comment
Share on other sites

For nr 2 I suggest you mod the sanity delta function to look for nearby fires instead of modifying every single prefab in the game.

 

Something like this

 

function modsanitydelta(inst)	oldsanitydelta = inst.DoDelta	inst.DoDelta = function(self, delta, overtime)		if self.inst.prefab == "NameOfmyCharacterPrefab" then			local x,y,z = self.inst.Transform:GetWorldPosition()			local ents = TheSim:FindEntities(x,y,z, 4, {'fire'} )			for k,v in pairs(ents) do 				delta = delta + 1			end		end		oldsanitydelta(self, delta, overtime)	endendAddComponentPostInit("sanity", modsanitydelta)

 

Link to comment
Share on other sites

Tried the equippable component and it had the same issue that I was having with aura  (but worked in the end), If I set equippable.dapperness = TUNING.CRAZINESS_MED it doesn't work.  But if I set equippable.dapperfn = CalcSanity it works.

 

Could someone please tell me how I could be wrong in my assumption?  I just don't get it.

 

Anyway the Willow tip worked great.  It works for all objects that are on fire including the torch.

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...