• 🏆 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!

[Trigger] Summon Ability with unit cap

Level 2
Joined
Oct 11, 2020
Messages
7
Hello, I'd like to make a summon ability where the cap of units that can be summoned is fixed to the level of the ability.

So let's say the ability is level 4, then I can summon a maximum of 4 units. This is what I tried, and it initially works. However, when a summon dies, the ability will not always summon another unit. Sometimes all summons have to die until the ability works again, and it starts summoning.

1694727019127.png
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,714
If you have Summon Wolves from other sources they could be interfering. Also, dead units may cause problems like a corpse being picked up in the Unit Group but it looks like you check for that.

I would track the number of wolves with an Integer variable:
  • Then - Actions
    • Unit - Create 1 Wolf Guard...
    • Set WolfCount = WolfCount + 1
  • Events
    • Unit - A unit Dies
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to Wolf Guard
  • Actions
    • Set WolfCount = WolfCount - 1
This variable will always be equal to the exact number of Wolf Guards assuming that your ability is the only way to create them. This design is Event driven which helps keep the data precise and accessible whenever you need it.

If this ability needs to work for multiple Players then you can make WolfCount an Array and use the Player Number of the Owner of the Wolf as the [index]. To make the ability work for any number of units owned by a player then you'll probably want to use a Hashtable.
 
Last edited:
Level 2
Joined
Oct 11, 2020
Messages
7
If you have Summon Wolves from other sources they could be interfering. Also, dead units may cause problems like a corpse being picked up in the Unit Group but it looks like you check for that.

I would track the number of wolves with an Integer variable:
  • Then - Actions
    • Unit - Create 1 Wolf Guard...
    • Set WolfCount = WolfCount + 1
  • Events
    • Unit - A unit Dies
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to Wolf Guard
  • Actions
    • Set WolfCount = WolfCount - 1
This variable will always be equal to the exact number of Wolf Guards assuming that your ability is the only way to create them. This design is Event driven which helps keep the data precise and accessible whenever you need it.

If this ability needs to work for multiple Players then you can make WolfCount an Array and use the Player Number of the Owner of the Wolf as the [index]. To make the ability work for any number of units owned by a player then you'll probably want to use a Hashtable.
Thanks! I'll give that a try


Edit: It works splendidly! Best of all, I wanted to include another summon ability, so I can technically keep a combination of both at 4, which was my initial goal
 
Last edited:
Top