Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Switch randomization triggers not running in order
Switch randomization triggers not running in order
Jan 4 2025, 2:39 pm
By: sethmachine  

Jan 4 2025, 2:39 pm sethmachine Post #1



Hi,

I am doing the technique to get a random value (power of 2) by randomizing a switch N times and summing each power of 2 until I have a random value I need.

What I noticed is that my checks for switch being set are not running in their trigger order, and I get output that's out of order. This seems to cause other problems.

What is wrong with my trigger set up? Do I need to explicitly clear the switch each time a power of 2 is added? That seemed to fix the out of order triggers. Triggers below, and a test map is attached showing the problem. Note that I am also using hyper triggers.


Quote
{'_conditions': [DeathsCondition(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _comparator=<NumericComparator.EXACTLY: (10, 'Exactly')>, _amount=0, _unit=<UnitId.ALAN_SCHEZAR_TURRET: (18, 'Alan Schezar Turret')>, _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetDeathsAction(_group=<PlayerId.CURRENT_PLAYER: (13, 'Current Player')>, _unit=<UnitId.ALAN_SCHEZAR_TURRET: (18, 'Alan Schezar Turret')>, _amount=1, _amount_modifier=<AmountModifier.SET_TO: (7, 'Set to')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), WaitAction(_milliseconds=0, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.CURRENT_PLAYER: (13, 'Current Player')>, _unit=<UnitId.ALAN_SCHEZAR_TURRET: (18, 'Alan Schezar Turret')>, _amount=0, _amount_modifier=<AmountModifier.SET_TO: (7, 'Set to')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), WaitAction(_milliseconds=0, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), PreserveTrigger(_flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='1'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=1, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='2'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=2, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='4'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=4, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='8'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=8, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='16'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=16, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='32'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=32, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [AlwaysCondition(_flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [SetSwitchAction(_switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _switch_action=<SwitchAction.RANDOMIZE: (11, 'Randomize switch')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}
{'_conditions': [SwitchCondition(_switch_state=<SwitchState.SET: (2, 'Switch is set')>, _switch=RichSwitch(_custom_name=RichString(_value='kingdoms-assignment-switch'), _index=None), _flags=TriggerConditionFlags(unknown=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_actions': [DisplayTextMessageAction(_text=RichString(_value='64'), _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False)), SetDeathsAction(_group=<PlayerId.PLAYER_6: (5, 'Player 6')>, _unit=<UnitId.CANTINA: (181, 'Cantina')>, _amount=64, _amount_modifier=<AmountModifier.ADD: (8, 'Add')>, _flags=TriggerActionFlags(ignore_wait_or_transmission_once=False, disabled=False, always_display=False, unit_properties_is_used=False, unit_type_is_used=False))], '_players': {<PlayerId.PLAYER_1: (0, 'Player 1')>}}


Attachments:
plain-dirt-2025-01-03.scx
Hits: 1 Size: 668.12kb
triggers.jsonl
Hits: 0 Size: 12.03kb



None.

Jan 4 2025, 4:25 pm Ultraviolet Post #2

We do a little trolling

That's not very readable. Here's a working single switch example of randomizing a DC between 0 and 31 every trigger cycle. Personally, I prefer using multiple switches to accomplish this as it's a little cleaner implementation, but this should work about the same.

Trigger("Player 1"){
Conditions:
Always();

Actions:
Preserve Trigger();
Set Deaths("Current Player", "Independent Command Center", Set To, 0);
Set Switch("Switch1", randomize);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Switch("Switch1", Set);

Actions:
Preserve Trigger();
Set Deaths("Current Player", "Independent Command Center", Add, 1);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Always();

Actions:
Preserve Trigger();
Set Switch("Switch1", randomize);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Switch("Switch1", Set);

Actions:
Preserve Trigger();
Set Deaths("Current Player", "Independent Command Center", Add, 2);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Always();

Actions:
Preserve Trigger();
Set Switch("Switch1", randomize);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Switch("Switch1", Set);

Actions:
Preserve Trigger();
Set Deaths("Current Player", "Independent Command Center", Add, 4);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Always();

Actions:
Preserve Trigger();
Set Switch("Switch1", randomize);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Switch("Switch1", Set);

Actions:
Preserve Trigger();
Set Deaths("Current Player", "Independent Command Center", Add, 8);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Always();

Actions:
Preserve Trigger();
Set Switch("Switch1", randomize);
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
Switch("Switch1", Set);

Actions:
Preserve Trigger();
Set Deaths("Current Player", "Independent Command Center", Add, 16);
}

//-----------------------------------------------------------------//



My Projects:

Impossible Ultraviolet | Impossible UV 2 | Impossible UV 3
Mercenaries 2020 | Mercenaries III
Squad Defense

Legacy Projects (No guarantee of functionality in modern SC):

Pixel Adventure 2 | Space Snipers | Control the Ball

______________________________________________

Join me in Torn City

Jan 5 2025, 8:39 am NudeRaider Post #3

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

You check trigger order in Scmdraft, not some json file. Not familiar with this type of trigger generation, so I can't give any tips with it.

But in the end the execution order actually doesn't matter. Yes, you gonna get a different random number than you would've with "correct" ordering, but it's just as random so it should be good anyhow, right?




Jan 5 2025, 5:09 pm Ultraviolet Post #4

We do a little trolling

Quote
But in the end the execution order actually doesn't matter.

Depending on how the triggers are built (I can't read that json trigger stuff either), it could matter greatly. For example, I usually establish a reset at the top of the trigger list so that the number is starting from 0 every cycle. If that reset got put out of order, it could affect it in such a way that you never got a random number at all, you could just get stuck with it generating 0 every time if it was at the bottom of the list instead.



My Projects:

Impossible Ultraviolet | Impossible UV 2 | Impossible UV 3
Mercenaries 2020 | Mercenaries III
Squad Defense

Legacy Projects (No guarantee of functionality in modern SC):

Pixel Adventure 2 | Space Snipers | Control the Ball

______________________________________________

Join me in Torn City

Jan 5 2025, 6:18 pm NudeRaider Post #5

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from Ultraviolet
Depending on how the triggers are built (I can't read that json trigger stuff either), it could matter greatly. For example, I usually establish a reset at the top of the trigger list so that the number is starting from 0 every cycle. If that reset got put out of order, it could affect it in such a way that you never got a random number at all, you could just get stuck with it generating 0 every time if it was at the bottom of the list instead.
Yeah the reset trigger has to be above all others. For all the others, namely randomizing and addition it doesn't matter. Randomization can even happen one or more trigger cycles ahead of time.

At least for the common methods I can think of.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:36 am]
Moose -- Thinking on it more, I vaguely remember it being annoying because it kept repeating some short loop of the Super Mario World theme LMAO
[12:57 am]
Oh_Man -- I thought i remembered an old mario map but i searched super mario starcraft on utube and i couldnt see anything cept UMS
[11:40 pm]
lil-Inferno -- Blizzard forgot about SC so it's okay
[2026-8-09. : 7:04 pm]
Symmetry -- malware maps for everyone
[2026-8-09. : 7:03 pm]
Moose -- probs lmao
[2026-8-09. : 6:57 pm]
Symmetry -- (and will be patched)
[2026-8-09. : 6:56 pm]
Symmetry -- The old stuff would've gotten patched no? this is current
[2026-8-09. : 6:55 pm]
Moose -- Just made? I thought we had that years ago
[2026-8-09. : 5:23 pm]
Oh_Man -- so someone just made super mario in brood war https://www.youtube.com/watch?v=DmrUcKU65oQ
[2026-8-06. : 2:41 am]
Oh_Man -- i used to play TF2 competitive in that clan, and also was PR manager (ie: i wrote all the website posts)
Please log in to shout.


Members Online: NudeRaider