Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Randomising Stats

6 years ago

I've been toying with the idea of a randomise button for the 7 stats you can pick in my storygame. When I started actually trying to script the damn thing, it all started to become a lot more complex! I've been thinking about how to do it a little bit today and had a go at starting to script it, but my method would take a long time to and I was wondering if anybody knows a more efficient/quicker way of doing it, or has any ideas. Below is roughly what I've scripted so far, though I know it has some issues (also stated below. I'm sure I've missed others as well though). %ZMAXSTAT keeps track of the 15 points you can spend overall on these stats. I realised this way you kind of have to work backwards, using loads of 'BEGIN's and filling out each combination it could be from the bottom up (I think), hence why a lot of the 'BEGIN's don't have 'END's. @P409 returns the player to the stat page where they hit the randomise button in the first place so they can see their stats via On Page Script etc.

%CUNNING:= 0
%INTELLECT:= 0
%STRENGTH:= 0
%SNEAK:= 0
%MAGIC:= 0
%SKILL:= 0
%LUCK:= 0
%ZMAXSTAT:= 0

%RAND:= 1D7
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%CUNNING:= %CUNNING + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
IF %ZMAXSTAT = 0 THEN $DEST:= @P409
ELSE THEN %RAND:= 1D6 
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%INTELLECT:= %INTELLECT + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
IF %ZMAXSTAT < 1 THEN $DEST:= @P409         
//Going below 0 is something I'll need to resolve later. See bottom//

ELSE THEN %RAND:= 1D5 
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%LUCK:= %LUCK + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
IF %ZMAXSTAT < 1 THEN $DEST:= @P409
ELSE THEN %RAND:= 1D4 
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%MAGIC:= %MAGIC + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
IF %ZMAXSTAT < 1 THEN $DEST:= @P409
ELSE THEN %RAND:= 1D3 
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%SKILL:= %SKILL + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
IF %ZMAXSTAT < 1 THEN $DEST:= @P409
ELSE THEN %RAND:= 1D2 
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%SNEAK:= %SNEAK + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
%STRENGTH:= %STRENGTH + (15 - %ZMAXSTAT)
END
ELSE IF %RAND = 2 THEN
BEGIN
%RAND:= 1D15 
%STRENGTH:= %STRENGTH + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
%SNEAK:= %SNEAK + (15 - %ZMAXSTAT)
END
ELSE IF %RAND = 2 THEN

BEGIN
%RAND:= 1D15 
%SNEAK:= %SNEAK + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
IF %ZMAXSTAT < 1 THEN $DEST:= @P409
ELSE THEN %RAND:= 1D2 
IF %RAND = 1 THEN
BEGIN
%RAND:= 1D15 
%SKILL:= %SKILL + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
%STRENGTH:= %STRENGTH + (15 - %ZMAXSTAT)
END
ELSE IF %RAND = 2 THEN
BEGIN
%RAND:= 1D15 
%STRENGTH:= %STRENGTH + %RAND
%ZMAXSTAT:= %ZMAXSTAT - %RAND
%SKILL:= %SKILL + (15 - %ZMAXSTAT)
END...

...And then at the bottom would be the rest that sorts out all the other combinations in the same kind of way, addressing each of the 'BEGIN's used earlier on. Then I'd copy and paste that 7 times, make the needed adjustments for the 1D7 roll being 2, 3, 4... etc. and all of the branching combinations for each of those, and have my probably-not-worth-it-but-hell-I-love-me-some-polish randomise button. 

Also, if this would even work (which I have no idea if it would. Might make a smaller model with maybe 2 or 3 stats in a bit to see), there are some issues. For one, the 1D15 rolls not only make it highly improbable to get a nice spread of stats with the randomise, but also can make the %ZMAXSTAT variable drop below zero. While I think I can sort out the latter issue fairly easily, I was considering lowering the dice roll to 1D10, or having increasingly low or random dice rolls to determine the value of each stat. While this wouldn't be entirely random, it would make the stats randomise in a better way (I think!). I just feel like there's a glaringly obvious better way of doing this I'm missing.

Randomising Stats

6 years ago
Probably easiest if you simply add 1 to each stat randomly 15 times.

%RAND := 1D7
IF %RAND = 1 THEN %CUNNING := %CUNNING + 1
IF %RAND = 2 THEN %INTELLECT := %INTELLECT + 1
IF %RAND = 3 THEN %STRENGTH := %STRENGTH + 1
IF %RAND = 4 THEN %SNEAK := %SNEAK + 1
IF %RAND = 5 THEN %MAGIC := %MAGIC + 1
IF %RAND = 6 THEN %SKILL := %SKILL + 1
IF %RAND = 7 THEN %LUCK := %LUCK + 1

And repeat the above lines 14 more times (because we sadly do not have loops).

Randomising Stats

6 years ago

Agh! I knew there was an easier way. Killa man, you've just saved me hours of scripting and thinking and it's a hell of a better system than my absolutely filthy script. I've got a bad habit of overcomplicating stuff so thank you so much!!

Randomising Stats

6 years ago
Indeed, nice way to quickly turn the logic around effectively, Killa!