Hello again! I'm attempting to construct a simple turn based rpg that involves an agility stat.
Monsters and the player can have an agility of between 1-65. That inherent agility is added with a random number between 1-35. Then the higher number gets to act first such as attack or run away. I'm not a math guru so I did something pretty simple.
I've been able to determine the higher number as long as it is only two numbers using a function I've seen in the wiki.
something like if (PlayerAgi >= MonsterAgi) >><stuff>
I don't know how to get the highest number when there are 3 or more agility stats being compared though.
I've been able to generate the random numbers and everything so far, but I don't know how to give twine more than two numbers.
What if its:
PartyMember1/PartyMember2/Monster1/Monster2 and each one has a different value. How do I calculate the order? Do I need to just use a page worth of 1-to-1 comparisons or is there a simpler short hand way? This is SugarCane 1.42.
Comments
Here's the code for anyone having the same issue, though I didn't use generic names and again it's huge:
<<if $MonsterAgilityTemp >= $JonathanAgilityTemp and $MonsterAgilityTemp >= $ElijahAgilityTemp and $MonsterAgilityTemp >= $MicChreaAgilityTemp >>
<<set $First = "Monster">>
<<if $JonathanAgilityTemp >= $ElijahAgilityTemp and $JonathanAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Second = "Jonathan">>
<<if $ElijahAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Third to "Elijah">>
<<set $Fourth to "Chrea" >>
<<else if $MicChreaAgilityTemp
>= $ElijahAgilityTemp>>
<<set $Third to "Chrea">>
<<set $Fourth to "Elijah">>
<<endif>>
<<else if $ElijahAgilityTemp >= $JonathanAgilityTemp and $ElijahAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Second = "Elijah">>
<<if $JonathanAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Third to "Jonathan">>
<<set $Fourth to "Chrea">>
<<else if $MicChreaAgilityTemp
>= $JonathanAgilityTemp>>
<<set $Third to "Chrea">>
<<set $Fourth to "Jonathan">>
<<endif>>
<<else if $MicChreaAgilityTemp >= $JonathanAgilityTemp and $MicChreaAgilityTemp >= $ElijahAgilityTemp>>
<<set $Second = "Chrea">>
<<if $JonathanAgilityTemp >= $ElijahAgilityTemp>>
<<set $Third to "Jonathan">>
<<set $Fourth to "Elijah" >>
<<else if $ElijahAgilityTemp
>= $JonathanAgilityTemp>>
<<set $Third to "Elijah">>
<<set $Fourth to "Jonathan">>
<<endif>>
<<endif>>
<<elseif $JonathanAgilityTemp >= $MonsterAgilityTemp and $JonathanAgilityTemp >= $ElijahAgilityTemp and $JonathanAgilityTemp >= $MicChreaAgilityTemp >>
<<set $First = "Jonathan">>
<<if $MonsterAgilityTemp >= $ElijahAgilityTemp and $MonsterAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Second = "Monster">>
<<if $ElijahAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Third to "Elijah">>
<<set $Fourth to "Chrea" >>
<<else if $MicChreaAgilityTemp
>= $ElijahAgilityTemp>>
<<set $Third to "Chrea">>
<<set $Fourth to "Elijah">>
<<endif>>
<<else if $ElijahAgilityTemp >= $MonsterAgilityTemp and $ElijahAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Second = "Elijah">>
<<if $MonsterAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Third to "Monster">>
<<set $Fourth to "Chrea">>
<<else if $MicChreaAgilityTemp
>= $MonsterAgilityTemp>>
<<set $Third to "Chrea">>
<<set $Fourth to "Monster">>
<<endif>>
<<else if $MicChreaAgilityTemp >= $MonsterAgilityTemp and $MicChreaAgilityTemp >= $ElijahAgilityTemp>>
<<set $Second = "Chrea">>
<<if $MonsterAgilityTemp >= $ElijahAgilityTemp>>
<<set $Third to "Monster">>
<<set $Fourth to "Elijah" >>
<<else if $ElijahAgilityTemp
>= $MonsterAgilityTemp>>
<<set $Third to "Elijah">>
<<set $Fourth to "Monster">>
<<endif>>
<<endif>>
<<elseif $ElijahAgilityTemp >= $JonathanAgilityTemp and $ElijahAgilityTemp >= $MonsterAgilityTemp and $ElijahAgilityTemp >= $MicChreaAgilityTemp >>
<<set $First = "Elijah">>
<<if $JonathanAgilityTemp >= $MonsterAgilityTemp and $JonathanAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Second = "Jonathan">>
<<if $MonsterAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Third to "Monster">>
<<set $Fourth to "Chrea" >>
<<else if $MicChreaAgilityTemp
>= $MonsterAgilityTemp>>
<<set $Third to "Chrea">>
<<set $Fourth to "Monster">>
<<endif>>
<<else if $MonsterAgilityTemp >= $JonathanAgilityTemp and $MonsterAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Second = "Monster">>
<<if $JonathanAgilityTemp >= $MicChreaAgilityTemp>>
<<set $Third to "Jonathan">>
<<set $Fourth to "Chrea">>
<<else if $MicChreaAgilityTemp
>= $JonathanAgilityTemp>>
<<set $Third to "Chrea">>
<<set $Fourth to "Jonathan">>
<<endif>>
<<else if $MicChreaAgilityTemp >= $JonathanAgilityTemp and $MicChreaAgilityTemp >= $MonsterAgilityTemp>>
<<set $Second = "Chrea">>
<<if $JonathanAgilityTemp >= $MonsterAgilityTemp>>
<<set $Third to "Jonathan">>
<<set $Fourth to "Monster" >>
<<else if $MonsterAgilityTemp
>= $JonathanAgilityTemp>>
<<set $Third to "Monster">>
<<set $Fourth to "Jonathan">>
<<endif>>
<<endif>>
<<elseif $MicChreaAgilityTemp >= $JonathanAgilityTemp and $MicChreaAgilityTemp >= $ElijahAgilityTemp and $MicChreaAgilityTemp >= $MonsterAgilityTemp >>
<<set $First = "MicChrea">>
<<if $JonathanAgilityTemp >= $ElijahAgilityTemp and $JonathanAgilityTemp >= $MonsterAgilityTemp>>
<<set $Second = "Jonathan">>
<<if $ElijahAgilityTemp >= $MonsterAgilityTemp>>
<<set $Third to "Elijah">>
<<set $Fourth to "Monster" >>
<<else if $MonsterAgilityTemp
>= $ElijahAgilityTemp>>
<<set $Third to "Monster">>
<<set $Fourth to "Elijah">>
<<endif>>
<<else if $ElijahAgilityTemp >= $JonathanAgilityTemp and $ElijahAgilityTemp >= $MonsterAgilityTemp>>
<<set $Second = "Elijah">>
<<if $JonathanAgilityTemp >= $MonsterAgilityTemp>>
<<set $Third to "Jonathan">>
<<set $Fourth to "Monster">>
<<else if $MonsterAgilityTemp
>= $JonathanAgilityTemp>>
<<set $Third to "Monster">>
<<set $Fourth to "Jonathan">>
<<endif>>
<<else if $MonsterAgilityTemp >= $JonathanAgilityTemp and $MonsterAgilityTemp >= $ElijahAgilityTemp>>
<<set $Second = "Monster">>
<<if $JonathanAgilityTemp >= $ElijahAgilityTemp>>
<<set $Third to "Jonathan">>
<<set $Fourth to "Elijah" >>
<<else if $ElijahAgilityTemp
>= $JonathanAgilityTemp>>
<<set $Third to "Elijah">>
<<set $Fourth to "Jonathan">>
<<endif>>
<<endif>>
<<endif>>
<<endsilently>>
Afterward, you'd simply index the array (0-based) and name property of the associated object. For example, comparing the old ($First) to new ($initiative[0].name):