Morale-boosting trait -- mod or build?


I’d like to add a trait that provides a constant morale boost. I’ve tried to look at the wiki, but I haven’t made a lot of progress with the Lua page. I asked on IRC, but I was met with ‘just take optimist’.

For this trait, is it possible to be done through a mod, or would I have to compile the source code with the trait?


Unfortunately at the moment morale boost types are hardcoded, meaning that even if you got the boost working through lua, you’d have to either override optimist (ie. make the new mutation incompatible with it and use the same morale message), edit the sources or use some other morale type and have wrong messages.

Another problem is that there aren’t many lua hooks implemented yet. The closest one would be on_day_passed, but this doesn’t trigger until the end of the first day.

If it’s OK for the trait not to work in the first day and use the optimist message, the lua function would look roughly like:

function MOD.on_day_passed()
    player:add_morale("MORALE_PERM_OPTIMIST", bonus_value_here, bonus_value_here, 10 * 60 * 24, 10 * 60 * 24)

For example on how to set up the mod, check the existing StatsThroughSkills mod. Actually just copy it and change the .on_day_passed to what I provided above, then adjust until it works.

It would need to be more reactive than once per day (I’m thinking like the Stylish trait), but I’ll still take a look at the StatsThroughSkills mod to check out how it works – for now, it seems like I’ll have to wait for more Lua hooks.

Thanks for the response anyway!

Amusing fact if you set the world time to start at 0, then StatsThroughSkills will trigger right at the start, useful if you steal point off stats to add to skills (with the minor effect of starting in darkness…better then running around with 4str?) the mod is overpoweringly broken once you get past the first month… think it should start at 6-7 (maybe less to give a reason TO take the extra points) rather then 8 and take more skill for the 3rd stat gain…

thinking about it may try a run with skill rust off and turning off skill leveling up…

was optimists +5 to weak for you? (dosn’t feel that traits worth taking)

No, Optimist isn’t too weak – it’s one of my favorite traits. I just wanted to make a trait in the style of Optimist’s constant boost that triggers similarly to Stylish.