Andrewgosu
The Silent Pandaren Helper
- Reaction score
- 716
This is an easy, simple to use system, which gives you more freedom when it comes to special effects.
The system allows you to create special effects for a single player, add an expiration timer or custom value to it or even retrieve the model name or coordinates of the effect.
This system is still in beta, so, any feedback whatsoever is appreciated, especially ideas concerning adding new functions and extras!
version: BETA
Extended Effects functions list:
Extended Effects code:
Andrewgosu
The system allows you to create special effects for a single player, add an expiration timer or custom value to it or even retrieve the model name or coordinates of the effect.
This system is still in beta, so, any feedback whatsoever is appreciated, especially ideas concerning adding new functions and extras!
version: BETA
Extended Effects functions list:
Code:
_______________________________________________________________________________________________________________________________________
[B] function[/B] AddSpecialEffectEx [B]takes [COLOR="RoyalBlue"]string[/COLOR][/B] modelName, [B][COLOR="RoyalBlue"]real[/COLOR][/B] x, [COLOR="RoyalBlue"][B]real[/B][/COLOR] y [B]returns [COLOR="RoyalBlue"]effect[/COLOR][/B]
[B]function [/B]AddSpecialEffectTargetEx [B]takes [COLOR="RoyalBlue"]string[/COLOR][/B] modelName, [COLOR="RoyalBlue"][B]widget[/B][/COLOR] targetWidget, string attachPointName [B]returns [COLOR="RoyalBlue"]effect[/COLOR][/B]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* These two functions do exactly the same as Blizzard's two effect functions, however, they also save the passed variables,
to a struct, so you can later use the "Get" functions to retrieve data associated with the specified effect.
_______________________________________________________________________________________________________________________________________
[B] function[/B] AddSpecialEffectForPlayer [B]takes [COLOR="RoyalBlue"]player[/COLOR][/B] id, [COLOR="RoyalBlue"][B]string[/B][/COLOR] modelName, [COLOR="RoyalBlue"][B]real[/B][/COLOR] x, [COLOR="RoyalBlue"][B]real[/B][/COLOR] y [B]returns [COLOR="RoyalBlue"]effect[/COLOR][/B]
[B] function [/B]AddSpecialEffectTargetForPlayer [B]takes [COLOR="RoyalBlue"]player[/COLOR][/B] id, [COLOR="RoyalBlue"][B]string[/B][/COLOR] modelName, [COLOR="RoyalBlue"][B]widget[/B][/COLOR] targetWidget, [B][COLOR="RoyalBlue"]string [/COLOR][/B]attachPointName [B]returns [COLOR="RoyalBlue"]effect[/COLOR][/B]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* Similar to the above functions, though, with a difference to create a special effect only for a single player.
* Use function "GetEffectOwner" to get the "owner" of the effect - the local player you created the effect.
_______________________________________________________________________________________________________________________________________
[B] function[/B] RemoveEffect [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns nothing[/B]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* Destroys the specified effect plus the struct attached to it.
_______________________________________________________________________________________________________________________________________
[B] function[/B] EffectApplyTimedLife [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect, [B][COLOR="RoyalBlue"]real[/COLOR][/B] duration [B]returns nothing[/B]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* This functions applies a timed life to a given special effect.
_______________________________________________________________________________________________________________________________________
[B]function[/B] SetEffectUserData [B]takes[COLOR="RoyalBlue"] effect[/COLOR][/B] whichEffect, [B][COLOR="RoyalBlue"]integer[/COLOR][/B] data [B]returns nothing[/B]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* Gives the effect a custom value, which you can later retrieve.
_______________________________________________________________________________________________________________________________________
[B]function[/B] GetEffectX [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]real[/COLOR][/B]
[B]function[/B] GetEffectY [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]real[/COLOR][/B]
[B]function[/B] GetEffectUserData [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]integer[/COLOR][/B]
[B]function[/B] GetEffectOwner [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]player[/COLOR][/B]
[B]function[/B] GetEffectModelName [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]string[/COLOR][/B]
[B]function[/B] GetEffectAttachPointName [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]string[/COLOR][/B]
[B]function[/B] GetEffectTargetWidget [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]widget[/COLOR][/B]
[B]function[/B] GetEffectUserData [B]takes [COLOR="RoyalBlue"]effect[/COLOR][/B] whichEffect [B]returns [COLOR="RoyalBlue"]integer[/COLOR][/B]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* Retrieving functions, which obtain values from a given effect.
Extended Effects code:
JASS:
//version BETA launch
library EXTENDEDEFFECTS requires CACHE, TIMERLIB
struct effectdata
integer effectData = 0
string modelName = ""
string attachPointName = ""
widget targetWidget = null
player owner = null
effect storedEffect = null
real x
real y
static method CreateEffect takes string modelName, real x, real y returns effectdata
local effectdata data = effectdata.allocate()
set data.modelName = modelName
set data.x = x
set data.y = y
set bj_lastCreatedEffect = AddSpecialEffect(modelName, x, y)
set data.storedEffect = bj_lastCreatedEffect
call SetHandleStruct(bj_lastCreatedEffect, data)
return data
endmethod
static method CreateEffectTarget takes string modelName, widget targetWidget, string attachPointName returns effectdata
local effectdata data = effectdata.allocate()
set data.modelName = modelName
set data.targetWidget = targetWidget
set data.attachPointName = attachPointName
set bj_lastCreatedEffect = AddSpecialEffectTarget(modelName, targetWidget, attachPointName)
set data.storedEffect = bj_lastCreatedEffect
call SetHandleStruct(bj_lastCreatedEffect, data)
return data
endmethod
endstruct
function AddSpecialEffectEx takes string modelName, real x, real y returns effect
local effectdata data = effectdata.CreateEffect(modelName, x, y)
return bj_lastCreatedEffect
endfunction
function AddSpecialEffectTargetEx takes string modelName, widget targetWidget, string attachPointName returns effect
local effectdata data = effectdata.CreateEffectTarget(modelName, targetWidget, attachPointName)
return bj_lastCreatedEffect
endfunction
function AddSpecialEffectForPlayer takes player id, string modelName, real x, real y returns effect
local effectdata data
local string path = ""
if (GetLocalPlayer() == id) then
set path = modelName
endif
set data = effectdata.CreateEffect(path, x, y)
set data.owner = id
return bj_lastCreatedEffect
endfunction
function AddSpecialEffectTargetForPlayer takes player id, string modelName, widget targetWidget, string attachPointName returns effect
local effectdata data
local string path = ""
if (GetLocalPlayer() == id) then
set path = modelName
endif
set data = effectdata.CreateEffectTarget(path, targetWidget, attachPointName)
set data.owner = id
return bj_lastCreatedEffect
endfunction
function SetEffectUserData takes effect whichEffect, integer data returns nothing
local effectdata eyeCandy = GetHandleStruct(whichEffect)
set eyeCandy.effectData = data
endfunction
function RemoveEffect takes effect whichEffect returns nothing
local effectdata data = GetHandleStruct(whichEffect)
call DestroyEffect(whichEffect)
call data.destroy()
endfunction
function EffectApplyTimedLifeRun takes nothing returns nothing
local timer t = GetExpiredTimer()
local effectdata data = GetHandleStruct(t)
call RemoveEffect(data.storedEffect)
call TimerDestroy(t)
endfunction
function EffectApplyTimedLife takes effect whichEffect, real duration returns nothing
local timer t = TimerCreate()
call SetHandleStruct(t, GetHandleStruct(whichEffect))
call TimerStart(t, duration, false, function EffectApplyTimedLifeRun)
endfunction
//! textmacro GetEffectTYPE takes NAME, DATA, RETURN
function GetEffect$NAME$ takes effect whichEffect returns $RETURN$
local effectdata eyeCandy = GetHandleStruct(whichEffect)
return eyeCandy.$DATA$
endfunction
//! endtextmacro
//! runtextmacro GetEffectTYPE("X", "x", "real")
//! runtextmacro GetEffectTYPE("Y", "y", "real")
//! runtextmacro GetEffectTYPE("Owner", "owner", "player")
//! runtextmacro GetEffectTYPE("ModelName", "modelName", "string")
//! runtextmacro GetEffectTYPE("AttachPointName", "attachPointName", "string")
//! runtextmacro GetEffectTYPE("TargetWidget", "targetWidget", "widget")
//! runtextmacro GetEffectTYPE("UserData", "effectData", "integer")
endlibrary
Andrewgosu