- Joined
- Oct 18, 2007
- Messages
- 930
This system of mine was inspired by Justify's own system. Credits to him for the ida.
->[RAINBOW]REQUIRES JNGP[/RAINBOW]http://www.wc3campaigns.net/showthread.php?t=90999http://www.wc3campaigns.net/showthread.php?t=90999<-
[RAINBOW]All of this is made from scratch[/RAINBOW]
I did this to make an efficient code for removing effects over a period of time.
Script:
Ok if you find any bugs with it or ways of improvement, please reply.
Fixes
Tip: If you want to have a more accurate timer just set the global variable "Tick" to a lower value. Lower that 0.05 is not recommended
How To Use
Added test map:
->[RAINBOW]REQUIRES JNGP[/RAINBOW]http://www.wc3campaigns.net/showthread.php?t=90999http://www.wc3campaigns.net/showthread.php?t=90999<-
[RAINBOW]All of this is made from scratch[/RAINBOW]
I did this to make an efficient code for removing effects over a period of time.
Script:
JASS:
library EffectOverTime
globals
private constant real Tick = 0.1
private timer Tim = CreateTimer()
private integer array Er
private integer Total = 0
endglobals
private struct Effect
effect StoredEffect
real Counter = 0
real CounterMax = 0
static method ExecuteEffect takes nothing returns nothing
local Effect dat
local integer i = 0
loop
exitwhen i >= Total
set dat = Er[i]
if dat.Counter >= dat.CounterMax then
set Total = Total - 1
set Er[i] = Er[Total]
set i = i - 1
call dat.destroy()
else
set dat.Counter = dat.Counter + Tick
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Tim)
endif
endmethod
static method create takes effect StoringEffect, real Time returns Effect
local Effect dat = Effect.allocate()
set dat.StoredEffect = StoringEffect
set dat.CounterMax = Time - Tick
if Total == 0 then
call TimerStart(Tim, Tick, true, function Effect.ExecuteEffect)
endif
set Er[Total] = dat
set Total = Total + 1
return dat
endmethod
method onDestroy takes nothing returns nothing
call DestroyEffect(.StoredEffect)
set .StoredEffect = null
endmethod
endstruct
function DestroyEffectTimed takes effect StoringEffect, real Time returns nothing
call Effect.create(StoringEffect, Time)
endfunction
endlibrary
Ok if you find any bugs with it or ways of improvement, please reply.
Fixes
- Update: Fixed the things that Deaod found ( another thing to ^^ )
Tip: If you want to have a more accurate timer just set the global variable "Tick" to a lower value. Lower that 0.05 is not recommended
How To Use
-[RAINBOW]Example use of Triggering:[/RAINBOW][RAINBOW]Example use of Jass:[/RAINBOW]
- Example
- Events
- Unit - A unit Begins casting an ability
- Conditions
- (Ability being cast) Equal to Storm Bolt
- Actions
- -------- Just a variable ( not needed for the call ) --------
- Set Unit = (Triggering unit)
- -------- - --------
- -------- A Time variable to set the time it takes to remove the effect ( you dont need this variable, you could set the value yourself. But a variable is recommended! --------
- Set Time = 3.00
- -------- - --------
- -------- Creating and setting the effect --------
- Special Effect - Create a special effect attached to the origin of Unit using Abilities\Spells\NightElf\EntanglingRoots\EntanglingRootsTarget.mdl
- Set Effect = (Last created special effect)
- -------- - --------
- -------- Doing the call. This requires an special effect variable, and a real variable ( can be just a number ) --------
- Custom script: call DestroyEffectTimed( udg_Effect , udg_Time )
- -------- - --------
- -------- Nulling the effects --------
- Set Unit = No unit
- Custom script: set udg_Effect = null
- -------- - --------
JASS:function Trig_Example_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'AHtb' endfunction function Trig_Example_Actions takes nothing returns nothing // Just a variable ( not needed for the call ) local unit Unit = GetTriggerUnit() // - // A Time variable to set the time it takes to remove the effect ( you dont need this variable, you could set the value yourself. But a variable is recommended! local real Time = 3.00 // - // Creating and setting the effect local effect Effect = AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl" , Unit , "origin" ) // - // Doing the call. This requires an special effect variable, and a real variable ( can be just a number ) call DestroyEffectTimed( Effect , Time ) // - // Nulling the effects set Unit = null set Effect = null // - endfunction //=========================================================================== function InitTrig_Example takes nothing returns nothing set gg_trg_Example = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Example, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Example, Condition( function Trig_Example_Conditions ) ) call TriggerAddAction( gg_trg_Example, function Trig_Example_Actions ) endfunction
Attachments
Last edited: