Setting up variables for highest underline relationship calculations

So, I ran into a bit of an issue, and want a second opinion.
I am running code for calculating highest_relationship calculations, and want to see if the code I am running is correct, because when I playtest my game, it skips the code.
Here is the code:

*if Highest_relationship_stat = 51
	*set highest_relationship "t_relationship"
	*set Highest_relationship_stat t_relationship
*elseif friendship_stat =50
	*set friendship_stat "l_relationship"
	*set friendship_stat_stat l_relationship
*if t_relationship > Highest_relationship_stat
	*set Highest_relationship "t_relationship"
	*set Highest_relationship_stat t_relationship
*elseif ((t_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "t_relationship"
	*set friendship_stat_stat t_relationship
*if l_relationship > Highest_relationship_stat
	*set Highest_relationship "l_relationship"
	*set Highest_relationship_stat l_relationship
*elseif ((l_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "l_relationship"
	*set friendship_stat_stat l_relationship
*if n_relationship > Highest_relationship_stat
    *set Highest_relationship "n_relationship"
    *set Highest_relationship_stat n_relationship
*elseif ((n_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "n_relationship"
	*set friendship_stat_stat n_relationship
*if d_relationship > Highest_relationship_stat
    *set Highest_relationship "d_relationship"
    *set Highest_relationship_stat d_relationship
*elseif ((d_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "d_relationship"
	*set friendship_stat_stat d_relationship
*gosub_scene high_relationship_calc

*if Highest_relationship = "t_relationship"
    *goto_scene driver t_reaction_shoulder2
*elseif second_highest_relationship ="t_relationship"
	*goto_scene driver t_reaction_shoulder2

*if Highest_relationship = "l_relationship"
     *goto_scene driver l_reaction_shoulder2
*elseif second_highest_relationship ="l_relationship"
	*goto_scene driver l_reaction_shoulder2

*if Highest_relationship = "n_relationship"
     *goto_scene driver n_reaction_shoulder2
*elseif second_highest_relationship "n_relationship"
	*goto_scene driver n_reaction_shoulder2

*if Highest_relationship = "d_relationship"
     *goto_scene driver d_reaction_shoulder
*elseif second_highest_relationship ="d_relationship"
	*goto_scene driver d_reaction_shoulder2

Also, looking over it again, How would I link it back to my game? It’s going to be used a lot over the course of at least the early game, and the friendship is going to be used a bunch throughout the series, and I don’t think having a bunch of *if’s is going to work. I would need something like 20 or so for each one?
Anyway, if someone could help me a bit with this and the over-all code, would be appreciated. Also, for those who are wondering, next update of the book should be out in the next week and a half or so. Yeah, I know it’s a bit off-topic but. Anyway. Hope anyone who is reading this has a good day, and, yeah.

1 Like

I am not 100% following why you have all the *if and *elseif logic and what the relevance of 50 and 51 are. But my understanding of your code is that you have multiple relationship stats, one of each character (e.g. l_relationship, n_relationship, etc.) and you want to see which of these are higher and add that relationship into the ‘highest’ variable.

What I’m going to put below is simply for looping through all your character relationships, identifying the highest, and storing that in the ‘highest relationship’ variable. I think you’ll need additional logic for handling this 50/51 stuff, but I’ll need you to describe exactly what you want to achieve there first. I’ll also need to understand what the difference between the relationship and friendship variables are.

You’ll notice that I switch all your character relationship traits to a different name, this allows us to loop through them easily. By having an underscore and a number, we can take advantage of a useful bit of CS code.

*create Highest_relationship ""
*create Highest_relationship_stat 0

*create Relationship_name_1 "Sarah"
*create Relationship_1 0
*create Relationship_name_2 "Steve"
*create Relationship_2 0
*create Relationship_name_3 "Kiran"
*create Relationship_3 0

*create Total_relationships 3

*label Highest_relationship_calc
*temp Relationship_counter 1

*label Relationship_calc_loop_start
*if Relationship_counter <= Total_relationships
    *if Relationship[Relationship_counter] > Highest_relationship_stat
        *set Highest_relationship_stat Relationship[Relationship_counter]
        *set Highest_relationship Relationship_name[Relationship_counter]
    *set Relationship_counter + 1
    *goto Relationship_calc_loop_start

You then call this with *gosub_Highest_relationship_calc whenever you want to update your two variables.

Let me know how the friendship variable and the 50/51 are designed to be used as I can take a look. Also, this won’t handle ties (and depends on if they can happen and what you want to do with them).

Relationship variables have to do with the relationship with that character, and if it is currently the highest one.
Friendship variables are most of the same, but designed to someone replace relationship variables after a very specific point in the book, notably when the romance takes place and the person you choose gets a roughly 15% give or take relationship increase. Also, since I’m going to make a specific variable for whoever you’re romancing, I wanted to make sure that I could still have a highest and one relationship, a.k.a., friendship.

Also, do you put all of that in the highest_relationship_calc document, or in startup? Some of it looks like stuff you would put in startup, and some in the highest_relationship calc.

This might help…

1, would you put the *gosub in the highest_calc or the startup, or do you put that when ever you want to see whose relationship is higher, like this:

*gosub highest_calc)```
Though, I am not sure how you would call, say, between if t_relationship or l_relationship is higher though, for example.

Also, currently each relationship has a percentage. I might be wrong here, and if so could someone please explain this to me, but as I look over this, I am not sure how it would mesh, since you have that "relationship_counter, and 

*if (relationship_counter =total_relationships)
So yeah, a little confused.

With the code I put above, you would do something like this:

Before you stands 3 people, who do you like most?
        *set relationship_1 + 10
        *set relationship_2 +10
        *set relationship_3 +10

*gosub Highest_relationship_calc

Your current highest relationship is ${Highest_relationship}.

Writing this on my phone, so a bit quick.
Essentially, whenever you modify your underlying relationship stats then you run the gosub to update your highest relationship stat.

Percentage should work fine, the code just looks at which number is higher.

The code will run through all the relationship stats you have and compare them all to see which is highest

1 Like

So, something like this? Modded your code a bit to try and get a variable for the if, elseif, etc.

*create highest_relationship_stat 0
*create t_relationship "t_relationship"
*create t_relationship 0
*create l_relationship "l_relationship"
*create l_relationship 0
*create n_relationship "n_relationship"
*create n_relationship 0
*create d_relationship "d_relationship"
*create d_relationship 0
*create total_relationships4

*label highest_relationship_calc
*temp relationship_counter 1
*label relationship_calc_loop

*if Relationship_counter <= Total_relationships
    *if Relationship[Relationship_counter] > Highest_relationship_stat
        *set Highest_relationship_stat Relationship[Relationship_counter]
        *set Highest_relationship relationship_name[Relationship_counter]
    *set Relationship_counter + 1
    *goto Relationship_calc_loop

Also, would the Gosub go after each choice to alter the relationship, and if not, how would something like that look. I assume something to the tune of,
option 1,
text text text etc,
goto what ever,
option 2,
text text text,
goto what ever,
etc, then the gosub_highest_calc at the end of the choice block, between the final *goto and the next label down?
Also, I assume that you would use the relationship_name_1, relationship_name_2, etc when you needed to send the player to different scenes depending on the relationship stat? Though may change that just because of the existing structure I have already sset-up, if I can. The variables, I mean.

I think you should differentiate the name of these variables, because something like this will throw up an error. Same goes with l_relationship ,n_relationship and d_relationship. Sinnie avoids this by adding “name” somewhere in the middle.

If you have implicit_control_flow turned on, then you can add *gosub at the end of the choice block like Sinnie had shown. If not, add the *gosub after choices that alter the relationship.

You would have to use Highest_relationship instead to direct the player to different scene.

Also, I think in order for Sinnie’s code to work, there’s a bit of restriction on how you name your variables. The number within the variables name is required.

*create highest_relationship ""
*create highest_relationship_stat 0

*create relationship_name_1 "t"
*create relationship_1 0
*create relationship_name_2 "l"
*create relationship_2 0
*create relationship_name_3 "n"
*create relationship_3 0
*create relationship_name_4 "d"
*create relationship_4 0

*create total_relationships 4

*label highest_relationship_calc
*temp relationship_counter 1

*label relationship_calc_loop_start
*if relationship_counter <= total_relationships
    *if relationship[relationship_counter] > highest_relationship_stat
        *set highest_relationship_stat relationship[relationship_counter]
        *set highest_relationship relationship_name[relationship_counter]
    *set relationship_counter + 1
    *goto relationship_calc_loop_start

Gosub placement:

	#Option 1
		*gosub highest_relationship_calc
		*goto whatever
	#Option 2
		*gosub highest_relationship_calc
		*goto whatever

*label whatever


	#Option 1
		*goto whatever
	#Option 2
		*goto whatever

*label whatever
*gosub highest_relationship_calc

Then, when you want to send the player to different scene depending on the highest relationship they have with, you can do something like this.

*if highest_relationship = "t"
	*goto t_scene
*if highest_relationship = "l"
	*goto l_scene
*if highest_relationship = "n"
	*goto n_scene
*if highest_relationship = "d"
	*goto d_scene

Edit: Added example.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.