• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Timed Effect v1.1

  • Like
Reactions: deepstrasz
  • Timed Effect by Almia
  • Requires:
  • Code
    JASS:
    //************************************************************************************
    //*
    //*
    //*                            TIMED EFFECT
    //*
    //*                             by: ALMIA
    //*
    //*
    //************************************************************************************
    //*
    //*    Creates timed effects
    //*
    //************************************************************************************
    //*
    //*    Requires:
    //*
    //*    Linked List Table = http://www.hiveworkshop.com/forums/spells-569/linked-list-table-v1-3-a-230076/
    //*
    //************************************************************************************
    //*
    //*    CODE API
    //* 
    //*    function TimedEffectPeriodic takes nothing returns nothing
    //*
    //*        - Periodic function of system
    //*
    //*    function CreateTimedEffectOnUnit takes string mdl, unit target, string attach, real duration returns nothing
    //* 
    //*        - Creates timed effect on unit
    //*
    //*    function CreateTimedEffectOnLoc takes string mdl, real x, real y, real duration returns nothing
    //*
    //*        - Creates timed effect on location(via coords)
    //*
    //************************************************************************************
    //*
    //*    Variables
    //*
    //*    TS_List = integer
    //*    TS_Unit = unit array
    //*    TS_Timer = timer
    //*    TS_Effect = special effect array
    //*    TS_Duration = real array
    //*    TS_Count = integer
    //*
    //************************************************************************************
    
    function TimedEffectPeriodic takes nothing returns nothing
        local integer i = GetFirstIndexFromLinkedList(udg_TS_List)
        loop
            exitwhen 0 == i
            if 0 < udg_TS_Duration[i] then
                set udg_TS_Duration[i] = udg_TS_Duration[i] - 0.03125
            else
                call DestroyEffect(udg_TS_Effect[i])
                call RecycleIndexFromLinkedList(udg_TS_List, i)
                set udg_TS_Effect[i] = null
                set udg_TS_Unit[i] = null
                set udg_TS_Count = udg_TS_Count - 1
                if 0 == udg_TS_Count then
                    call PauseTimer(udg_TS_Timer)
                endif
            endif
            set i = GetNextIndexFromLinkedList(udg_TS_List, i)
        endloop
    endfunction
    //************************************************************************************
    function CreateTimedEffectOnUnit takes string mdl, unit target, string attach, real duration returns nothing
        local integer i = GetNewIndexFromLinkedList(udg_TS_List)
        set udg_TS_Effect[i] = AddSpecialEffectTarget(mdl, target, attach)
        set udg_TS_Unit[i] = target
        set udg_TS_Duration[i] = duration
        set udg_TS_Count = udg_TS_Count + 1
        if 1 == udg_TS_Count then
            call TimerStart(udg_TS_Timer, 0.03125, true, function TimedEffectPeriodic)
        endif
    endfunction
    //************************************************************************************
    function CreateTimedEffectOnLoc takes string mdl, real x, real y, real duration returns nothing
        local integer i = GetNewIndexFromLinkedList(udg_TS_List)
        set udg_TS_Effect[i] = AddSpecialEffect(mdl, x, y)
        set udg_TS_Duration[i] = duration
        set udg_TS_Count = udg_TS_Count + 1
        if 1 == udg_TS_Count then
            call TimerStart(udg_TS_Timer, 0.03125, true, function TimedEffectPeriodic)
        endif
    endfunction
    //************************************************************************************
    function InitTrig_Timed_Effect takes nothing returns nothing
        set udg_TS_List = CreateLinkedList()
    endfunction
  • Demo
    • Example
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
      • Actions
        • Custom script: call CreateTimedEffectOnUnit("Abilities\\Weapons\\IllidanMissile\\IllidanMissile.mdl", GetTriggerUnit(), "chest", 5)
  • Changelogs
    - Updated due to Linked List Table new update
Contents

Timed Effect v1.1 (Map)

Reviews
04:26, 30th Mar 2013 Magtheridon96: Approved. This has use-cases and it fulfills its purpose fine. Just one thing: CreateTimedEffectOnLoc <- This shouldn't not have "Loc" in the name because it implies that the user has to pass in a location...

Moderator

M

Moderator

04:26, 30th Mar 2013
Magtheridon96: Approved.
This has use-cases and it fulfills its purpose fine.

Just one thing:
CreateTimedEffectOnLoc <- This shouldn't not have "Loc" in the name because it implies that the user has to pass in a location variable. Use something else. Suggestion: CreatedTimedEffectXY
 
Considering the size of all of these, really ought to be compiled into the singular resource which is your linked list table, as they all require it, and none are large enough to warrant individual submissions for it. My suggestion would also be to rename it Linked List Utilities (once compiled), though you may want to put off doing that until each individual resource is approved, and maybe not at all. But I think it would be a wise move to do so.
 
Top