Jump to content

Recommended Posts

Hello! 

I was wondering if I could get some assistance on a few perks. 

* How can you consume a normally non-consumable item and get your character to gain health from it such as Dark Petals?

* Make it so your character has more/less natural protection due to the more or less hunger they have. i.e if a character was at 130/150 hunger they'd get a 25% buff from damage, but if they were at 15/150 hunger they'd take 30% more damage. 

* Can you inversely insulate a beard? i.e cools you in summer and winter instead of providing cold protection in winter 

* Instantly die at 0 hunger.

Also I was working on making it so the character has increased damage at night, normal damage at dusk, and less damage in the day but the code I was using doesn't seem to work for DST. It gives me the following error:

Spoiler

errroereroer.PNG

I've uploaded a copy of the mod down below. Any help at all would be very appreciated!

shadowwilson.zip

Link to comment
Share on other sites

1. give the prefab the edible component, and make it a foodtype that only your character can eat

2. you can do this by listening to the "hungerdelta" event

3. not sure

4. listen for "startstarving" event

inst:ListenForEvent("startstarving", function(inst)
	if inst.components.health then
		inst.components.health:Kill()
	end
end)

Issue: GetClock():IsNight() is not in DST you have to do TheWorld.state.isnight

Link to comment
Share on other sites

1. I tried doing a 

FOODTYPE.SHADOW = "NIGHTMAREFUEL"
   
  inst.components.eater:SetDiet( { FOODGROUP.OMNI }, { FOODTYPE.SHADOW } )
  inst.components.eater:SetCanEatShadow()
  inst.components.eater:SetOnEatFn( oneat )

but it just ended up crashing the game. 

2. What would be the code for the buff?  Is it similar to           

             inst.components.combat.damagemultiplier = #

3. That's alright, thank you!
4. That's perfect! 
 

That completely fixed it and it's working like a charm. Many thanks for your help so far!

Link to comment
Share on other sites

3. You could try inst.components.beard.insulation_factor = -1 or some other negative number. This should increase your insulation in the summer (keeping you cold for a longer time) and decrease your insulation in the winter (keeping you warm for a shorter time).

Link to comment
Share on other sites

2. (i didn't test it but it should work)

inst:ListenForEvent("hungerdelta", function(inst, data)
	local damagepercent = data.newpercent - .7
	if damagepercent >= 0 then--ranges from +0% to +30% damage buff
		inst.components.combat.damagemultiplier = 1 + damagepercent-- 1 + X, change the 1 to the base damage your character has if any
	end
end)

inst:ListenForEvent("attacked", function(inst, data)
	local hunger = inst.components.hunger and inst.components.hunger:GetPercent() or nil
	if hunger and hunger <= 0.3 and data.damage ~= 0 then--ranges from 0% to 30% extra damage
		local extradamage = data.damage * (.3 - hunger)
		inst.components.combat:GetAttacked(data.attacker, extradamage, data.weapon, data.stimuli)
	end
end)

1. SetCanEatShadow() function doesn't exist, so you can remove that line

Link to comment
Share on other sites

7 hours ago, Muche said:

3. You could try inst.components.beard.insulation_factor = -1 or some other negative number. This should increase your insulation in the summer (keeping you cold for a longer time) and decrease your insulation in the winter (keeping you warm for a shorter time).

Thank you, I think that worked, but I'll do further testing to make sure!
 

Spoiler
5 hours ago, Aquaterion said:

2. (i didn't test it but it should work)



inst:ListenForEvent("hungerdelta", function(inst, data)
	local damagepercent = data.newpercent - .7
	if damagepercent >= 0 then--ranges from +0% to +30% damage buff
		inst.components.combat.damagemultiplier = 1 + damagepercent-- 1 + X, change the 1 to the base damage your character has if any
	end
end)

inst:ListenForEvent("attacked", function(inst, data)
	local hunger = inst.components.hunger and inst.components.hunger:GetPercent() or nil
	if hunger and hunger <= 0.3 and data.damage ~= 0 then--ranges from 0% to 30% extra damage
		local extradamage = data.damage * (.3 - hunger)
		inst.components.combat:GetAttacked(data.attacker, extradamage, data.weapon, data.stimuli)
	end
end)

1. SetCanEatShadow() function doesn't exist, so you can remove that line

 

2. That works just fine, thank you very much!
1. I deleted that line but it still caused a crash without text upon booting up the server with the mod on it.

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