• 🏆 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] Why this trigger doesn't work well?

Status
Not open for further replies.

NightKnight

Hosted Project RUID
Level 14
Joined
Sep 3, 2014
Messages
222
I am working on a project, "Demonic Rage 2.0" and as far I failed to make it MUI. I'm trying to learn and change some or many triggers.
Whats the problem in these triggers? (why does it pick every unit with no regard to the condition and to demonic_caster variable) and how to fix and the effects are permanent:
  • Demonic Rage
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to DEMONIC RAGE
    • Actions
      • Set Demonic_Index = (Demonic_Index + 1)
      • Set Demonic_Counter[Demonic_Index] = 0.00
      • Set CasterDR[Demonic_Index] = (Triggering unit)
      • Set Demonic_Caster[Demonic_Index] = CasterDR[Demonic_Index]
      • Set TempPoint[Demonic_Index] = (Position of Demonic_Caster[Demonic_Index])
      • Custom script: set bj_wantDestroyGroup=true
      • -------- --------------------------------------------------------- --------
      • -------- Damage and AOE (area of effect) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Demonic_Index Greater than or equal to 1
        • Then - Actions
          • Set Demonic_UnitGroup = (Units within Demonic_Radius of TempPoint[Demonic_Index])
          • Unit Group - Pick every unit in Demonic_UnitGroup and do (Actions)
            • Loop - Actions
              • Set Demonic_pickedunits = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Demonic_pickedunits is Magic Immune) Equal to False
                  • (Demonic_pickedunits belongs to an enemy of (Owner of Demonic_Caster[Demonic_Index])) Equal to True
                • Then - Actions
                  • Unit - Cause Demonic_Caster[Demonic_Index] to damage Demonic_pickedunits, dealing Demonic_Damage damage of attack type Chaos and damage type Universal
                    • Custom script: call DestroyGroup(udg_Demonic_UnitGroup)
                    • -------- --------------------------------------------------------- --------
                    • -------- Those first 8 actions is for the effect (Dummies) --------
                  • Unit - Create 1 Dummy (small) for Neutral Passive at TempPoint[Demonic_Index] facing Default building facing degrees
                    • Unit - Add a Demonic_Effectdummies_timer second Generic expiration timer to (Last created unit)
                  • Unit - Create 1 Dummy (big) for Neutral Passive at TempPoint[Demonic_Index] facing Default building facing degrees
                    • Unit - Add a Demonic_Effectdummies_timer second Generic expiration timer to (Last created unit)
                  • Unit - Create 1 Dummy (crono) for Neutral Passive at TempPoint[Demonic_Index] facing Default building facing degrees
                    • Unit - Add a Demonic_Effectdummies_timer second Generic expiration timer to (Last created unit)
                  • Unit - Create 1 Dummy2 (raising skull/howl) for Neutral Passive at TempPoint[Demonic_Index] facing Default building facing degrees
                    • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                    • -------- Demonic Rage Str gained --------
                    • Hero - Modify Strength of Demonic_Caster[Demonic_Index]: Add Demonic_Strength_Gained
                    • Hero - Modify Agility of Demonic_Caster[Demonic_Index]: Add Demonic_Agility_Gained
                    • Trigger - Turn on pos test <gen>
                    • Trigger - Turn on Demonic Loop Config <gen>
                    • Trigger - Turn on test <gen>
                • Else - Actions
        • Else - Actions
  • [trigger]
  • pos test
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy (small) for Player 1 (Red) at ((Position of (Picked unit)) offset by (0.00, 0.00)) facing Default building facing degrees
            • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
  • [trigger]
  • test
    • Events
      • Time - Every 4.00 seconds of game time
    • Conditions
      • Demonic_Index Greater than or equal to 2
    • Actions
      • Game - Display to (All allies of (Owner of Demonic_Caster[Demonic_Index])) for 2.00 seconds the text: yep!
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of Demonic_Caster[Demonic_Index])) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Equal to Demonic_Caster[Demonic_Index]
            • Then - Actions
              • Unit - Create 1 Dummy (small) for Neutral Passive at ((Position of (Picked unit)) offset by (0.00, 0.00)) facing Default building facing degrees
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
            • Else - Actions
              • Unit - Kill (Picked unit)
        • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
          • Loop - Actions
        • Trigger - Turn on test2 <gen>
  • -----------------------------------------
  • condition isnt working
  • ----------------------------------------------
  • [trigger]
  • test
    • Events
      • Time - Every 4.00 seconds of game time
    • Conditions
      • Demonic_Index Greater than or equal to 2
    • Actions
      • Game - Display to (All allies of (Owner of Demonic_Caster[Demonic_Index])) for 2.00 seconds the text: yep!
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of Demonic_Caster[Demonic_Index])) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Equal to Demonic_Caster[Demonic_Index]
            • Then - Actions
              • Unit - Create 1 Dummy (small) for Neutral Passive at ((Position of (Picked unit)) offset by (0.00, 0.00)) facing Default building facing degrees
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
            • Else - Actions
              • Unit - Kill (Picked unit)
        • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
          • Loop - Actions
        • Trigger - Turn on test2 <gen>
  • [trigger]
  • test2
    • Events
      • Time - Every 8.00 seconds of game time
    • Conditions
      • Demonic_Index Equal to 4
    • Actions
      • Game - Display to (All players) for 8.00 seconds the text: 46521
  • [trigger/]
 
Level 25
Joined
May 11, 2007
Messages
4,651
Change A unit begins casting an ability to "A unit starts the effect of ability".
Otherwise this spell can be activated everytime someone begins casting the spell and then hits stop, thus not using any mana or cooldown on the spell.

Your trigger is leaking locations, you don't clearup the tempPoints.

I'm assuming your problem is this trigger?
  • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of Demonic_Caster[Demonic_Index])) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Picked unit) Equal to Demonic_Caster[Demonic_Index]
        • Then - Actions
          • Unit - Create 1 Dummy (small) for Neutral Passive at ((Position of (Picked unit)) offset by (0.00, 0.00)) facing Default building facing degrees
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
        • Else - Actions
          • Unit - Kill (Picked unit)
Well, the only condition you have there is a check if the owner is your casting player, so if it selects a unit that isn't the caster owned by the caster in the WHOLE map. It kills ALL those units, pretty sure that's not what you're after.

So I would change the unit group selection to properly select the units you want to select instead of selecting EVERY unit owned by the player as you do right now.
 
Last edited by a moderator:
Level 13
Joined
May 10, 2009
Messages
868
Well... what's the spell supposed to do? Also, I see that you enable Demonic Loop trigger, but it's not in your post.

Every time a unit casts your spell, you increment the variable Demonic_Index by 1, however:

  • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of Demonic_Caster[Demonic_Index])) and do (Actions)
  • -------- --------
  • (Picked unit) Equal to Demonic_Caster[Demonic_Index]
Demonic_Caster[Demonic_Index] will only return the last unit that cast your spell, and that trigger even kills other casters.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
4,994
Did you read my post in your other thread? Aside from what's pointed out there and in this thread, there is one minor but potentially really bad thing you're doing:
  • Custom script: set bj_wantDestroyGroup=true
  • -------- --------------------------------------------------------- --------
  • -------- Damage and AOE (area of effect) --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • Then - Actions
      • Unit Group - Pick every unit in Demonic_UnitGroup and do (Actions)
You're setting bj_wantDestroyGroup before you run the if-block, where the unit group action actually happens. So what if the if block evaluates to false and the Then actions are never run? Then bj_wantDestroyGroup is still set = true until the next time any Unit Group - Pick.... action is called, at which point it will automatically destroy the group (and bj_wantDestroyGroup is automatically set = false again).

Imagine that the next trigger that runs uses Unit Group - Pick every unit in Some_group_that_shouldn't_ever_be_destroyed and do actions. Whoops, now you've accidentally deleted your 'permanent' group! It might then be very hard to track down what is causing this bug because it's not necessarily coming from the same trigger that is now not working properly

The solution is simply to move the custom script line inside the if block so it happens right before the Unit Group - Pick..... I would advise you always do it this way unless you have a good reason to set bj_wantDestroyGroup significantly beforehand.
 
Status
Not open for further replies.
Top