Non-Repeating Integer Question

anvio

New Member
Reaction score
1
Well I'm making a Maze Escape map that when you beat a level you get ported to another random level in the maze; for instance Area of Ice Escape works in that sense.

Currently I'm using AceHart's Non-Repeating Integer Sequence to do this (AceHart's Tutorial); but every now and then I get a level that repeats, as in when I beat the level I just get ported right back to the start of the level again sometimes.

This is how I'm using AceHart's system at the moment...

(Ps: I shortened the Sequence Total variable from 34 to 5 and the If Then and Else conditions from 34 actions to 5 actions so it would be much more easier to read. :thup: You should get the idea though.)

(Pps: To be obvious I have 34 levels in my Maze in total. ;))

Trigger:
  • SequenceStart
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set SequenceTotal = 5
      • For each (Integer A) from 1 to SequenceTotal, do (Actions)
        • Loop - Actions
          • Set Sequence[(Integer A)] = (Integer A)
      • Set SequenceCurrent = SequenceTotal


Trigger:
  • SequenceEnd
    • Events
    • Conditions
    • Actions
      • Set RandomLevel = (Random integer number between 1 and SequenceCurrent)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLevel Equal to 1
        • Then - Actions
          • Set Respawn = Levels[1]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomLevel Equal to 2
            • Then - Actions
              • Set Respawn = Levels[2]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RandomLevel Equal to 3
                • Then - Actions
                  • Set Respawn = Levels[3]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • RandomLevel Equal to 4
                    • Then - Actions
                      • Set Respawn = Levels[4]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • RandomLevel Equal to 5
                        • Then - Actions
                          • Set Respawn = Levels[5]
                        • Else - Actions
      • Set Sequence[RandomLevel] = Sequence[SequenceCurrent]
      • Set SequenceCurrent = (SequenceCurrent - 1)


The next trigger is the one I'm using to port the player and other players when they reach the end of the level. To be explanatory I have the upcoming trigger placed in my map 34 times, 1 for each level that I have.

And to be clear when the "Level1End" trigger is run it runs the "SequenceEnd" trigger which runs the random integer action and in return sets the respawn variable for the "Level1End" trigger.

Trigger:
  • Level1End
    • Events
      • Unit - A unit enters Region 066 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Hero_Type
    • Actions
      • Trigger - Turn off Lose <gen>
      • Trigger - Turn off RedDeath <gen>
      • Trigger - Turn off BlueDeath <gen>
      • Trigger - Turn off TealDeath <gen>
      • Trigger - Turn off PurpleDeath <gen>
      • Trigger - Turn off YellowDeath <gen>
      • Trigger - Turn off OrangeDeath <gen>
      • Trigger - Turn off GreenDeath <gen>
      • Trigger - Turn off PinkDeath <gen>
      • Trigger - Turn off GrayDeath <gen>
      • Trigger - Turn off LightBlueDeath <gen>
      • Trigger - Turn off DarkGreenDeath <gen>
      • Trigger - Run SequenceEnd <gen> (checking conditions)
      • Set Level = (Level + 1)
      • Hero - Set (Triggering unit) Hero-level to ((Hero level of (Triggering unit)) + 1), Hide level-up graphics
      • Set Heroes = (Units of type Hero_Type)
      • Unit Group - Pick every unit in Heroes and do (Unit - Kill (Picked unit))
      • Player Group - Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of Respawn) over 0.00 seconds)
      • Unit Group - Pick every unit in Heroes and do (Hero - Instantly revive (Picked unit) at (Center of Respawn), Show revival graphics)
      • Trigger - Turn on RedDeath <gen>
      • Trigger - Turn on BlueDeath <gen>
      • Trigger - Turn on TealDeath <gen>
      • Trigger - Turn on PurpleDeath <gen>
      • Trigger - Turn on YellowDeath <gen>
      • Trigger - Turn on OrangeDeath <gen>
      • Trigger - Turn on GreenDeath <gen>
      • Trigger - Turn on PinkDeath <gen>
      • Trigger - Turn on GrayDeath <gen>
      • Trigger - Turn on LightBlueDeath <gen>
      • Trigger - Turn on DarkGreenDeath <gen>
      • Trigger - Turn on Lose <gen>
      • Custom script: call DestroyGroup( udg_Heroes )
      • Custom script: call DestroyTrigger( GetTriggeringTrigger() )


Ps. The Levels region variable is set on map initialization in this manner...

Trigger:
  • SetRegionsStart
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Levels[1] = Region 001 <gen>
      • Set Levels[2] = Region 002 <gen>
      • Set Levels[3] = Region 003 <gen>
      • Set Levels[4] = Region 004 <gen>
      • Set Levels[5] = Region 005 <gen>
      • All the way up to 34...


If anyone has any ideas on if I'm missing something in one of my triggers, or if I added something wrong, don't hesitate to tell me; I'm willing to try anything at this point.

Seriously any help is appreciated :)

Thanks Anvio.
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
First of all; Why do you do this:
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
          RandomLevel Equal to 1
    Then - Actions
          Set Respawn = Levels[1]
    Else - Actions
          If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                      RandomLevel Equal to 2
                Then - Actions
                      Set Respawn = Levels[2]
....etc
Instead of this:
Code:
Set Respawn = Levels[RandomLevel]
This here: Set Level = (Level + 1), whats this? The levels should be random? If so it should be "Set level = RandomLevel", after you run the SequenceEnd... Or it just keeps the count of how many levels that is completed?

>>>but every now and then I get a level that repeats, as in when I beat the level I just get ported right back to the start of the level again
Which levels? The same level? Have you checked again the "end" trigger on those levels...?

Are you sure no other triggers uses the variables?:
Sequence
RandomLevel
SequenceCurrent
SequenceTotal
Respawn
 

anvio

New Member
Reaction score
1
Alright well the RandomLevel variable is the integer I use when setting the random number right here. And when the RandomLevel variable condition is picked it sets the Respawn variable to the region of a random level.

Code:
Set RandomLevel = (Random integer number between 1 and SequenceCurrent)

Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
          RandomLevel Equal to 1
    Then - Actions
          Set Respawn = Levels[1]
    Else - Actions
          If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                      RandomLevel Equal to 2
                Then - Actions
                      Set Respawn = Levels[2]
....etc

This here: Set Level = (Level + 1), whats this? The levels should be random? If so it should be "Set level = RandomLevel", after you run the SequenceEnd... Or it just keeps the count of how many levels that is completed?

Yea I'm using it to count the levels that have been completed and btw instead of using Set Respawn = Levels[RandomLevel] is there any way to use this Set Respawn = RandomLevel as in having the RandomLevel somehow 34 different regions lol? Anyway I need to get the RandomLevel to be 34 different regions so I'm using If Then and Else conditions; and at the moment I'm starting to think that it takes the game to long to go through all 34 conditions and just picks the closet one and sets that as respawn. Is there any easier way to set all 34 regions into the RandomLevel integer variable?

Which levels? The same level? Have you checked again the "end" trigger on those levels...?

Are you sure no other triggers uses the variables?:
Sequence
RandomLevel
SequenceCurrent
SequenceTotal
Respawn

No it's never the same level it's a random level that gets repeated sometimes, and the end level triggers all look perfectly right (I tripple checked lol :banghead:) And I checked my variables with the Object Editor and none of those variables are being used in any other triggers.

But yea once again as I said I think the problem is when it has to check which number has been picked; right now I'm trying to get this to work Instead of my multiple If Then and Else conditions. Set Respawn = RandomLevel

Thanks for the insight though.

Anvio. :)
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
I should never try to check other persons triggering at 8 AM after a night without sleep!;)

Here is your mistake, you do not use the sequence number, you use only the random number, not "Sequence[RandomNumber]"...
Code:
                      RandomLevel Equal to 2
                Then - Actions
                      Set Respawn = Levels[2]
Of course random level can be 2 multiple times! An example:
Set randomlevel = random number between 1 - 34
Next time you use that line, you set it to this:
Set randomlevel = random number between 1- 33...
See? Of course a level can repeat, more than ones too! :)

Which mean: The whole SequenceEnd Trigger should look like this:
Trigger:
  • Actions
    • Set RandomLevel = (Random integer number between 1 and SequenceCurrent)
    • Unit - Create 1 Footman for Player 1 (Red) at Respawn[Sequence[RandomLevel]] facing Default building facing degrees
    • Set Sequence[RandomLevel] = Sequence[SequenceCurrent]
    • Set SequenceCurrent = (SequenceCurrent - 1)


Instead of creating a footman at "Respawn[Sequence[RandomLevel]]", you revive all units there/pan camera so on...

PS: Do note that "Respawn[]" in this code is a point variable. Why this is? To prevent leaks. So I set it like this:
Code:
Map Init
    Events
        Map initialization
    Conditions
    Actions
        Set Respawn[1] = (Center of 1 <gen>)
        Set Respawn[2] = (Center of 2 <gen>)
        Set Respawn[3] = (Center of 3 <gen>)

If you use "Respawn" as a Region type, it leaks a point/location everytime you revive a hero/pan camera to any place within it.

And I am curious to what those Triggers named "LightBlueDeath" etc really do... Since you got one per player, I bet my left ear on that all those could be in the one and same trigger...
 

anvio

New Member
Reaction score
1
Haha thanks man; the funny thing is I just figured it out before I checked back here, but yea you really led me in the right direction.

Btw this is how I got it to work...

Trigger:
  • Set Respawn = Levels[Sequence[RandomLevel]]


And I had the Levels variable as an array set on map initialization like this...

Trigger:
  • SetRegions
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Levels[1] = Level1 &lt;gen&gt;
      • Set Levels[2] = Level2 &lt;gen&gt;
      • Set Levels[3] = Level3 &lt;gen&gt;
      • Set Levels[4] = Level4 &lt;gen&gt;
      • And so on...


+Rep...

Thanks from Anvio :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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