• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Need help with conflicting ability trigger

Status
Not open for further replies.
Level 8
Joined
Mar 17, 2016
Messages
133
So I'm making a spell where, every 4 attacks the hero attacking will be given the barrage skill and it will be taken away after shooting. I'm currently using integers to count the attacks in a trigger and it works for the most part, however, I'm using Bribes damage engine to detect when the attacks land to count and 2 triggers for the task. One to count and the other to give the ability and check when the play has attacked to remove it and re-enable the counter.

The issue is that, since barrage counts as auto-attacks it counts every instance of barrage firing off as a counter towards the next cycle of the trigger. Eg. If there are 3 units around the hero and it fires an attack, it counts all 3 heroes towards the next cycle of 4 attacks, meaning that the hero could, if there are 4 units around, have barrage for every attack.
  • CR RisingWinds Count
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • IsDamageRanged Equal to True
          • DamageEventSource Equal to UnitPlayerCaster[20]
          • (UnitPlayerCaster[20] has buff Rising Winds ) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PulsesInteger[5] Less than 3
        • Then - Actions
          • Set VariableSet PulsesInteger[5] = (PulsesInteger[5] + 1)
          • Game - Display to (All players) the text: (String(PulsesInteger[5]))
        • Else - Actions
          • Game - Display to (All players) the text: Barrage
          • Unit - Add Rising Winds (CR) to UnitPlayerCaster[20]
          • Unit - Set level of Rising Winds (CR) for UnitPlayerCaster[20] to (Level of Rising Winds (CR) for UnitPlayerCaster[20])
          • Trigger - Turn off CR RisingWinds Count <gen>
          • Trigger - Turn on CR RisingWinds Barrage <gen>
  • CR RisingWinds Barrage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • IsDamageRanged Equal to True
          • DamageEventSource Equal to UnitPlayerCaster[20]
          • (UnitPlayerCaster[20] has buff Rising Winds ) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PulsesInteger[5] Greater than or equal to 4
        • Then - Actions
          • Game - Display to (All players) the text: Barrage
          • Unit - Remove Rising Winds (CR) from UnitPlayerCaster[20]
          • Set VariableSet PulsesInteger[5] = 0
          • Custom script: call GameTimeWait(.10)
          • Trigger - Turn off (This trigger)
          • Trigger - Turn on CR RisingWinds Count <gen>
        • Else - Actions
Is there something I can add to this to remove the extra attacks from being counted, or use a different method of counting?
 
One method would be to have a flag variable that tells the trigger to increment when false, and do nothing otherwise. After a 0-second timer expiration, set the flag variable as false.

Basically, the logical process is like this:
Lua:
if PulsesInteger [5] < 3 and not DoIncrement[<index>] then
    PulsesInteger[5] = PulsesInteger[5] + 1
    DoIncrement[<index>] = true
    doAfter(0.00, function()
        DoIncrement[<index>] = false
    end)
end
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,457
Unless i'm mistaken you can't rely on a damage event for removing barrage. During the time that it takes for a projectile to reach its target the unit could have attacked several more times (releasing more barrages).

A solution would be to rely on the "A unit is attacked" event and a short Wait/Timer before removing barrage. At least with this way you wouldnt ever barrage more than once. Although you could cancel the attack and lose the barrage but that's not a very big deal.

The issue regarding barrage attacks counting towards the 4th attack counter is a tough one. Once again, there's no guarantee when and even if attack projectiles will reach their targets.

You could always trigger barrage yourself, with the features we have available now it wouldn't be too difficult.

Or use an illusion of your hero that mimics its orders. Give the illusion barrage but not your hero. It would only mimic attacks and any orders that would cancel the attacks.
 
Last edited:
Level 8
Joined
Mar 17, 2016
Messages
133
I appreciate the response, if I were hell bent on making this work I would definitely try triggering it myself. I've sort of taken the "quick fix" route, however with a chance on attack to give barrage for X seconds. It works almost exactly the same just with slightly less emphasis on the player building attack speed.
 
Status
Not open for further replies.
Top