Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Any way to tell which score is the highest?

4 years ago

So, what I want to do is to somehow have a different event occour depending on which stat is highest... So, if Strength is your highest stat, it goes to event A. If Speed is the highest, it goes to event B, ect... But I don't know how to script the game to figure out which os the stats is highest. frown

Any way to tell which score is the highest?

4 years ago
How many stats are there?

Any way to tell which score is the highest?

4 years ago

Five. Strength, Speed, Accuracy, Intelligence and Stealth. ^_^

Any way to tell which score is the highest?

4 years ago
And when you talk about "events," do you mean going to a specific page?

Any way to tell which score is the highest?

4 years ago

Yep. Was hoping I could do it with a Link Restriction, but that doesn't look possible (at least from what I can see.)

Any way to tell which score is the highest?

4 years ago
BEGIN
IF %STRENGTH > %SPEED
AND
IF %STRENGTH > %STEALTH
AND
(and so on)
$DEST := @P122
END

And then do that for each skill it checks for.

.....assuming AND isn't broken. Which it possibly could be. Something to do with either AND or OR is anyway but I can never remember what.

You should be able to use link restrictions though, the AND is already implied when you set but more than one variable. You need a link for each skill it's checking for and then ultimately only one will show up.

Any way to tell which score is the highest?

4 years ago
Sadly, I think that's the easiest way. It would be simple with arrays and loops, but we don't have those, so I think you're going to have piles of codes with lots and lots and lots of ANDs becuase you can't use the link restrictions and compare them. The only other way I could think of is keeping track when the stats change to see which one is the highest, but if your stats change in lots of places, that's just as much work...

Any way to tell which score is the highest?

4 years ago

Awesome! Thanks miz! So... Uhh... Since I'm a fucking idiot, where exactly do I put this code, and how to I make it apply to a certain page?

Any way to tell which score is the highest?

4 years ago
You would put it in the link script, but go with Brad's advice instead obviously. Although like I said it would work as a link restriction and that may be simpler for you. There's basically an invisible AND in between each of these:

Any way to tell which score is the highest?

4 years ago

Yeah, AND doesn't work with inequalities unfortunately. But you could calculate the maximum value and then check for which variable(s) equal(s) that maximum. It's possible some or all of them could be equal so you might need to tweak the stat order for tiebreaking.

%MAX := %STRENGTH
IF %SPEED > %MAX THEN %MAX := %SPEED
IF %ACCURACY > %MAX THEN %MAX := %ACCURACY
IF %INTELLIGENCE > %MAX THEN %MAX := %INTELLIGENCE
IF %STEALTH > %MAX THEN %MAX := %STEALTH

IF %STRENGTH = %MAX THEN # Strength is highest
ELSE IF %SPEED = %MAX THEN # Speed is highest
ELSE IF %ACCURACY = %MAX THEN # Accuracy is highest
ELSE IF %INTELLIGENCE = %MAX THEN # Intelligence is highest
ELSE # Stealth is highest

Any way to tell which score is the highest?

4 years ago

Unfortunately, the way the game works, it's highly unlikely that any of the stats will be at their maximum. 

Any way to tell which score is the highest?

4 years ago

Oh, no, I mean the maximum of the five current stat values. If the stats are currently 3, 1, 2, 5, and 4, then the max would be 5. Nothing to do with the potential maximum.

Any way to tell which score is the highest?

4 years ago

Oh, okay, I think I get it. Thank you! ^_^

Not sure how I could tweak it for a tie-break though. frown

Any way to tell which score is the highest?

4 years ago
Logically? You'd do the tests in order of what matters.

IF %STRENGTH = %MAX THEN # Strength is highest
ELSE IF %SPEED = %MAX THEN # Speed is highest
ELSE IF %ACCURACY = %MAX THEN # Accuracy is highest
ELSE IF %INTELLIGENCE = %MAX THEN # Intelligence is highest
ELSE # Stealth is highest

Right now the priority is Strength > Speed > Accuracy > Intelligence > Stealth.

If Speed and Stealth are tied, Speed is chosen.
If Accuracy and Intelligence are tied, Accuracy is chosen.
If Strength, Speed and Stealth are tied, Strength is chosen.

Etc, etc. If you want a more intelligent tied break... well it'd require a good deal more coding lol.

Any way to tell which score is the highest?

4 years ago

Nah, I'm cool. Thanks Killa ^_^

Any way to tell which score is the highest?

4 years ago

... Oh wow, I actually figured out a way that works! (Used that %MAX thingy Brad showed me and then created another variable to keep track of what skill actually is the %MAX, and then used that variable as a Link Restriction... Thanks so much guys! ... Was also kind of hoping there was a way to track the second highest stat... But I don't think my poor little brain would be able to wrap itself around that in a million years. cheeky

Any way to tell which score is the highest?

4 years ago

Also managed to track the lowest score... This is a good day. ^_^

Any way to tell which score is the highest?

4 years ago

I'd imagine that you could just go through the max check thing but ignoring the highest option once (by having an extra variable to figure out if you ignored the change once so far or not, in case you have two variables sharing the maximum). (If you want to ignore the value if it is equal to max then it should be easier to do).

Note that %EXTRA starts as 0, it is the extra variable I'm using for finding the second highest. %MAX2 is second highest.

IF %MAX = %STRENGTH THEN %EXTRA := 1
ELSE %MAX2 := %STRENGTH

IF %MAX = %SPEED THEN IF %EXTRA = 1 THEN %MAX2 := %SPEED ELSE
IF %EXTRA != 1 THEN
IF %MAX2 < %SPEED THEN %MAX2 := %SPEED

IF %MAX = %ACCURACY THEN IF %EXTRA = 1 THEN %MAX2 := %ACCURACY ELSE
IF %EXTRA != 1 THEN
IF %MAX2 < %ACCURACY THEN %MAX2 := %ACCURACY

IF %MAX = %INTELLIGENCE THEN IF %EXTRA = 1 THEN %MAX2 := %INTELLIGENCE ELSE
IF %EXTRA != 1 THEN
IF %MAX2 < %INTELLIGENCE THEN %MAX2 := %INTELLIGENCE

IF %MAX = %STEALTH THEN IF %EXTRA = 1 THEN %MAX2 := %STEALTH ELSE
IF %EXTRA != 1 THEN
IF %MAX2 < %STEALTH THEN %MAX2 := %STEALTH

IF %STRENGTH = %MAX2 THEN # Strength is second highest
ELSE IF %SPEED = %MAX2 THEN # Speed is second highest
ELSE IF %ACCURACY = %MAX2 THEN # Accuracy is second highest
ELSE IF %INTELLIGENCE = %MAX2 THEN # Intelligence is second highest
ELSE # Stealth is second highest

Hope this works, according to my primitive testing it should(?) but I don't trust myself. I'm also not sure if I structured it properly, but it can be rearranged as desired.

EDIT - There is some redundancy in my checks, I think, but I'm too lazy to go check it myself so I'll just leave this unedited. Someone can always post a better version anyway.

Any way to tell which score is the highest?

4 years ago

Bloody hell that looks complex. Might be brave enough to try it out later, ^_^

Any way to tell which score is the highest?

4 years ago

Nah, can't seem to get it to work, and my poor brain is too small to figure out what's wrong with it... Still, knowing the second highest stat isn't really a must have. Thanks for trying though! heart