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

[Solved] Giving Mortar Team Limited Ammo

Status
Not open for further replies.
Level 7
Joined
Oct 9, 2020
Messages
35
Hello. I'm hoping someone will be able to help me with this. I want the Mortar Team to have limited ammo. My current trigger is posted below using Bribe's DamageEngine system. I have tried the following approaches but I each has issues with it:

  1. AOEDamageEvent - Mostly works. The issue, only works when AOE damage has occurred. If only the direct target is damaged, the ammo is not spent.
  2. DamageEvent - A ammo is spent for every unit damaged in the AOE, even though it's just one attack.
  3. Unit is attacked event - This is so buggy as to be completely off the table. The ammo is spent when the Mortar Team begins their attack animation. The slightest interruption results in ammo being spent without the missile even being launched (move commands, stop commands, switching targets, etc.). Also, won't even launch the last missile, but spends it anyway.

  • Ammo
    • Events
      • Game - AOEDamageEvent becomes Equal to 1.00
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of AOEDamageSource) Equal to Mortar Team
    • Actions
      • Item - Set charges remaining in (Item carried by AOEDamageSource in slot 1) to ((Charges remaining in (Item carried by AOEDamageSource in slot 1)) - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by AOEDamageSource in slot 1)) Less than or equal to 0
        • Then - Actions
          • Unit - Add Disable Attack to AOEDamageSource
        • Else - Actions

Suggestions on how to fix my trigger or for alternative solutions are greatly appreciated. The more elegant the solution, the better. I'd prefer not to install yet another system to my project unless it has wide utlility. Thanks!
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,397
Use the DamageEvent option and create a condition that prevents the trigger from running more than once for a unit in a short time span:

  • Events
  • Game - DamageEvent becomes Equal to 1.00
  • Conditions
  • (Unit-type of DamageEventSource) Equal to Mortar Team
  • Level of AttackCooldown for DamageEventSource Equal to 0
  • Actions
  • Custom script: local unit udg_CooldownUnit = udg_DamageEventSource
  • Unit - Add AttackCooldown to DamageEventSource
  • /// do your charge stuff ///
  • Wait 0.00 seconds
  • Unit - Remove AttackCooldown from CooldownUnit
  • Custom script: set udg_CooldownUnit = null
CooldownUnit is a unit variable.
AttackCooldown would be some hidden ability with no effects.

Here's an explanation for the local variable method that's used to make this MUI: local udg_

Keep in mind the possibility that the Mortar Team doesn't deal any damage with it's attack. In this case charges won't be spent despite the Mortar Team having launched an attack.

The only option around this is to create or use a custom missile system. The problem with that is it's generally a pain in the ass to manage in GUI and it can be confusing for less advanced users. The neat thing about it is that you'd have full control of EVERYTHING and it would remove the need for this DamageEvent trigger.
 
Last edited:
Level 7
Joined
Oct 9, 2020
Messages
35
Thanks Uncle! It now works as I intended it to, with the rare exception that an attack deals no damage (even rarer since I disabled the Attack Position command for my map). I'm not going to be too bothered by it though. Out of curiosity, what is the purpose of the "Wait 0.00 seconds" action?
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,397
Triggers execute in a sequential order, but they still happen at the "same time" in the sense that there's no time delay between them.

So for example when your Mortar Team launches it's attack and damages 3 units here's what happens:

The game logically can't damage all 3 units at once, so it splits this process up and runs your Ammo trigger once for each damaged unit. This is why you end up losing an Item Charge once for EACH damaged unit. Note that the order that it damages these units in is completely random, or at least out of your control.

So using our example, the execution of the Ammo triggers would look something like this:

1: Your Ammo trigger runs for the 1st of the 3 damaged units.
2: After that, your Ammo trigger runs again for the 2nd damaged unit.
3: After that, your Ammo trigger runs again for the 3rd damaged unit.

Now what I did in my trigger is use that AttackCooldown Condition to temporarily "disable" the Ammo trigger after the 1st unit is damaged, resulting in this:

1: Your Ammo trigger runs for the 1st of the 3 damaged units. Additionally, the Mortar Team is given the AttackCooldown ability and the Wait timer begins.
2: After that, your Ammo trigger runs again for the 2nd unit BUT it can't get past the Conditions since the Mortar Team now has the AttackCooldown ability.
3: After that, your Ammo trigger runs again for the 3rd damaged unit but it can't get past the Conditions either for the same reason.

Then after a very short delay (Wait 0.00 seconds) the AttackCooldown ability is removed, thus allowing the process to repeat all over again.

Note that Waits are slightly imprecise, especially when playing online, so Wait 0.00 seconds is not literally 0 seconds, it's more like ~0.20 seconds. This SHOULD be a short enough time that your Mortar Team couldn't possibly get in another attack, so we don't have to worry about a situation where the Mortar Team attacks again while still having the AttackCooldown ability leftover from a previous attack. Mortar Teams can only attack about once every 3 seconds so we have way more than enough time to spare, and even if they could attack much faster they shouldn't get anywhere near ~4 attacks per second.
 
Last edited:
Status
Not open for further replies.
Top