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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top