1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Spawning trigger assistance

Discussion in 'World Editor Help Zone' started by Marcell, Jan 29, 2018.

  1. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Hi all,

    I'm fiddling around with the spawning of units and made the following script that makes sense to me but doesn't work :S

    Code (Text):
    Events
    - Unit - A unit enters Region 024 <gen>
    - Time - Every 2.00 Seconds of game time
    Conditions
    - ((Triggering unit) is A ground unit) Equal to ((Triggering unit) is in (Random 2 units from (Units in (Playable map area))))
    Actions
    Unit - Create 1 Redeemer for (Owner of (Triggering unit)) at (((Owner of (Triggering unit)) start location) offset by (0.00, 0.00)) facing Default  building facing degrees
    What I'd like the code to do is: You must have 2 units standing in the region to spawn an unit called Redeemer every 2 seconds until you remove the units from the region.

    Edit: How do I move this script myself to the right section?
     
    Last edited: Jan 29, 2018
  2. Chaosium

    Chaosium

    Joined:
    Aug 29, 2012
    Messages:
    417
    Resources:
    2
    Models:
    2
    Resources:
    2
    I think your condition doesn't work. You'd want to use an "AND" condition and uses booleans, because right now I guess it returns nothing.
     
  3. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,484
    Resources:
    18
    Tools:
    2
    Maps:
    3
    Spells:
    8
    Tutorials:
    4
    JASS:
    1
    Resources:
    18
    Your Trigger has mixed up many informations in one, therefore should not be solve in one trigger.

    Inside the Event " Time - Every 2.00 Seconds of game time" triggering Unit is not set (aka no unit) and therefore can not be a ground unit nor it can be part of units of units in playable map.

    Splitup the task in multiple triggers so each becomes more simple, you could do a logic flow like below:
    1. Enter the region
    2. Leave region
    3. death (while in region)
    4. spawning the redeemer, with the 2 seconds timer.

    How To Post Your Trigger
     
  4. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    • Redeemer
      • Events
        • Unit - A unit enters Region 024 <gen>
      • Conditions
        • (Number of units in (Units in Region 024 <gen>)) Equal to 2
      • Actions
        • Unit - Create 1 Redeemer for (Owner of (Triggering unit)) at (((Owner of (Triggering unit)) start location) offset by (0.00, 0.00)) facing Default building facing degrees
        • For each (Integer A) from 1 to 1000, do (Actions)
          • Loop - Actions
            • Unit - Create 1 Redeemer for (Owner of (Triggering unit)) at ((Owner of (Triggering unit)) start location) facing (Random point in (Playable map area))
            • Wait 4.00 seconds
            • Trigger - Run (This trigger) (checking conditions)


    I know you're not suppose to use wait, but I can't find "set time delay" as recommended.
    With this script, it spawns a unit every 4 seconds, but I must let 1 unit at a time enter the region, how do I fix this so that I can just select 2 units and let them run into the region triggering the script?
     
  5. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,484
    Resources:
    18
    Tools:
    2
    Maps:
    3
    Spells:
    8
    Tutorials:
    4
    JASS:
    1
    Resources:
    18
    You do not need that loop.
    When the event "enters region" fires the entering unit is not yet inside the region.
    Easy Fix is place a little bit bigger region at the same spot and check units inside that bigger region, but use the enter region from the smaller one.
     
  6. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    I have 100 units like the above, would this still be the easy fix? Or is there perhaps a different trigger I can copy paste for all 100?
     
  7. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,484
    Resources:
    18
    Tools:
    2
    Maps:
    3
    Spells:
    8
    Tutorials:
    4
    JASS:
    1
    Resources:
    18
    That is for units, then don't use regions at all, base it on units. make a group of all control Points.
    Every x seconds of gametime change ownership of the point.
    Every y seconds of gametime spawn a redeemer for its current owner.

    • Redeem trigger
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • -------- Change ownership every second --------
        • Unit Group - Pick every unit in RedeemGroup and do (Actions)
          • Loop - Actions
            • Set Loc = (Position of (Picked unit))
            • Set Max = 0
            • Set Player = Neutral Passive
            • Player Group - Pick every player in (All players) and do (Actions)
              • Loop - Actions
                • Set Group = (Units within 300.00 of Loc matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and ((Owner of (Matching unit)) Equal to (Picked player)))))
                • Unit Group - Remove (Picked unit) from Group
                • Custom script: set bj_wantDestroyGroup = true
                • Set Count = (Number of units in Group)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count Greater than Max
                  • Then - Actions
                    • Set Max = Count
                    • Set Player = (Picked player)
                  • Else - Actions
            • Custom script: call RemoveLocation(udg_Loc)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Max Greater than or equal to 2
              • Then - Actions
                • Unit - Change ownership of (Picked unit) to Player and Change color
              • Else - Actions
                • Unit - Change ownership of (Picked unit) to Neutral Passive and Change color
        • -------- Every 4 seconds of gametime spawn a unit for the current owner of each point. --------
        • -------- Could be done inside anouther trigger with every 4 seconds but you might encounter execution order problems. --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Execution count of (This trigger)) Equal to 4
          • Then - Actions
            • Unit Group - Pick every unit in RedeemGroup and do (Actions)
              • Loop - Actions
                • Set Player = (Owner of (Picked unit))
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Player Not equal to Neutral Passive
                  • Then - Actions
                    • Set Loc = (Player start location)
                    • Unit - Create 1 Soldat for Player at Loc facing Default building facing degrees
                    • Custom script: call RemoveLocation(udg_Loc)
                  • Else - Actions
            • Custom script: call ResetTrigger( GetTriggeringTrigger() )
          • Else - Actions
    • Redeem Init
      • Events
        • Map initialization
      • Conditions
      • Actions
        • -------- Add all Units spawning this redeemers to a group --------
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Circle der Macht)) and do (Actions)
          • Loop - Actions
            • Unit Group - Add (Picked unit) to RedeemGroup
     

    Attached Files:

    Last edited: Jan 31, 2018
  8. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Wow, thanks for the huge effort. +2 rep. I'll check out the script tonight.
     
  9. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Hey, thanks again for the script. After 2 weeks I could finally check it out. I see the script checks who currently owns the circle of power, but I have 1 area that all players use to spawn units in the battle field. Is there a quick fix to the script that can be done? As I see the whole script is focused on ownership of the area, a quick brainstorm is to add 8 circle of powers (total number of players) to each region that spawns units?
     
  10. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    • Redeem trigger
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in RedeemGroup and do (Actions)
          • Loop - Actions
            • Set Loc = (Position of (Picked unit))
            • Set Max = 0
            • Set Player = Neutral Passive
            • Player Group - Pick every player in (All players) and do (Actions)
              • Loop - Actions
                • Set Group = (Units within 300.00 of Loc matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and ((Owner of (Matching unit)) Equal to (Picked player)))))
                • Unit Group - Remove (Picked unit) from Group
                • Custom script: set bj_wantDestroyGroup = true
                • Set Count = (Number of units in Group)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count Greater than Max
                  • Then - Actions
                    • Set Max = Count
                    • Set Player = (Owner of (triggering unit))
                  • Else - Actions
            • Custom script: call RemoveLocation(udg_Loc)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Max Greater than or equal to 2
                • Player Not equal to Neutral Passive
                • (Execution count of (This trigger)) Equal to 4
              • Then - Actions
                • Set Loc = (Player start location)
                • Unit - Create 1 Footman for Player at Loc facing Default building facing degrees
                • Custom script: call RemoveLocation(udg_Loc)
              • Else - Actions
                • Custom script: call ResetTrigger( GetTriggeringTrigger() )


    This is my failed attempt at making the script work as I would like. Can anyone please assist in making it so that if any amount of players match the condition on one circle of power, it will spawn an unit at their starting location?
     
  11. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,484
    Resources:
    18
    Tools:
    2
    Maps:
    3
    Spells:
    8
    Tutorials:
    4
    JASS:
    1
    Resources:
    18
    Well i missunderstood you last time as you want all players be able to use 1 point at the same time.

    this should do the trick, Spawns 1 Unit for each Point for each player having atleast 2 units nearby.
    • Redeem trigger
      • Events
        • Time - Every 4.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in RedeemGroup and do (Actions)
          • Loop - Actions
            • -------- Reset Counter for all Players --------
            • Player Group - Pick every player in (All players) and do (Actions)
              • Loop - Actions
                • Set Count[(Player number of (Picked player))] = 0
            • -------- Get Units around --------
            • Set Loc = (Position of (Picked unit))
            • Set Group = (Units within 240.00 of Loc matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A ground unit) Equal to True)))
            • -------- Remove the location object --------
            • Custom script: call RemoveLocation(udg_Loc)
            • -------- Exclude the circle from beeing counted --------
            • Unit Group - Remove (Picked unit) from Group
            • -------- autodestroy the temp group --------
            • Custom script: set bj_wantDestroyGroup = true
            • -------- count up for each player the amount of units they have around --------
            • Unit Group - Pick every unit in Group and do (Actions)
              • Loop - Actions
                • Set Index = (Player number of (Owner of (Picked unit)))
                • Set Count[Index] = (Count[Index] + 1)
            • Player Group - Pick every player in (All players) and do (Actions)
              • Loop - Actions
                • Set Index = (Player number of (Picked player))
                • -------- this player has at least 2 units in the group. --------
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count[Index] Greater than or equal to 2
                  • Then - Actions
                    • Set Loc = (Player start location)
                    • Unit - Create 1 Soldat for (Picked player) at Loc facing Default building facing degrees
                    • Custom script: call RemoveLocation(udg_Loc)
                  • Else - Actions
     
  12. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Yea, I've learned posting around these parts that my posts aren't clear :D. Thanks for fixing it, gonna give it a try in a bit.
     
  13. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    I've entered your script exactly as is but it's not working, makes me think I probably declared by variables incorrectly.
    My count is an Integer array
    Group - Unit group
    Index - Integer
    Loc - Point
    RedeemGroup - Unit Group
     
  14. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,484
    Resources:
    18
    Tools:
    2
    Maps:
    3
    Spells:
    8
    Tutorials:
    4
    JASS:
    1
    Resources:
    18
    Not working
    it does not spawn units?
    or error when writing?​

    i made a small misstake:
    Set Loc = (Player start location)
    -> Set Loc = ((Picked Player) start location)​
    The variable types are correct.

    you filled the redeemGroup?
    And if yes how you filled it.
     
  15. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    I used the same Redeemgroup as your third post here.

    The unit doesn't spawn at all. I tried with 2 players standing on it and also as 1 player. Will try it with your Loc adjustment.
     
  16. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    I've spent 5 minutes making sure I match your script line for line and there is no unit being spawned, perhaps my eye is off as I've fixed a few mistakes I made from the first time I thought I matched it line for line. Please check that I entered it exactly as you have to make sure I did it right:
    • Redeem trigger
      • Events
        • Time - Every 4.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in RedeemGroup and do (Actions)
          • Loop - Actions
            • Player Group - Pick every player in (All players) and do (Actions)
              • Loop - Actions
                • Set Count[(Player number of (Picked player))] = 0
            • Set Loc = (Position of (Picked unit))
            • Set Group = (Units within 300.00 of Loc matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A ground unit) Equal to True)))
            • Custom script: call RemoveLocation(udg_Loc)
            • Unit Group - Remove (Picked unit) from Group
            • Custom script: set bj_wantDestroyGroup = true
            • Unit Group - Pick every unit in Group and do (Actions)
              • Loop - Actions
                • Set Index = (Player number of (Owner of (Picked unit)))
                • Set Count[Index] = Count[(Index + 1)]
            • Player Group - Pick every player in (All players) and do (Actions)
              • Loop - Actions
                • Set Index = (Player number of (Picked player))
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count[Index] Greater than or equal to 2
                  • Then - Actions
                    • Set Loc = ((Picked player) start location)
                    • Unit - Create 1 Footman for (Picked player) at Loc facing Default building facing degrees
                    • Custom script: call RemoveLocation(udg_Loc)
                  • Else - Actions
     
  17. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,484
    Resources:
    18
    Tools:
    2
    Maps:
    3
    Spells:
    8
    Tutorials:
    4
    JASS:
    1
    Resources:
    18
    Set Count[Index] = Count[(Index + 1)]
    ^^ wrong. Currently sets the counter to match the counter of the next player.
    ->
    But you wana count units up, Therefore the next line is right.
    set Count[Index] = Count[Index] + 1
     
  18. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Motherf. Need to be so precise. It seems to work, I assume it only works for players so I can't test it 100% yet, thanks a lot, this component is 90% of my map. Hehe
     
  19. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Plugged in my laptop and both players spawned units. Thanks a lot, hopefully I'm not too lazy and post the map in say 3 weeks.
     
  20. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Hi again. I would just like to find out, how would I go about modifying this trigger so that each player can have a limited amount of the unit? I've implemented the trigger on many units, but I'd like one of my units to be limited per player.