• 🏆 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!

Spell Event Auxiliar vars

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Hello everyone, some days ago i decided i wanted to share some useful resource at the Hive. But my spells are generally "too simple" for Hive(at least that's my point of view), so now i'm presenting to you:

SEA
What is SEA?
- Is a big mass of water, also, the initials of this little "system"
What does SEA means?
- Spell Event Auxiliars vars. A simple and useful utility for triggering spells
What does SEA provides?
- It provides useful variables unique for each unit in the map to retrieve target of spell, current "state" of the cast, and set a custom target if you want
SEA works using the awesome Unit Indexer from Bribe, in the form of GUI Unit Event(same thing, with more stuff)


But enough talking, let's get to the triggs and usage instructions
  • SEA Channel
    • Acontecimientos
      • Unidad - A unit Comienza a canalizar una habilidad
    • Condiciones
      • (Custom value of (Triggering unit)) No igual a (!=) 0
    • Acciones
      • Set SpellEvent_UnitId = (Custom value of (Triggering unit))
      • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_CASTED_FALSE
  • SEA BeginsCast
    • Acontecimientos
      • Unidad - A unit Comienza a lanzar una habilidad
    • Condiciones
      • (Custom value of (Triggering unit)) No igual a (!=) 0
    • Acciones
      • Set SpellEvent_UnitId = (Custom value of (Triggering unit))
      • -------- Here we save the targets data. is easier for everyone --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • Si: Condiciones
            • (Target unit of ability being cast) No igual a (!=) Ninguna unidad
          • Entonces: Acciones
            • Set SpellEvent_Target[SpellEvent_UnitId] = (Target unit of ability being cast)
            • Custom script: set udg_SpellEvent_TargetX[udg_SpellEvent_UnitId] = GetUnitX(udg_SpellEvent_Target[udg_SpellEvent_UnitId])
            • Custom script: set udg_SpellEvent_TargetY[udg_SpellEvent_UnitId] = GetUnitY(udg_SpellEvent_Target[udg_SpellEvent_UnitId])
          • Otros: Acciones
            • Set SpellEvent_Target[SpellEvent_UnitId] = Ninguna unidad
            • Custom script: set udg_SpellEvent_TargetX[udg_SpellEvent_UnitId] = GetSpellTargetX()
            • Custom script: set udg_SpellEvent_TargetY[udg_SpellEvent_UnitId] = GetSpellTargetY()
      • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_CASTED_TRUE
      • -------- This check might be unnecesary, but if a unit end an spell cast, and starts another in less than a frame, this check will ensure i won't be cleaning the values early --------
      • Set SpellEvent_SafetyCheck[SpellEvent_UnitId] = True
      • -------- The unit has oficially began casting --------
      • Set SpellEvent_IsCasting[SpellEvent_UnitId] = True
  • SEA Effect
    • Acontecimientos
      • Unidad - A unit Inicia el efecto de una habilidad
    • Condiciones
      • (Custom value of (Triggering unit)) No igual a (!=) 0
    • Acciones
      • Set SpellEvent_UnitId = (Custom value of (Triggering unit))
      • Set SpellEvent_CurrentSpell[SpellEvent_UnitId] = (Ability being cast)
      • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_CHANNELING
  • SEA StopCast
    • Acontecimientos
      • Unidad - A unit Detiene el lanzamiento de una habilidad
    • Condiciones
      • (Custom value of (Triggering unit)) No igual a (!=) 0
    • Acciones
      • Set SpellEvent_UnitId = (Custom value of (Triggering unit))
      • -------- If the unit hasn't starting casting, then we avoid more work --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • Si: Condiciones
            • SpellEvent_SuccesfulCast[SpellEvent_UnitId] No igual a (!=) SEA_CASTED_FALSE
          • Entonces: Acciones
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • Si: Condiciones
                • SpellEvent_SuccesfulCast[SpellEvent_UnitId] Igual a (==) SEA_CASTED_TRUE
              • Entonces: Acciones
                • -------- If the unit hasn't started channeling, then we say that the cast failed --------
                • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_CASTED_FALSE
              • Otros: Acciones
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • Si: Condiciones
                    • SpellEvent_SuccesfulCast[SpellEvent_UnitId] No igual a (!=) SEA_CASTED_FALSE
                  • Entonces: Acciones
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • Si: Condiciones
                        • SpellEvent_SuccesfulCast[SpellEvent_UnitId] Igual a (==) SEA_CHANNELING
                      • Entonces: Acciones
                        • -------- If the unit is currently channeling, then it means that the unit has cancelled the casting --------
                        • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_STOPPED_CHANNEL
                        • Set SpellEvent_LastCastedSpell[SpellEvent_UnitId] = (Ability being cast)
                        • Set SpellEvent_EC_Finished = False
                      • Otros: Acciones
                        • -------- Else, it means the unit has succesfully finished the cast --------
                        • Set SpellEvent_EC_Finished = True
                    • -------- Now we trigger the event --------
                    • Set SpellEvent_EC_AbilityCasted = (Ability being cast)
                    • Set SpellEvent_EndCast = 0.00
                    • Set SpellEvent_EndCast = 1.00
                    • Set SpellEvent_EndCast = 0.00
                  • Otros: Acciones
            • -------- We remove the safety --------
            • Set SpellEvent_SafetyCheck[SpellEvent_UnitId] = False
            • -------- The unit is no longer casting --------
            • Set SpellEvent_IsCasting[SpellEvent_UnitId] = False
            • -------- This timer will trigger the clean function --------
            • Custom script: if FirstOfGroup(udg_SEA_Group) == null then
            • Cuenta atrás del reloj - Start SEA_Timer as a Un tiro timer that will expire in 0.02 seconds
            • Custom script: endif
            • Grupo de unidad - Add (Triggering unit) to SEA_Group
          • Otros: Acciones
            • -------- And we say that the unit is not casting anymore --------
            • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_NOT_CASTING
  • SEA Finish
    • Acontecimientos
      • Unidad - A unit Finaliza el lanzamiento de una habilidad
    • Condiciones
      • (Custom value of (Triggering unit)) No igual a (!=) 0
    • Acciones
      • -------- We check this, so we don't get false positives --------
      • -------- Interesting note: This only happens with Force of nature when you attempt to cast it on a tree-free zone --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • Si: Condiciones
            • SpellEvent_SuccesfulCast[SpellEvent_UnitId] No igual a (!=) SEA_CASTED_FALSE
          • Entonces: Acciones
            • Set SpellEvent_UnitId = (Custom value of (Triggering unit))
            • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_FINISHED_TRUE
            • Set SpellEvent_LastCastedSpell[SpellEvent_UnitId] = SpellEvent_CurrentSpell[SpellEvent_UnitId]
          • Otros: Acciones
  • SEA Clean
    • Acontecimientos
      • Tiempo - SEA_Timer expires
    • Condiciones
    • Acciones
      • Grupo de unidad - Pick every unit in SEA_Group and do (Actions)
        • Bucle: Acciones
          • Set SpellEvent_UnitId = (Custom value of (Picked unit))
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • Si: Condiciones
                • SpellEvent_SafetyCheck[SpellEvent_UnitId] Igual a (==) False
              • Entonces: Acciones
                • Custom script: set udg_SpellEvent_CurrentSpell[udg_SpellEvent_UnitId] = 0
                • Set SpellEvent_TargetY[SpellEvent_UnitId] = 0.00
                • Set SpellEvent_TargetX[SpellEvent_UnitId] = 0.00
                • Set SpellEvent_Target[SpellEvent_UnitId] = Ninguna unidad
                • Set SpellEvent_SuccesfulCast[SpellEvent_UnitId] = SEA_NOT_CASTING
                • Set SpellEvent_CustomTarget[SpellEvent_UnitId] = Ninguna unidad
                • Set SpellEvent_SafetyCheck[SpellEvent_UnitId] = True
              • Otros: Acciones
          • Grupo de unidad - Remove (Picked unit) from SEA_Group

Instructions:
The system provides the next functions in form of variables, unitId will refer to the unit custom value
-------- SpellEvent_IsCasting[unitId], boolean that returns true when the unit is currently casting or channeling an spell --------
--------
SpellEvent_CurrentSpell[unitId], returns the ability being casted by the unit, returns 0 in case the unit is not casting --------
--------
SpellEvent_Target[unitId] returns the current target of the ability being casted by the unit, returns null if there is no target or if the unit is not casting --------
--------
SpellEvent_TargetX[unitId] returns real. This is the X coordinate of the target point of the ability being casted, if the ability has a target unit, returns X coordinate of target unit --------
--------
SpellEvent_TargetY[unitId] returns real. This is the Y coordinate of the target point of the ability being casted, if the ability has a target unit, returns Y coordinate of target unit --------
--------
SpellEvent_LastCastedSpell[unitId] returns the last ability casted by the unit, perfect for stealing spells like Rubick --------
--------
SpellEvent_CustomTarget[unitId] this variable can be setted by the developer, the system will clean its value later, useful for spells like Mass teleport or similars --------
--------
SpellEvent_SuccesfulCast[unitId] returns an integer, this integer defines the current state of the unit --------
-------- --------------------------------------------- --------
-------- SEA_CASTED_FALSE: the unit is currently channeling the spell but having begins casting, or the unit has finished the cast without triggering the ability effect --------
-------- SEA_CASTED_TRUE: the unit has begun casting the ability but hasn't trigger the spell effect yet --------
-------- SEA_CHANNELING: the unit has trigger spell effect and is currently channeling the spell --------
-------- SEA_STOPPED_CHANNEL: The unit manually stopped the spell channeling --------
-------- SEA_FINISHED_TRUE: The unit has succesfully finished the spell casting --------
-------- SEA_NOT_CASTING: The unit is not casting any spell right now --------
-------- --------------------------------------------- --------
--------
The system also provides an event --------
--------
Game - SpellEvent_EndCast becomes Equal to 1.00 --------
--------
This function will trigger when the unit ends casting the ability --------
--------
You can use Triggering Unit with no problem, also you can use two extra variables --------
--------
SpellEvent_EC_AbilityCasted, returns the ability casted in the event --------
--------
SpellEvent_EC_Finished, returns boolean, if true, the unit has succesfully finished the ability casting --------
--------
Note: The event unit end ability cast triggers when you cancel an ability at ANY point of it --------
--------
This custom event will ONLY trigger if the unit has trigger spell effect event succesfully --------

Welp, that's all you need to know. Download and tell me if you find some errors, hopefully the usefulness of this system is not opaqued by its simplicity
Contents

Spell Event Auxiliar vars (Map)

Reviews
KILLCIDE
As of right now, Bribe's GUI Spell System is top notch. There is no need to close the thread, as some people might find it useful and or would like to use it as a reference.
Level 7
Joined
Jan 23, 2011
Messages
350
I saw the system before posting. But GUI Event is more complex, handles more things for the developer, it makes the loop for yourself, you have a register each ability to the system, overall, is a more powerful system than this. This is a simplier approach, just makes your life a bit easier by giving you easy access to the targets of the abil, current state of the unit casting. I made this just so i could make a Flame Strike-like ability
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Ideally I'd like to see all GUI spells use Spell System as it would make it all a lot easier to import into a map without the map maker having to do the conversion him/her self.

If you need help using Spell System, PLEASE ask me! I am known to do the work importing it into peoples' maps for them because I value the system so much. Though Damage Engine gets much of the credit, it's Spell System that I want showcased above any other.
 
Level 7
Joined
Jan 23, 2011
Messages
350
The reason why i posted it even after seeing Spell System, is because i don't really like how Spell System does EVERYTHING for you.
This system only intention is to help a bit, with extra data to make spell easier :D
Specially Flame Strike
To make GUI Spells i personally use Mui
Basically it works like a simple JASS spell
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Yeah the thing is you can ultimately use whatever you want to make a spell.

I originally set out to make the spell Big Dipper and found myself typing out the same crap as I see in every Spell and the programmer in me took over and said "this can be streamlined" hence a light version of Spell System was made which eventually became larger and larger.

Your system would evolve to the same point if you put more time and testing and research into it. You have values which would bug because of not compensating for overlapping abilities for example.

That's one reason why reinventing the wheel is not a good idea.

Spell System should be the standard because it is a proven and meaningful way to create spells. If you don't use all of its features it's understandable, but aside from the extra events the variable responses would be about 80% utilized by the average spell.
 
Top