• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

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...
 
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))]
 
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.
 
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.
Back
Top