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

[Trigger] Ability spreading from dying units

Status
Not open for further replies.
Level 2
Joined
Jun 27, 2016
Messages
13
Hi
I tried to make an ability which periodically damage target. When target dies while it has a buff, dummy should cast same ability on random enemy unit within range. Unfortunately it triggers only twice/more times and doesn't more even when it clearly should.

Here are the triggers:

  • Corruption
    • Events
      • Unit - A unit begin casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Warunki
          • (Ability being cast) Equals to Corruption
          • (Ability being cast) Equals to Dummy Corruption
    • Actions
      • Set Corrupter = (Triggering unit)
      • Set Corrupted = (Target unit of ability being cast)
      • Unit Group - Add Corrupted to CoruptedUnits
      • Trigger - Turn on Corruption Dmg <gen>
  • Corruption Dmg
    • Events
      • Time - Every 0.30 seconds of game time
    • Coditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Corrupted has buff Corrutpin ) Equals to NO
        • Then - Actions
          • Unit Group - Remove Corrupted from CoruptedUnits
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (CoruptedUnits is empty) Equals to NO
        • Then - Actions
          • Unit - Cause Corruptor to damage Corrupted, dealing 5.00 damage of attack type
  • Spreading Corruption
    • Events
      • Unit - A unit dies
    • Conditions
      • ((Dying unit) is in CoruptedUnits) Equals to YES
    • Actions
      • Set Corrupted = (Dying unit)
      • Set point = (Position of Corrupted)
      • Set RandomUnitFromGroup = (Units within 1000.00 of point matching (((Matching unit) belongs to an enemy of (Owner of Corruptor)) Equals to YES))
      • Unit Group - Pick every unit in (Random 1 units from RandomUnitFromGroup) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 dummy for (Owner of Corruptor) at point facing default
          • Unit - Add Dummy Corruption to (Last created unit)
          • Unit - Order (Last created unit) to Undead - Necromancer - ‚ (Picked unit)
          • Unit - Add a 2.00 second expiration timer to (Last created unit)
          • Set Corrupted = (Picked unit)
          • Unit Group - Add Corrupted to CoruptedUnits
          • Unit Group - Remove (Dying unit) from CoruptedUnits
It didn't work with checking if unit has a buff at all, without that part it worked, but not correctly.
And btw I'm wondering if anyone could explain me how variables are passed between triggers. I mean - if I create a trigger is it like a template and each time event happens it creates a class? If so - how would be variable passed between them if each object would have it's own. If it's not like that what would happen if we run multiple triggers at once for example playing online - and each player overwrites variables? I hope what I tried to say is clear.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The periodic damage part in Corruption Dmg is wrong? It probably should be pick all units in CoruptedUnits and cause Corruptor to damage picked unit, otherwise at most a single unit could be damaged at a time and not all units with the buff. It is also a good idea to add a test that if the group is empty then turn off the periodic trigger to save computational resources.

In Spreading Corruption a location and 2 groups are being leaked. The location assigned to point is never removed by RemoveLocation. The group assigned to RandomUnitFromGroup and the group created as part of the "pick every unit in" action are never destroyed by DestroyGroup. There is no need to Add Corrupted to CoruptedUnits in that trigger as the Corruption trigger should do that already. The potential victim unit group may require more filters as it must return valid targets that can be affected by the dummy ability (eg, should it be able to affect buildings or invulnerable units?).

Make sure the dummy unit can cast the dummy ability within 2 seconds on potential victim targets. This can be done by removing locust and adding a model to the dummy unit and then attempting to manually cast the ability from the command card in a test session. Once the dummy is configured so that the dummy ability can be manually cast as desired it can be hidden again with locust and no model.
 
Level 2
Joined
Jun 27, 2016
Messages
13
I haven't removed leaks yet, because it doesn't work either way. Damage part is working, however I have to fix it for multiple targets. I was turning off that trigger, but deleted that actions for tests. The actual problem is - let's say I display text in event Corruption. It is displayed only twice, although there are clearly viable targets and no buildings around.
Edit: Now it has worked 3 times, I seriously don't have any clue what's going on.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Does both the original and dummy ability give the same buff?

Try to place debug text around the trigger to see where it breaks. Maybe one of the conditional tests is not evaluating to what is desired. For example maybe it is not in the unit group when it should be for some reason or another. Such debug text can be to display values of certain variables at various places during the execution of the actions to see if they are what is expected. They could also be simple messages to check the decision flow of the actions to make sure that it is what is expected.

If only WC3 had the SC2 trigger debugger...
 
Level 2
Joined
Jun 27, 2016
Messages
13
Yes, both abilities have the same buff. From what I've observed it stops working between last and first triggers. Now it doesn't work at all. The most suprising thing from me is how random it works. My first guess was Unit Group as well, but I even add a unit to this unit group twice. And btw is unit deleted from a Unit Group when it dies? My very first guess was that it can pick random dead unit and it stucks there, but even if that was the case I delete dying unit anyway. The part with checking buff is turned off, because it remove unit on the very begining, but I think it may have something to do with timing and it checks a buff before unit has it.
 
Last edited:
Level 2
Joined
Jun 27, 2016
Messages
13
No, it doesn't work even if I have one instance. Outcome is random, it spreaded once, twice and even three times while running the same map. It looks like the problem is that trigger picks a random unit which cannot be a target from group, but I delete dead units so they can't be target if I'm correct with trigger stuff.
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
You are probably picking dead units, since you don't check that in the filter:
  • Set RandomUnitFromGroup = (Units within 1000.00 of point matching (((Matching unit) belongs to an enemy of (Owner of Corruptor)) Equals to YES))
  • -------- Should be --------
  • Set RandomUnitFromGroup = (Units within 1000.00 of point matching ((((Matching unit) belongs to an enemy of (Owner of Corruptor)) Equals to YES) and (((Matching Unit) is alive) equal to true))
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Oh I guess I forgot to click "Post Reply"
Capture.PNG
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
And btw is unit deleted from a Unit Group when it dies?
No it is not. In fact failure to remove a unit from a unit group before the unit is removed from the game results in a possible leak as it will remain in the unit group and cannot be removed from the unit group anymore without clearing the entire group. Such removed from game units will return null in for unit group loops.

It looks like the problem is that trigger picks a random unit which cannot be a target from group, but I delete dead units so they can't be target if I'm correct with trigger stuff.
Nothing stops it from picking the unit which just died and used to have the buff because the filter is not strict enough.
 
Status
Not open for further replies.
Top