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 havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. 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.

Unit-type per map

Discussion in 'Triggers & Scripts' started by Kamulec, May 31, 2013.

  1. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I need a trigger that limits non-hero unit of specified type to 8 per map at once. The problem is:
    EVENT_PLAYER_UNIT_TRAIN_CANCEL occurs when train order is removed from the queue
    EVENT_PLAYER_UNIT_TRAIN_START occurs when unit is starting to be trained (so it is 1st in the queue)

    That means every cancel from 2nd and further places in queue makes my current system useless.

    I would strongly appreciate your help.
     
  2. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,529
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    can u post ur system ?
    all u need to do for this is have a counter for each unit type u want. then increase the counter when a unit of that unit type has begun training. if it is max then order it to stop training. have a trigger that reduces the number when the unit cancels training or when the unit dies.
     
  3. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,628
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    this would do
    • Untitled Trigger 001
      • Events
        • Unit - A unit enters (Playable map area)
      • Conditions
      • Actions
        • Custom script: set udg_integer_varaible [ GetUnitTypeId(GetTriggerUnit())] = udg_integer_variable [ GetUnitTypeId(GetTriggerUnit())] + 1
        • Custom script: if udg_integer_variable [ GetUnitTypeId(GetTriggerUnit()) >= 8] then
        • Unit - Remove (Triggering unit) from the game
        • Custom script: endif
     
  4. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,529
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    i believe unit type ids are larger than array limits so this wont work u need hashtables.
     
  5. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    • Player - Limit Training Of Unit-Type
     
  6. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,529
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    thats what i get for not using GUI lol
     
  7. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    Doesn't he want to limit units so the sum of that unit-type from all players make 8?
    If yes, then limiting training of unit-type per player will be useless
     
  8. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,529
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    he will have to use what was suggested at the top then.
     
  9. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,628
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Aint unit type id like a000? If no there is a solution ima find it in a second
     
  10. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,529
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    yes they are but that is ascii values.

    ascii values can be as high as 127,127,127,127 i believe
    'zzzz' would be 122,122,122,122 i believe.
    its been awhile since i looked at a chart for them
     
  11. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Thanks for the will of help.

    I need it for a specified unit-type, not all unit-types. I cannot just "remove" units, people wouldn't be happy to loose invested gold.

    I think I have found another solution. If I am wrong, I'll be back and write more.