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

GUI Spell System v1.8.0.0

This bundle is marked as director's cut. It exceeds all expectations and excels in every regard.
GUI Spell System
version 1.8.0.0

About:

Spell System revolutionizes the spell making process. It handles spell indexing, end-cast events, timed triggers, configurable unit-in-range filters, memory leak management, gives you access to a part of a global hashtable and reduces your variable and handle count drastically per spell. This system unifies all spell events and runs your triggers for you, directly. The result is an efficient, fully-featured and clean spell coding experience, and my personal favorite contribution to the GUI community.

Included in the demo map is the first spell I've made in 5 years: The Big Dipper. I am pleased to present this project to the Hive community!

Features:
  • Automatic event handling of spells. The system runs your triggers for you once you have configured your spell with a couple of variables.
  • Automatic creation and destruction of spell indices.
  • Automatic variable setting: sets the cast ability, the ability level, caster, target, caster position and target position and more into Spell__ variables.
  • Automatically runs a spell instance periodically if you specify an OnLoop trigger from a spell.
  • Automatic memory management of caster/target locations.
  • Unified common variables to reduce user's need to constantly create the same, redudant variables each time per spell.
  • Automatically gets all units in a range matching pre-specified conditions.
  • You can configure which units in range are chosen from the configuration trigger of your spell.


Spell Preview: Spell System GIF - Find & Share on GIPHY


Required variables

Spell__Ability (ability)

Set in each spell's Config trigger to the ability you want a trigger for.​

Spell System <gen> (trigger)

Run this trigger, ignoring conditions, once all Config variables are set.​

At least one event trigger is required

Spell__Trigger_OnEffect (trigger)

Trigger runs when a unit starts the effect of the specified ability.​

Spell__Trigger_OnFinish (trigger)

When a unit is done casting the ability (completed/canceled).​

Spell__Trigger_OnCast/Channel (trigger)

Usually unused. For more information about what these do, see Casting events guide

Event Responses

Spell__Caster (unit)

The unit casting the spell.​

Spell__Target (unit)

The target unit of the spell, if applicable. Will be set to (no unit) if it was a point-target or no-target spell.​

Spell__CastPoint (point)

The position of the casting unit. If the caster moves, this point moves with it.​

Spell__TargetPoint (point)

The target point of the spell. If the target was a unit and the unit moves, this point moves with it.​

Commonly-extracted variables

Spell__Level (integer)

The level of the ability being cast.​

Spell__CasterOwner (player)

The caster owner is also commonly used to determine friend from foe, or to specify the owner of a dummy unit.​

MUI variables

Spell__Index (integer)

The unique index which is used in an array to store specific stuff with your spell. Using this variable as an array index ensures your spell is fully-MUI.​

Spell__Hash (hashtable)

You can store anything extra you want or need for your spell into this hashtable as long as you only use Spell__Index as the parent key.​

Common Time variables

Does your spell do something over time? If not, skip this section.

Spell__Trigger_OnLoop (trigger)

Usually set from the config trigger, but can be set or changed at any point in the spell's lifespan. This trigger runs after a specified period of time.​

Spell__Time (real)

How long (in seconds) to wait before the OnLoop trigger runs (or runs again, if used sequentially). It must be set to a value above 0.00 to be registered with the system.

Spell__Duration (real)

Specified during Config or during any phase of the spell. Will keep repeating the OnLoop trigger every Spell__Time seconds until the duration is expired.

If you've already set a duration and wish to terminate it early, simply set the Duration to 0.00.

If you need to know if the duration has ended, check if it's equal to or less than 0.00. If it will still run, it will be greater than 0.00.​

Units-in-range essential variables

Spell__InRangePoint (point)

Set to the center of where you want to pick units from.​

Spell__InRange (real)

How wide should the radius be?​

Spell__InRangeGroup (unit group)

Filled with all units in range of the given point who matched the spell filter criteria.​

Spell__Filter_AllowX (boolean)

Specify what kind of targets you allow to be added to Spell__InRangeGroup. Specify any of these filters from your spell's Config trigger if you want custom ones. What you leave unspecified defaults to whatever the filters are set to in Spell System Config <gen>​



Spell__DurationPerLevel (real)

You can specify a duration per level from the Config trigger. The formula is Spell__Duration + (Spell__Level x Spell__DurationPerLevel).​

Spell__StartDuration (boolean)

Set to True if you specified a duration from the Config trigger so the system knows when you intend to have the duration start from.​

Spell__LevelMultiplier (real)

Made available as a real so you don't have to convert the spell level into a real yourself.​



Spell__UseTargetGroup (boolean)

Set to True from the Config trigger if you want a group to keep track of your target units.​

Spell__TargetGroup (unit group)

If you specified Spell__UseTargetGroup, this group is available to you throughout the duration of the spell. It is empty until you manually add units to it.​

Spell__InRangeCount (integer)

The number of units added to Spell__InRangeGroup.​

Spell__InRangeUnits[] (unit array)

An array with indices between 1 and Spell__InRangeCount listing the units in Spell__InRangeGroup.​

Spell__Trigger_InRange (integer)

Set from your spell's Config trigger (if desired), It is used to add additional things to the unit filter that couldn't be covered otherwise.​

Spell__InRangeMax (integer)

Set before setting Spell__InRange. This integer limits the number of units added to Spell__InRangeGroup. The extra units are removed at random.​



Want to detect if a caster has finished channeling or a spell was canceled early?

Spell__Channeling (boolean)

True if the caster is still channeling the ability. Useful from an OnLoop trigger if you want to interrupt the loop if the caster stops.​

Spell__Completed (boolean)

True if the caster successfully completed the channeling of the spell without it getting interrupted. Invaluable if you want to do bonus effects upon successful execution of the ability.​



Inspiration:

  • SpellEvent by Anitarf - Without his system, GUI Spell System wouldn't be nearly what it is now. Almost all the fundamentals of this system are encapsulated by SpellEvent.
  • vJass structs by Vexorian - Create a unique integer variable which will act as an array index. Has OnDestroy functionality which is run automatically and is double-free safe.
  • Timer32 by Jesus4Lyf - One timer for all periodic events; handles iteration of instances for you behind-the-scenes.
  • Constant Timer Loop 32 by Nestharus - A combination of Timer32 and vJass struct creation/destruction which pauses timers/removes system triggers when completed.
  • GroupUtils by Rising_Dusk - Factors in a unit's collision size into the InRange check and recycles unit groups.
  • Table by Vexorian - The idea to use one hashtable with unique indexes as parent keys so it can be used for many different things.


  • Spell System Config
    • Events
    • Conditions
    • Actions
      • -------- Only one dummy unit type is needed as you can attach an effect to it of any kind --------
      • -------- --------
      • Set Spell__DummyType = Dummy (Vexorian, Anitarf, Infrane)
      • Set Spell__DummyOwner = Neutral Extra
      • Set Spell__Interval = (1.00 / 32.00)
      • -------- --------
      • -------- Configure default values for the unit filter: --------
      • -------- --------
      • 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
      • -------- --------
      • -------- Magic immunity is a great thing to block, as it also discludes invulnerable units from being picked --------
      • -------- --------
      • Set Spell__Filter_AllowMagicImmune = False
      • -------- --------
      • -------- Normal WC3 abilities, like Channel, wake sleeping creeps - even if they don't deal damage or apply buffs. --------
      • -------- Because of this, I provided an option to wake up creeps when they are enumerated by an InRange command. --------
      • -------- --------
      • Set Spell__WakeTargets = True


JASS:
function SpellIndexGetVars takes integer i returns nothing
    set udg_Spell__Ability = udg_Spell_i_Abil[udg_Spell_i_Head[i]]
    set udg_Spell__Index = i
    set udg_Spell__Caster = udg_Spell_i_Caster[i]
    set udg_Spell__CasterOwner = GetOwningPlayer(udg_Spell__Caster)
    set udg_Spell__Level = udg_Spell_i_Level[i]
    set udg_Spell__LevelMultiplier = udg_Spell__Level //Spell__LevelMultiplier is a real variable.
    set udg_Spell__Target = udg_Spell_i_Target[i]
   
    //Magic to ensure the locations never leak.
    call MoveLocation(udg_Spell__CastPoint, GetUnitX(udg_Spell__Caster), GetUnitY(udg_Spell__Caster))
    if udg_Spell__Target == null then
        call MoveLocation(udg_Spell__TargetPoint, udg_Spell_i_TargetX[i], udg_Spell_i_TargetY[i])
    else
        call MoveLocation(udg_Spell__TargetPoint, GetUnitX(udg_Spell__Target), GetUnitY(udg_Spell__Target))
    endif
    set udg_Spell__TargetGroup = udg_Spell_i_TargetGroup[i]
    set udg_Spell__Completed = udg_Spell_i_Completed[i]
    set udg_Spell__Channeling = udg_Spell_i_Channeling[i]
endfunction
function SpellSetFilters takes integer i returns nothing
    set udg_Spell_i_AllowEnemy[i]       = udg_Spell__Filter_AllowEnemy
    set udg_Spell_i_AllowAlly[i]        = udg_Spell__Filter_AllowAlly
    set udg_Spell_i_AllowDead[i]        = udg_Spell__Filter_AllowDead
    set udg_Spell_i_AllowLiving[i]      = udg_Spell__Filter_AllowLiving
    set udg_Spell_i_AllowMagicImmune[i] = udg_Spell__Filter_AllowMagicImmune
    set udg_Spell_i_AllowMechanical[i]  = udg_Spell__Filter_AllowMechanical
    set udg_Spell_i_AllowStructure[i]   = udg_Spell__Filter_AllowStructure
    set udg_Spell_i_AllowFlying[i]      = udg_Spell__Filter_AllowFlying
    set udg_Spell_i_AllowHero[i]        = udg_Spell__Filter_AllowHero
    set udg_Spell_i_AllowNonHero[i]     = udg_Spell__Filter_AllowNonHero
endfunction
function SpellIndexDestroy takes integer i returns nothing
    local integer indexOf
    local integer index
    if udg_Spell_i_RecycleList[i] >= 0 then
        return
    endif
    //If the caster is still channeling on the spell, don't destroy until it's finished:
    if not udg_Spell_i_Channeling[i] then
        set index = udg_Spell_i_Head[i]
        set udg_Spell_i_RecycleList[i] = udg_Spell_i_Recycle
        set udg_Spell_i_Recycle = i
       
        //Reset things to defaults:
        set udg_Spell_i_Time[i] = 0.00
        set udg_Spell_i_LastTime[i] = 0.00
        set udg_Spell_i_Duration[i] = 0.00
        set udg_Spell_i_Completed[i] = false
        set udg_Spell_i_Caster[i] = null
        set udg_Spell_i_Target[i] = null
        set udg_Spell_i_OnLoopStack[i] = null
       
        //Recycle any applicable target unit group.
        if udg_Spell_i_TargetGroup[i] != null then
            call GroupClear(udg_Spell_i_TargetGroup[i])
            set udg_Spell_i_GroupStack[udg_Spell_i_GroupN] = udg_Spell_i_TargetGroup[i]
            set udg_Spell_i_GroupN = udg_Spell_i_GroupN + 1
            set udg_Spell_i_TargetGroup[i] = null
        endif
       
        //Clear any user-specified data in the hashtable:
        call FlushChildHashtable(udg_Spell__Hash, i)
        //call BJDebugMsg("Destroying index: " + I2S(i))
    endif
   
    set indexOf = udg_Spell_i_StackRef[i]
    if indexOf >= 0 then
        set index = udg_Spell_i_StackN - 1
        set udg_Spell_i_StackN = index
       
        set udg_Spell_i_StackRef[udg_Spell_i_Stack[index]] = indexOf
        set udg_Spell_i_Stack[indexOf] = udg_Spell_i_Stack[index]
        if index == 0 then
            //If no more spells require the timer, pause it.
            call PauseTimer(udg_Spell_i_Timer)
        endif
        set udg_Spell_i_StackRef[i] = -1
    endif
endfunction
function SpellTriggerExecute takes integer i, trigger t returns real
    local real d = udg_Spell_i_Duration[i]
    local boolean b = false
    set udg_Spell__Duration = d
    set udg_Spell__Time = 0.00
    if t != null then
        set udg_Spell__Trigger_OnLoop = null
        set udg_Spell__Expired = d <= 0.00 //If the duration is <= 0, the spell has expired.
        call SpellIndexGetVars(i)
        if TriggerEvaluate(t) then
            call TriggerExecute(t)
        endif
        if udg_Spell__Trigger_OnLoop != null then
            set udg_Spell_i_OnLoopStack[i] = udg_Spell__Trigger_OnLoop
        endif
        //The remaining lines in this function process the duration specified by the user.
        if udg_Spell__StartDuration then
            set udg_Spell__StartDuration = false
            set udg_Spell__Duration = udg_Spell_i_Duration[udg_Spell_i_Head[i]] + udg_Spell_i_LastTime[udg_Spell_i_Head[i]]*udg_Spell__LevelMultiplier
        elseif (udg_Spell__Expired and d > 0.00) or (udg_Spell__Duration <= 0.00) then
            set udg_Spell__Duration = 0.00
            return udg_Spell__Time
            //The user manually expired the spell or the spell duration ended on its own.
        endif
        if d != udg_Spell__Duration then
            //A new duration has been assigned
            set d = udg_Spell__Duration
            set b = true
        endif
        set udg_Spell__Duration = 0.00
        if udg_Spell__Time == 0.00 then
            if udg_Spell_i_LastTime[i] == 0.00 then
                if udg_Spell_i_Time[udg_Spell_i_Head[i]] > 0.00 then
                    //The user specified a default interval to follow:
                    set udg_Spell__Time = udg_Spell_i_Time[udg_Spell_i_Head[i]]
                else
                    //Set the spell time to the minimum.
                    set udg_Spell__Time = udg_Spell__Interval
                endif
            else
                //Otherwise, set it to what it was before.
                set udg_Spell__Time = udg_Spell_i_LastTime[i]
            endif
        //else, the user is specifying a new time for the spell.
        endif
        set udg_Spell_i_LastTime[i] = udg_Spell__Time //Whatever the case, remember this time for next time.
        if b then
            //The duration was just assigned
            set udg_Spell_i_Duration[i] = d
        else
            //The duration has been ongoing
            set udg_Spell_i_Duration[i] = d - udg_Spell__Time
        endif
    endif
    return udg_Spell__Time
endfunction
//===========================================================================
// Runs every Spell__Interval seconds and handles all of the timed events.
//
function SpellTimerLoop takes nothing returns nothing
    local integer i = udg_Spell_i_StackN
    local integer node
    local real time
    set udg_Spell__Running = true
   
    //Run stack top to bottom to avoid skipping slots when destroying.
    loop
        set i = i - 1
        exitwhen i < 0
        set node = udg_Spell_i_Stack[i]
        set time = udg_Spell_i_Time[node] - udg_Spell__Interval
        if time <= 0.00 then
            set time = SpellTriggerExecute(node, udg_Spell_i_OnLoopStack[node])
        endif
        if time <= 0.00 then
            call SpellIndexDestroy(node)
        else
            set udg_Spell_i_Time[node] = time
        endif
    endloop
    set udg_Spell__Running = false
endfunction
//===========================================================================
// This is the meat of the system as it handles the event responses.
//
function RunSpellEvent takes nothing returns boolean
    local boolean b
    local integer aid = GetSpellAbilityId()
    local integer head = LoadInteger(udg_Spell__Hash, 0, aid)
    local integer i
    local integer id
    local trigger t
    local playerunitevent eid
    if head == 0 then
        //Nothing for this ability has been registered. Skip the sequence.
        return false
    endif
    set eid = ConvertPlayerUnitEvent(GetHandleId(GetTriggerEventId()))
    set udg_Spell__Caster = GetTriggerUnit()
    set id = GetHandleId(udg_Spell__Caster)
    set i = LoadInteger(udg_Spell__Hash, aid, id)
    if i == 0 then
        //This block will almost always happen with the OnChannel event. In the
        //case of Charge Gold and Lumber, only an OnEffect event will run.
        set i = udg_Spell_i_Recycle
        if i == 0 then
            //Create a new, unique index
            set i = udg_Spell_i_Instances + 1
            set udg_Spell_i_Instances = i
        else
            //Repurpose an existing one
            set udg_Spell_i_Recycle = udg_Spell_i_RecycleList[i]
        endif
        //call BJDebugMsg("Creating index: " + I2S(i))
        set udg_Spell_i_RecycleList[i] = -1
        set udg_Spell_i_StackRef[i] = -1
        set udg_Spell_i_Head[i] = head
       
        if eid == EVENT_PLAYER_UNIT_SPELL_CHANNEL then
            set udg_Spell_i_Channeling[i] = true
            call SaveInteger(udg_Spell__Hash, aid, id, i)
            set t = udg_Spell_i_OnChannelStack[head]
        else //eid == EVENT_PLAYER_UNIT_SPELL_EFFECT
            set t = udg_Spell_i_OnEffectStack[head]
        endif
        set udg_Spell_i_Caster[i] = udg_Spell__Caster
        set udg_Spell_i_Level[i] = GetUnitAbilityLevel(udg_Spell__Caster, aid)
        set udg_Spell_i_Target[i] = GetSpellTargetUnit()
        set udg_Spell_i_TargetX[i] = GetSpellTargetX()
        set udg_Spell_i_TargetY[i] = GetSpellTargetY()
       
        set udg_Spell_i_OnLoopStack[i] = udg_Spell_i_OnLoopStack[head]
        if udg_Spell_i_UseTG[head] then
            //Get a recycled unit group or create a new one.
            set id = udg_Spell_i_GroupN - 1
            if id >= 0 then
                set udg_Spell_i_GroupN = id
                set udg_Spell_i_TargetGroup[i] = udg_Spell_i_GroupStack[id]
            else
                set udg_Spell_i_TargetGroup[i] = CreateGroup()
            endif
        endif
    elseif eid == EVENT_PLAYER_UNIT_SPELL_CAST then
        set t = udg_Spell_i_OnCastStack[head]
    elseif eid == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        set t = udg_Spell_i_OnEffectStack[head]
    elseif eid == EVENT_PLAYER_UNIT_SPELL_FINISH then
        set udg_Spell_i_Completed[i] = true
        return true
    else //eid == EVENT_PLAYER_UNIT_SPELL_ENDCAST
        set udg_Spell_i_Channeling[i] = false
        call RemoveSavedInteger(udg_Spell__Hash, aid, id)
        set t = udg_Spell_i_OnFinishStack[head]
    endif
    if SpellTriggerExecute(i, t) > 0.00 then
        //Set the spell time to the user-specified one.
        set udg_Spell_i_Time[i] = udg_Spell__Time
        if udg_Spell_i_StackRef[i] < 0 then
            //Allocate the spell index onto the loop stack.
            set aid = udg_Spell_i_StackN
            set udg_Spell_i_Stack[aid] = i
            set udg_Spell_i_StackRef[i] = aid
            set udg_Spell_i_StackN = aid + 1
            if aid == 0 then
                //If this is the first spell index using the timer, start it up:
                call TimerStart(udg_Spell_i_Timer, udg_Spell__Interval, true, function SpellTimerLoop)
            endif
        endif
    elseif (not udg_Spell_i_Channeling[i]) and (t != null or udg_Spell_i_Time[i] <= 0.00) then
        call SpellIndexDestroy(i)
    endif
    set t = null
    return true
endfunction
//This function is invoked if an event was launched recursively by another event's callback.
function RunPreSpellEvent takes nothing returns nothing
    local integer i = udg_Spell__Index
    local real time = udg_Spell__Time
    local real d = udg_Spell__Duration
    local boolean expired = udg_Spell__Expired
    if udg_Spell__Trigger_OnLoop != null then
        set udg_Spell_i_OnLoopStack[i] = udg_Spell__Trigger_OnLoop
    endif
    if RunSpellEvent() then
        set udg_Spell__Time = time
        set udg_Spell__Duration = d
        set udg_Spell__Expired = expired
        call SpellIndexGetVars(i)
    endif
endfunction
//===========================================================================
// Base function of the system: runs when an ability event does something.
//
function SpellSystemEvent takes nothing returns boolean
    if udg_Spell__Running then
        call RunPreSpellEvent()
    else
        set udg_Spell__Running = true
        call RunSpellEvent()
        set udg_Spell__Running = false
    endif
    return false
endfunction
//===========================================================================
// Set Spell__Ability to your spell's ability
// Set Spell__Trigger_OnChannel/Cast/Effect/Finish/Loop to any trigger(s) you
// want to automatically run.
//
// GUI-friendly: Run Spell System <gen> (ignoring conditions)
//
function SpellSystemRegister takes nothing returns nothing
    local integer aid = udg_Spell__Ability
    local integer head = udg_Spell_i_Instances + 1
   
    if HaveSavedInteger(udg_Spell__Hash, 0, aid) or aid == 0 then
        //The system rejects duplicate or unassigned abilities.
        return
    endif
    set udg_Spell_i_Instances = head
    set udg_Spell_i_Abil[head] = aid
   
    //Preload the ability on dummy unit to help prevent first-instance lag
    call UnitAddAbility(udg_Spell_i_PreloadDummy, aid)
   
    //Save head index to the spell ability so it be referenced later.
    call SaveInteger(udg_Spell__Hash, 0, aid, head)
   
    //Set any applicable event triggers.
    set udg_Spell_i_OnChannelStack[head]= udg_Spell__Trigger_OnChannel
    set udg_Spell_i_OnCastStack[head]   = udg_Spell__Trigger_OnCast
    set udg_Spell_i_OnEffectStack[head] = udg_Spell__Trigger_OnEffect
    set udg_Spell_i_OnFinishStack[head] = udg_Spell__Trigger_OnFinish
    set udg_Spell_i_OnLoopStack[head]   = udg_Spell__Trigger_OnLoop
    set udg_Spell_i_InRangeFilter[head] = udg_Spell__Trigger_InRangeFilter
   
    //Set any customized filter variables:
    call SpellSetFilters(head)
   
    //Tell the system to automatically create target groups, if needed
    set udg_Spell_i_AutoAddTargets[head] = udg_Spell__AutoAddTargets
    set udg_Spell_i_UseTG[head] = udg_Spell__UseTargetGroup or udg_Spell__AutoAddTargets
   
    //Handle automatic buff assignment
    set udg_Spell_i_BuffAbil[head] = udg_Spell__BuffAbility
    set udg_Spell_i_BuffOrder[head] = udg_Spell__BuffOrder
   
    //Set the default time sequences if a duration is used:
    set udg_Spell_i_Time[head]     = udg_Spell__Time
    set udg_Spell_i_Duration[head] = udg_Spell__Duration
    set udg_Spell_i_LastTime[head] = udg_Spell__DurationPerLevel
   
    //Set variables back to their defaults:
    set udg_Spell__Trigger_OnChannel    = null
    set udg_Spell__Trigger_OnCast       = null
    set udg_Spell__Trigger_OnEffect     = null
    set udg_Spell__Trigger_OnFinish     = null
    set udg_Spell__Trigger_OnLoop       = null
    set udg_Spell__Trigger_InRangeFilter= null
    set udg_Spell__AutoAddTargets       = false
    set udg_Spell__UseTargetGroup       = false
    set udg_Spell__Time                 = 0.00
    set udg_Spell__Duration             = 0.00
    set udg_Spell__DurationPerLevel     = 0.00
    set udg_Spell__BuffAbility          = 0
    set udg_Spell__BuffOrder            = 0
   
    set udg_Spell__Filter_AllowEnemy        = udg_Spell_i_AllowEnemy[0]
    set udg_Spell__Filter_AllowAlly         = udg_Spell_i_AllowAlly[0]
    set udg_Spell__Filter_AllowDead         = udg_Spell_i_AllowDead[0]
    set udg_Spell__Filter_AllowMagicImmune  = udg_Spell_i_AllowMagicImmune[0]
    set udg_Spell__Filter_AllowMechanical   = udg_Spell_i_AllowMechanical[0]
    set udg_Spell__Filter_AllowStructure    = udg_Spell_i_AllowStructure[0]
    set udg_Spell__Filter_AllowFlying       = udg_Spell_i_AllowFlying[0]
    set udg_Spell__Filter_AllowHero         = udg_Spell_i_AllowHero[0]
    set udg_Spell__Filter_AllowNonHero      = udg_Spell_i_AllowNonHero[0]
    set udg_Spell__Filter_AllowLiving       = udg_Spell_i_AllowLiving[0]
endfunction
function SpellFilterCompare takes boolean is, boolean yes, boolean no returns boolean
    return (is and yes) or ((not is) and no)
endfunction
//===========================================================================
// Before calling this function, set Spell__InRangePoint to whatever point
// you need, THEN set Spell__InRange to the radius you need. The system will
// enumerate the units matching the configured filter and fill them into
// Spell_InRangeGroup.
//
function SpellGroupUnitsInRange takes nothing returns boolean
    local integer i = udg_Spell_i_Head[udg_Spell__Index]
    local integer j = 0
    local unit u
    local real padding = 64.00
    if udg_Spell_i_AllowStructure[i] then
        //A normal unit can only have up to size 64.00 collision, but if the
        //user needs to check for structures we need a padding big enough for
        //the "fattest" ones: Tier 3 town halls.
        set padding = 197.00
    endif
    call GroupEnumUnitsInRangeOfLoc(udg_Spell__InRangeGroup, udg_Spell__InRangePoint, udg_Spell__InRange + padding, null)
    loop
        set u = FirstOfGroup(udg_Spell__InRangeGroup)
        exitwhen u == null
        call GroupRemoveUnit(udg_Spell__InRangeGroup, u)
        loop
            exitwhen udg_Spell_i_AutoAddTargets[i] and IsUnitInGroup(u, udg_Spell__TargetGroup)
            exitwhen not IsUnitInRangeLoc(u, udg_Spell__InRangePoint, udg_Spell__InRange)
            exitwhen not SpellFilterCompare(IsUnitType(u, UNIT_TYPE_DEAD), udg_Spell_i_AllowDead[i], udg_Spell_i_AllowLiving[i])
            exitwhen not SpellFilterCompare(IsUnitAlly(u, udg_Spell__CasterOwner), udg_Spell_i_AllowAlly[i], udg_Spell_i_AllowEnemy[i])
            exitwhen not SpellFilterCompare(IsUnitType(u, UNIT_TYPE_HERO) or IsUnitType(u, UNIT_TYPE_RESISTANT), udg_Spell_i_AllowHero[i], udg_Spell_i_AllowNonHero[i])
            exitwhen IsUnitType(u, UNIT_TYPE_STRUCTURE) and not udg_Spell_i_AllowStructure[i]
            exitwhen IsUnitType(u, UNIT_TYPE_FLYING) and not udg_Spell_i_AllowFlying[i]
            exitwhen IsUnitType(u, UNIT_TYPE_MECHANICAL) and not udg_Spell_i_AllowMechanical[i]
            exitwhen IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) and not udg_Spell_i_AllowMagicImmune[i]
            set udg_Spell__InRangeUnit = u
            //Run the user's designated filter, if one exists.
            exitwhen udg_Spell_i_InRangeFilter[i] != null and not TriggerEvaluate(udg_Spell_i_InRangeFilter[i])
            set j = j + 1
            set udg_Spell__InRangeUnits[j] = u
            exitwhen true
        endloop
    endloop
    if j > udg_Spell__InRangeMax and udg_Spell__InRangeMax > 0 then
        //The user has defined a maximum number of units allowed in the group.
        //Remove a random unit until the total does not exceed capacity.
        loop
            set i = GetRandomInt(1, j)
            set udg_Spell__InRangeUnits[i] = udg_Spell__InRangeUnits[j]
            set j = j - 1
            exitwhen j == udg_Spell__InRangeMax
        endloop
    endif
    set udg_Spell__InRangeCount = j
    set udg_Spell__InRangeMax = 0
    set udg_Spell__InRange = 0.00
    set i = udg_Spell_i_Head[udg_Spell__Index]
    loop
        exitwhen j == 0
        set u = udg_Spell__InRangeUnits[j]
        call GroupAddUnit(udg_Spell__InRangeGroup, u)
        if udg_Spell_i_AutoAddTargets[i] then
            call GroupAddUnit(udg_Spell__TargetGroup, u)
        endif
        if udg_Spell__WakeTargets and UnitIsSleeping(u) then
            call UnitWakeUp(u)
        endif
        if udg_Spell_i_BuffAbil[i] != 0 and udg_Spell_i_BuffOrder[i] != 0 then
            //Auto-buff units added to group:
            call UnitAddAbility(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffAbil[i])
            call IssueTargetOrderById(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffOrder[i], u)
            call UnitRemoveAbility(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffAbil[i])
        endif
        set j = j - 1
    endloop
    set u = null
    return false
endfunction
function SpellPreloadEnd takes nothing returns nothing
    local integer i = udg_Spell_i_Instances
    loop
        exitwhen i == 0
        //Remove preloaded abilities so they don't interfere with orders
        call UnitRemoveAbility(udg_Spell_i_PreloadDummy, udg_Spell_i_Abil[udg_Spell_i_Head[i]])
        set i = i - 1
    endloop
endfunction
//===========================================================================
function InitTrig_Spell_System takes nothing returns nothing
    local integer i = bj_MAX_PLAYER_SLOTS
    local player p
    local trigger t
   
    if gg_trg_Spell_System != null then
        //A JASS function call already initialized the system.
        return
    endif
   
    //This runs before map init events so the hashtable is ready before then.
    set udg_Spell__Hash = InitHashtable()
   
    //Initialize these two locations which will never get removed
    set udg_Spell__CastPoint = Location(0, 0)
    set udg_Spell__TargetPoint = Location(0, 0)
   
    //Recycle existing unit groups into the recycle stack to avoid needing to destroy any extras.
    set udg_Spell_i_GroupStack[2] = udg_Spell__TargetGroup
    set udg_Spell_i_GroupStack[3] = udg_Spell_i_TargetGroup[0]
    set udg_Spell_i_GroupStack[4] = udg_Spell_i_TargetGroup[1]
    set udg_Spell_i_GroupN = 5 //There are already five valid unit groups thanks to Variable Editor.
   
    set t = CreateTrigger()
    call TriggerRegisterVariableEvent(t, "udg_Spell__InRange", GREATER_THAN, 0.00)
    call TriggerAddCondition(t, Filter(function SpellGroupUnitsInRange))
   
    set t = CreateTrigger()
    call TriggerAddCondition(t, Filter(function SpellSystemEvent))
    loop
        set i = i - 1
        set p = Player(i)
        call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_SPELL_CHANNEL, null)
        call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_SPELL_CAST, null)
        call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_SPELL_FINISH, null)
        call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_SPELL_ENDCAST, null)
        exitwhen i == 0
    endloop
    set p = null
    set t = null
   
    //Run the configuration trigger so its variables are ready before the
    //map initialization events run.
    call TriggerExecute(gg_trg_Spell_System_Config)
    call SpellSetFilters(0)
   
    //Create this trigger so it's GUI-friendly.
    set gg_trg_Spell_System = CreateTrigger()
    call TriggerAddAction(gg_trg_Spell_System, function SpellSystemRegister)
    set gg_trg_Spell_System_Config = gg_trg_Spell_System //In case the user accidentally picks this one
   
    //Create a dummy unit for preloading abilities and casting buffs.
    set udg_Spell_i_PreloadDummy = CreateUnit(udg_Spell__DummyOwner, udg_Spell__DummyType, 0, 0, 0)
   
    //Start the timer to remove its abilities:
    call TimerStart(udg_Spell_i_Timer, 0.00, false, function SpellPreloadEnd)
    call UnitRemoveAbility(udg_Spell_i_PreloadDummy, 'Amov') //Force it to never move to cast spells
endfunction


  • SS Holy Light Demo Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Spell__Ability = Holy Light
      • -------- When holy light is cast on a unit, heal it each second for 4/6/8 seconds. --------
      • Set Spell__Time = 1.00
      • Set Spell__Duration = 2.00
      • Set Spell__DurationPerLevel = 2.00
      • -------- --------
      • Set Spell__Trigger_OnEffect = SS Holy Light Demo Effect <gen>
      • Set Spell__Trigger_OnLoop = SS Holy Light Demo Loop <gen>
      • Trigger - Run Spell System <gen> (ignoring conditions)
  • SS Holy Light Demo Effect
    • 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)
  • SS Holy Light Demo Loop
    • 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



JASS:
// This function is run every 1.00 for each active divine shield
function SSDivineShieldDemoLoop takes nothing returns nothing
    local integer i = 1
    set udg_Spell__InRangePoint = udg_Spell__CastPoint
    set udg_Spell__InRange = 600.00
    //Spell__CastPoint will always be the Caster's own location, even if he moves from where he originally casted
    loop
        exitwhen i > udg_Spell__InRangeCount
        call IssuePointOrderLoc(udg_Spell__InRangeUnits[i], "move", udg_Spell__CastPoint)
        set i = i + 1
    endloop
endfunction

// The next function will be run when the effect of Divine Shield starts.
function SSDivineShieldDemoEffect takes nothing returns nothing
    //Set the time until next expiration
    set udg_Spell__Time = 1.00
    //Set how long the buff will last
    set udg_Spell__Duration = 15.00*udg_Spell__Level
endfunction

//===========================================================================
function InitTrig_SS_Divine_Shield_Demo takes nothing returns nothing
    //Use of this spell requires you to copy the SpellSystem_Register function from the
    //map header or use the vJass library which contains it.
    call SpellSystem_Register('AHds', function SSDivineShieldDemoEffect, function SSDivineShieldDemoLoop)
endfunction


Keywords:
Spell, system, gui, anitarf, vexorian, jesus4lyf, timer32, spellevent, nestharus, struct
Contents

GUI Spell System (Map)

Reviews
Approved on the 11th Jan 2016 Last review update on the 4th Apr 2016 This resource has been approved by THW moderators BPower and IcemanBo. In consultation with the spell moderation team we agreed on a rating of 6/5, Director's Cut. Criticism...
I want to call a Function with different arguments depending on ally and enemy Filter is set.
From the source code you accessed them with Spell_i_Head[Spell__Index] is that safe/recommented?

Lines in the "OnEffect"-Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Spell_i_AllowAlly[Spell_i_Head[Spell__Index]] Equal Spell_i_AllowEnemy[Spell_i_Head[Spell__Index]]
    • Then - Actions
      • Custom script: call function(a)
    • Else - Actions
      • Custom script: call function(b)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
What is in today's update :O
Automatic buffing as well as some unimportant bug fixes.

I'll update the documentation later, but essentially this allows you to configure a buff for your spell and a dummy unit will cast the spell automatically based on the buff ability and order ID.

The ability needs a range of 99999 and the mana/cooldown should be 0.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I'll be re-documenting all of the API for my resources because I've found it is simply much easier to read and understand in a table format. @dtnmang you wanted to know what's new in the latest release - it's mostly the 3 new variables at the end of this table:

Name
Type
Use Frequency
Description
Spell__Ability Ability Always The ability you're writing the spell for.
Spell System Config <gen> Trigger Always Run this trigger when all configuration for the spell is set.
Spell__Trigger_OnEffect Trigger Pretty much always Set to the trigger you want to run when the spell effect starts.
Spell__Trigger_OnFinish Trigger Sometimes Trigger runs when the unit's casting is complete or interrupted.
Spell__Trigger_OnCast/Channel Trigger Almost never Trigger runs as per the Casting Events Guide
Spell__Trigger_OnLoop Trigger Very frequently Set to a trigger which runs after Spell__Time seconds.
Spell__Time Real Very frequently When the OnLoop trigger is set, it will be run after this length of time.
Spell__Duration Real Sometimes Automatically runs the OnLoop trigger every Spell__Time seconds until the duration runs out.
Spell__DurationPerLevel Real Occasionally Spell__Duration will increase dynamically by this much per level.
Spell__Filter_AllowX Booleans Frequently General configuration for targets allowed to be automatically enumerated.
Spell__UseTargetGroup Boolean Sometimes Allows you to remember a group of target units for each spell instance to be tracked in Spell__TargetGroup.
Spell__AutoAddTargets Boolean Occasionally Will add all units picked in range to Spell__TargetGroup and only pick new units which aren't already in it.
Spell__BuffAbility Ability Occasionally An ability which would be used to apply a buff to a unit, ie. Slow or Banish. The Object Editor range should be maxed out and it should have 0 mana cost/cooldown.
Spell__BuffOrder Order Occasionally Set to the Order a unit requires to cast said buff ability. If this, BuffAbility and AutoAddTargets are set, a dummy unit will automatically and instantly cast the ability on picked units in range.

Note: this table is only what can be set from the Config trigger for each spell. I'll do another table for what you can do from an event response and another with what you can do with a unit group.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
I really want to use this, but I have 1 big concern. In the past I dealt with the OP Limit, due to having too many operations running on <Map Initialization>.
This system appears to set multiple variables for every spell that would use the system on the <Map Initialization>. Could this be problematic in a bigger map with many abilities and triggers?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I was worried I might need to update this with the renumbering of event IDs, but this had been using the constants for some time now just because I felt it was better practice. Chalk one up to not being too hacky.

The only update to this that will be released when the patch goes live is to update the demo spells to use the new kick ass special effect natives.

Projectile systems are going to get balls over dick crazy performance improvements.
 
Level 6
Joined
Oct 31, 2015
Messages
95
IDK if this question has been made before but I want to add the second line: (Not counting comments)

Code:
if udg_Spell_i_BuffAbil != 0 and udg_Spell_i_BuffOrder != 0 then
            //Auto-buff units added to group:
            call UnitAddAbility(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffAbil)
            //THE LINE BELLOW
            call SetUnitAbilityLevelSwapped( udg_Spell_i_BuffAbil, udg_Spell_i_PreloadDummy, udg_Spell_i_Level )
            //THE LINE ABOVE
            call IssueTargetOrderById(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffOrder, u)
            call UnitRemoveAbility(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffAbil)

But udg_Spell_i_Level and udg_Spell_i_Caster does not returns me nor the ability level or the casting unit. I know nothing about jass (just like jon snow :p) but i'm trying to make the buff ability to match the casting skill's level to make proper use of Entagling Roots dps scalling without having to trigger it someway. It would be easy to do this GUI myself but I would like to see this function inside the code.

EDIT
By the way all the rest is already part of the code except the second line which obviously contains some noobish crap made by me. :D
 
JASS:
       call SetUnitAbilityLevel(udg_Spell_i_PreloadDummy, udg_Spell_i_BuffAbil[i], udg_Spell__Level)
udg_Spell_i_Level[i] will not work here, i refers to the index of the used spellType but one needs the current spellcast instance data.

Using the buffplacer dummy to deal damage will destroy correct ownership of damage.
-> gold/exp/lumber gain on kill will not be provided.
 
Last edited:
Level 6
Joined
Oct 31, 2015
Messages
95
Thank you guys :D

EDIT:

Hello again. I'm back still to talk about the buffing part. It now levels properly with the spell level but when the buff is a damaging one the casting unit and his allies gain no EXP for the kills. This happens because the owner of the casting unit is Neutral Extra and can be easily solved by changing Aspect of Alliance of Neutral Extra towards the players.

But still I think that there will be some cases where this won't be doable so can you make the buff caster's owner equal to the casting unit/hero's owner?

EDIT 2:

Also I discovered the buff functionality recently by accident when looking at Whiplash's triggers after years using this system. There is no mention about it in the system samples. I don't know even how exactly it works and who will be affect by the buffs. It's a very cool functionality which could receive a bit more attention in documentation and maybe even be improved a bit. :)
 
Last edited:
Level 7
Joined
Apr 18, 2010
Messages
102
Question:

Example I have 2 spells. Spell A and Spell B.
The spells are quite complicated, they use "stages"
so.. the question is, IS 1 variable called "Spell_Stage" (array) enough for both the spells? or do I need to use 2 variables, "SpellA_Stage" for Spell A and "SpellB_Stage" for Spell B?
Ofcourse, the spells should be MUI, and both the mentioned variables will use the "Spell__Index"" integer
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Question:

Example I have 2 spells. Spell A and Spell B.
The spells are quite complicated, they use "stages"
so.. the question is, IS 1 variable called "Spell_Stage" (array) enough for both the spells? or do I need to use 2 variables, "SpellA_Stage" for Spell A and "SpellB_Stage" for Spell B?
Ofcourse, the spells should be MUI, and both the mentioned variables will use the "Spell__Index"" integer
I replied on YouTube. Did that answer your question?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Spell Duration per Level might not be working properly (doesn't add duration) and Set InRange Max too (on the first loop of the OnLoop trigger the number of units that get put into InRangeGroup still overrides this limit)
This was on 1.26.
I will want to see your test map where you have seen these glitches. This doesn't sound possible unless you were working on an old version of the system.
 
Nope, latest version. I think it has been undetected since previous versions as well, that's why I avoided using DurationPerLevel.
In this map you can test using the Warden's Fan of Knives ability. Now there are 3 problems I can pinpoint:

  • Spell__DurationPerLevel ignored by the system, the loop only run on Spell__Duration's value.
  • On the first cast of the spell, Spell__InRangeMax = 1 gets ignored on the first loop (fireball hits all peons in range). Later casts seem to have no problem.
  • The text displays "Actual time passed = 4" but it shows up when Fan of Knives has cooled down 5/9 of the way, which is 5 seconds (should be 4 seconds). So, intended string is correct, but timing is not. I think this is related to the Spell__Expired check. I suspect this is because after Spell__Duration actually ends, the system only checks for Spell__Expired after another Spell__Time instance is run. If that is the case, the delay between Spell__Duration and Spell__Expired check should be as small as possible.
 

Attachments

  • Cyclone Test Map.w3x
    32.2 KB · Views: 57
Last edited:
Based on SpellSystem code Spell__DurationPerLevel is only read when creating a new Spell, Therefore it can not be used inside onEffect/OnChannel etc triggers, one needs to setup spell__Time, spell__Duration and Spell__DurationPerLevel in the config, inside the onEffect one loads this values with "Spell__startduration = true".

On the first cast of the spell, Spell__InRangeMax = 1 gets ignored on the first loop (fireball hits all peons in range). Later casts seem to have no problem.
As soon one writes onto Spell__InRange, Spell System will instantly calculate the InRangeGroup. The next line (InRangeMax = 1 in your Trigger) will have no effect on the current InRangeGroup calculation, it will affect the next InRangeGroup.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Huh, thanks for clarification, guess I didn't read the documentation carefully. But my third point still stands. With a significant Spell__Time there might be a timing problem for spells that depend on Spell__Expired to create an end-of-spell effect.
It sounds like you're misusing the variable Spell Expired and its relation to the duration. The in-game events and any timers you set aren't tethered together.

Best approach is to use the EndCast event and do your wrap-up stuff from there. Timer wouldn't even be needed in that case.
 
What is this EndCast event? Can you explain how Spell__Expired is related to the spell system? My first time using a Spell System map, Spell__Expired was used to determine a loop's end, so I just used it for all my spells from there.
And why need 3 different checks for an ability's expiration (Spell__Expired, Spell__Running, Spell__Duration <= 0.00)?
 
I have run into another problem. In this map, the spell Fan of Knives is supposed to create a lightning ball that grows in size for 2 seconds, then at the end of the spell duration it explodes, dealing damage. But a few seconds after, the spell inexplicably automatically finds a Spell_InRangeGroup and deals damage to units in it again, when no action is taken.
 

Attachments

  • Cyclone Test Map.w3x
    33.5 KB · Views: 69

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
What is this EndCast event? Can you explain how Spell__Expired is related to the spell system? My first time using a Spell System map, Spell__Expired was used to determine a loop's end, so I just used it for all my spells from there.
And why need 3 different checks for an ability's expiration (Spell__Expired, Spell__Running, Spell__Duration <= 0.00)?

There is a difference between Spell__Expired and Spell__Running. The latter measures if the caster has stopped casting (based on in-game circumstances which depend on the object editor data of the casting time / any spell interruption.

The former measures if the timer duration has expired. The duration <= 0.00 check should not be needed and is only used by the system internally to compare the Spell__Expired variable with the duration (in case a new duration was set by the user).

I won't be able to open the map you attached for a while. Every time I turn on my netbook it is downloading a new Windows 10 update and the thing takes forever being an Atom N450.
 
Wierd, after explosion + dealing damage spell__Duration reloads with 5.010 seconds (right after the group loop). If none was hit the spell ends correctly.

you could add this line after the group block it will force an spell instance end:
  • Set Spell__Duration = 0.00
 
Last edited:
Level 6
Joined
Oct 31, 2015
Messages
95
Thank you guys :D

EDIT:

Hello again. I'm back still to talk about the buffing part. It now levels properly with the spell level but when the buff is a damaging one the casting unit and his allies gain no EXP for the kills. This happens because the owner of the casting unit is Neutral Extra and can be easily solved by changing Aspect of Alliance of Neutral Extra towards the players.

But still I think that there will be some cases where this won't be doable so can you make the buff caster's owner equal to the casting unit/hero's owner?

EDIT 2:

Also I discovered the buff functionality recently by accident when looking at Whiplash's triggers after years using this system. There is no mention about it in the system samples. I don't know even how exactly it works and who will be affect by the buffs. It's a very cool functionality which could receive a bit more attention in documentation and maybe even be improved a bit. :)

I'm quoting myself because as it seems my post has been ignored or unseen for some time so here comes the need to say it again: damaging buffs like Entangling Roots does not grant EXP or gold when they kill an enemy unit because the caster's owner is Neutral Extra. Please change the buff dummy's owner to Spell__CasterOwner. If I knew how to do it I would do this myself. However it would be a great addition to the system if this is implemented as default and also if more documentation about the buffing is added.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
The issue is that those buffs are not supposed to deal damage. I cast everything from a single dummy unit and changing ownership won't help if another spell just changes its owner a second time.

Do your damage using the built in system timers and rely on buffs just for their non damaging effects (ie. just the immobilization).

Edit: but yes the documentation should mention this).
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
We can just add True Sight to the dummy unit that is created though
That may not be the right solution, unless one were to massively expand the sight radius of this dummy unit and also the true sight ability. Requires more object editor data to be changed and also screws with other dummy units' vision.

Perhaps a fogmodifier with truesight could be created in behalf of the Neutral Extra player. It'll need more testing.
 
Yes, however I believe 1.29 added an "Is Invulnerable" checker so I can create a 1.29+ only version (like I did with Damage Engine) if you want that additional control.
I'd rather have a version that's compatible for all patches using a "Level of Invulnerability Not equal to 0" checker. I don't trust 1.29 yet :p
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
What if the unit is invulnerable in a non-spell way ?

regards
-Ned
Yeah that's exactly it. There's Divine Shield, Neutral Hostile Invulnerable, Big Bad Voodoo, custom spells, the first half second of Sleep... ultimately it's too much to include for just one resource.

I'd rather have a version that's compatible for all patches ... I don't trust 1.29 yet :p

1.29 is the only way to play on Battle.net, but what I'm saying is that I would still have 2 versions out. The main one, unchanged, and a standalone 1.29-exclusive one which has no backwards compatibly.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Here is a new 1.30 (maybe 1.29 as well) copy of Spell System.

The only change to the system is the addition of a checker for BlzIsUnitInvulnerable. Therefore, I am only attaching the map to this post (and not updating the actual resource).

Additionally, the Demo Map with the Whiplash ability using the new spell effect movement technique. In it, I found that the original Whiplash had a memory leak (two of the effects were not getting destroyed at the end (specifically at index 15), but the effects were getting "removed from visibility" because the dummy they were attached to got removed.

The effect natives seem to be just as smooth as when they were attached to the unit, but without the overhead of needing to be attached to a unit. Therefore, maps using this new technique will not only be using fewer handles, but quite likely have much less overhead on the CPU.

If someone wants to do a benchmark using the new natives vs moving a dummy with the effect attached, I'd be grateful. I'm sure every single missile system out there will want to be updated.

I haven't updated The Big Dipper yet, as the dummy unit movement is tethered to Knockback2.5D. I might eventually switch it over to just using the effect movement.
 

Attachments

  • GUI Spell System.w3x
    92.7 KB · Views: 24
I was hoping to get this done before my sleep but I've been failing with the InRange. Either I use it wrong or it being an ass (tried using hardcoded value, same effect).

The InRange was suppose to be radius detection in my spell for damage of the ability, but it keeps failing no matter how many attempts I made to make it work (I attach messages to show the range of the spell used <Amaterasu_Range[Spell__Index]> and InRange variables)

Map attached.
 

Attachments

  • SasukeAmaterasu.w3x
    53.4 KB · Views: 25

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I was hoping to get this done before my sleep but I've been failing with the InRange. Either I use it wrong or it being an ass (tried using hardcoded value, same effect).

The InRange was suppose to be radius detection in my spell for damage of the ability, but it keeps failing no matter how many attempts I made to make it work (I attach messages to show the range of the spell used <Amaterasu_Range[Spell__Index]> and InRange variables)

Map attached.
Here. The issue was you had the target point of the group pick at the caster's position rather than the target point of the ability.
 

Attachments

  • SasukeAmaterasu.w3x
    53.3 KB · Views: 27
Top