Page 1 of 1

Luck design doc

Posted: Fri Aug 06, 2021 9:43 pm
by PKPenguin321
Found this on my PC dated to October 2019, a design doc for what is basically a luck stat that would interact with the game in minor fun ways. I had forgotten all about this but I figure I might as well share it
Spoiler:

Code: Select all

main thing:
- all mobs now have a luck component that primarily stores a luck value (an int from -100 to 100).
  by default, this value is 0.

- generally, positive luck should not have a combat advantage (if it does, it should be very minimal).
  negative luck, however, should have major combat disadvantages.


helper procs:
- getluck(): checks if an atom has a luck component. if it does not, return the luck as 0.
  if it does, return the luck value.

- addluck(x): add x to luck value

- setluck(x): set luck value to x

- probluck(x): a prob() check where luck is flat added onto the end. IE: probluck(50) with a mob that has 10 luck
  is the same as prob(60). min cap 0, upper cap 100
  Examples:
  - chance of getting a good event in orion trail
  - chance of succeeding in a risky surgery operation

- lucksave(x, y): a prob() check where luck has a chance of being flat added. y is the prob of luck being added.
  by default, this value is set to luck, so 1 luck = 1/100 chance of 1 being added to a prob. (maybe make this
  an algorithm...) good for dice rolls or other things with small values.
  Examples:
  - literal ingame dice rolls (maybe not die of fate though)
  - chance to not drop things when you cough
  - chance to bump roulette wheel towards your chosen number
  - chance for flash to not burn out if it would have
  - chance that you get stun punched (negative luck only)

- getLucky(): equal to prob([luck value]). used for things where no prob previously existed.
  Examples:
  - orion trail glitches in your favor and grants free resources
  - "You slip on the water, but do a backflip and land on your feet!"
  - chance of avoiding appendictus (it gets passed to the next guy)
  - "Despite saying that you lost, the slot machine still spits out a coin. How fortunate!"

- getUnlucky(): if your luck is negative, this is prob(|[luck value]|). outputs should be bad
  Examples:
  - your arcade machine freezes in the middle of your game, so you have to reboot it and lose progress
  - "The slot machine starts to pay out your winnings, but the coin slot gets jammed..."
  - "The airlock doesn't notice you, and you bump headfirst into it. Ow..."
  - nanotrasen paycheck error means you dont get paid this cycle
  - slipping makes things fall out of your pockets, will activate any dropped grenades
  - getting up from a slip will make you slip *again*
  - harvesting plants has a lower yield, x* smaller yield for clovers where x is |your luck| (min 0).
  - you have a chance to screw up (de)construction steps of basic things like walls and windows
  - your gun jams and is disabled for a few seconds
  - when you throw something you accidentally only throw it a tile ahead
  - your voice can crack mid-sentence, giving you a wacky font
  - spells you cast misfire (like what happens when you read a used spellbook)
  - getting stunned can knock your shoes off
  - burn damage will ignite you


other examples:
 - prob(min(0, max((victim.getluck() - attacker.getluck())), 10))//prob(your luck - their luck) min 0 max 10
   	"[attacker] swings to punch you, but misses and hits [him/her]self instead!"

 - //die of fate
   roll = rand(1,20)
   if(roller.getUnlucky())
   	roll += roller.getluck
   	roll = min(1, roll)
   else if(roller.getLucky())
   	roll += floor(roller.getluck()/10)
   	roll = max(20, roll)

luck modifiers:
- lucky trait: +3 luck

- unlucky trait: -3 luck

- break a mirror: -7 luck for 7 minutes

- add a boon/punishment admins can do on prayers that give/remove luck.

- being a bit drunk/high makes you luckier, being blackout drunk/hallucinating makes you un-luckier

- new alcohol that specifically raises your luck by a slight extra amount, a second new alcohol that lowers it

- (lavaland?) cursed amulet of luck: you can choose to either permanently gain +30 luck at the cost of taking 5% more damage, or take 5% less at the cost of -30 luck

- corgi paw necklace: get a corgi paw by butchering a corgi. add it to a necklace chain to make a necklace.
  making the necklace gives you a curse of -5 luck, but wearing it gives +5 luck.

- new plant, clovers, can be eaten for a status effect that gives luck. if you have luck, they have a chance
  of being x-leafed (x = 3 + luck), giving 2x the luck.
  - green beers and clover cakes can be made that give a stronger version of the effect that stacks with the first

- devils are very lucky (+50), and their contracts can steal luck from whoever signs them. this would
  siphon 5(?) luck.

- wizards can see luck on examine, and can buy an amulet of extreme luck that gives a flat buff to luck (+50?)
  and prevents all luck loss. goes in necklace slot.

- chaplains smacking you with a bible blesses you with better luck for a short time

- summon event that applies a status effect on all mobs that modifies sets luck to a random amount for a decent time.
  ("You feel as though your destiny has slipped away...")

- wand of misfortune, which gives the victim a 1 minute debuff that sets their luck to -100

- lavaland reward: miracle cream. 5-use item that
  gives a 30 second buff of +100 luck (and a random genetics power?).


other additions:
- new span class that's like notify but green, for when lucky things happen to you
https://pastebin.com/jGG0SP1U

Re: Luck design doc

Posted: Fri Aug 06, 2021 10:58 pm
by RaveRadbury
I love Luck stat

Re: Luck design doc

Posted: Fri Aug 06, 2021 11:25 pm
by Super Aggro Crag
luck

Re: Luck design doc

Posted: Sat Aug 07, 2021 1:14 am
by Armhulen
I've always really liked the idea, it's just come with the understanding that the code cost of implementing it is huge and repository wide which sucks. you have to manually sort every probability into something that can be lucky and based off of someone and a probability that should be immutable

Re: Luck design doc

Posted: Sat Aug 07, 2021 1:22 am
by PKPenguin321
Armhulen wrote:I've always really liked the idea, it's just come with the understanding that the code cost of implementing it is huge and repository wide which sucks. you have to manually sort every probability into something that can be lucky and based off of someone and a probability that should be immutable
The doc pretty much says it should only actually take luck into consideration on a few select things, but yeah you would have to pretty much comb through a lot of prob() calls to see where it would fit in

Re: Luck design doc

Posted: Sat Aug 07, 2021 1:36 am
by Shadowflame909
PKPenguin321 wrote:Found this on my PC dated to October 2019, a design doc for what is basically a luck stat that would interact with the game in minor fun ways. I had forgotten all about this but I figure I might as well share it
Spoiler:

Code: Select all

main thing:
- all mobs now have a luck component that primarily stores a luck value (an int from -100 to 100).
  by default, this value is 0.

- generally, positive luck should not have a combat advantage (if it does, it should be very minimal).
  negative luck, however, should have major combat disadvantages.


helper procs:
- getluck(): checks if an atom has a luck component. if it does not, return the luck as 0.
  if it does, return the luck value.

- addluck(x): add x to luck value

- setluck(x): set luck value to x

- probluck(x): a prob() check where luck is flat added onto the end. IE: probluck(50) with a mob that has 10 luck
  is the same as prob(60). min cap 0, upper cap 100
  Examples:
  - chance of getting a good event in orion trail
  - chance of succeeding in a risky surgery operation

- lucksave(x, y): a prob() check where luck has a chance of being flat added. y is the prob of luck being added.
  by default, this value is set to luck, so 1 luck = 1/100 chance of 1 being added to a prob. (maybe make this
  an algorithm...) good for dice rolls or other things with small values.
  Examples:
  - literal ingame dice rolls (maybe not die of fate though)
  - chance to not drop things when you cough
  - chance to bump roulette wheel towards your chosen number
  - chance for flash to not burn out if it would have
  - chance that you get stun punched (negative luck only)

- getLucky(): equal to prob([luck value]). used for things where no prob previously existed.
  Examples:
  - orion trail glitches in your favor and grants free resources
  - "You slip on the water, but do a backflip and land on your feet!"
  - chance of avoiding appendictus (it gets passed to the next guy)
  - "Despite saying that you lost, the slot machine still spits out a coin. How fortunate!"

- getUnlucky(): if your luck is negative, this is prob(|[luck value]|). outputs should be bad
  Examples:
  - your arcade machine freezes in the middle of your game, so you have to reboot it and lose progress
  - "The slot machine starts to pay out your winnings, but the coin slot gets jammed..."
  - "The airlock doesn't notice you, and you bump headfirst into it. Ow..."
  - nanotrasen paycheck error means you dont get paid this cycle
  - slipping makes things fall out of your pockets, will activate any dropped grenades
  - getting up from a slip will make you slip *again*
  - harvesting plants has a lower yield, x* smaller yield for clovers where x is |your luck| (min 0).
  - you have a chance to screw up (de)construction steps of basic things like walls and windows
  - your gun jams and is disabled for a few seconds
  - when you throw something you accidentally only throw it a tile ahead
  - your voice can crack mid-sentence, giving you a wacky font
  - spells you cast misfire (like what happens when you read a used spellbook)
  - getting stunned can knock your shoes off
  - burn damage will ignite you


other examples:
 - prob(min(0, max((victim.getluck() - attacker.getluck())), 10))//prob(your luck - their luck) min 0 max 10
   	"[attacker] swings to punch you, but misses and hits [him/her]self instead!"

 - //die of fate
   roll = rand(1,20)
   if(roller.getUnlucky())
   	roll += roller.getluck
   	roll = min(1, roll)
   else if(roller.getLucky())
   	roll += floor(roller.getluck()/10)
   	roll = max(20, roll)

luck modifiers:
- lucky trait: +3 luck

- unlucky trait: -3 luck

- break a mirror: -7 luck for 7 minutes

- add a boon/punishment admins can do on prayers that give/remove luck.

- being a bit drunk/high makes you luckier, being blackout drunk/hallucinating makes you un-luckier

- new alcohol that specifically raises your luck by a slight extra amount, a second new alcohol that lowers it

- (lavaland?) cursed amulet of luck: you can choose to either permanently gain +30 luck at the cost of taking 5% more damage, or take 5% less at the cost of -30 luck

- corgi paw necklace: get a corgi paw by butchering a corgi. add it to a necklace chain to make a necklace.
  making the necklace gives you a curse of -5 luck, but wearing it gives +5 luck.

- new plant, clovers, can be eaten for a status effect that gives luck. if you have luck, they have a chance
  of being x-leafed (x = 3 + luck), giving 2x the luck.
  - green beers and clover cakes can be made that give a stronger version of the effect that stacks with the first

- devils are very lucky (+50), and their contracts can steal luck from whoever signs them. this would
  siphon 5(?) luck.

- wizards can see luck on examine, and can buy an amulet of extreme luck that gives a flat buff to luck (+50?)
  and prevents all luck loss. goes in necklace slot.

- chaplains smacking you with a bible blesses you with better luck for a short time

- summon event that applies a status effect on all mobs that modifies sets luck to a random amount for a decent time.
  ("You feel as though your destiny has slipped away...")

- wand of misfortune, which gives the victim a 1 minute debuff that sets their luck to -100

- lavaland reward: miracle cream. 5-use item that
  gives a 30 second buff of +100 luck (and a random genetics power?).


other additions:
- new span class that's like notify but green, for when lucky things happen to you
https://pastebin.com/jGG0SP1U
Oh man I'd totally be the dude who when the long shift gets boring makes 1000 corgi paws just to get trolled by the game. Sounds like a fun time

Re: Luck design doc

Posted: Sat Aug 07, 2021 2:52 am
by Mothblocks
seems funny

Re: Luck design doc

Posted: Sat Aug 07, 2021 6:25 am
by Farquaar
I dig it.

Re: Luck design doc

Posted: Sat Aug 07, 2021 5:49 pm
by Agux909
+1 sounds like fun.

A question tho. What defines the amount of luck/bad luck you accumulate? Or is it completely random?

Re: Luck design doc

Posted: Sat Aug 07, 2021 8:31 pm
by PKPenguin321
Agux909 wrote:+1 sounds like fun.

A question tho. What defines the amount of luck/bad luck you accumulate? Or is it completely random?
It says so in the doc under luck modifiers. Traits, certain items, a new botany blant, drunkenness, blessed by the chaplain...

Re: Luck design doc

Posted: Sat Aug 07, 2021 9:14 pm
by Agux909
PKPenguin321 wrote:
Agux909 wrote:+1 sounds like fun.

A question tho. What defines the amount of luck/bad luck you accumulate? Or is it completely random?
It says so in the doc under luck modifiers. Traits, certain items, a new botany blant, drunkenness, blessed by the chaplain...
Missed that, thanks. Also that's cool!