% chance for action

WildTurkey

Previously known as giv_me_rep
Reaction score
88
Hi,

I want to have like a 10 (1/10) chance of an action concurring
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Random real number between 1.00 and 10.00) Equal to 1.00
    Then - Actions
        Floating Text - Create floating text that reads 1 above Player_Hero[1] with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 20.00% transparency
    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random real number between 1.00 and 10.00) Equal to 2.00
            Then - Actions
                Floating Text - Create floating text that reads 2 above Player_Hero[1] with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 20.00% transparency
            Else - Actions
.
etc

Been years, dont remember what I am doing wrong.
 

Accname

2D-Graphics enthusiast
Reaction score
1,461
You create a new random number in each if-statement. So the first one has a 10% chance of being triggered, the next one has a (90 * 0.1)% chance of being triggered, and so forth.

Instead, save the result of the random number generation in a variable and compare the value of this variable in your if-conditions.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The forum software says we have 554 members online now. We did not have that many unique visitors the whole day today. Too many bots and the disconnect between the forum counts and the stats.
  • Varine Varine:
    Currently it says 413 guests and 2 members
    +1
  • Varine Varine:
    Aww
  • The Helper The Helper:
    That is going to be mostly bots
  • The Helper The Helper:
    527 (members: 2, guests: 525)
  • The Helper The Helper:
    Happy Saturday!
    +1
  • V-SNES V-SNES:
    Happy Saturday!
    +1
  • The Helper The Helper:
    622 (members: 2, guests: 620)
  • The Helper The Helper:
    666 (members: 4, guests: 662) :)
    +1
  • Varine Varine:
    609 (members: 4, guests: 605)
  • The Helper The Helper:
    I was posting that last one because the 666 users online :)
    +1
  • The Helper The Helper:
    Happy Wednesday Night!
    +1
  • The Helper The Helper:
    Happy Thursday!
    +1
  • The Helper The Helper:
    Marathon watching The Expanse!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    leaving for the weekend in San Antonio will be gone until Sunday afternoon
    +1
  • The Helper The Helper:
    and I am back :)
    +1
  • The Helper The Helper:
    Happy Tuesday!
    +1

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top