I have no idea how to use a script to do that, so I don't think I can :/
You can use the Script Call command for that. Just paste the code I gave you into it and call it where you would call the text message.
Set how many events will spawn 1 OR 2.
LOOP STARTS
Check if the rarity value is matched (if it is >= 95)
if true, spawn 1 event in the proper region
SUBTRACT number of events that will spawn by 1
if it reaches 0, break the loop. otherwise repeat it until the number o events that will spawn reaches 0.
activate switch to change pages
His point is that the only way you'll subtract 1 from the number of events that will spawn is if you spawn an event. Basically what your loop does is roll the random variable until you get >= 95 some number of times.
Here's some pseudocode for what you're doing:
Code:
set n_events = random 1..2
loop
set spawn_rarity = random 0..100
if spawn_rarity >= 95
spawn(<ID>)
n_events -= 1
if n_events == 0
break loop
end if
end if
end loop
You can see that while spawn_rarity < 95 you'll just keep looping, until it goes above 95 and you finally decrement n_events, then repeat this until you decrement n_events to 0. This basically means you
have to roll above 95, the event will simply keep going until you do.
I think what you want is this:
Code:
set n_events = random 1..2
loop
set spawn_rarity = random 0..100
if spawn_rarity >= 95
spawn(<ID>)
end
n_events -= 1
if n_events == 0
break loop
end if
end loop
That's what I meant by "move the logic to right before the end of the loop". This way you'll decrement the loop counter whether you roll > 95 or not.
You'll notice every time you talk to this event it will say either 1 or 2.
If it says 2 it rolled a 95 or higher. If it says 1 it rolled a 94 or lower.
@GmOcean that's not true. If it says 1 then it rolled 1 for variable #1, and if it says 2 then it rolled 2 for variable #1. You're not actually doing anything with the value you roll for variable #2. Basically what you did is this:
Code:
set temp = 0
set n = random 1..2
loop
temp += 1
set chance = random 1..100
if chance >= 95
n -= 1
else
n -= 1
end
if n == 0
break loop
end
end loop
But "if X then Y else Y" is the same as just "Y".
Off: That's a fairly common exercise students are given on an introductory first order logic course btw:
(a => b) ^ (!a => b)
<=> (!a v b) ^ (a v b) [Definition of =>]
<=> (!a ^ a) v (!a ^ b) v (b ^ a) v (b ^ b) [Distributive property]
<=> F v (!a ^ b) v (b ^ a) v b [Inverse law, Idempotence]
<=> b [Identity for F and then absorption twice].
Then that's the same as this:
Code:
set temp = 0
set n = random 1..2
loop
temp += 1
set chance = random 1..100
n -= 1
if n == 0
break loop
end
end loop
Which in turn is just this, since we don't use "chance" anywhere:
Code:
set temp = 0
set n = random 1..2
loop
temp += 1
n -= 1
if n == 0
break loop
end
end loop
That's just counting. This is equivalent: