• 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.

[Trigger] Summon Ability with unit cap

Status
Not open for further replies.
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 73
Joined
Aug 10, 2018
Messages
7,871
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:
Status
Not open for further replies.
Top