1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  5. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  6. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  7. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Viewer

Simple Temporary Ability System v0.0.2.w3x
Variables
Inicialización
Test
STAS Config
STAS Cast
Simple Temporary Ability System

		
Name Type Is Array Initial Value
Test
  Events
    Map initialization
  Conditions
  Actions
    Visibility - Disable fog of war
    Visibility - Disable black mask
    Game - Display to (All players) the text: |cffffff00Credits to|r: ALLKNOWLEDGE AKA IAM20842|cffffff00Also|r: HateSimple Temporary Ability System |cffffff00V.0.0.2|r
globals
    hashtable STASSkills = InitHashtable()
    hashtable STASIndexer = InitHashtable()

    integer BASE_SPELL      = 'A000'
    integer UP_SPELL        = 'A001'
    integer UP_FOR_UP_SPELL = 'A002'

    real UP_SPELL_ET = 3.00
    real UP_FOR_UP_SPELL_ET = 1.00

endglobals

function STASConfigActions takes nothing returns nothing

    // Configuring the spell, in this example you have BASE_SPELL (Q) -> UP_SPELL (Q) -> UP_FOR_UP_SPELL (Q)

    // Save the spell ID in integer vars, better in order like base -> next -> next -> n..., base --> next --> next

    // SAMPLE FOR base -> next -> next

    // 1. Save the spell ID for BASE_SPELL -> NEXT_SPELL
    call SaveInteger(STASSkills, BASE_SPELL, StringHash("NEXT_SPELL"), UP_SPELL)

    // 2. Save the spell EXPIRATION TIME for BASE_SPELL -> NEXT_SPELL
    call SaveReal(STASSkills, BASE_SPELL, StringHash("EXPIRATION_TIME"), UP_SPELL_ET)
   
    // 3. Save the spell ID for UP_SPELL -> UP_FOR_UP_SPELL
    call SaveInteger(STASSkills, UP_SPELL, StringHash("NEXT_SPELL"), UP_FOR_UP_SPELL)
   
    // 4. Save the spell EXPIRATION TIME for TEMP_SPELL_ONE -> TEMP_SPELL_TWO
    call SaveReal(STASSkills, UP_SPELL, StringHash("EXPIRATION_TIME"), UP_FOR_UP_SPELL_ET)

endfunction

//===========================================================================
function InitTrig_STAS_Config takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventSingle(t, 0.00)
    call TriggerAddAction(t, function STASConfigActions)
endfunction

 
function STASHandler takes nothing returns nothing
    // USE: On timer expiration, remove the next_spell

    // Get the expired timer
    local timer t = GetExpiredTimer()

    // Get the caster unit through timer ID

    local unit caster = LoadUnitHandle(STASIndexer, GetHandleId(t), StringHash("CASTER"))

    // Get the next_spell spell ID

    local integer NEXT_SPELL = LoadInteger(STASIndexer, GetHandleId(t), StringHash("NEXT_SPELL"))

    // Remove the spell
    call UnitRemoveAbility(caster, NEXT_SPELL)

    // For avoid bugs of timer, pause it

    call PauseTimer(t)

    // Destroy the timer

    call DestroyTimer(t)

    // Remove leak

    set t = null

    set caster = null

endfunction

function STASActions takes nothing returns nothing
    // USE: create a timer to every unit that cast a spell that have next_spell

    // Get the caster unit
    local unit caster = GetSpellAbilityUnit()

    // Get the casted spell
    local integer CASTED_SPELL = GetSpellAbilityId()

    // Later will save the expiration time of the combo / wombo spell

    local real expirationTime

    // Create a timer
    local timer t

    // Get the next_spell spell that correspond to the cast spell

    local integer NEXT_SPELL = LoadInteger(STASSkills, CASTED_SPELL, StringHash("NEXT_SPELL"))
   
    // Check if next_spell spell ID is greather than zero (have combo spell)
   
    if (NEXT_SPELL != 0) then

        // Initialize the timer
        set t = CreateTimer()

        // Save expiration time
        set expirationTime = LoadReal(STASSkills, CASTED_SPELL, StringHash("EXPIRATION_TIME"))
       
        // Save to hashtable the unit that cast the spell
        call SaveUnitHandle(STASIndexer, GetHandleId(t), StringHash("CASTER"), caster)

        // Save the next_spell spell ID
        call SaveInteger(STASIndexer, GetHandleId(t), StringHash("NEXT_SPELL"), NEXT_SPELL)

        // Add new spell to caster
        call UnitAddAbility(caster, NEXT_SPELL)

        // Start the timer
       
        call TimerStart(t, expirationTime, false, function STASHandler)
    else
         return
    endif
   
    // Avoid leaks
    set caster = null
    set t = null

endfunction

function InitTrig_STAS_Cast takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0

    call TriggerAddAction(t, function STASActions)

    // Set all players
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
    exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction