I’m having trouble with a gosub_scene error that only happens in a random test. I also use the same gosub_scene multiple places in the game and the error only appears under one half of a choice option. When the else condition is met random test will error.
The error I’m getting is: RANDOMTEST FAILED: Error: routines line 72: invalid return; we’ve already returned from the last gosub
My code looks like this:
Choice that leads to error
#Third door on the right.
*set fork 2
*if (random =0) or (random =1)
*set Luck +1
*gosub_scene routines stat_cap
The placard on the door reads [i]Restrooms[/i]. You hurry through the door hoping they didn't see you come in. There's nothing but empty stalls in the darkroom. You hide in one of the stalls and catch your breath. It only takes a minute before you hear the soldiers rumble past you. You listen. Waiting for someone to kick in the door of your stall. After a minute of nothing you release the breath your holding.
*goto bathroom
*else
[b]BANG[/b]
A bullet rips through your right shoulder almost sending you skidding past the door. The pain is searing, but you have to keep going.
[i]I thought they were farther behind me![/i]
You scurry through the bathroom hoping they didn't see you come in. There's nothing but empty stalls in the darkroom. You stumble into one of the stalls and catch your breath. The pain from your gunshot wound reminds you it's still there. Gritting your teeth in order not to make any noise you rip off your shirt sleeve and tie it tightly around your shoulder noticing the small droplets of blood on the floor.
"Shit."
*set Luck -1
*set Health -20
*set shot "true"
*gosub_scene routines stat_cap
*if Health <15
*set pow "true"
*set pow_marker +1
*goto_scene pow
*goto bathroom
Where the error happens
*label stat_cap
*if Luck > 7
*set Luck 7
*if Weapons >100
*set Weapons 100
*if Explosives > 100
*set Explosives 100
*if Diplomatic > 100
*set Diplomatic 100
*if Subterfuge > 100
*set Subterfuge 100
*if Rebellion > 100
*set Rebellion 100
*if IIndependent > 100
*set IIndependent 100
*if IAloof > 100
*set IAloof 100
*if LIndependent > 100
*set LIndependent 100
*if LAloof > 100
*set LAloof 100
*if Agent_kit > 4
*set Agent_kit 4
*if amlh > 4
*set amlh 4
*if nine_mm > 16
*set nine_mm 16
*if mtraderrelationship > 5
*set mtraderrelationship 5
*if missionone_success > 100
*set missionone_success 100
*if pool_level >10
*set pool_level 10
*if Luck < 1
*set Luck 1
*if Weapons < 0
*set Weapons 0
*if Explosives < 0
*set Explosives 0
*if Diplomatic < 0
*set Diplomatic 0
*if Subterfuge < 0
*set Subterfuge 0
*if Rebellion < 0
*set Rebellion 0
*if IIndependent < 0
*set IIndependent 0
*if IAloof < 0
*set IAloof 0
*if LIndependent < 0
*set LIndependent 0
*if LAloof < 0
*set LAloof 0
*if Agent_kit < 1
*set Agent_kit 1
*if amlh < 1
*set amlh 1
*if nine_mm < 1
*set nine_mm 1
*if mtraderrelationship < 1
*set mtraderrelationship 1
*if missionone_success < 0
*set missionone_success 0
*if pool_level <1
*set pool_level 1
*if Health < 1
*set Health 1
*if (Health >100) and (flak=false)
*set Health 100
*if (((Health >115) and (flak=true)) and (plates=false))
*set Health 115
*if (((Health >120) and (flak=true)) and (plates=true))
*set Health 120
*return