Login
Register
Menu
Home
Forum
JassDoc
Types
Functions
Variables
Help
Chat
Media
Search
Search posts
WC3 JASS.com
"The Jass Vault" plus vJASS and Zinc
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
[Snippet] Timed Effects
Warcraft III:
Maps
Models
Skins
Icons
Spells / Systems
Tools
Tutorials
Snippets
JASS vJASS Spells and Systems
Tutorials
Chat @Discord
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation
-
Zinc documentation
-
WC3 Optimizer documentation
[Snippet] Timed Effects
Codes & Snippets
Started by
moyack
Views
9829
Replies
0
Users
1
1
Pages:
1
Go Down
0 Members and 1 Guest are viewing this topic.
Rating
Average Score
- 5 / 5
«
Created: August 06, 2018, 08:39:36 AM by moyack
»
moyack
Site Owner
Administrator
Posts:
970
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
[Snippet] Timed Effects
on:
January 09, 2012, 07:03:32 PM
Category:
Execution, Variables
Language:
vJASS
Related Topics or Resources
Hibrid TimerUtils
by
moyack
Timed Effects
by moyack. 2009-2011
Introduction
So... have you been needing a simple way (or function) to create an effect temporally and don't worry about destroying it? or you're needing that an effect with different animations (birth, stand, death) will show all of them?? if your answer is yes to any of those questions, then you're in the right place.
This script is used in my project
Power of Corruption
, as you'll see, it's simple as hell.
Just to point out: this library is very useful with effects that have different animations, so using this library with single animation effect will do the same as
Code: jass
call
DestroyEffect
(
AddSpecialEffect
(....))
How to use it?
Just add an effect as parameter and then you set its duration.
Example:
Code: jass
call
StartTimedEffect(
AddSpecialEffect
(fx, 0., 0.), 2.)
You won't need anything else, the system will care of cleaning the effect properly and recycle the values for you.
The code.
Here we have two flavors, acccording to the timer libraries you could have in your map. Select your best option.
This library requires
TimerUtils
Code: jass
//***********************
//* Timed Effects *
//* by moyack. 2011 *
//***********************
//*
//* Requires Jass NewGen Pack and TimerUtils by Various coders
//*
//* Introduction
//* ============
//*
//* So... have you been needing a simple way (or function) to create an effect temporally
//* and don't worry about destroying it? or you're needing that an effect with different
//* animations (birth, stand, death) will show all of them?? if your answer is yes to any
//* of those questions, then you're in the right place.
//*
//* This script is used in my project Power of Corruption ([url]http://poc.it.cx[/url]), as you'll see,
//* it's simple as hell.
//*
//* Just to point out: this library is very useful with effects that have different
//* animations, so using this library with single animation effect will do the same as
//* call DestroyEffect(AddSpecialEffect(....))
//*
//* How to use it?
//* ==============
//* - Create a trigger with a convenient name (like Timed Effects)
//* - Convert the trigger to custom text
//* - Copy and paste this code and save your map.
//*
//* With all this done, you just have to call the function StartTimedEffect(), and as parameters
//* an effect and a real value which will be the effect duration.
//*
//* Example: call StartTimedEffect(AddSpecialEffect(fx, 0., 0.), 2.)
//*
//* You won't need anything else, the system will care of cleaning the effect properly
//* and recycle the values for you.
library_once
TimedEffects
requires
TimerUtils
private
struct
data
effect
f =
null
timer
t
static
method
create
takes
effect
f
returns
data
local
data dt = data.
allocate
()
set
dt.t = NewTimer()
set
dt.f = f
call
SetTimerData(dt.t,
integer
(dt))
return
dt
endmethod
endstruct
private
function
DestroyTimedEffect
takes
nothing
returns
nothing
local
data d = data(GetTimerData(
GetExpiredTimer
()))
call
DestroyEffect
(d.f)
call
ReleaseTimer(d.t)
call
d.destroy()
endfunction
function
StartTimedEffect
takes
effect
f,
real
dur
returns
nothing
local
data d = data.
create
(f)
call
TimerStart
(d.t, dur,
false
,
function
DestroyTimedEffect)
endfunction
endlibrary
This library requires
TimedLoop
Code: jass
//***********************
//* Timed Effects *
//* by moyack. 2011 *
//***********************
//*
//* Requires Jass NewGen Pack and TimedLoop by Vexorian
//*
//* Introduction
//* ============
//*
//* So... have you been needing a simple way (or function) to create an effect temporally
//* and don't worry about destroying it? or you're needing that an effect with different
//* animations (birth, stand, death) will show all of them?? if your answer is yes to any
//* of those questions, then you're in the right place.
//*
//* This script is used in my project Power of Corruption ([url]http://poc.it.cx[/url]), as you'll see,
//* it's simple as hell.
//*
//* Just to point out: this library is very useful with effects that have different
//* animations, so using this library with single animation effect will do the same as
//* call DestroyEffect(AddSpecialEffect(....))
//*
//* How to use it?
//* ==============
//* - Create a trigger with a convenient name (like Timed Effects)
//* - Convert the trigger to custom text
//* - Copy and paste this code and save your map.
//*
//* With all this done, you just have to call the function StartTimedEffect(), and as parameters
//* an effect and a real value which will be the effect duration.
//*
//* Example: call StartTimedEffect(AddSpecialEffect(fx, 0., 0.), 2.)
//*
//* You won't need anything else, the system will care of cleaning the effect properly
//* and recycle the values for you.
library_once
TimedEffects
requires
TimedLoop
private
struct
data
effect
f =
null
real
time = 0.
real
dur
private
method
onTimedLoop
takes
nothing
returns
boolean
set
.time = .time + TimedLoop_PERIOD
if
.time > .dur
then
call
DestroyEffect
(.f)
return
TimedLoop_STOP
endif
return
TimedLoop_CONTINUE
endmethod
implement
TimedLoop
static
method
create
takes
effect
f,
real
t
returns
thistype
local
thistype
dt =
thistype
.
allocate
()
set
dt.dur = t
set
dt.f = f
call
dt.startTimedLoop()
return
dt
endmethod
endstruct
function
StartTimedEffect
takes
effect
f,
real
dur
returns
nothing
local
data d = data.
create
(f,dur)
endfunction
endlibrary
Changelog
* 1/21/2009: First Release
* 3/08/2009: Now
Code: jass
StartTimedEffect
returns the index of the TimedEffect object and added the
Code: jass
StopTimedEffect
function so you can stop it manually.
* 3/20/2009: Simplified more to avoid the .execute call
* 6/10/2011: Added TimedLoop version
«
Last Edit: December 23, 2017, 11:40:27 AM by moyack
»
WC3 Modding Information Center
Print
Pages:
1
Go Up
« previous
next »
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
[Snippet] Timed Effects
Suggested Topics
How to develop spells with effects over time
Started by
moyack
Replies: 4
Views: 12445
Jass Tutorials
InjuryEffectScript
Started by
moyack
Replies: 0
Views: 1566
Codes & Snippets
[reference] common.j
Started by
moyack
Replies: 40
Views: 58356
Jass Theory & Questions
PortaMx-SEF 1.54
|
PortaMx © 2008-2015
,
PortaMx corp.
Search
Username
Password
Always stay logged in
Forgot your password?