Jump to content

Question about a custom character perk


Recommended Posts

Hey guys! So, I just created a custom character for DST, and at this point the only thing left to do is add any custom stats and perks. The perk I'd like the character to have is that the lower their hunger is (as in, the lower the score/the hungrier they are) the higher their strength proportionately. So basically, that if the character is close to starving they are much stronger, and if they are full they are weaker. How would I go about programming this, and where would I put it? Under stats?

I would also be willing to go with what I assume would be a lot easier to program, where if the hunger goes below a certain set value, the character's strength immediately goes up to a higher set value, like a reversed Wolfgang.

 

Thanks!

Edited by Metajoker
Ability -> Perk
Link to comment
Share on other sites

Yes. Works similar with sanity, as posted in

local function CalculateStrength(inst, data)
	inst.components.combat.damagemultiplier = Remap(1 - data.newpercent, 0, 1, 0.75, 2.25)
end

local function master_postinit(inst)
	inst:ListenForEvent("hungerdelta", CalculateStrength)
end

This would be the equivalent code.

In the hunger component the hungerdelta event gets pushed to the player entity when the DoDelta method is executed. It gives a data table, with a newpercent key that holds the value that represents the percentage of how full you are.

So if you are full, percent 1, 1 - 1 is 0, 0 remaps to 0.75. You do less damage.

Starving, percent 0, 1 - 0 is 1, remaps to 2.25. Yo do more damage.

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