Turning a rand number into a permanent var?

I have set up an if statement, if true then run *rand and then set *rand to another variable. Then set false so we cannot call on this if function again, then leave for another scene. The problem is when I check the var that should not be changing it acts like it is still a rand number. Any ideas on how to fix. On my phone so cannot post snippet currently but will later tonight of existing code. Thanks for any help.
*edit it only acts like rand number when I click Return to game in Stats, but if I click next and return seems to be a constant number.
**edit the problem goes away as soon a a choice is made. Unless someone can solve before the choice than may just live with it lol. Thanks.

*create IntStr true
*create ResultStr 0

*title Thief's Apprentice Journey
*comment to add later ifid df316270-35ff-4a8b-8fac-822caac0ff65

*label str
*temp Str 0
*if (IntStr)
    *rand Str 3 19
    *set ResultStr Str
    *set IntStr false
    *goto int
*else
    *goto int

*label int


*goto_scene page1

Probably when you return from the stats you are returning to the *label that runs the rand command. Try making a label that does that and then *goto another label without any page_break or choice.
So the rand will be executed and the game will stop after that happens, so it can’t return and do the rand command again.

Edit:
Okay, now I see the code and that’s not what’s happening…

1 Like

I’m not 100% sure what the problem is from your description, but I’m going to hazard a guess that you’re rechecking the variable before you’ve hit another page_break or *choice. *rand rerolls. It’s super annoying, but you will find that say if the player checks their stats and then goes back to the page they were on then it will be a different number. You’re always best to run the *rand command earlier than you need to have it permanently set it to avoid this.

3 Likes

You are correct in your summation of the problem. I ran the *rand fist thing, but until the first choice is made the numbers do fluctuate. Minor hickup in the sceme of things, but will give a savy player and edge.

1 Like

Yup, sooo (I have ones like this) what I tend to do personally is set it right at the start of the game so it’s already fixed in stone and ready to go (but you can set it anywhere before a choice or page_break to usually stop the rerolls).

If you need to re-roll it (say in a battle situation) then I’ll set it earlier in the round. For (simplistic) example let’s say you have the opponent’s attack type on random.

*label fight

*set opponent_attack 1 2

You attack with...

*fake_choice
  #A sword
    blah blah text about fight and damages to opponent here

  #A spear
    blah blah text about fight and damages to opponent here
    

You opponent attacks

*if (opponent_attack = 1)
  text about attack type 1

*if (opponent_attack = 2)
  text about attack type 2

*page_break

*if opponent_health < 1
  *goto finished_fight

*if opponent_health > 0
  *goto fight


Because there’s a choice between where you set the variable and where it is actually applied, it should stop people rerolling to “game the system”. This is actually pretty important where stats are addative (like in a battle) as I have had some glitches where every time someone visits the stat screen during a fight it applies more and more damage to them or their opponent due to the repeated rerolls.

If it’s rerolling before the stat matters and the player can’t see the result in game, I wouldn’t worry about it.

3 Likes

That gives me a simple.idea, hide the stat until the first choice has been made. Thanks for the idea.

1 Like

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