Sanity

This component adds sanity to your character. Sanity can be twisted and bent by the methods mentioned below (and the SanityAura component), but there are certain dangers when giving it to non-player creatures, so don’t do that unless you’re somewhat experienced already.

Component Sanity Fields

TypeNameDescription
numbermaxthe upper limit of sanity; lowering it doesn't make one insane, as "max" represents 100% sanity
numbercurrentthe current level of sanity
numberratethis number is not to be edited, it represents the change of current sanity (per second)
booleansanewhether the player is sane or vulnerable to shadow creeps
numberfxtimeThis value is not to be edited, and used for the insanity effects
numberdappernessThis is an inherent sanity rate, similiar to how the dapperness component works.
booleaninducedinsanitywhether the player wears a nightmare amulet or alike; forced insanity
number (percent)night_drain_multthis number is a multiplier for sanity loss in darkness
number (percent)neg_aura_multthis number is a multiplier for entities with a negative sanityaura component
numberpenaltyYou can lower the players upper sanity limit without bringing the total 100% down.

Component Sanity Methods

NameParameterReturnsDescription
IsSanenilbooleanreturns true when the shadow creatures are not materialised
IsCrazynilbooleaninverted version of IsSane
RecalculatePenaltynilnilUpdates the sanity penalty
GetPenaltyPercentnilnumber (percent)returns penalty/max
GetMaxSanitynilnumberconsiders penalty
GetPercentusepenaltynumber (percent)returns current/max; if usepenalty, then current/GetMaxSanity
SetPercentnumber (percent)nilsets the current sanity, ignoring penalty
SetMaxamountnilalso sets current to amount
DoDeltavalue, overtimeniladds or subtracts the value from the current. overtime doesn't do anything
Recalcdt (time)nilrecalculates and applies the sanity rate for that long (in seconds), and updates the badge (even when dt is 0)

Example