Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Mad Poster
Original Poster
#1 Old 29th Jul 2018 at 8:41 PM
Default Some issues with BHAVs
I'm working on a very old project that XPTL helped me with back in 2011-ish, but I never finished. Basically it's a "working" baby scale cloned from a changing table, with some added functionality, where instead of changing the diaper the baby lies on the table for a bit, and a dialog with a random weight comes up (nice for a hospital setting, or for when people want to randomize play with preemies or some such).

I wanted to add some more weight options, because there are just 4 in the original object. I thought it would be nice with some 8-10 options. However, I'm a BHAV noob, so I'm not entirely sure how to continue, which buttons to press, and whether I need those "expression" lines every so often.

Does anybody know?
Screenshots
Advertisement
Field Researcher
#2 Old 30th Jul 2018 at 8:55 AM
I would have tested



The Dialog Wizard:
Screenshots
Scholar
#3 Old 30th Jul 2018 at 2:49 PM
You actually only have three options there. The first line sets temp 0 to a random value from 0 to less than 3, so 2 is the highest it can be and the last line will never be used.
You can use the local variables to have an infinite range. The example here uses the baby's hunger motive instead of a random number so a well fed baby will weigh more than a hungry one.
Note that the values you see in the image are hex values while the values I type here are the decimal values

Line 0, you must send the baby's ID as the parameter.
Line 1, Local:0 will be the grams value, begins with baby's hunger motive (range of -100 to 100)
Line 2, Add 260 to get a usable value (range is now 160 to 360), increase or decrease this value to adjust the result if too low or high
Line 3, multiply by 18 to get the final grams value, increase or decrease this value to change the range of results
Line 4 & 5, We're going to half the value for newborns, a baby ready to age to toddler should weigh a lot more than a new one.
Line 4 & 5, We don't just divide by 'age days left' or anyone using an age mod could get really weird results
Line 6, Local:1 is the pounds value
Line 7, begin to convert to ounces, we need to divide by 28 but the op-codes truncate fractions so 6.99 will result in just 6
Line 8 & 9, By dividing by half the amount we want then adding 1 before dividing by 2 we effectively add 0.5 so the result will round to the nearest whole number
Line A, Local:2 is ounces
Line B, Mod basically is the remaining value after division, 16 ounces to a pound so Mod 16 removes the pounds and results in the leftover ounces
Line C, Convert Local:1 from ounce to pounds. Truncating the fractions works in our favour here

This image is the result of weighing a newborn girl, the first dialogue (the lower one) is normal, the next one was right after using max motives cheat.
Screenshots
Attached files:
File Type: zip  WeighBubExample.zip (416 Bytes, 3 downloads) - View custom content
Mad Poster
Original Poster
#4 Old 30th Jul 2018 at 4:25 PM
Quote:
You actually only have three options there. The first line sets temp 0 to a random value from 0 to less than 3, so 2 is the highest it can be and the last line will never be used.


Is there a way to fix and increase the options in the example I posted? I'd really like it to just be random and pick between a bunch of options (but your example could probably work, too - I'll give it a go if I can't figure out the random version).
Alchemist
#5 Old 30th Jul 2018 at 4:46 PM
If you just want it to be random, you can use the code clsve posted.
Back to top