Random Seed

Status
Not open for further replies.
Level 6
Joined
Mar 18, 2005
Messages
153
i got a problem:
as some of u might know a computer is unable to create any random at all (yes its true!). instead it refers to the system time or infinite sources like the number PI.
this is obviously NOT the case in weu under certain circumstances although it usually works.
heres the main part of the trigger who doesnt work as he should: the random is just always the same! i tested it with game messages always returning 6 9 6 as random numbers "from 1 to (1 to 10))" independend of the time the trigger is executed.
wait commands and other types of randomizing dont change the outcome either! any suggestions? :?

Code:
If (All Conditions are True) then do (Then Actions)
(Random integer number between 1 and 100) Less than or equal to modevalue[11]
[...]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Random integer number between 1 and 3) Equal to 1
        (Number of units in (Units owned by Player 3 (Teal))) Less than or equal to 3
    Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 4) Equal to 1
            Then - Actions
                Unit - Create 1 typesoldier[(Random integer number between 1 and nrofraces)] for Player 3 (Teal) at (Position of (Random destructible in brett 1 <gen> matching (((Destructible-type of (Matching destructible)) Equal to forboard) and ((Number of units in (Units within 90.00 of (Position of (Matching destructible)) matching ((Custom value of (Matching unit)) N facing (Random angle) degrees
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Random integer number between 1 and 3) Equal to 1
                    Then - Actions
                        Unit - Create 1 typearcheretc[(Random integer number between 1 and nrofraces)] for Player 3 (Teal) at (Position of (Random destructible in brett 1 <gen> matching (((Destructible-type of (Matching destructible)) Equal to forboard) and ((Number of units in (Units within 90.00 of (Position of (Matching destructible)) matching ((Custom value of (Matching unit)) N facing (Random angle) degrees
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Random integer number between 1 and 2) Equal to 1
                            Then - Actions
                                Unit - Create 1 typeknight[(Random integer number between 1 and nrofraces)] for Player 3 (Teal) at (Position of (Random destructible in brett 1 <gen> matching (((Destructible-type of (Matching destructible)) Equal to forboard) and ((Number of units in (Units within 90.00 of (Position of (Matching destructible)) matching ((Custom value of (Matching unit)) N facing (Random angle) degrees
                            Else - Actions
                                Unit - Create 1 typecaster[(Random integer number between 1 and nrofraces)] for Player 3 (Teal) at (Position of (Random destructible in brett 1 <gen> matching (((Destructible-type of (Matching destructible)) Equal to forboard) and ((Number of units in (Units within 90.00 of (Position of (Matching destructible)) matching ((Custom value of (Matching unit)) N facing (Random angle) degrees
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Unit-type of (Last created unit)) Equal to Tornado Elemental
            Then - Actions
                Animation - Change (Last created unit)'s size to ((150.00 x minime)%, (150.00 x minime)%, (150.00 x minime)%) of its original size
            Else - Actions
                Animation - Change (Last created unit)'s size to ((200.00 x minime)%, (200.00 x minime)%, (200.00 x minime)%) of its original size
        Unit - Set the custom value of (Last created unit) to 3
        Unit - Pause (Last created unit)
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Camera - Pan camera for (Picked player) to (Position of (Last created unit)) over 1.00 seconds
        Advanced - Create a special effect rain using Abilities\Spells\Human\Avatar\AvatarCaster.mdl as model and (Position of (Last created unit)) as center, 300.00 as radius and let it have a total number of 5 effects
        Advanced - Create at Attach Point - Chest of (Triggering unit) the Abilities\Spells\Human\CloudOfFog\CloudOfFog.mdl effect lasting 4.00 seconds
        Sound - Play gravity <gen>
        Environment - Create a 3.00 second random deformation at (Position of (Last created unit)) with radius 300.00, using depths between -32.00 and 32.00, updating every 0.10 seconds
        Game - Display to (All players) for 4.00 seconds the text: (|c0000ff66 + ((Name of (Last created unit)) +  spawned as neutral creep.|r))
        Wait 2.00 seconds
    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 2) Equal to 1
            Then - Actions
[...]
            Else - Actions
[...]
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        [...]
                        Or - Any (Conditions) are true
                            Conditions
                                And - All (Conditions) are true
                                    Conditions
                                        (Number of units in vips) Equal to 2
                                        (Number of units in (Units of type Aznereth)) Equal to 0
                                And - All (Conditions) are true
                                    Conditions
                                        (Number of units in vips) Equal to 3
                                        (Number of units in (Units of type Aznereth)) Equal to 1
                    Then - Actions
[...]
                    Else - Actions
[...]

sry for the lack of overview, i already replaced the most irrelevant stuff as "[...]" XD
 
Level 7
Joined
Jul 30, 2004
Messages
451
if you're doing it on map init or something like that the random seed won't be set either

i'm not really sure how it goes about it, but the intro to my map which uses randomness isn't random at all, everything else works though
 
Level 22
Joined
May 11, 2004
Messages
2,863
It aslo depends how the trigger is fired. If the trigger initiating random variables is fired by another trigger, i.e.;

event
condition
action
----> run
  • checking/ignoring conditions (the trigger with the randoms),
  • it will run the same random every time. Best way to avoid this is to have the trigger with the random variables in it have its own events as opposed to being fired by another trigger.
  • -VGsatomi
 
Status
Not open for further replies.
Top