Personality trait system, how to randomly choose traited text for mixed personality character

So I posted on here back in May for a personality trait system (I’m using @SpokesWriter’s code for it and it’s been working great!) but I’m finding that the mixed trait I needed for characters that had the same numbers in multiple traits is falling…flat.

Logistically it works, but I can’t write text that feels personalized for the characters in this case, whereas characters with a dominant trait get specifically tailored text to that personality.

SO what I’m thinking is, I want the mixed trait to ping which of those traits are equal and then randomly pick from those to present that trait’s text in-game.

i.e.
Character has the following personality
Aggressive: 3
Shy: 1
Emotional: 3

They’ll show up as having a mixed personality but only between aggressive and emotional. The game will then pick, randomly per playthrough, either the aggressive or emotional text to display in-game.

Except I have no idea how to code for this or where to even begin.

I imagine it’d start with
*if dom_trait = “mixed”
*gosub_scene mixedtrait

Then create a gosub that fits the code I need for it to ping which traits are causing the mixed trait.
So, if anyone has any ideas, I’d appreciate it! :slight_smile:

Here is the code for the gosub_scene I have for the personality trait system.

Summary
*label findtrait
*comment Code provided by SpokesWriter
*temp tvalue 0
*temp tname "unknown"
*temp mixedflag 0
*if dom_personality = "true"
    *if (tvalue = aggressive)
        *set mixedflag 1
    *if (tvalue < aggressive)
        *set tvalue aggressive
        *set tname "aggressive"
        *set mixedflag 0
    *if (tvalue = benevolent)
        *set mixedflag 1
    *if (tvalue < benevolent)
        *set tvalue benevolent
        *set tname "benevolent"
        *set mixedflag 0
    *if (tvalue = charming)
        *set mixedflag 1
    *if (tvalue < charming)
        *set tvalue charming
        *set tname "charming"
        *set mixedflag 0
    *if (tvalue = cruel)
        *set mixedflag 1
    *if (tvalue < cruel)
        *set tvalue cruel
        *set tname "cruel"
        *set mixedflag 0
    *if (tvalue = diplomatic)
        *set mixedflag 1
    *if (tvalue < diplomatic)
        *set tvalue diplomatic
        *set tname "diplomatic"
        *set mixedflag 0    
    *if (tvalue = emotional)
        *set mixedflag 1
    *if (tvalue < emotional)
        *set tvalue emotional
        *set tname "emotional"
        *set mixedflag 0
    *if (tvalue = shy)
        *set mixedflag 1
    *if (tvalue < shy)
        *set tvalue shy
        *set tname "shy"
        *set mixedflag 0
    *if (tvalue = stoic)
        *set mixedflag 1
    *if (tvalue < stoic)
        *set tvalue stoic
        *set tname "stoic"
        *set mixedflag 0
    *if (mixedflag = 1)
        *set dom_trait "mixed"
        *set dom_value tvalue
        *return
    *set dom_trait tname
    *set dom_value tvalue
    *return
*return

Having the game randomly pick between the two is dangerous; as tedious as it may be, allowing the reader pick between the two might be more effective and also allow for more replayability (the reader wonders what would change if they were more aggressive instead of emotional.)

With that in mind:

the following code should be adaptable for your use:

scene = random_cards
*label startofreading
*comment Są to pierwsze możliwe z 26 kart. Dla drugiej i trzeciej opcji będzie również 26 do wyboru./ / /

*temp tarotcard

*if have_made_random_roll1 = false
 *rand tarotcard 1 10
 *set have_made_random_roll1 true

*if (tarotcard=1)
 *set t_fool true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=2)
 *set t_empress true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=3)
 *set t_lovers true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=4)
 *set t_hermit true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=5)
 *set t_hanged_man true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=6)
 *set t_devil true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=7)
 *set t_moon true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=8)
 *set t_world true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=9)
 *set ace_of_c true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=10)
 *set a4_of_c true
 *gosub_scene cardsandmeaning
scene = cardsandmeaning
*if t_fool = true
	*goto t_fool
*elseif t_empress = true
	*goto t_empress
*elseif t_lovers = true
	*goto t_lovers
*elseif t_hermit
	*goto t_hermit
*elseif t_hanged_man
	*goto t_hanged_man
*elseif t_devil
	*goto t_devil
*elseif t_moon
	*goto t_moon
*elseif t_world
	*goto t_world
*elseif ace_of_c
	*goto ace_of_c
*elseif a4_of_c
 *goto a4_of_c

and then pretty much the *labels :slight_smile:

3 Likes

Thank you! I’ll give this a try and see if it works for me, It’ll probably take me awhile to work it out but I’ll post back if I get it working! :smiley:

1 Like

Okay so, I didn’t end up using that code but it really helped me wrap my head around trying to figure out what I was going for! So thank you!

I’ve made a code that works for what I want it to do, its probably horribly inelegant and rip-shod, but now going to the stat screen causes it to randomize again and, therefore, changes the text–which isn’t what I want at all.

So, say the character has the following personality.

Aggressive: 3
Benevolent: 1
Charming: 3
Stoic: 3

The game randomizes between the dominant traits of aggressive, charming, and stoic and goes as follows.

“I have an aggressive personality”
goto stat screen
return to game
“lol nvm I have a stoic personality type!”
etc.

In-game code
*set aggressive 3
*set stoic 3
*set charming 3

*gosub_scene findtrait
Testing randomization in mixed personality, dominant trait.
*if dom_trait = "mixed"
	*gosub_scene mixedtrait
*if mixed_trait = "aggressive"
	"I have an aggressive personality"
*if mixed_trait = "benevolent"
	Benevolent text
*if mixed_trait = "charming"
	"I have a charming personality"
*if mixed_trait = "cruel"
	Cruel text
*if mixed_trait = "diplomatic"
	Diplomatic text
*if mixed_trait = "emotional"
	Emotional text
*if mixed_trait = "shy"
	Shy text
*if mixed_trait = "stoic"
	"lol nvm I have a stoic personality type!"

Is there anyway to stop this? :thinking:

If there isn’t, I totally don’t mind players going to the stats and back to try and get the response they want from their mixed personality traits, so mostly just wondering if it is indeed a fixable issue?

Code
*temp mtrait1
*temp mtrait2
*temp mtrait3
*temp mtrait4
*temp mtrait5
*temp mtrait6
*temp mtrait7
*temp mtrait8
*temp domixtrait

*set mtrait1 aggressive
*set mtrait2 benevolent
*set mtrait3 charming
*set mtrait4 cruel
*set mtrait5 diplomatic
*set mtrait6 emotional
*set mtrait7 shy
*set mtrait8 stoic

*temp mtrait1_value false
*temp mtrait2_value false
*temp mtrait3_value false
*temp mtrait4_value false
*temp mtrait5_value false
*temp mtrait6_value false
*temp mtrait7_value false
*temp mtrait8_value false

*if aggressive = benevolent
	*set mtrait1_value true
	*set mtrait2_value true
	*goto charming
*if aggressive = charming
	*set mtrait1_value true
	*set mtrait3_value true
	*goto cruel
*if aggressive = cruel
	*set mtrait1_value true
	*set mtrait4_value true
	*goto diplomatic
*if aggressive = diplomatic
	*set mtrait1_value true
	*set mtrait5_value true
	*goto emotional
*if aggressive = emotional
	*set mtrait1_value true
	*set mtrait6_value true
	*goto shy
*if aggressive = shy
	*set mtrait1_value true
	*set mtrait7_value true
	*goto stoic
*if aggressive = stoic
	*set mtrait1_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto benevolent

*label benevolent
*if benevolent = charming
	*set mtrait2_value true
	*set mtrait3_value true
	*goto cruel
*if benevolent = cruel
	*set mtrait2_value true
	*set mtrait4_value true
	*goto diplomatic
*if benevolent = diplomatic
	*set mtrait2_value true
	*set mtrait5_value true
	*goto emotional
*if benevolent = emotional
	*set mtrait2_value true
	*set mtrait6_value true
	*goto shy
*if benevolent = shy
	*set mtrait2_value true
	*set mtrait7_value true
	*goto stoic
*if benevolent = stoic
	*set mtrait2_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto charming

*label charming
*if (mtrait1_value = true) or (mtrait2_value = true)
	*if (aggressive = charming) or (benevolent = charming)
		*set mtrait3_value true
		*goto cruel
*if charming = cruel
	*set mtrait3_value true
	*set mtrait4_value true
	*goto diplomatic
*if charming = diplomatic
	*set mtrait3_value true
	*set mtrait5_value true
	*goto emotional
*if charming = emotional
	*set mtrait3_value true
	*set mtrait6_value true
	*goto shy
*if charming = shy
	*set mtrait3_value true
	*set mtrait7_value true
	*goto stoic
*if charming = stoic
	*set mtrait3_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto cruel

*label cruel
*if mtrait1_value = true
	*if aggressive > cruel
		*goto diplomatic
*if mtrait2_value true
	*if benevolent > cruel
		*goto diplomatic
*if mtrait3_value true
	*if charming > cruel
		*goto diplomatic
*if cruel = diplomatic
	*set mtrait4_value true
	*set mtrait5_value true
	*goto emotional
*if cruel = emotional
	*set mtrait4_value true
	*set mtrait6_value true
	*goto shy
*if cruel = shy
	*set mtrait4_value true
	*set mtrait7_value true
	*goto stoic
*if cruel = stoic
	*set mtrait4_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto diplomatic

*label diplomatic
*if mtrait1_value = true
	*if aggressive > diplomatic
		*goto emotional
*if mtrait2_value true
	*if benevolent > diplomatic
		*goto emotional
*if mtrait3_value true
	*if charming > diplomatic
		*goto emotional
*if mtrait4_value true
	*if cruel > diplomatic
		*goto emotional
*if diplomatic = emotional
	*set mtrait5_value true
	*set mtrait6_value true
	*goto shy
*if diplomatic = shy
	*set mtrait5_value true
	*set mtrait7_value true
	*goto stoic
*if diplomatic = stoic
	*set mtrait5_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto emotional

*label emotional
*if mtrait1_value = true
	*if aggressive > emotional
		*goto shy
*if mtrait2_value true
	*if benevolent > emotional
		*goto shy
*if mtrait3_value true
	*if charming > emotional
		*goto shy
*if mtrait4_value true
	*if cruel > emotional
		*goto shy
*if mtrait5_value true
	*if diplomatic > emotional
		*goto shy
*if emotional = shy
	*set mtrait5_value true
	*set mtrait7_value true
	*goto stoic
*if emotional = stoic
	*set mtrait5_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto shy

*label shy
*if mtrait1_value = true
	*if aggressive > shy
		*goto stoic
*if mtrait2_value true
	*if benevolent > shy
		*goto stoic
*if mtrait3_value true
	*if charming > shy
		*goto stoic
*if mtrait4_value true
	*if cruel > shy
		*goto stoic
*if mtrait5_value true
	*if diplomatic > shy
		*goto stoic
*if mtrait6_value true
	*if emotional > shy
		*goto stoic
*if shy = stoic
	*set mtrait6_value true
	*set mtrait8_value true
	*goto traitest
*else
	*goto stoic

*label stoic
*if mtrait1_value = true
	*if aggressive = stoic
		*set mtrait8_value true
		*goto traitest
*if mtrait2_value = true
	*if benevolent = stoic
		*set mtrait8_value true
		*goto traitest
*if mtrait3_value = true
	*if charming = stoic
		*set mtrait8_value true
		*goto traitest
*if mtrait4_value = true
	*if cruel = stoic
		*set mtrait8_value true
		*goto traitest
*if mtrait5_value = true
	*if diplomatic = stoic
		*set mtrait8_value true
		*goto traitest
*if mtrait6_value = true
	*if emotional = stoic
		*set mtrait8_value true
		*goto traitest
*if mtrait7_value = true
	*if shy = stoic
		*set mtrait8_value true
		*goto traitest
*goto traitest

*label traitest
*rand domixtrait 1 8
*if domixtrait = 1
	*if mtrait1_value = true
		*set mixed_trait "aggressive"
		*return
	*if mtrait1_value = false
		*goto traitest
*if domixtrait = 2
	*if mtrait2_value = true
		*set mixed_trait "benevolent"
		*return
	*if mtrait2_value = false
		*goto traitest
*if domixtrait = 3
	*if mtrait3_value = true
		*set mixed_trait "charming"
		*return
	*if mtrait3_value = false
		*goto traitest
*if domixtrait = 4
	*if mtrait4_value = true
		*set mixed_trait "cruel"
		*return
	*if mtrait4_value = false
		*goto traitest
*if domixtrait = 5
	*if mtrait5_value = true
		*set mixed_trait "diplomatic"
		*return
	*if mtrait5_value = false
		*goto traitest
*if domixtrait = 6
	*if mtrait6_value = true
		*set mixed_trait "emotional"
		*return
	*if mtrait6_value = false
		*goto traitest
*if domixtrait = 7
	*if mtrait7_value = true
		*set mixed_trait "shy"
		*return
	*if mtrait7_value = false
		*goto traitest
*if domixtrait = 8
	*if mtrait8_value = "true"
		*set mixed_trait "stoic"
		*return
	*if mtrait8_value = false
		*goto traitest
*return

I’m kinda iffy about the random selection between the two tbh . None the least because of that much code. That’s a lot of checks for something that will only occur a small percentage of the time. If you don’t want to have the player pick which text is displayed, maybe consider a priority system instead? So if you’re using the example you gave there, have it prioritize Aggressive > Benevolent > Charming > Stoic.

So if you have:

Aggressive: 3
Benevolent: 1
Charming: 3
Stoic: 3

It’ll display the text for Aggressive (which takes priority). And if instead you have
Aggressive: 1
Benevolent: 1
Charming: 3
Stoic: 3

It displays Charming (the next one on the priority list). If you want variant personalities, just switch up the priority list for the next set of text you call this in, so Aggressive is the one called last in this scenario. Remember that most people are only going to play through once, or are going to be playing different character builds, so the odds of them noticing this aren’t especially high.

That being said, if you are going this route, the bug you’re encountering is on the documentation page for this (in the Known bugs section): https://choicescriptdev.fandom.com/wiki/Rand. The fix is to have a *page_break in the code after you run the subroutine and before you display the text.

This is their example
You carefully open the chest at arm's length, wary of traps . . .

*temp treasure

*rand treasure 50 100

*page_break It creaks open . . .

You gasp in amazement, finding ${treasure} gold coins in the chest!

*set gold + treasure
1 Like

Yeah I was going to consider the priority option too and I’ll probably re-visit this thing several times going forward.

I do kind of have a priority system set up for some personality checks, this is my attempt at a work around with the mixed trait personality to try and avoid having to write out a mixed trait dialog that just won’t be as personal as the other trait’s dialogs (for obvious reasons).

Thank you for the link and the input! I think with the way my personality trait tests are in-game it’d be awkward to just slam a page break in the middle of them. It’ll probably work for some, and it’s good to know going forward! :slight_smile:

I’ll go ahead and mark this as resolved though so this can be put to rest, for now.

1 Like

I know you checked it off but wrt to this:

Is it possible for you to do it a little ahead of time? (Maybe have it *set mixed_trait before the last page break already in the code, or run the subroutine to update whenever the stats themselves change), so you don’t have to force a new page break in text? It’s a bit ugly, but so long as you’re mindful about where you adjust personality stats, it should work.

Sorry if this is harping ^^. Either way, good luck to you!

2 Likes

Ooooh no you’re totally right I can definitely do that. I don’t expect my game to be pretty coding wise just so long as it works!

I hadn’t even thought about that which is funny because that’s what I already do for the dominant trait tests, run the sub routine whenever theres a choice that changes the personality traits, so throwing the mixed trait routine in there should work great!

It feels like an ‘oh duh’ moment for me but that’ll totally work so thanks for pointing it out :smiley:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.