Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Sugarcube 2] %chance (not random) for goto different routes

Hi guys,
i'm total noob, so i asking about someting what i don't know "how to make".

First i was started go with tutorials, documentations and forums solutions with all past problems [maybe somewhere this is but i wasn't find this problem], and in all go i find moment when i have silly problem :)
i try solve it a few times and every times this doesn't work like i need.

i have a little more complicated problem becouse in single route i don't have problems but i was want making something harder and find this problem:

go to city -> and in city i get: %chance"goto GotRobed1/2/3/4" and rest%"goto Street1,2,3,4[random]".
somethink like i have:
example: 15.5% chance goto either("Robed 1/2/3/4") and rest% <<elseif goto either("Street1"...)>>

because i want use this in diffrent actions, so i was started thinking about set variable and i was ended in place where i have stat like this:

<<set $chrobed to 50/(($str+$agi+$int+$lucky+$hp)-($badLucky*$badFame+($gold*0.0005)))>>
<<if $chrobed gte 95 set $chrobed to 95>>

i add this for block chance to break game and make 150% chamce on get robed :) and i know this isn't best and i will go to remaking but is for example of this situation

but i don't know how to add/make it in form what i needed for this situation.
Because i need that dignit in stat $chrobed example "15.5" is as % of chance for go to route of get robed, and rest is go to Street.
Because statistic $chrobed is dynamic to the rest of game stats so this is main % chance for goto to bad route.

so we look on what we have to use:
Room "Home"
Room "City"
Room "Street1", "Street2", "Street3", "Street4"
Room "Robed1", "Robed2", "Robed3"
and a few stats with main chance to got robed -> $chrobed

i was started thinking i must use <<if>> and <<elseif>> but doesn't know how to make go to where [%$robed is a chance to "goto Robed1/2/3" and rest is for goto Street1/2/3/4], so started with add room for a'la "rulete machine" but it wasn't what i needed :|



Somebody can help?

BTW: please don't go with Java because i dosn't know, how to go with this xD

im working in Twine with sugarcube 2.12.0 of a 1 month.



P.S. sorry for my teriffied english but this isn't my native language :)

Comments

  • Once you've calculated your percentage, generate a random number from 1 to 100. If it's less than you percent, go that way, if it's greater go the other.

    You may find it easier to resolve the outcome and simply set the destination you goto in a variable before you put the link out. The payer will see the same effect - click on the link and either get robbed or go home - only you'll know that the outcome we predetermined before the link was rendered. This is mostly because trying to resolve conditional links inside a print statement is a pain.
    <<if $chrobbed gte random(1,100)>><<set $dest to "Robbed1">><<else>><<set $dest to "Home1">><<endif>>\
    [[Go home||$dest]]
    

    Untested as usual. ;-(
Sign In or Register to comment.