1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  3. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  4. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Why this trigger doesn't work well?

Discussion in 'Triggers & Scripts' started by Deadreyo, Nov 20, 2016.

  1. Deadreyo

    Deadreyo

    Joined:
    Sep 3, 2014
    Messages:
    102
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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/]
     
  2. LordDz

    LordDz

    Joined:
    May 11, 2007
    Messages:
    4,308
    Resources:
    0
    Resources:
    0
    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: Nov 20, 2016
  3. Deadreyo

    Deadreyo

    Joined:
    Sep 3, 2014
    Messages:
    102
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I uses demon form ability as a base, so "A unit starts the effect of ability" just makes the ability restarts after ending.

    Can you tell me the steps to change the group selection? I mean buttons as i searched for any trigger to do that and failed.
     
  4. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    724
    Resources:
    2
    Spells:
    2
    Resources:
    2
    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: Nov 21, 2016
  5. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,546
    Resources:
    0
    Resources:
    0
    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.
     
  6. Deadreyo

    Deadreyo

    Joined:
    Sep 3, 2014
    Messages:
    102
    Resources:
    1
    Maps:
    1
    Resources:
    1
    It is supposed to make some big (explosions) effect at the start then winds around caster every 1 second.