• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[JASS] Spell: Mirror image spread illusions and caster in a circle

Level 6
Joined
Jul 3, 2006
Messages
102
I am trying to create the effect with Mirror image of all illusions including the caster getting moved to positions around a certain location in equidistant angles.
I am using EVENT_PLAYER_UNIT_SUMMON which successfully catches all illusions and moves them, the caster however remains an issue.

It seems that if I use the event callback for EVENT_PLAYER_UNIT_SUMMON to move the caster, the caster stays in place. I assume it's the effect of Mirror image itself that repositions the units when the effect ends!? I tried using all possible spell events like spell effect/finish/end cast to move the caster, but this results in cancelling the cast altogether.

My last idea was to use a timer inside the summon callback with 0.03125s timeout in order to hopefully move the caster after the spell is finished but before the player can notice. This seems to work inconsistently (sometimes it does), even with 0.0625 (which is noticeable to the eye).

Any ideas how I could make such a spell work? Triggering the whole thing with custom made illusions is certainly one but I was hoping for something else, in order to keep the Mirror image cast effect.
 
It seems to be random, so half the time it works and half it doesn't. I can't think of anything else than triggering the illusions myself, maybe with Wand of Illusion!?

Still works when queuing an order? Ex. move to point, queue Mirror Image and queue another move order.
This is an enemy boss spell only, so if I understand you correctly, this is not a concern.
 
Here's a custom triggered Mirror Image:
You can probably modify it to get what you want.
 
The way Mirror Image handles spawning illusions is as follows:
  1. 'Unit starts casting the ability' event: There are no illusions yet, caster is visible.
  2. 'Unit stops casting the ability' event: Immediately triggered after above event. There are no illusions yet, caster is visible, but becomes hidden right after this event is processed (or maybe this event is fired because caster is about to be hidden, which forces him to stop casting the ability, hard to say).
  3. After delay set in 'Data - Animation Delay' field, N+1 illusions are created at locations around the caster.
    • Number N is the value set in 'Data - Number of Images'.
    • So in essence, if you set 3 images to spawn, then 4 images are created.
    • These images trigger the 'Unit enters (Playable map area)' event.
    • All images are hidden, have same unit-type as caster and have 'Illusion' flag/attribute.
  4. Game picks which one out of the N+1 illusions will be replaced by caster.
  5. Game iterates over the group of illusions. If given illusion:
    • is not the illusion picked in previous step, then that illusion will be unhidden and triggers the 'Unit spawns a summoned unit' event.
    • is the illusion picked in previous step, then caster is moved to that illusion's position and unhidden. Picked illusion will lose its 'Illusion' flag/attribute as well as its unit-type and is moved to center of map. The illusion unit then triggers the 'Unit spawns a summoned unit' event.
There is a delay between illusions entering map (step #3) and firing the 'spawned' event (step #5). Observed delay was between 0-200ms on my PC.

When caster appears in step #5 varies from cast to cast. One cast the first illusion may be picked to be replaced by caster, other cast the third illusion may be picked, etc.
If you had trigger like this:
  • Test
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Summoning unit) Equal to caster
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Summoned unit) is an illusion) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: ((( + (String(Ticks))) + ) Is illusion!)
        • Else - Actions
          • Game - Display to (All players) the text: ((( + (String(Ticks))) + ) Not illusion!)
where "Ticks" counts how many hundredths of seconds passed since illusions entered playable map area, you would see something like:
JASS:
//cast #1
(0) Is illusion!
(7) Not illusion! <-- at this point caster is at correct location and visible
(14) Is illusion!
(17) Is illusion!

//cast #2
(3) Is illusion!
(9) Is illusion!
(16) Is illusion!
(20) Not illusion! <-- at this point caster is at correct location and visible

What I think you could do (if you really needed to do this via Mirror Image), is to listen to the 'Unit starts casting the ability' event. When caster starts casting Mirror Images, determine their location - where caster should be and where images should be.
Then listen to 'Unit spawns a summoned unit' event. Check if (Summoning unit) is the caster and if so, check if (Summoned unit) is an illusion:
  • If not, then it is the illusion that was replaced by caster, so move caster to your pre-determined location for caster.
  • If yes, then it is an illusion that stays in game, so move it one of your pre-determined locations for illusions.
 
The way Mirror Image handles spawning illusions is as follows:
I have to ask, how do you know such details?
With this information, it would be trivial to make this work with Mirror Image.
However, I already switched to a custom version of "Mirror image" using Wand of Illusion.

Much of the functionality is the same:
1) Spell is cast -> show effect, create dummies for wand of illusion and cast illusion on caster, set up trigger to listen to illusion summoning
2) Trigger gathers illusions in group and hides them. When the expected number is reached, hide the hero as well and start timer.
3) Timer fires -> move them to desired locations and show them.

If you think it could help, I will post source code but I haven't polished it or anything.
 
Last edited:
I have to ask, how do you know such details?
Testing, nothing else.
In this case, all I did was subscribe to the four events I mentioned in my previous post ('start cast', 'stop cast', 'enters region' and 'spawns unit').
On top of that I had an initially-turned-off counter trigger (i.e. a trigger running every 0.01 seconds that just increments integer variable called Ticks).
The 'Start cast' trigger printed caster's location and turned on the counter trigger.
The 'Stop cast' trigger printed value of Ticks, caster's location and whether caster was hidden or not.
The 'Enters region' and 'Spawns unit' triggers basically did the same thing: both printed value of Ticks, location of entering/summoned unit, its unit type, whether it is an illusion and/or hidden. Also printed the location and hidden/unhidden state of caster.
 
Back
Top