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!
I've been off of working on a map for a long time now and returning to it, I want to make sure all my spells are MUI. But I really don't understand Indexing at all or how to use the Spell_Index and Spell_Hashtable variables that come with Bribe's Spell System. Even after hours of looking at old tutorials and multiple examples of MUI spells that use this system.
I've tried replacing every storable variable in a spell as an array. then putting them in the trigger as SpellVariableExample[Spell_Index] = Last whatever and I can't seem to get it to work. I want to try Spell_Hashtable as well but even after looking through a lot of hashtable guides I just don't know what im doing.
Set VariableSet Spell__Trigger_OnCast = Mirror Clone Cast <gen>
Set VariableSet Spell__Trigger_OnLoop = Mirror Clone Loop <gen>
Trigger - Run Spell System <gen> (ignoring conditions)
2nd
Mirror Clone Cast
Events
Conditions
Actions
Unit - Create 1 Dummy - Mirror Clone 1 for Spell__CasterOwner at ((Position of Spell__Caster) offset by (Random real number between 250.00 and 300.00) towards (Random real number between 1.00 and 360.00) degrees.) facing Default building facing degrees
Set VariableSet MirrorClone1 = (Last created unit)
Unit - Add a 6.00 second Generic expiration timer to MirrorClone1
Lightning - Create a Drain Mana lightning effect from source (Position of Spell__Caster) to target (Position of MirrorClone1)
Set VariableSet LightningEffect = (Last created lightning effect)
Set VariableSet Spell__StartDuration = True
Wait 6.00 seconds
Lightning - Destroy LightningEffect
3rd
Mirror Clone Loop
Events
Conditions
Actions
Set VariableSet MirrorCloneCheck = (Units within 75.00 of (Position of MirrorClone1) matching ((((Unit-type of (Matching unit)) Equal to Mirror Sorceress) or ((Unit-type of (Matching unit)) Equal to Mirror Sorceress - Ascended)) and (((Matching unit) is alive) Equal to True)).)
Lightning - Move (Last created lightning effect) to source (Position of Spell__Caster) and target (Position of MirrorClone1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(MirrorCloneCheck is empty) Equal to True
Then - Actions
Do nothing
Else - Actions
Lightning - Destroy LightningEffect
Unit - Remove MirrorClone1 from the game
Special Effect - Create a special effect at (Position of Spell__Caster) using war3mapImported\Winter Blast SD.mdx
Special Effect - Set Scale of (Last created special effect) to 3.00
Special Effect - Destroy (Last created special effect)
Unit Group - Pick every unit in (Units within 600.00 of (Position of Spell__Caster) matching ((((Matching unit) belongs to an enemy of Spell__CasterOwner.) Equal to True) and (((Matching unit) is alive) Equal to True)).) and do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Spell__Caster to damage (Picked unit), dealing ((100.00 x (Real((Level of Mirror Clone for Spell__Caster)))) x (((Real(1)) x 0.01) + 1.00)) damage of attack type Spells and damage type Universal
Basically, It creates an invincible clone and an attached lightning effect in a random radius around the caster, and when the spell detects the caster contacts the clone. It explodes, and both the clone and lightning are removed, Definitely works but not MUI.
Let's put MUI aside for now and focus on what your trigger does first.
Mirror Clone Start
I'm guessing this is where you want to configure your ability. You stored Mirror Clone Ability, 6 seconds duration, time, and triggers into variables. Presumably to be used later on. Then you run Spell System trigger. My question is, what is Spell System trigger? As you did not include it in your post. Not only that, what is the purpose of Spell_Time? I don't see it being used anywhere in your triggers.
Mirror Clone Cast
So how does this trigger work without any single event and condition? To keep it simple, trigger works this way; we have events, conditions, and actions. Events will be the cause of all the actions below if the conditions are met. Look at this trigger:
Animate Dead
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Animate Dead
Actions
-------- Do what you want your spell to do here --------
Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
Let's say I have an ability called Animate Dead, I want this ability to create footman at the center of the map when it is cast.
Unit - A unit Starts the effect of an ability
This part will detect if a unit uses an ability, regardless which ability it's using.
(Ability being cast) Equal to Animate Dead
We add this condition so that the action will only happen IF the ability cast is Animate Dead. If different ability is cast, the action will not happen.
Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
This is the effect; create 1 footman at the center of the map for the player who owns the unit that uses the ability.
Now, let's get back to your trigger. You don't have events nor conditions in your Mirror Clone Cast. So my question is how do you run this trigger?
Mirror Clone Loop
A trigger called loop is usually, as the name suggests, a looping trigger that involves periodic timer. However, I do not see a timer there. Same question as before, how do you run this trigger?
Before you try to understand how Indexing and MUI work, let's try to grasp a good understanding of how trigger works first.
While you can separate your ability into 3 different triggers (Start, Cast, Loop), oftentimes if there's not much to configure, you can just combine Start and Cast into one, so there's only 2 triggers (Cast and Loop).
To go over what the spell is going to do; the spell is called Mirror Clone which if it is cast, it'll create a clone with an attached lightning effect from the caster towards the clone. If the caster gets too close to the clone, the clone will explode and be removed along with the attached lightning effect.
This will be my attempt to re-create your spell along with some explanations on why I did it that way:
Mirror Clone Start
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Mirror Clone
Actions
-------- This is the guy who uses the spell --------
Set Spell_Caster = (Triggering unit)
-------- This is the duration for your mirror clone --------
Set Spell_Duration = 6.00
-------- We use Counter variable to count whether the duration is up or not --------
-------- We make sure it starts off with 0 --------
Set Counter = 0.00
-------- We create the clone --------
Unit - Create 1 Footman for (Owner of Spell_Caster) at ((Position of Spell_Caster) offset by 300.00 towards (Facing of Spell_Caster) degrees) facing Default building facing degrees
-------- Assign the clone into a variable so we can reference it easier later --------
Set MirrorClone = (Last created unit)
-------- Give our clone a duration so it does not stay forever --------
-------- In this case, we have Spell_Duration from earlier, so use that --------
-------- Keep in mind to always use the variables you've prepared, otherwise they serve no purpose --------
Unit - Add a Spell_Duration second Generic expiration timer to MirrorClone
-------- Let's create the lightning effect --------
Lightning - Create a Drain Mana lightning effect from source (Position of Spell_Caster) to target (Position of MirrorClone)
-------- Assign the lightning effect into a variable so we can reference it easier later --------
Set LightningEffect = (Last created lightning effect)
-------- Let's turn on Mirror Clone Loop Trigger --------
Trigger - Turn on Mirror Clone Loop <gen>
Mirror Clone Loop
Events
Time - Every 0.20 seconds of game time
Conditions
Actions
-------- Every second, we check how far the distance between our clone and our caster --------
-------- If they are too close, time to remove the clone and the lightning effect --------
-------- We also check if the duration is up, so we can destroy the lightning effect --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Distance between (Position of Spell_Caster) and (Position of MirrorClone)) Less than or equal to 150.00
Counter Greater than or equal to Spell_Duration
Then - Actions
-------- Because one of the conditions is met --------
-------- Here we destroy the lightning effect --------
Lightning - Destroy LightningEffect
-------- Here we remove the clone --------
Unit - Remove MirrorClone from the game
-------- Here we create special effect, set the size, and destroy it right away --------
Special Effect - Create a special effect at (Position of Spell_Caster) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
Special Effect - Set Scale of (Last created special effect) to 3.00
Special Effect - Destroy (Last created special effect)
-------- Now we want to deal damage to nearby enemies --------
Unit Group - Pick every unit in (Units within 600.00 of (Position of Spell_Caster)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is alive) Equal to True
((Picked unit) belongs to an enemy of (Owner of Spell_Caster)) Equal to True
Then - Actions
-------- Here we create another special effect, and destroy it right away --------
Special Effect - Create a special effect at (Position of Spell_Caster) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
Special Effect - Destroy (Last created special effect)
-------- Deal some damage to the enemies --------
Unit - Cause Spell_Caster to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
Else - Actions
-------- When we're done, turn off this trigger --------
Trigger - Turn off (This trigger)
Else - Actions
-------- Neither conditions are met --------
-------- That means the duration is not up yet and the clone is far away from the caster --------
-------- We increment the counter --------
Set Counter = (Counter + 0.20)
-------- We also move the lightning effect --------
Lightning - Move LightningEffect to source (Position of Spell_Caster) and target (Position of MirrorClone)
This is not MUI, however.
Now, turning this into MUI is very doable but you have to understand what you're doing with the triggers first.
Hopefully, you can understand the flow of my triggers.
Keep in mind, this contains Memory Leaks. Once you understand how to make spell properly, you can try to read Visualize: Dynamic Indexing to get a better understanding of indexing. And then, you can make MUI spells. Good luck!
Note how your MirrorClone1 and LightningEffect variables are not Arrays and don't reference Spell__Index.
Now look at Bribe's example found in the system thread. This is his Cast trigger:
Events
Conditions
Actions
Set Spell__StartDuration = True
Special Effect - Create a special effect attached to the origin of Spell__Target using Abilities\Spells\NightElf\Rejuvenation\RejuvenationTarget.mdl
Set HolyLightBuff[Spell__Index] = (Last created special effect)
^ Note how he's storing his Special Effect in the HolyLightBuff Array variable and uses Spell__Index as it's [index]. Spell__Index is an Integer that is automatically set to a unique number by the system. This is what makes things MUI as it prevents your data from being overwritten by outside sources. If that is confusing then you should research and practice using Array variables, they're extremely simple to understand. But even if you're confused you can still follow the design pattern shown here to create your spell.
Now look at your Cast trigger. Let's take the logic Bribe used in his trigger and apply it to your own trigger. So you know that you DON'T need to track a Special Effect over time. But you DO know that you need to track a Unit (the clone) and a Lightning over time. Here's the trigger modified to rely on the spell system:
Mirror Clone Cast
Events
Conditions
Actions
Set VariableSet Spell__StartDuration = True
Set VariableSet MirrorClonePoint = (Spell__CastPoint offset by (Random real number between 250.00 and 300.00) towards (Random real number between 1.00 and 360.00) degrees.)
Unit - Create 1 Dummy - Mirror Clone 1 for Spell__CasterOwner at MirrorClonePoint facing Default building facing degrees
Set VariableSet MirrorCloneDummy[Spell__Index] = (Last created unit)
Lightning - Create a Drain Mana lightning effect from source Spell__CastPoint to target MirrorClonePoint
Set VariableSet MirrorCloneLightning[Spell__Index] = (Last created lightning effect)
^ Note how the things I need to keep track of over time are now using Array variables (clone + lightning). I also added a Point variable to address a memory leak issue.
Next up is the Loop trigger, here's the one from Bribe's example:
Events
Conditions
Actions
-------- Heals for 10/15/20 each second --------
Unit - Set life of Spell__Target to ((Life of Spell__Target) + (5.00 + (5.00 x Spell__LevelMultiplier)))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Spell__Duration Less than or equal to 0.00
Then - Actions
-------- When the heal-over-time has ended, destroy the rejuvenation effect --------
Special Effect - Destroy HolyLightBuff[Spell__Index]
Else - Actions
^ Spell__Target is another system variable that has been automatically set for us. It obviously refers to the (Target unit of ability being cast), which in his case would be whoever he cast Holy Light on. Spell__LevelMultiplier represents the Ability Level and Spell__Duration is how much time has passed so far. If Spell__Duration is <= 0.00 then we know that this instance of the spell has ended and we can finish things up.
Just like before we can apply this logic to your own Loop trigger:
Mirror Clone Loop
Events
Conditions
Actions
Set VariableSet MirrorClonePoint = (Position of MirrorCloneDummy[Spell__Index]
Lightning - Move MirrorCloneLightning[Spell__Index] to source Spell__CastPoint and target MirrorClonePoint
-------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between Spell__CastPoint and MirrorClonePoint) Less than or equal to 75.00
Then - Actions
Set VariabeSet Spell__Duration = 0.00
Special Effect - Create a special effect at Spell__CastPoint using war3mapImported\Winter Blast SD.mdx
Special Effect - Set Scale of (Last created special effect) to 3.00
Special Effect - Destroy (Last created special effect)
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within 600.00 of Spell__CastPoint matching ((((Matching unit) belongs to an enemy of Spell__CasterOwner.) Equal to True) and (((Matching unit) is alive) Equal to True)).) and do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Spell__Caster to damage (Picked unit), dealing (100.00 x Spell__LevelMultiplier) damage of attack type Spells and damage type Universal
Else - Actions
-------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
^ Here I am utilizing the spell system variables again to create your desired effect. I also address some more memory leaks. Spell__CastPoint refers to the current position of the caster. I set Spell__Duration to 0.00 when you collide with a mirror clone so that the spell ends early.
Ah, I guess I misunderstood the context. Thankfully, @Uncle provided a clear explanation on how to apply the Spell System right away. Feel free to use my post as reference if needed.
@Uncle Thank you very much I just got back on and got it working as MUI, only thing missing was MirrorClonePoint should be an array too since multiple lightning effects can point to different clones simultaneously. Also not using waits anymore is a big helper so also appreciated.
@Uncle Thank you very much I just got back on and got it working as MUI, only thing missing was MirrorClonePoint should be an array too since multiple lightning effects can point to different clones simultaneously. Also not using waits anymore is a big helper so also appreciated.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.