Goregonzola Posted June 3, 2021 Share Posted June 3, 2021 (edited) Hey everyone! I recently had a showerthought about randomness in DST. Most mobs and characters have strict values and attributions in their codings. There came the idea: What if I would create a character that would have randomly changing abilities? I'm curious: Is there a (not too advanced) way to add something like these to a survivor: - Randomly adding or removing certain tags to/from a survivor every in-game day - Randomly changing damage multiplier after a certain action (let's say eating) - with predefined min and max values I didn't faced such roulette-like codings so far. Is there a way I could approach these and similar ideas? Is there any in-game lua file that could serve as a reference? I don't expect fully polished codings from you (though, if you have some on the tip of your tounge, I wouldn't refuse them either), I'm mostly curious about a general strategy or a reference. I'm really excited! Thanks in advance! Cheers! Edited June 6, 2021 by C_Thun Link to comment https://forums.kleientertainment.com/forums/topic/130500-answered-how-much-randomness-can-be-added-to-an-entity/ Share on other sites More sharing options...
Monti18 Posted June 5, 2021 Share Posted June 5, 2021 Well randomness is pretty easy to add, you can just use math.random. For example, adding or removing tags: local tags = { "tag1", "tag2", "tag3", } local function IsDay(inst) local tag = tags[math.random(1,3)] inst:AddTag(tag) end inst:WatchWorldState("startday", IsDay) We have a table and get a random tag from a certain list at the beginning of a day. If you want to change the damage multiplier after eating, you call SetOnEatFn and add your changes: local function EatingDamage(inst) inst.components.combat.damagemultiplier = math.random(50,150)/100 end inst.components.eater:SetOnEatFn(EatingDamage) This function changes the damagemultiplier after each thing that was eaten to a random value between 0.5 and 1.5. If you need more help, let me know 1 1 Link to comment https://forums.kleientertainment.com/forums/topic/130500-answered-how-much-randomness-can-be-added-to-an-entity/#findComment-1466680 Share on other sites More sharing options...
Goregonzola Posted June 6, 2021 Author Share Posted June 6, 2021 Ah, thanks for the quick guide, @Monti18! I'm especially happy about the examples. I've discovered math.random as well, but since it's such a versatile tool, it's good to see how it should look like in such situations. Have a nice day! 1 Link to comment https://forums.kleientertainment.com/forums/topic/130500-answered-how-much-randomness-can-be-added-to-an-entity/#findComment-1466758 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now