1. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  2. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice
  3. Melee Mapping Contest #3 - Results are out! Congratulate the winners and check plenty of new 4v4 melee maps designed for this competition!
    Dismiss Notice
  4. The winners of our cinematic soundtrack competition have been decided! Step by the Music Contest #11 - Results to check the entries and congratulate the winners!
    Dismiss Notice

help...

Discussion in 'World Editor Help Zone' started by victorsuazo1991, Jan 14, 2019.

  1. victorsuazo1991

    victorsuazo1991

    Joined:
    Oct 25, 2018
    Messages:
    81
    Resources:
    0
    Resources:
    0
    Hello, I need help with a map, in which I am creating waves of enemies. It happens that too many creeps accumulate to the point that it becomes impossible to play ... is there any way to put a limit of units for each wave? that is to say if every one minute I create 10 creeps, that attack a specific zone, having 40 creeps on the map, they will no longer be produced?
     
  2. Sir Moriarty

    Sir Moriarty

    Spell Reviewer

    Joined:
    Jun 13, 2016
    Messages:
    279
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Here's a very trivial example of how you could do this. The condition is the primary part.

    • Melee Initialization
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
        • (Number of units in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Rifleman))) Less than 10
      • Actions
        • Unit - Create 1 Rifleman for Player 2 (Blue) at (Center of (Playable map area)) facing Default building facing degrees
     
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,030
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Yes there is a way.

    Most simple would be to use food. One can then have a conditional test in the spawn trigger to check if current food is less than the produced food and only if so create the units.

    Instead of food, like in the case that already has another use, one could use an integer variable.

    Leaks a group, so not a good idea to use that trigger.
     
  4. victorsuazo1991

    victorsuazo1991

    Joined:
    Oct 25, 2018
    Messages:
    81
    Resources:
    0
    Resources:
    0
    Is that an integer condition or multiple conditions?
     
  5. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    integer
    but I suggest that one, then the group object gets destroyed.
    • Conditions
      • (Number of living Scharfsch├╝tze units owned by Player 1 (Red)) Less than 10
     
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,030
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Problem is it leaks a handle ID due to the local declared local agent variable reference counter leak on return bug.

    Here is the function showing the leak.
    Code (vJASS):
    function CountLivingPlayerUnitsOfTypeId takes integer unitId,player whichPlayer returns integer
        local group g
        local integer matchedCount
        set g = CreateGroup()
        set bj_livingPlayerUnitsTypeId = unitId
        call GroupEnumUnitsOfPlayer(g, whichPlayer, filterLivingPlayerUnitsOfTypeId)
        set matchedCount = CountUnitsInGroup(g)
        call DestroyGroup(g)
        return matchedCount
    endfunction


    This may eventually be fixed but until then here is a leak free version.
    Code (vJASS):
    function CountLivingPlayerUnitsOfTypeIdNoleak takes integer unitId,player whichPlayer returns integer
        local group g
        local integer matchedCount
        set g = CreateGroup()
        set bj_livingPlayerUnitsTypeId = unitId
        call GroupEnumUnitsOfPlayer(g, whichPlayer, filterLivingPlayerUnitsOfTypeId)
        set matchedCount = CountUnitsInGroup(g)
        call DestroyGroup(g)
        set g = null
        return matchedCount
    endfunction
     
  7. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    Actually there is a native doing the counting, but not ported to GUI.
    Code (vJASS):

    constant native GetPlayerTypedUnitCount takes player whichPlayer, string unitName, boolean includeIncomplete, boolean includeUpgrades returns integer
     


    one uses it that way
    Code (vJASS):

    call GetPlayerTypedUnitCount (Player(0), UnitId2String('hfoo'),false,true)
     
     
  8. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,030
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    The native is not doing the counting in GUI as I posted above. If it was there would not be any problems.

    Still the food method might be the most easy as long as food is not used for other things. Especially if interacting with many different unit types it would allow one to more simply regulate them.
     
  9. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    yes, food would be indeed easy and good. One could even use a player State Event when using food to en/dis able the spawning timer/Trigger.