1. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  2. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  3. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  4. Check out the Staff job openings thread.
    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

    Joined:
    Jun 13, 2016
    Messages:
    315
    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,260
    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,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    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,260
    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,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    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,260
    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,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    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.