• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Limit training of one hero error.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
  • Slayer Creation
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Slayer P
          • (Unit-type of (Trained unit)) Equal to Slayeress
    • Actions
      • Game - Display to (All players) the text: ((Name of (Owner of (Triggering unit))) + has created a slayer!)
      • Player - Limit training of Worker to 50 for (Owner of (Triggering unit))
      • Player - Limit training of Heroes to 1 for (Owner of (Triggering unit))
I mean I guess I could limit training of the specific unit type. But I would of thought "Heroes" would limit all training of heroes?
 
Level 13
Joined
Oct 12, 2016
Messages
769
Is Slayer P and Slayeress a custom hero?

And if they are, are they what you want to limit?
Are they registered in Gameplay Constants under the "equivilents" section if they are heroes?
You'll find this under Advanced (at the top) -> Gameplay Constants.
 
Level 12
Joined
Dec 2, 2016
Messages
733
Is Slayer P and Slayeress a custom hero?

And if they are, are they what you want to limit?
Are they registered in Gameplay Constants under the "equivilents" section if they are heroes?
You'll find this under Advanced (at the top) -> Gameplay Constants.

Sorry I forgot to include what was wrong, these are supposed to be heroes. And when I train one I can still train more than 1.

This is the only equivalents section I found.

Gyazo - d1a50ec4928790fd49a9470de4a769bd.png

Only my vamp hero is there, and only 1 of them. Not my slayers which are the ally team heroes.
 
Level 13
Joined
Oct 12, 2016
Messages
769
There's more than 1 way to do this.

1) You could put all heroes into the equivalents. The way the hero limit trigger works, is that it takes all heroes in the "equivalents" to calculate the maximum number of heroes.
Add those "slayers" to the hero list, and set the limit of training to 2.

2) You could just limit the number of each slayer unit to 1 like so:
  • Limit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Slayer P to 1 for (Picked player)
          • Player - Limit training of Slayeress to 1 for (Picked player)
After, for either method, make a trigger so that when you finish training 1 slayer, it limits the number of the other type to "0":
  • Slayer Trained
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Slayer P
          • (Unit-type of (Trained unit)) Equal to Slayeress
    • Actions
      • Player - Limit training of Slayer P to 0 for (Owner of (Triggering unit))
      • Player - Limit training of Slayeress to 0 for (Owner of (Triggering unit))

I also highly recommend setting limits during "Map Initialization" unless the limit to workers and such are a feature of the Slayer.
 
Level 12
Joined
Dec 2, 2016
Messages
733
There's more than 1 way to do this.

1) You could put all heroes into the equivalents. The way the hero limit trigger works, is that it takes all heroes in the "equivalents" to calculate the maximum number of heroes.
Add those "slayers" to the hero list, and set the limit of training to 2.

2) You could just limit the number of each slayer unit to 1 like so:
  • Limit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Slayer P to 1 for (Picked player)
          • Player - Limit training of Slayeress to 1 for (Picked player)
After, for either method, make a trigger so that when you finish training 1 slayer, it limits the number of the other type to "0":
  • Slayer Trained
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Slayer P
          • (Unit-type of (Trained unit)) Equal to Slayeress
    • Actions
      • Player - Limit training of Slayer P to 0 for (Owner of (Triggering unit))
      • Player - Limit training of Slayeress to 0 for (Owner of (Triggering unit))

I also highly recommend setting limits during "Map Initialization" unless the limit to workers and such are a feature of the Slayer.

I put them in equivalents, just to let you know. If you do the second trigger you recommended. That only fires when it's finished training. But you can actually create the max que of slayers and have like 8 heroes before you can't make anymore. Would need multiple triggers to check when it's started and cancelled to remove the hero. Thank.
 
Level 18
Joined
Nov 21, 2012
Messages
835
But I would of thought "Heroes" would limit all training of heroes?
Yes.
This:
You could put all heroes into the equivalents.
And this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • For each (Integer A) from 1 to 12, do (Player - Limit training of Heroes to 3 for (Player((Integer A))))
assuming you want players can have up to 3 heroes
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I mentioned it in another similar thread recently:
  • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
only works for the standard melee heroes. It's a simple function, that basically uses this function:
  • Player - Limit training of Mountain King to 1 for Player 1 (Red)
for every standard melee hero for every player.

So for custom heroes, you have to limit them to 1 for every player manually.

This function however:
  • Player - Limit training of Heroes to 3 for Player 1 (Red)
works for every hero marked as hero in the equivalents.
 
Status
Not open for further replies.
Top