Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[General] Making this trigger for multiple players

Discussion in 'World Editor Help Zone' started by Qrom Bellascream, Jun 29, 2016.

  1. Qrom Bellascream

    Qrom Bellascream

    Joined:
    Apr 5, 2013
    Messages:
    150
    Resources:
    0
    Resources:
    0
    I'm trying to make a car in the World Editor for my city map that has 10 players. It has 1 problem, it only works for 1 player, as in trigger 2, if 2 players are inside a car in the same time, the PlayerNumber integer gets overwritten by the latter player entering a car. How do I fix this?

    [Trigger 1]
    Car Add Movement
    Events
    Unit - A unit Is loaded into a transport
    Conditions
    (Unit-type of (Transporting unit)) Equal to Car
    Actions
    Unit - Set (Transporting unit) movement speed to 300.00
    Unit Group - Add (Triggering unit) to InsideCar[(Player number of (Owner of (Triggering unit)))]
    Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
    Trigger - Turn off Car is inside <gen>

    [Trigger 2]
    Car is inside
    Events
    Time - Every 0.10 seconds of game time
    Conditions
    Actions
    Unit Group - Pick every unit in InsideCar[PlayerNumber] and do (Actions)
    Loop - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    ((Picked unit) is being transported) Equal to False
    Then - Actions
    Unit Group - Remove (Picked unit) from InsideCar[PlayerNumber]
    Else - Actions
     
  2. Dehua_Darbuya

    Dehua_Darbuya

    Joined:
    Jan 28, 2016
    Messages:
    483
    Resources:
    0
    Resources:
    0
    Like this! :D

    • Car 1
      • Events
        • Unit - A unit Is loaded into a transport
      • Conditions
        • (Unit-type of (Transporting unit)) Equal to Car
      • Actions
        • Unit - Set (Transporting unit) movement speed to 300.00
        • Unit Group - Add (Triggering unit) to CampSite[(Player number of (Owner of (Triggering unit)))]

    • Car 2
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
      • Actions
        • For each (Integer TempInteger) from 1 to 10, do (Actions)
          • Loop - Actions
            • Unit Group - Pick every unit in InsideCar[(Player number of (Player(TempInteger)))] and do (Actions)
              • Loop - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ((Picked unit) is being transported) Equal to False
                  • Then - Actions
                    • Unit Group - Remove (Picked unit) from InsideCar[(Player number of (Player(TempInteger)))]
                  • Else - Actions

    It's a little confusing but you were on the right track. I removed the PlayerNumber variable from the first trigger because it's setting the number to a fixed value and over-ridding (pun intended) any previous values in the second trigger like you said. Instead I looped through each player with an integer to checked each player's group.

    The only thing I didn't understand is why you were turning off the second trigger at the end of the first. Oh and you can use trigger tags to post GUI code, like so: [TRIGGER]Insert trigger text here![/TRIGGER]
     
    Last edited: Jun 29, 2016
  3. Alright

    Alright

    Joined:
    May 20, 2014
    Messages:
    230
    Resources:
    0
    Resources:
    0
    IIRC, for the second trigger you can also use the event 'an unit enters the playable map', and checking if unit was part of the unit group, since an unit leaving a transport will cause the event to fire. At least I remember this from other thread some time back.
     
  4. Qrom Bellascream

    Qrom Bellascream

    Joined:
    Apr 5, 2013
    Messages:
    150
    Resources:
    0
    Resources:
    0
    Thanks for the help both of you. And the turn trigger off at the end of the first script was an accident. Was meant to turn on the other trigger.
     
  5. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,638
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Also be sure that the unit groups for the other players exists.
    Index 2+ will not have a unit group by default so you have to set the size of the array to 11 (i guess).
     
  6. Qrom Bellascream

    Qrom Bellascream

    Joined:
    Apr 5, 2013
    Messages:
    150
    Resources:
    0
    Resources:
    0
    Thanks Wietlol, haven't got a chance to test it with multiple players yet, and that would probably had went unnoticed if it wasn't for you.