Jump to content

Recommended Posts

local function sanitydelta(inst)
   if inst.components.sanity.current >= 100 then
      inst.components.combat.damagemultiplier = 1.5
   elseif inst.components.sanity.current >= 50 then
      inst.components.combat.damagemultiplier = 2
   elseif inst.components.sanity.current <= 50 then
      inst.components.combat.damagemultiplier = 4
   end
end

This code, as almost every one who looks at it will know this already, increases the damage multiplier as sanity goes down, I want to tweak it so it not only increases the attack damage of a character but also increases the hunger rate of the character. I've got an Idea but not too sure if it'll work.

36 minutes ago, Andreasgamming said:

local function sanitydelta(inst)
   if inst.components.sanity.current >= 100 then
      inst.components.combat.damagemultiplier = 1.5
   elseif inst.components.sanity.current >= 50 then
      inst.components.combat.damagemultiplier = 2
   elseif inst.components.sanity.current <= 50 then
      inst.components.combat.damagemultiplier = 4
   end
end

This code, as almost every one who looks at it will know this already, increases the damage multiplier as sanity goes down, I want to tweak it so it not only increases the attack damage of a character but also increases the hunger rate of the character. I've got an Idea but not too sure if it'll work.

inst.components.hunger.hungerrate = 1

So then I just do

 

local function sanitydelta(inst)
   if inst.components.sanity.current >= 100 then
      nst.components.hunger.hungerrate = 1.5
   elseif inst.components.sanity.current >= 50 then
      nst.components.hunger.hungerrate = 2
   elseif inst.components.sanity.current <= 50 then
      nst.components.hunger.hungerrate = 4
   end
end

Right?

if they're gonna trigger at the same time as sanity changes then you should do them like so;

local function sanitydelta(inst)
   if inst.components.sanity.current >= 100 then
      inst.components.combat.damagemultiplier = 1.5
      inst.components.hunger.hungerrate = 1.5
   elseif inst.components.sanity.current >= 50 then
      inst.components.combat.damagemultiplier = 2
      inst.components.hunger.hungerrate = 2
   elseif inst.components.sanity.current <= 50 then
      inst.components.combat.damagemultiplier = 4
      inst.components.hunger.hungerrate = 4
   end
end

New Question, How can I make this code

 

inst:AddComponent("healthRegen")

 

Configurable or add a value that I can change?

Also how can I make it to where the shadow creatures ignore the player or be passive towards her?

Okay, for the damage increase when starving, you'll need something like this:


 

local function sanitydelta(inst)
	if inst.components.sanity.current > 100 then 
		inst.components.health:SetAbsorptionAmount (-0.1)  -- 10% more damage taken
	elseif inst.components.sanity.current > 50 then 
		inst.components.health:SetAbsorptionAmount (-0.3) -- 30% more damage taken
	elseif inst.components.sanity.current < 50 then 
		inst.components.health:SetAbsorptionAmount (-0.5) -- 50% more damage taken
	end
end

This should work; here are both the damage multiplier above and this code put into one block:

.

local function sanitydelta(inst)
   if inst.components.sanity.current >= 100 then
      	inst.components.combat.damagemultiplier = 1.5 --1.5x damage multiplier
      	inst.components.hunger.hungerrate = 1.5 --1.5x hunger rate
    	inst.components.health:SetAbsorptionAmount (-0.1) -- 10% more damage taken
   elseif inst.components.sanity.current >= 50 then
      	inst.components.combat.damagemultiplier = 2 -- 2x damage multiplier
     	inst.components.hunger.hungerrate = 2 -- 2x hunger rate
    	inst.components.health:SetAbsorptionAmount (-0.3) -- 30% more damage taken
   elseif inst.components.sanity.current <= 50 then
    	inst.components.combat.damagemultiplier = 4 -- 4x damage multiplier
    	inst.components.hunger.hungerrate = 4 -- 4x hunger rate
    	inst.components.health:SetAbsorptionAmount (-0.5) -- 50% more damage taken
   end
end

I can work on the regeneration after class.

 

Edited by Kyrogeniz

Did the last code work? I'm experimenting with triggering regeneration states now.

Quote

function HealthRegeneration(inst)
	if inst.components.sanity.current > 100 and inst.components.health.current < 100 then --set that to the max hp in them all
		inst.components.health:StartRegen(2,2) --amount, period
	elseif inst.components.sanity.current > 50 and inst.components.health.current < 100 then 
		inst.components.health:StartRegen(4,2)
	elseif inst.components.sanity.current < 50 and inst.components.health.current < 100 then 
		inst.components.health:StartRegen(6,2)
	end
end

 

 

Here's my theory; it's untested cause I'm going to eat soon, but lemme know if it helps out! @Andreasgamming

Well the health Regen isn't based on the sanity like the hunger rate and the strength is... I need is to be passive and strong enough to at least give players a little time to find food before they die. I would also like to know how to make night vision toggle-able, have players being able to turn their night vision on or off with the push of a key or a configuration...

46 minutes ago, Andreasgamming said:

Well the health Regen isn't based on the sanity like the hunger rate and the strength is... I need is to be passive and strong enough to at least give players a little time to find food before they die. I would also like to know how to make night vision toggle-able, have players being able to turn their night vision on or off with the push of a key or a configuration...

So for the health regen, then, just take the code straight out of it like this:

Quote

	function HealthRegeneration(inst)
		if inst.components.health.current < 100 then --set that to the max hp in them all
			inst.components.health:StartRegen(2,2) --amount, period
    	end
     end

 

 

 

Where did you place it? I copy-pasted it directly into Pryce's .lua and his master_postinit and it worked fine.

 

Quote

local master_postinit = function(inst)
	inst.soundsname = "pryce"
		
	inst.components.health:SetMaxHealth(200)
	inst.components.hunger:SetMax(170)
	inst.components.sanity:SetMax(90)

    inst.components.combat.damagemultiplier = 1.75
	
	inst.components.hunger.hungerrate = 1.5 * TUNING.WILSON_HUNGER_RATE
	
	inst.OnLoad = onload
   
	
	inst.components.health:StartRegen(2,2)
	
	inst:ListenForEvent("killed", onkilledother)
	
end

 

 
 

 

Edited by Kyrogeniz

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
×
  • Create New...