Spell System for GUI MUI Coding

Spell System for GUI MUI Coding

By Daffa the Mage

Required Materials

  • World Editor
  • GUI Spell System v1.8.0.0 by Bribe
  • Basic knowledge of how to import Spell System into your map
  • Knows how to open Trigger Editor and making a new trigger
  • Have basic knowledge of trigger editor workings

Introduction

Greetings,

This tutorial is aimed at newbie GUI triggerer to be able to make simple spells that fit the MUI criteria by utilizing spell event. This is part of my aim to make Spell Section a more interesting place with more MUI resources to boot and the first tutorial of a series of tutorial related to this.

Making Your First Spell

So, for the startup, we will make a simple 'Heal' spell using the Spell System. I'm talking about Priest 'Heal', but instead of just healing, we want it to increase our max health per second for a few seconds.

So, buckle up and get yourself ready. First, follow instruction to install the Spell System. Then, open the trigger editor and copy the Spell System Sample Config. Let's call the new trigger Heal Config. Enable Heal Config and set your ability to your healing ability. Create 2 empty triggers called Heal Cast and Heal Loop.
Then, configure the config to be somewhat like the following. This is configuration is based on Bribe's documentation on example config trigger.
  • Heal Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- You must assign an ability ID to let the system know which spell you're using: --------
      • Set Spell__Ability = Heal
      • -------- Next, you must pick at least one of the following types of triggers to run at a phase of the spell: --------
      • Set Spell__Trigger_OnCast = Heal Cast <gen>
      • -------- Next, you can specify a trigger to run periodically, if you want that type of behavior. --------
      • Set Spell__Trigger_OnLoop = Heal Loop <gen>
      • -------- Added 28 Feb 2016: You can now specify Spell__Time, Spell__Duration and Spell__DurationPerLevel from the Config trigger. --------
      • -------- NOTE: With these settings, the OnLoop trigger will run every 1 second for 4/5/6 seconds --------
      • Set Spell__Time = 1.00
      • Set Spell__Duration = 3.00
      • Set Spell__DurationPerLevel = 1.00
      • -------- The next ones are for the InRange filter, if you use it. You don't have to include any of these for many typical spells. --------
      • -------- TIPS: --------
      • -------- > For healing spells, you'll want to set AllowAllies to True and AllowEnemies to False. --------
      • -------- > If you are creating a "kill unit" spell, you'll want to set AllowHero to False. --------
      • -------- > If you are making a custom "Resurrect", you'll want to set AllowDead to True and AllowLiving to False. --------
      • -------- > AllowMagicImmune as False also prevents invulnerable units from being picked, which is a plus in my opinion. --------
      • Set Spell__Filter_AllowEnemy = True
      • Set Spell__Filter_AllowLiving = True
      • Set Spell__Filter_AllowHero = True
      • Set Spell__Filter_AllowNonHero = True
      • Set Spell__Filter_AllowAlly = False
      • Set Spell__Filter_AllowDead = False
      • Set Spell__Filter_AllowFlying = False
      • Set Spell__Filter_AllowMechanical = False
      • Set Spell__Filter_AllowStructure = False
      • Set Spell__Filter_AllowMagicImmune = False
      • -------- NEW: Added 17 May 2016 - you can specify your own trigger conditions to add to the InRange check --------
      • -------- The trigger conditions reference the unit "Spell__InRangeUnit" --------
      • Set Spell__Trigger_InRangeFilter = Spell System Sample Filter <gen>
      • -------- If you want to keep track of which units have already been hit by the spell, set UseTargetGroup to True --------
      • -------- TIPS: --------
      • -------- > The group is called Spell__TargetGroup. It starts empty and will destroy itself when the spell is finished --------
      • -------- > After using a Spell__InRange check, you can use "Add all units in Spell__InRangeGroup to Spell__TargetGroup" --------
      • Set Spell__UseTargetGroup = True
      • -------- When everything is set the way you want it, run Spell System <gen>: --------
      • Trigger - Run Spell System <gen> (ignoring conditions)
We will not use the filters, so I just skim it. You can alter the duration as needed.​

  • Heal Cast
    • Events
    • Conditions
    • Actions
      • Set Spell__StartDuration = True
Heal Cast is only for duration triggering. Without it, the spell loop effect will not run.​

  • Heal Loop
    • Events
    • Conditions
    • Actions
      • Unit - Set Max HP of Spell__Target to ((Max HP of Spell__Target) + 10)
Heal Loop will add 10 Max HP per second. Something odd I found with my test map running the spell 5 times despite I set it to 4 seconds. It can easily be fixed by checking the remaining duration as shown below:​
  • Heal Loop
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spell__Duration Greater than 0.00
        • Then - Actions
          • Unit - Set Max HP of Spell__Target to ((Max HP of Spell__Target) + 10)
        • Else - Actions
Now, it works as intended. I provided a test map for you to look at the final result. If you don't get the same result, feel free to compare your code with the provided attachment.​

~Daffa the Mage
 

Attachments

  • SpellTutorial1.w3x
    52.9 KB · Views: 56
Last edited:
Level 8
Joined
Jul 4, 2016
Messages
494
Not sure if this question is specifically related to this tutorial, but I notice that in some of your spells, you sometimes use the GUI spell system's arrays instead of the non-arrayed variables? Why is that? When is it necessary to use the arrays over the standard variables to keep it MUI.
I never could understood the purpose behind it while working with the system.
 
Not sure if this question is specifically related to this tutorial, but I notice that in some of your spells, you sometimes use the GUI spell system's arrays instead of the non-arrayed variables? Why is that? When is it necessary to use the arrays over the standard variables to keep it MUI.
I never could understood the purpose behind it while working with the system.
I'm experimenting on it and trying to see the difference. So far, I found it's mostly related to how the readibility concerning the spell. I still need to investigate further.
 
GUI Spell System has internal data structure and system variables, they are array.

Before the user spell "InternalSpell[SpellIndex]" runs, the usage of system variables gets simplified...
  • Duration[SpellIndex] becomes only Duration
  • Caster[SpellIndex] becomes only Caster
    ....
so it's easier to work with for the user. Technically, you also could use his internal system variables Duration[SpellIndex], for example, instead of only Duration, it will work the same.

The very same SpellIndex is also provided for the user, so he might use it, too. It might be useful for example, if the user wants to store additional information to the spell, like creating a temporary extra effect for the spell. So he stores it in his NewSpellEffect[SpellIndex] array variable, and can refer to it later.

In Chidori Lightning Storms v1.0, one can see some internal system variables are used, like ChidoriLS_BlastRange[Spell_i_Level[Spell__Index]], in the "Chidori LS Effect trigger". But instead ChidoriLS_BlastRange[Spell__Level] could be used, too.
 
Last edited:
GUI Spell System has internal data structure and system variables, they are array.

Before the user spell "InternalSpell[SpellIndex]" runs, the usage of system variables gets simplified...
  • Duration[SpellIndex] becomes only Duration
  • Caster[SpellIndex] becomes only Caster
    ....
so it's easier to work with for the user. Technically, you also could use his internal system variables Duration[SpellIndex], for example, instead of only Duration, it will work the same.

The very same SpellIndex is also provided for the user, so he might use it, too. It might be useful for example, if the user wants to store additional information to the spell, like creating a temporary extra effect for the spell. So he stores is in his NewSpellEffect[SpellIndex] array variable, and can refer to it later.

In Chidori Lightning Storms v1.0, one can see some internal system variables are used, like ChidoriLS_BlastRange[Spell_i_Level[Spell__Index]], in the "Chidori LS Effect trigger". But instead ChidoriLS_BlastRange[Spell__Level] could be used, too.

Thanks for pointing that out. I personally like it when I can see the index just to be certain of the whole spell, especially when there are external variables at play. I can ascertain all goes with index that way. Never know it had it's own internal data structure.

@Clanzion hope @IcemanBo clears your questions.
 

Chaosy

Tutorial Reviewer
Level 39
Joined
Jun 9, 2011
Messages
13,083
Solid overall.

There are a few minor things I would suggest however.

1. Use a different color for titles to make it easier to read
2. Indent the text underneath a title

How to become awesome
Just do it
3. I think the config trigger has waaaaaaaaaaaay too many comments. Its more comments than code. I suggest maybe putting the comments in a hidden bb tag to make them more optional. I think they can be useful, but I also think good variable naming should make it so no comments (or very few) are required. It also feels a bit weird to have parts of the tutorial inside the trigger code.

I would not say either of these are a must-change but giving you a few days to update if you feel like it before I approve it.
 
Solid overall.

There are a few minor things I would suggest however.

1. Use a different color for titles to make it easier to read
2. Indent the text underneath a title

How to become awesome
Just do it
3. I think the config trigger has waaaaaaaaaaaay too many comments. Its more comments than code. I suggest maybe putting the comments in a hidden bb tag to make them more optional. I think they can be useful, but I also think good variable naming should make it so no comments (or very few) are required. It also feels a bit weird to have parts of the tutorial inside the trigger code.

I would not say either of these are a must-change but giving you a few days to update if you feel like it before I approve it.

Something to surprise me after AGES :p
Anyway, thanks for the review. I'll do them ASAP.

EDIT:

1. Changed color for all texts. Cyan apparently is very irritating when I look at it again.
2. Hopefully all set now.
3. Config trigger is based on Bribe's own, but I made some adjustment now.
 
Last edited:
Top