• 🏆 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] Need help with a spell based on illusions ! (SOLVED)

Status
Not open for further replies.
Level 2
Joined
May 29, 2021
Messages
8
Hello everyone.

If I understand correctly, this is the place to make a post when you need help to fix a trigger that has already been started and is almost functional.
I need help to fix some problems with a trigger for a spell.
Overall I'm working on a MOBA map and one of the heroes is illusion based, his passive gives him a chance to create an illusion when he attacks an enemy, his ultimate works as "Mirror Image", his first active allows him to teleport to an enemy and have a chance to create an illusion, finally his second active (the one that is causing problems) allows him to cast a "Fan of knives" and make the illusions near him cast it too.

I modified the animation of the "Fan of Knives" projectile by the "Black Arrow" projectile so that it is more visible (there are two animations to modify).
Concerning the objective of the spell itself:

Level 1: Only the hero casts "Fan of Knives".
Level 2: The hero and a nearby illusion (area of 800 and this is the case for all levels) cast "Fan of Knives".
Level 3: The hero and two illusions cast "Fan of Knives".
Level 4: The hero and three illusions cast "Fan of Knives

Here is the trigger I have created for the moment:

  • Deluge des ombres Configuration
    • Evénements
      • Unité - A unit Initie l'effet d'une compétence
    • Conditions
      • (Ability being cast) Egal à Déluge des ombres
    • Actions
      • Set DDO_caster = (Triggering unit)
      • Set DDO_caster_loc = (Position of DDO_caster)
      • Set DDO_groupe = (Units within 800.00 of DDO_caster_loc matching ((((Matching unit) is an illusion) Egal à TRUE) and ((Owner of (Matching unit)) Egal à (Owner of DDO_caster))))
      • Groupe unité - Pick every unit in DDO_groupe and do (Actions)
        • Boucle - Actions
          • If ((Level of Déluge des ombres for DDO_caster) Egal à 1) then do (Do nothing) else do (Do nothing)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Level of Déluge des ombres for DDO_caster) Egal à 2
              • (Number of units in DDO_groupe) Inférieur ou égal à ((Level of Déluge des ombres for DDO_caster) - 1)
            • Alors - Actions
              • Unité - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Random unit from DDO_groupe)) facing Orientation bâtiment par défaut degrees
              • Set DDO_dummy = (Last created unit)
              • Unité - Add a 1.00 second Générique expiration timer to DDO_dummy
              • Unité - Add Déluge des ombres Dummy to DDO_dummy
              • Unité - Set level of Déluge des ombres Dummy for DDO_dummy to 2
              • Unité - Order DDO_dummy to Garde elfe de la nuit - Tourbillon de lames
            • Sinon - Actions
              • If ((Number of units in DDO_groupe) Supérieur à ((Level of Déluge des ombres for DDO_caster) - 1)) then do (Groupe unité - Remove (Picked unit) from DDO_groupe) else do (Do nothing)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Level of Déluge des ombres for DDO_caster) Egal à 3
              • (Number of units in DDO_groupe) Inférieur ou égal à ((Level of Déluge des ombres for DDO_caster) - 1)
            • Alors - Actions
              • Unité - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Random unit from DDO_groupe)) facing Orientation bâtiment par défaut degrees
              • Set DDO_dummy = (Last created unit)
              • Unité - Add a 1.00 second Générique expiration timer to DDO_dummy
              • Unité - Add Déluge des ombres Dummy to DDO_dummy
              • Unité - Set level of Déluge des ombres Dummy for DDO_dummy to 3
              • Unité - Order DDO_dummy to Garde elfe de la nuit - Tourbillon de lames
            • Sinon - Actions
              • If ((Number of units in DDO_groupe) Supérieur à ((Level of Déluge des ombres for DDO_caster) - 1)) then do (Groupe unité - Remove (Picked unit) from DDO_groupe) else do (Do nothing)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Level of Déluge des ombres for DDO_caster) Egal à 4
              • (Number of units in DDO_groupe) Inférieur ou égal à ((Level of Déluge des ombres for DDO_caster) - 1)
            • Alors - Actions
              • Unité - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Random unit from DDO_groupe)) facing Orientation bâtiment par défaut degrees
              • Set DDO_dummy = (Last created unit)
              • Unité - Add a 1.00 second Générique expiration timer to DDO_dummy
              • Unité - Add Déluge des ombres Dummy to DDO_dummy
              • Unité - Set level of Déluge des ombres Dummy for DDO_dummy to 4
              • Unité - Order DDO_dummy to Garde elfe de la nuit - Tourbillon de lames
            • Sinon - Actions
              • If ((Number of units in DDO_groupe) Supérieur à ((Level of Déluge des ombres for DDO_caster) - 1)) then do (Groupe unité - Remove (Picked unit) from DDO_groupe) else do (Do nothing)
My editor is in French (if anyone knows how to put it in English by the way) so I will translate some things to make it easier to understand. The fact that the editor is in French replaces all the "é" with special characters, it turns the trigger into something unreadable so here it is in another form and with accents.

_________________________________________________________________________________________________________________________________________________________________________

Deluge des ombres Configuration
Event
Unit - A unit Initie starts the effect of an ability
Conditions
(Ability being cast) Egal à Déluge des ombres
Actions
Set DDO_caster = (Triggering unit)
Set DDO_caster_loc = (Position of DDO_caster)
Set DDO_groupe = (Units within 800.00 of DDO_caster_loc matching ((((Matching unit) is an illusion) Egal à TRUE) and ((Owner of (Matching unit)) Egal à (Owner of DDO_caster))))
Unit group - Pick every unit in DDO_groupe and do (Actions)
Loop - Actions
If ((Level of Déluge des ombres for DDO_caster) Equal to 1) then do (Do nothing) else do (Do nothing)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Déluge des ombres for DDO_caster) Equal to 2
(Number of units in DDO_groupe) Less than or equal to ((Level of Déluge des ombres for DDO_caster) - 1)
Then - Actions
Unit - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Random unit from DDO_groupe)) facing Orientation bàtiment par défaut degrees
Set DDO_dummy = (Last created unit)
Unit - Add a 1.00 second Générique expiration timer to DDO_dummy
Unit - Add Déluge des ombres Dummy to DDO_dummy
Unit - Set level of Déluge des ombres Dummy for DDO_dummy to 2
Unit - Order DDO_dummy to Garde elfe de la nuit - Tourbillon de lames
Else - Actions
If ((Number of units in DDO_groupe) Greater than ((Level of Déluge des ombres for DDO_caster) - 1)) then do (Unit group - Remove (Picked unit) from DDO_groupe) else do (Do nothing)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Déluge des ombres for DDO_caster) Equal to 3
(Number of units in DDO_groupe) Less than or equal to ((Level of Déluge des ombres for DDO_caster) - 1)
Then - Actions
Unit - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Random unit from DDO_groupe)) facing Orientation bàtiment par défaut degrees
Set DDO_dummy = (Last created unit)
Unit - Add a 1.00 second Générique expiration timer to DDO_dummy
Unit - Add Déluge des ombres Dummy to DDO_dummy
Unit - Set level of Déluge des ombres Dummy for DDO_dummy to 3
Unit - Order DDO_dummy to Garde elfe de la nuit - Tourbillon de lames
Else - Actions
If ((Number of units in DDO_groupe) Greater than ((Level of Déluge des ombres for DDO_caster) - 1)) then do (Unit group - Remove (Picked unit) from DDO_groupe) else do (Do nothing)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Déluge des ombres for DDO_caster) Equal to 4
(Number of units in DDO_groupe) Less than or equal to ((Level of Déluge des ombres for DDO_caster) - 1)
Then - Actions
Unit - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Random unit from DDO_groupe)) facing Orientation bàtiment par défaut degrees
Set DDO_dummy = (Last created unit)
Unit - Add a 1.00 second Générique expiration timer to DDO_dummy
Unit - Add Déluge des ombres Dummy to DDO_dummy
Unit - Set level of Déluge des ombres Dummy for DDO_dummy to 4
Unit - Order DDO_dummy to Garde elfe de la nuit - Tourbillon de lames
Then - Actions
If ((Number of units in DDO_groupe) Greater than ((Level of Déluge des ombres for DDO_caster) - 1)) then do (Unit group - Remove (Picked unit) from DDO_groupe) else do (Do nothing)

_________________________________________________________________________________________________________________________________________________________________________

Problem with the spell:

The first problem was that if the number of illusions was not equal to the level of spell-1 "(Number of units in DDO_group) Less than or equal to ((Level of Deluge of Shadows for DDO_caster) - 1)", nothing happened and just the hero cast "Fan of Knives". Basically if two illusions were to cast "Fan of Knives" and there were 3 illusions on the field it didn't work, there had to be two illusions and that was it. I managed to fix the problem with "If ((Number of units in DDO_group) Greater than ((Level of Shadow Flood for DDO_caster) - 1)) then do (Group unit - Remove (Picked unit) from DDO_group) else do (Do nothing)", I don't know if it's the right solution but it works and it allows to remove from the group the excess illusions.

After this fix, the second problem was that the number of illusions casting "Fan of Knives" was random from levels three and four of the spell. When there was only one illusion that could cast the spell everything worked fine, but when two or three were needed the number of illusions casting the spell was random. So for level 3 of the spell there was sometimes only one illusion that cast the spell instead of two, and for level 4 sometimes two or one illusion instead of three. So the objective was almost achieved, the spell did not seem to work properly randomly.

I then thought that the problem was with "(Position of (Random unit from DDO_groupe))" and so replaced "Random Unit" with "Picked Unit". However this time the problem was not the same, but there was still a problem. For level 3 and 4 of the spell the number of illusions that cast "Fan of Knives" was still one more than it should be. So at level 3 it was three illusions that cast the spell, and at level 4 four illusions. I don't know why it worked for level 2. I tried changing some of the values from "(Number of units in DDO_group) Less than or equal to ((Level of Shadow casting for DDO_caster) - 1)" to a fixed value like 2 or 3 but it still didn't work.

So I went back to step two of the problem and now I'm turning to you in the hope that you can help me solve it.

Thanks in advance to all those who will help me to solve the problem.

Kind regards.

PS: I'm working only on GUI
 

Attachments

  • déclo DDo.jpg
    déclo DDo.jpg
    264.2 KB · Views: 22
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey there,

I'm not sure I understand what is going on there being as I don't understand french (and am too lazy to look for translation line by line). from what I gather -

you are leaking. check this out: Things That Leak

besides that - why did you create dummies? if you want the illusions to cast the FoK than why are dummies involved? just have the illusions cast it... (just give and remove the ability and give them a version that takes no mana if that is a problem).

also - if you were going to take the time to translate the trigger - why not just do it inside the formatted one? that would make helping you much more approachable...
 
Level 2
Joined
May 29, 2021
Messages
8
hey there,

I'm not sure I understand what is going on there being as I don't understand french (and am too lazy to look for translation line by line). from what I gather -

you are leaking. check this out: Things That Leak

besides that - why did you create dummies? if you want the illusions to cast the FoK than why are dummies involved? just have the illusions cast it... (just give and remove the ability and give them a version that takes no mana if that is a problem).

also - if you were going to take the time to translate the trigger - why not just do it inside the formatted one? that would make helping you much more approachable...

(I don't know why all my messages take several hours to be validated by the moderation, so it is difficult for me to answer quickly as my message is not visible.)

Hello, indeed I could translate directly the trigger that I posted it would be easier. I just did it and edited my post, I hope it's more understandable now.

I know that the spell is leaking, I was going to fix the problem once it was working perfectly, maybe it's this leak problem that is causing the problem?

I didn't know it was possible to give spells to illusions, I'll try with that.
Edit : I tried without dummy, nothing works and it's even worse, there must be something I don't know/understand.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
Maybe unrelated to your exact issue but I figured I'd show you how you can make this trigger a lot more efficient and clean.
  • Example Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Variable Level = (Level of (Ability being cast) for (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Level Greater than 1
        • Then - Actions
          • Set Variable Caster = (Triggering unit)
          • Set Variable Caster_Loc = (Position of Caster)
          • Set Variable Group = (Units within 800.00 of Caster_Loc.)
          • Set Variable IllusionCount = 0
          • Set Variable IllusionLimit = (Level - 1)
          • Unit Group - Pick every unit in Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • IllusionCount Less than IllusionLimit
                • Then - Actions
                  • Set Variable IllusionCount = (IllusionCount + 1)
                  • -------- do fan of knives stuff. picked unit is the illusion. --------
                • Else - Actions
        • Else - Actions

And here's the same trigger but with some of the memory leaks removed:
  • Example Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Variable Level = (Level of (Ability being cast) for (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Level Greater than 1
        • Then - Actions
          • Set Variable Caster = (Triggering unit)
          • Set Variable Caster_Loc = (Position of Caster)
          • Set Variable Group = (Units within 800.00 of Caster_Loc.)
          • Custom script: call RemoveLocation (udg_Caster_Loc)
          • Set Variable IllusionCount = 0
          • Set Variable IllusionLimit = (Level - 1)
          • Unit Group - Pick every unit in Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • IllusionCount Less than IllusionLimit
                • Then - Actions
                  • Set Variable IllusionCount = (IllusionCount + 1)
                  • -------- do fan of knives stuff. picked unit is the illusion. --------
                • Else - Actions
          • Custom script: call DestroyGroup (udg_Group)
        • Else - Actions
Edit: In my example I am adding ANY units to the group and I left out the Ability being cast Condition. Keep this in mind.
 
Last edited:
Level 2
Joined
May 29, 2021
Messages
8
Maybe unrelated to your exact issue but I figured I'd show you how you can make this trigger a lot more efficient and clean.
  • Example Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Variable Level = (Level of (Ability being cast) for (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Level Greater than 1
        • Then - Actions
          • Set Variable Caster = (Triggering unit)
          • Set Variable Caster_Loc = (Position of Caster)
          • Set Variable Group = (Units within 800.00 of Caster_Loc.)
          • Set Variable IllusionCount = 0
          • Set Variable IllusionLimit = (Level - 1)
          • Unit Group - Pick every unit in Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • IllusionCount Less than IllusionLimit
                • Then - Actions
                  • Set Variable IllusionCount = (IllusionCount + 1)
                  • -------- do fan of knives stuff. picked unit is the illusion. --------
                • Else - Actions
        • Else - Actions

And here's the same trigger but with some of the memory leaks removed:
  • Example Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Variable Level = (Level of (Ability being cast) for (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Level Greater than 1
        • Then - Actions
          • Set Variable Caster = (Triggering unit)
          • Set Variable Caster_Loc = (Position of Caster)
          • Set Variable Group = (Units within 800.00 of Caster_Loc.)
          • Custom script: call RemoveLocation (udg_Caster_Loc)
          • Set Variable IllusionCount = 0
          • Set Variable IllusionLimit = (Level - 1)
          • Unit Group - Pick every unit in Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • IllusionCount Less than IllusionLimit
                • Then - Actions
                  • Set Variable IllusionCount = (IllusionCount + 1)
                  • -------- do fan of knives stuff. picked unit is the illusion. --------
                • Else - Actions
          • Custom script: call DestroyGroup (udg_Group)
        • Else - Actions

I will use the "reply" function because my posts take a long time to be validated by the moderation and I don't know if they are visible.

I've tried what you said to do, it doesn't work, or I haven't figured out a few things yet. However I understand the approach to make the spell cleaner.

The number of illusions casting the spell must be independent of the number of illusions near the hero. So if the spell is level 3 (allowing two illusions to cast the spell) and there are four nearby illusions, then only two illusions out of the four will cast the spell.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
In my example I am adding ANY units to the group and I left out the Ability being cast Condition. If you didn't adjust this to match your original design then you'll definitely have issues. Also, I need to see how you're trying to cast fan of knives because that's important. If you're using your original Dummy method then you need to adjust it to work with the Picked units and not random units.

Anyway, if it's done correctly it should work fine. IllusionCount and IllusionLimit are used to limit how many illusions cast fan of knives.

You're picking every nearby illusion that belongs to your hero. Then you're making X out of the illusions cast Fan of Knives, where X is the IllusionLimit. IllusionLimit is equal to Ability Level - 1, so it'll be 0/1/2/3 per level.

Example:
  • The ability is level 3 so IllusionLimit will be set to 2.
  • IllusionCount starts out at 0 and will count up to 2, once for each picked illusion until it's reached the limit.
  • You pick the first Illusion in the group and check to see if Count is still less than Limit (is 0 less than 2?). If true, then you make that picked illusion cast fan of knives using whatever method you wanted. Then you increase Count by 1.
You could create a dummy at the picked unit's position and order it to cast fan of knives or you could try Cheshire's method and have the picked illusion cast the spell themselves.
  • Then you pick the next Illusion in the group and check to see if Count is still less than Limit (is 1 less than 2?). It's still true, so you make that illusion cast fan of knives and increase Count by 1 again.
  • Eventually IllusionCount will be greater than or equal to IllusionLimit and any excess picked units will be ignored.


Some potential issues:
  • Illusions/Dummys are casting the same ability as the hero, causing the trigger to run again. Fix: Add a Condition to exclude these units from running the trigger or give them their own version of the ability.
  • You're creating/using the Dummys incorrectly. Fix: You should be creating the Dummy at the position of the Picked unit where I put this comment:
  • -------- do fan of knives stuff. picked unit is the illusion. --------
 
Last edited:
Level 2
Joined
May 29, 2021
Messages
8
My bad, I had made some mistakes in reproducing and adapting your trigger. I fixed the problems and now everything works perfectly

So this is the final trigger:

____________________________________________________________________________________________________________________________________________________

DDO
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Déluge des ombres
Actions
Set DDO_niveau = (Level of (Ability being cast) for (Triggering unit))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DDO_niveau Greater than 1
Then - Actions
Set DDO_caster = (Triggering unit)
Set DDO_caster_loc = (Position of DDO_caster)
Set DDO_groupe = (Units within 800.00 of DDO_caster_loc matching ((((Matching unit) is an illusion) Equal to TRUE) and ((Owner of (Matching unit)) Equal to (Owner of DDO_caster))))
Custom script: call RemoveLocation (udg_DDO_caster_loc)
Set DDO_nombre_illusions = 0
Set DDO_limite_illusions = (DDO_niveau - 1)
Unit group - Pick every unit in DDO_groupe and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DDO_nombre_illusions Less than DDO_limite_illusions
Then - Actions
Set DDO_nombre_illusions = (DDO_nombre_illusions + 1)
Unit - Create 1 Dummy DDO for (Owner of DDO_caster) at (Position of (Picked unit)) facing Orientation batiment par défaut degrees
Set DDO_dummy = (Last created unit)
Unit - Add a 1.00 second Generic expiration timer to DDO_dummy
Unit - Add Déluge des ombres Dummy to DDO_dummy
Unit - Set level of Déluge des ombres Dummy for DDO_dummy to DDO_niveau
Unit - Order DDO_dummy to Garde elfe de la nuit - Fan of Knives
Then - Actions
Custom script: call DestroyGroup (udg_DDO_groupe)
Then - Actions

____________________________________________________________________________________________________________________________________________________

Thank you very much for the help!
 
Status
Not open for further replies.
Top