Will "from 1 to X" work if players slots are closed.

Solu9

You can change this now in User CP.
Reaction score
216
Kinda odd title, but I didn't know what else to write.

I have these triggers:

Trigger:
  • Second Setup
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set Integer_Units = (Random integer number between 1 and 3)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Wizard for (Player((Integer A))) at Point_CreateUnit facing Point_MidMap
          • Selection - Select (Last created unit) for (Player((Integer A)))
          • Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using The unit's rotation
          • Set Hero[(Integer A)] = (Last created unit)
          • Custom script: call RemoveLocation (udg_Point_CreateUnit)
      • Countdown Timer - Start ThirdViewCam as a Repeating timer that will expire in 0.50 seconds
      • Custom script: call RemoveLocation (udg_Point_MidMap)
      • Game - Set the time of day to 12.00
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across (Playable map area)
          • Visibility - Enable (Last created visibility modifier)
          • Set VisMod_Default[(Integer A)] = (Last created visibility modifier)
      • Countdown Timer - Start Timer_GameTime as a One-shot timer that will expire in 300.00 seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title Remaining Time:
      • Trigger - Turn on Gameover <gen>
      • Trigger - Turn on Play 3rd view cam Copy <gen>


Trigger:
  • Play 3rd view cam Copy
    • Events
      • Time - ThirdViewCam expires
    • Conditions
    • Actions
      • For each (Integer B) from 1 to 12, do (Actions)
        • Loop - Actions
          • Camera - Set (Player((Integer B)))'s camera Distance to target to 2200.00 over 1.00 seconds
          • Camera - Set (Player((Integer B)))'s camera Angle of attack to 320.00 over 1.00 seconds
          • Camera - Set (Player((Integer B)))'s camera Field of view to 5000.00 over 1.00 seconds
          • Camera - Set (Player((Integer B)))'s camera Rotation to (Facing of Hero[(Integer B)]) over 1.00 seconds
          • Camera - Set (Player((Integer B)))'s camera Height Offset to 500.00 over 0.50 seconds
          • Camera - Set (Player((Integer B)))'s camera Far Z to 6000.00 over 0.50 seconds


I have changed "For each (Integer B) from 1 to 12, do (Actions)" to 12 instead of "count players in PlayerGroup_Players". I did this because I tried disabling player 1 and 2 in the editor to test if the trigger would still work. And when I did so, playing as teal (player 3) the camera trigger here did not work.

Note that in the first trigger is also says "For each (Integer A) from 1 to 12, do (Actions)" but WAS also "count players in PlayerGroup_Players".
PlayerGroup_Players get set another trigger concerning the multiboard. This happens before these triggers are run so that is not the problem.

The real questions here is. Did the camera trigger not work only because I disabled player 1 and 2 or was it because of the way I count the player in PlayerGroup_Players?
I personally thought the latter, and thats why I changed it to "For each (Integer A) from 1 to 12, do (Actions)" . But I'm in doubt and I don't want to change it further if it is not necessary.

Sorry for the long post.
 

Imp Midna

Active Member
Reaction score
52
I assume you tested it alone, being the only player?
If so, "count players in PlayerGroup_Players" will return 1, your for loop will iterate from 1 to 1 (leaving the only execution of that loop to be a 1) and therefor only do the camera stuff for player 1 (who is not there, so...)
Looping from 1 to 12 will always cover the first 12 players, whether they are there or not, which might get you into trouble as it will always create 12 wizards, no matter what.
If PlayerGroup_Players contains all the players from your leaderboard, you might as well use "pick every player in force". It would skip players that are not there.
 

Solu9

You can change this now in User CP.
Reaction score
216
If so, "count players in PlayerGroup_Players" will return 1, your for loop will iterate from 1 to 1 (leaving the only execution of that loop to be a 1) and therefor only do the camera stuff for player 1 (who is not there, so...)

I figured this and therefore chose to do it 1 to 12 instead of count numbers. Another reason I'dd rather do it is this manner is that if players leave a gab between them in the game lobby. Ex. occupying slot 1, 4 and 7 I will have the same problem again.

I worked around the spawn Wizard problem by throwing in an if/then/else action. Checking if that specific slot is being used.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Alternately, something like this:

Pick every player in (Players matching ((Matching Player) is Playing Equal to True)) and do Actions
- Etc.

It has been like a year since I've even loaded the editor, so my syntax is likely complete crap.
 

Solu9

You can change this now in User CP.
Reaction score
216
Aye. But won't I run into the same problem as before?

If slot 1,2, 4 and 5 is open, then only 4 players are playing. So the camera for player occupying slot nr. 5 will have a none function camera.
 

vypur85

Hibernate
Reaction score
803
Err. Not exactly. What Ghan is suggesting is that use 'Player loop' and NOT 'Integer loop'.

Player loop should work as it should, regardless of any gaps of non playing player.
If you're using player loop, all your Integer A/B are to be replaced with 'Player number' instead. So it should function well.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top