• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

Efficient Hero Limiting Trigger?

Status
Not open for further replies.
Level 6
Joined
Feb 6, 2008
Messages
166
I'm working on an Altered Melee map, and I'm adding more playable races in addition to the four already there.

I'm working on a trigger to prevent any one player from getting more than one of the same hero. Of course, there is "Melee Game - Limit Heroes to 1 per Hero-type (for all players)", but it apparently only works on the default heroes, even if you change the gameplay constants.

How effectively and efficiently does this trigger do the trick?
  • Hero Count Fix
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • For each (Integer ForLoop_Temp_Integer) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Trained unit)) Equal to Overlord
                  • (Unit-type of (Trained unit)) Equal to Imp
                  • (Unit-type of (Trained unit)) Equal to Succubus
                  • (Unit-type of (Trained unit)) Equal to War Contraption
                  • --- Just keep adding all the custom heroes here. ---
            • Then - Actions
              • Player - Make (Unit-type of (Trained unit)) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
            • Else - Actions
I'm new to "Or - Any (Conditions) are true", so I don't know if it works fine putting it where I did. I'm also concerned that if the trigger runs a check for the listed heroes every time any player creates any unit, it might slow down the gameplay. There's going to be 28 custom heroes, as well as the Firelord, Tinker, and Alchemist if need be. (For some reason, the tavern didn't include those three by default...)

Also, I don't know if this counts as a Trigger Creation or Trigger Fixing thread. Sorry if I put it in the wrong place. In a sense, I want to fix what I have above, but in another sense, I'm also looking to see if anyone knows of a better way to do it than me, in which case, I'd be creating a trigger, since the one above would be scrapped.

Yes, I said in my previous thread that I'm taking a break from THW and map-making, but I decided to at least make this race playable first. The duplicate hero problem is something that keeps this race from being playable. After all, it wouldn't be fair to get three of the same hero now, would it? Especially if it were a hero with AoE damaging spells...
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Using that trigger it would be more efficient to do it like this:

  • Hero Count Fix
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Overlord
          • (Unit-type of (Trained unit)) Equal to Imp
          • (Unit-type of (Trained unit)) Equal to Succubus
          • (Unit-type of (Trained unit)) Equal to War Contraption
          • --- Just keep adding all the custom heroes here. ---
    • Actions
      • Player - Make (Unit-type of (Trained unit)) Unavailable for training/construction by PlayerIndex[Player Number of (Owner of trained unit))]
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you set it to 0 then it makes the unit completely unavailable, useful if you're thinking of replacing certain units in the tech-tree with others in the middle of the game (if its upgraded, or whatever).
 
Level 3
Joined
Feb 6, 2009
Messages
50
just go to advanced, gameplay constants, techtree equivalent,

then add your heroes, make sure you have the melee game limit heroes still in your triggers.
 
Level 6
Joined
Feb 6, 2008
Messages
166
just go to advanced, gameplay constants, techtree equivalent,

then add your heroes, make sure you have the melee game limit heroes still in your triggers.

Doesn't work. I've had gameplay constants modified ever since I first made the map, and well, this thread is here, so. yeah. :grin:

Nice try though. The whole reason I modified them in the very beginning was for this exact reason, and it didn't work.
 
Status
Not open for further replies.
Top