• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Mathematical Logic - Random

Status
Not open for further replies.
Level 4
Joined
May 16, 2004
Messages
76
Pretty much, This is random script designed that everytime a person kills one of 3 buildings, a random 1 of 3 event will happen. And that if an event happens, it cannot happen again leaving the next 2 events.. etc The problem i am having is that i do not know how to program the 2 script. Please Help!

  • BuildingRandom
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) Equal to VineyardBuildingss[1]) or (((Dying unit) Equal to VineyardBuildingss[2]) or ((Dying unit) Equal to VineyardBuildingss[3]))
    • Actions
      • Set RandomVineNum = (Random integer number between BuildingNumMin and BuildingNumMax)
      • Set BuildingNumMin = 1
      • Set BuildingNumMax = 3
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomVineNum Equal to 1
        • Then - Actions
          • Set BuildingNumMin = 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomVineNum Equal to 2
        • Then - Actions
          • Custom script: WHAT GOES HERE????
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomVineNum Equal to 3
        • Then - Actions
          • Set BuildingNumMax = 2
        • Else - Actions
 
Level 16
Joined
Feb 22, 2006
Messages
960
so here my complicated trigger... but it works^^ sorry some parts are in german, but the main thing (variables) should be clear
Gleich = Equal to
Einheit = Unit
  • random event
    • Events
      • Einheit - A unit Stirbt
    • Conditions
      • Or - Any (Conditions) are true
        • Bedingungen
          • (Dying unit) Equal to building[1]
          • (Dying unit) Equal to building[2]
          • (Dying unit) Equal to building[3]
    • Actions
      • Set dying_unit_position = (Position of (Dying unit))
      • Set random = (Random integer number between 1 and 3)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • random Gleich 1
        • 'THEN'-Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • boolean[1] Gleich True
            • 'THEN'-Aktionen
              • -------- random event1 --------
              • Einheit - Create 1 Soldat for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
              • Set boolean[1] = False
            • 'ELSE'-Aktionen
              • Set random = (Random integer number between 2 and 3)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Bedingungen
                  • random Gleich 2
                • 'THEN'-Aktionen
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • boolean[2] Gleich True
                    • 'THEN'-Aktionen
                      • -------- random event2 --------
                      • Einheit - Create 1 Scharfschütze for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                      • Set boolean[2] = False
                    • 'ELSE'-Aktionen
                      • Set random = 3
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • random Gleich 3
                        • 'THEN'-Aktionen
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • 'IF'-Bedingungen
                              • boolean[3] Gleich True
                            • 'THEN'-Aktionen
                              • -------- random event3 --------
                              • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                              • Set boolean[3] = False
                            • 'ELSE'-Aktionen
                        • 'ELSE'-Aktionen
                • 'ELSE'-Aktionen
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • random Gleich 3
                    • 'THEN'-Aktionen
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • boolean[3] Gleich True
                        • 'THEN'-Aktionen
                          • -------- random event3 --------
                          • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                          • Set boolean[3] = False
                        • 'ELSE'-Aktionen
                          • Set random = 2
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • 'IF'-Bedingungen
                              • random Gleich 2
                            • 'THEN'-Aktionen
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • 'IF'-Bedingungen
                                  • boolean[2] Gleich True
                                • 'THEN'-Aktionen
                                  • -------- random event2 --------
                                  • Einheit - Create 1 Scharfschütze for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                                  • Set boolean[2] = False
                                • 'ELSE'-Aktionen
                            • 'ELSE'-Aktionen
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • 'IF'-Bedingungen
                                  • random Gleich 3
                                • 'THEN'-Aktionen
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • 'IF'-Bedingungen
                                      • boolean[3] Gleich True
                                    • 'THEN'-Aktionen
                                      • -------- random event3 --------
                                      • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                                      • Set boolean[3] = False
                                    • 'ELSE'-Aktionen
                                      • Set random = 2
                                • 'ELSE'-Aktionen
                    • 'ELSE'-Aktionen
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • random Gleich 3
                    • 'THEN'-Aktionen
                      • Set random = 3
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • boolean[3] Gleich True
                        • 'THEN'-Aktionen
                          • -------- random event3 --------
                          • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                          • Set boolean[3] = False
                        • 'ELSE'-Aktionen
                    • 'ELSE'-Aktionen
        • 'ELSE'-Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • random Gleich 2
            • 'THEN'-Aktionen
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Bedingungen
                  • boolean[2] Gleich True
                • 'THEN'-Aktionen
                  • -------- random event2 --------
                  • Einheit - Create 1 Scharfschütze for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                  • Set boolean[2] = False
                • 'ELSE'-Aktionen
                  • Set random = (Random integer number between 1 and 2)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • random Gleich 1
                    • 'THEN'-Aktionen
                      • Set random = 1
                    • 'ELSE'-Aktionen
                      • Set random = 3
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • boolean[1] Gleich True
                    • 'THEN'-Aktionen
                      • -------- random event1 --------
                      • Einheit - Create 1 Soldat for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                      • Set boolean[1] = False
                    • 'ELSE'-Aktionen
                      • Set random = 3
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • random Gleich 3
                        • 'THEN'-Aktionen
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • 'IF'-Bedingungen
                              • boolean[3] Gleich True
                            • 'THEN'-Aktionen
                              • -------- random event3 --------
                              • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                              • Set boolean[3] = False
                            • 'ELSE'-Aktionen
                        • 'ELSE'-Aktionen
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • random Gleich 3
                    • 'THEN'-Aktionen
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • boolean[3] Gleich True
                        • 'THEN'-Aktionen
                          • -------- random event3 --------
                          • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                          • Set boolean[3] = False
                        • 'ELSE'-Aktionen
                          • Set random = 1
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • 'IF'-Bedingungen
                              • boolean[1] Gleich True
                            • 'THEN'-Aktionen
                              • -------- random event1 --------
                              • Einheit - Create 1 Soldat for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                              • Set boolean[1] = False
                            • 'ELSE'-Aktionen
                    • 'ELSE'-Aktionen
            • 'ELSE'-Aktionen
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Bedingungen
                  • random Gleich 3
                • 'THEN'-Aktionen
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • boolean[3] Gleich True
                    • 'THEN'-Aktionen
                      • -------- random event3 --------
                      • Einheit - Create 1 Ritter for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                      • Set boolean[3] = False
                    • 'ELSE'-Aktionen
                      • Set random = (Random integer number between 1 and 2)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • boolean[1] Gleich True
                        • 'THEN'-Aktionen
                          • -------- random event1 --------
                          • Einheit - Create 1 Soldat for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                          • Set boolean[1] = False
                        • 'ELSE'-Aktionen
                          • Set random = 2
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • 'IF'-Bedingungen
                              • boolean[2] Gleich True
                            • 'THEN'-Aktionen
                              • -------- random event2 --------
                              • Einheit - Create 1 Scharfschütze for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                              • Set boolean[2] = False
                            • 'ELSE'-Aktionen
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • 'IF'-Bedingungen
                          • boolean[2] Gleich True
                        • 'THEN'-Aktionen
                          • -------- random event2 --------
                          • Einheit - Create 1 Scharfschütze for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                          • Set boolean[2] = False
                        • 'ELSE'-Aktionen
                          • Set random = 1
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • 'IF'-Bedingungen
                              • boolean[1] Gleich True
                            • 'THEN'-Aktionen
                              • -------- random event1 --------
                              • Einheit - Create 1 Soldat for Spieler 1 (Rot) at dying_unit_position facing dying_unit_position
                              • Set boolean[1] = False
                            • 'ELSE'-Aktionen
                • 'ELSE'-Aktionen
      • Custom script: call RemoveLocation(udg_dying_unit_position)
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Just use a boolean and make it true/false when number 2 is selected, then check if it is true/false (whatever you decided) and if it is make the random integer go random again, until it isn't 2, with a loop.

Also, your first variable should be beneath the other 2.
 
Level 9
Joined
Jul 24, 2007
Messages
308
firstly, make this
  • Set BuildingNumMin = 1
  • Set BuildingNumMax = 3
  • Set RandomVineNum = (Random integer number between BuildingNumMin and BuildingNumMax)

when one of the.. events (?!) or chances happens, make a boolean with an array of the building number to false, add to conditions for each if/then/else if boolean's name [bulding number array] equal to true

exmple:

  • Actions
  • Set BuildingNumMin = 1
  • Set BuildingNumMax = 3
  • Set RandomVineNum = (Random integer number between BuildingNumMin and BuildingNumMax)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • RandomVineNum Equal to 1
        • SomeBoolen[1] Equal to True
      • Then - Actions
        • Set SomeBoolen[2] Equal to False
        • Set BuildingNumMin = 2 (or do whatever you want ehre)
      • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomVineNum Equal to 2
          • SomeBoolen[2] Equal to True
        • Then - Actions
          • Custom script: what you want )
          • Set SomeBoolen[2] Equal to False
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RandomVineNum Equal to 3
            • SomeBoolen[3] Equal to True
          • Then - Actions
            • Set SomeBoolen[3] Equal to False
            • Set BuildingNumMax = 2
            • Else - Actions
however, you can change the booleans however you want to make "X" event work first, and "Y" event plays last by changing booleans on actions.


EDIT: lol i just did what ghostwolf said )))))))) but nvm
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
This is random script designed that everytime a person kills one of 3 buildings, a random 1 of 3 event will happen. And that if an event happens, it cannot happen again leaving the next 2 events.. etc

That cannot be the case. After the first two instances, it will be deterministic for the rest of the game, and hence non-random.
 
Status
Not open for further replies.
Top