How to get a different scene depending on stats?


#1

I’ve searched everywhere but I can’t seem to find a solution to my exact problem.

I’m currently creating a game where you branch off in to different stories (scenes) depending on your stats. For example if your relationship stats with person A is higher than with B and C, you will end up with person A. If your relationship is higher with B than with A and C, you will end end up with B and so on.

My first try of coding this was supposed to be who you’d dream of (depending on the stats) and looked like this:

*label A
*if (A > 0)
	*if (A > B)
		*if (A > C)
			*goto dreamA
				
*else
	*goto B


*label B
*if (B > A)
	*if (B > C)
		*if (B > 0)
			*goto dreamB
*else
	*goto C

etc...

I don’t think it’s correct considering I always get an error: It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block.

Could somebody explain how to do this? Sorry in advance if this has been asked before.


#2

Make sure to have a *else for every *if you have. When the code gets to *if (A>B) and this is incorrect (A isn’t bigger than B), there will be an error.


#3

Tried it, still get the “you must *goto or *finish…” error on *else *goto B


#4

your missing some additional *else and *goto

*label a
*if (a > 0)
	*if (a > b)
		*if (a > c)
			*goto dreama
		*else
			*goto c
	*else
		*goto b
				
*else
	*goto b

edited to add:

You could probally simplfify the code a bit by simply doing this.

*label a
*if (a > b)
	*if (a > c)
		*goto dream_a
	*else
		*goto dream_c
*else
	*goto b

*label b
*if (b > c)
	*goto dream_b
*else
	*goto dream_c

#5

Yes, thank you that seemed to solve the problem overall. :slight_smile: I assume there’s no easier (or other) way to do this?


#6

It depends on how much the dream changes.


#7

If you’re essentially checking for the highest stat out of a, b, or c, you could try:


*label a
*if ((a > b) and (a > c))
  *goto dream_a
*elseif (b > c)
  *goto dream_b
*else
  *goto dream_c

If A, B, and C are equal, they’ll be directed to C (or if A and B are equal and greater than C, it goes to B). Otherwise you could do something like:


*label a
*if ((a >= b) and (a >= c))
  *goto dream_a
*elseif (b >= c)
  *goto dream_b
*else
  *goto dream_c

That would prefer A, then B, if two or more stats are equal.


#8

I never thought of this, will definitely try it. In this case it’s not just A, B and C, I have about 4-5 labels so I would need to use a lot parentheses for this :slight_smile: thank you nevertheless.