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. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  5. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. 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.3.w3x
STAS Creation
Simple Temporary Ability System

Name Type Is Array Initial Value
    Map initialization
    Camera - Lock camera target for Player 1 (Red) to Mountain King 0002 <gen>, offset by (0, 0) using Default rotation
    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
    Game - Display to (All players) the text: |cff00ff00Now cast the BASE spell!|r
    hashtable STASSkills = InitHashtable()
    hashtable STASIndexer = InitHashtable()

    integer ONE_SPELL          = 'A000'
    integer ONE_TO_TWO_SPELL   = 'A001'
    integer TWO_TO_THREE_SPELL = 'A002'

    real ONE_TO_TWO_SPELL_ET = 3.00
    real TWO_TO_ONE_SPELL_ET = 1.00


library STAS
    function CreateTemporaryAbility takes integer bs, integer ns, real nset returns nothing
        call SaveInteger(STASSkills, bs, StringHash("NEXT"), ns)
        call SaveReal(STASSkills, bs, StringHash("EXPTIME"), nset)

    function STASTemporaryTimeHandler 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 = LoadInteger(STASIndexer, GetHandleId(t), StringHash("NEXT"))

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

        // For avoid bugs of timer, pause it
        call PauseTimer(t)

        // Destroy the timer
        call DestroyTimer(t)

        // Remove leak
        set t = null
        set caster = null

    function CastTemporaryAbility takes unit cu, integer cs returns nothing
        local real et
        local timer t
        local integer ns = LoadInteger(STASSkills, cs, StringHash("NEXT"))

        if (ns != 0) then

            // Initialize the timer
            set t = CreateTimer()

            // Save expiration time
            set et = LoadReal(STASSkills, cs, StringHash("EXPTIME"))
            // Save to hashtable the unit that cast the spell
            call SaveUnitHandle(STASIndexer, GetHandleId(t), StringHash("CASTER"), cu)

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

            // Add new spell to caster
            call UnitAddAbility(cu, ns)

            // Start the timer
            call TimerStart(t, et, false, function STASTemporaryTimeHandler)
        // Avoid leaks
        set cu = null
        set t = null

function sca takes nothing returns nothing

    call CreateTemporaryAbility(ONE_SPELL, ONE_TO_TWO_SPELL, ONE_TO_TWO_SPELL_ET)


function InitTrig_STAS_Creation takes nothing returns nothing
    local trigger tg = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( tg, 0.00 )
    call TriggerAddAction( tg, function sca )

function STASActions takes nothing returns nothing
    // Get the caster unit
    local unit c = GetSpellAbilityUnit()

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

    // Call the temporary system
    call CastTemporaryAbility(c, cs)

    set c = null    

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

    call TriggerAddAction(tg, function STASActions)

        call TriggerRegisterPlayerUnitEvent(tg, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
    exitwhen i == bj_MAX_PLAYERS