[Solved] Create more than 10 illusions?

Status
Not open for further replies.
Level 5
Joined
Feb 1, 2024
Messages
44
Hi, I'm making a spell which is similar to Mirror Image but instead it will create more than 10 illusions at a time. Even if I can change the number in Object Editor high than 10, it will always create 9 and my hero will vanish into nowhere with invulnerability.

So I consecutively create dummies to cast mirror image with less than 10 illusions at a time until it reachs the desired number of illusions but the problem is the last created dummy is not removed! So when that dummy dies enemy also gains bounty and experience.

The slight delay between casts is tolerable but do you have any suggestions to remove the last dummy or achieve the same result?

  • Fymryn Discoporate
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Fymryn_Discoporate
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FymrynDiscoporate Less than 2
        • Then - Actions
          • Wait 0.08 seconds
          • Set FymrynDiscoporate = (FymrynDiscoporate + 1)
          • Unit - Create 1 Fymryn Dummy for Player 1 (Red) at ((Position of Fymryn) offset by 150.00 towards 90.00 degrees) facing (Facing of Fymryn) degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Hero - Set (Last created unit) Hero-level to (Level of Fymryn), Hide level-up graphics
          • Set FymrynDummy = (Last created unit)
          • Unit - Add Fymryn_Discoporate to (Last created unit)
          • Unit - Order (Last created unit) to Orc Blademaster - Mirror Image
          • Wait 0.09 seconds
          • Unit - Remove (Last created unit) from the game
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FymrynDiscoporate Equal to 2
            • Then - Actions
              • Unit - Remove FymrynDummy from the game
              • Set FymrynDiscoporate = 0
            • Else - Actions
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
  • You cannot be that precise with a Wait; the minimum time it will wait is larger than that. Waits also interfere with event responses, and in your case stop this trigger from working for multiple units simultaneously.

  • You should use the Starts the Effect of an Ability event; the one you picked happens before mana cost and cooldown are consumed. In some rare cases you might want to check before the ability has actually gone off, and you would use your event then.

  • For testing purposes it doesn't matter but for long-term code you should know you're leaking some point variables here, and likely groups and points and forces in other triggers. The best resources to understand and learn how to fix these are this thread and the one that it links to: Things That Leak

  • When you cast the illusion with some dummy versions of the hero, they won't have any of the passives or stats associated with items from the main hero. I guess I'm just assuming Mirror Image copies those (I seem to remember auras?). In any case you can maybe use the Wand of Illusion item ability to cast illusion on the hero by a dummy unit. Usually items have weird orderids to cast their spells but it's probably worth to look into here. Another option is to duplicate the hero via GameCache save/restore and then just have both copies make 5 illusions.

  • No need to remove the dummy from the game manually; you gave it an expiration timer, and as long as you've set it up properly it'll decay and give nothing to anyone. Be thorough about going through the unit stats and disabling everythingthat could interact with/be used by other units or players directly. Finally, you can get a single dummy to cast instantly in any direction without having to turn to face it. Those settings are:
    • Movement Type: None, Speed Base: 0
    • Animation - Cast Point & Cast Backswing: 0
    • Ability: Locust ('aloc)
  • If you do the same to another hero that's a copy of this one, you could make it cast mirror image instantly, too. In this scenario you should only need to use 1 dummy to cast any number of Wand of Illusions. Finally, why does this do something different every third cast? (cast 0->1, cast 1->2, cast: 2->0 nospell, etc...)
 
Level 5
Joined
Feb 1, 2024
Messages
44
  • If you do the same to another hero that's a copy of this one, you could make it cast mirror image instantly, too. In this scenario you should only need to use 1 dummy to cast any number of Wand of Illusions. Finally, why does this do something different every third cast? (cast 0->1, cast 1->2, cast: 2->0 nospell, etc...)
Thanks, actually I also allowed for the Wait and think it might be the cause. I stop it on third cast because the sum of all illusions created on two casts are enough for my desired number otherwise it will continue indefinitely. Maybe I should use expiration timer despite its very small time. Do you have any alternatives?

In any case you can maybe use the Wand of Illusion item ability to cast illusion on the hero by a dummy unit. Usually items have weird orderids to cast their spells but it's probably worth to look into here. Another option is to duplicate the hero via GameCache save/restore and then just have both copies make 5 illusions.

Mirror Image created a lot of illusions swiftly which is required in my ability rather than one by one like Wand of Illusions as I mentioned why I had to resort to Trigger. And if the multicast is quick enough it might create the visual of one cast.

No need to remove the dummy from the game manually; you gave it an expiration timer, and as long as you've set it up properly it'll decay and give nothing to anyone. Be thorough about going through the unit stats and disabling everythingthat could interact with/be used by other units or players directly. Finally, you can get a single dummy to cast instantly in any direction without having to turn to face it.

The dummy would play its dead animation and sometimes trigger some other hero-related events like Respawn Time and Kill Blow. I can turn these off but dead animation is still visual to players about how this ability is created and I don't want that. And the illusions derive from caster which means if I set the dummy's stats uninteractive with players, the illusions will do the same thing. Also if I don't set the facing direction, the enemy can distinguish which illusions are based on my facing direction before and after the ability is being cast.

For testing purposes it doesn't matter but for long-term code you should know you're leaking some point variables here, and likely groups and points and forces in other triggers. The best resources to understand and learn how to fix these are this thread and the one that it links to: Things That Leak

I don't know if my Trigger really leaks when I refer to your link. Since I use no variable to store locations but refer it only through the caster. And if that location leak how can I remove if there's no variables associated with it?
 
Level 5
Joined
Feb 1, 2024
Messages
44
Also if one uses generic expiration instead of Remove, the dummy unit icon still appears, which means it is stored somewhere and the game would lag if I cast the ability too much. Meanwhile removing the dummy kills all illusions that dummy created as if they are non-existent.

Actually I found a workaround solution: Just add the dummy unit to a unit group after each time it casts and after a specific time remove all these units so it won't interfere with ongoing illusions. The dummy death animation is still unsolved though.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Also if one uses generic expiration instead of Remove, the dummy unit icon still appears, which means it is stored somewhere and the game would lag if I cast the ability too much. Meanwhile removing the dummy kills all illusions that dummy created as if they are non-existent.

Actually I found a workaround solution: Just add the dummy unit to a unit group after each time it casts and after a specific time remove all these units so it won't interfere with ongoing illusions. The dummy death animation is still unsolved though.
I think you're misunderstanding a few things that Pyro said.

1) Yes, you're leaking a Point (location). It's not the end of the world but there's nothing to really debate here.

2) Your Wait actions and the Event you're using are both unsafe (expect random bugs) and can easily be exploited by the player to break your map.

3) Mirror Image and Wand of Illusion, technically speaking, create 1 illusion at a time. It's impossible to create 10 things at once. So all 10 of them can be created within the same game frame but there's still going to be an order to it.

4) The Wand of Illusion solution means that you don't need a dummy Hero. You can create illusions of your Hero the normal way without any annoying side effects.

5) I've never heard of Mirror Image breaking with more than 9 images but I'll take your word for it. Maybe it's because you're on an older version?

6) The general use cae of a Dummy unit is to have an "invisible" caster that can cast spells immediately. However, there's a lot of misinformation out there, leading to people creating broken Dummy units. Here's how to do it the right way. Copy and paste the Locust and set Model = None, Shadow = None, Attacks Enabled = None, Movement Type = None, Speed Base = 0. (Optional: Use vexorian's dummy model instead, which has attachment points for art effects)

Here's how you would handle your own custom Mirror Image that uses Wand of Illusion to bypass the image limit:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Fymryn_Discoporate
  • Actions
    • Set FymrynPoint = (Position of Fymryn)
    • Unit - Create 1 Fymryn Dummy (Uncle) for (Triggering player) at FymrynPoint facing Default building degrees
    • Custom script: call RemoveLocation( udg_FymrymPoint )
    • Set FymrynDummy = (Last created unit)
    • Unit - Add a 0.10 second Generic expiration timer to FymrynDummy
    • Unit - Add Wand of Illusion (Fymryn) to FymrynDummy
    • For each (FymrynLoop) from 1 to 10, do (Actions)
      • Loop - Actions
        • Custom script: call IssueTargetOrderById( udg_FymrynDummy, 852274, udg_Fymryn )
So this tells the Dummy unit to cast Wand of Illusion 10 times on our Hero. Change the number 10 in the For Loop to however many illusions you want. The ability that Fymryn casts can be based on anything.

To detect when an illusion is spawned you can use this trigger (change Blademaster to the unit-type of Fymryn):
  • Fymryn Create Illusion
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • ((Summoned unit) is an illusion) Equal to True
      • (Unit-type of (Summoned unit)) Equal to Blademaster
      • (Unit-type of (Summoning unit)) Equal to Fymryn Dummy (Uncle)
    • Actions
Of course these triggers are missing the "disjointing" effect that moves the hero and it's images to random offset positions. They're also missing the image replacement effect which removes old images and replaces them with new ones. But both of these issues can be fixed within those two triggers by using a Unit Group / move actions.

Here's an example that I made in the past. It's not necessarily what you want since it still uses Mirror Image to create the initial images, but it shows how you could recreate the random positioning stuff and the replacement effect:
Also, the bug mentioned in this thread is probably not something you have to worry about since you're on an older version.
 
Last edited:
Level 5
Joined
Feb 1, 2024
Messages
44
+rep
Thank a lot Uncle, actually I discard the Wait and use Timer instead. I originally thought the position created through other unit is auto removed by WE, but it seems I was wronged. I still prefer the swift animation of Mirror Image to individual spawn of Wand of Illusion.

A little side question:
Custom script: call IssueTargetOrderById( udg_FymrynDummy, 852274, udg_Fymryn )
Since Wand of Illusion only have two charges, does this action allow multiple casts without running out of charges without having to re-add this item?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
+rep
Thank a lot Uncle, actually I discard the Wait and use Timer instead. I originally thought the position created through other unit is auto removed by WE, but it seems I was wronged. I still prefer the swift animation of Mirror Image to individual spawn of Wand of Illusion.

A little side question:

Since Wand of Illusion only have two charges, does this action allow multiple casts without running out of charges without having to re-add this item?
Wand of Illusion is both an ability and an item. The ability doesn't use charges. The item that uses the ability is what has charges. We would only be using the ability here. Also, the "swift animation" is something you can recreate with triggers, but I understand not wanting to go through that trouble.
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
First: in a quick search I found other people on this site trying to cap the maximum number of illusions at 10, so unless it’s a recent change there shouldn’t be anything preventing you from making 10. Did you try shift+doubleclick on the field?
___________
Mirror Image created a lot of illusions swiftly which is required in my ability rather than one by one like Wand of Illusions
When cast by a proper instant-cast-capable dummy, any number of casts can be achieved within a loop or on successive lines of code. This will appear instantaneous to a player. Yes they will be made in sequence, but it will appear synchronous to anyone watching. There might be a small follow-through animation from the spawned unit and it might not play the Blademaster sound, they will all ‘happen’ simultaneously without delay. This is why it’s important your dummy caster is configured properly.
The dummy would play its dead animation and sometimes trigger some other hero-related events like Respawn Time and Kill Blow. I can turn these off but dead animation is still visual to players about how this ability is created and I don't want that.
There is no reason your dummy cast should have a model assigned to it (why would you want to see it), and it’s cast points/backswing should be set to 0 so you will never see any animations it could play (and the spell cast should have 0 follow-through time).

It should be set to Can’t Raise, Doesn’t Decay. It should have Locust which will prevent ANY unit from interacting with it in any way (aside from through a trigger). Minimap display should be turned off. It should not have any unit classifications like Hero or Worker. It should have a point value of 0. By giving it an expiration timer so the unit ‘kills itself’, it will never award experience or gold bounty to any units/players.
And the illusions derive from caster which means if I set the dummy's stats uninteractive with players, the illusions will do the same thing.
I think you are confused. The invisible, instant-cast, non-interactive dummy unit should not be a mirror of the hero. It doesn’t need to be. It will cast Wand of Illusion on the the casting hero, which makes a copy of the targeted unit. The unit that made the copy by casting the wand ability is irrelevant.
Also if I don't set the facing direction, the enemy can distinguish which illusions are based on my facing direction before and after the ability is being cast.
As Uncle said, grabbing all the spawned illusions with a unit group will allow you to operate on and randomize their positions/facing directions. This issue can be overcome. Just so you understand consider these two lines:
  • Actions
    • Unit - Order DummyCaster to Wand of Illusion (Triggering Unit)
    • Game - Display to (All Players) the text “You’re too slow!”
By the time the trigger execution outputs the text, the dummy unit created by the wand of illusion already exists. It has entered the map and triggered the enter events Uncle showed (which would temporarily pause this trigger execution while they ran) and can be put in a unit group. The full cast happens instantly before the next line of the trigger is reached, which is not the case if your dummy caster is configured improperly.
Also if one uses generic expiration instead of Remove, the dummy unit icon still appears, which means it is stored somewhere and the game would lag if I cast the ability too much. Meanwhile removing the dummy kills all illusions that dummy created as if they are non-existent.
If you know you don’t need the dummy any more and a Wait doesn’t introduce some possible error (like overwriting variables) you can just manually Remove them. But an expiration timer on a unit that doesn’t decay or raise will just do exactly the same thing on a delay as you specify.

Again they should not have a minimap icon because their whole purpose is to be invisible and unnoticeable.
 
Last edited:
Status
Not open for further replies.
Top