A few words about this:
This system can be used in both versions(jass,gui)
But primarily it is good for GUI users
Why is it good for GUI users?
Because this system will replace this
Example
Events Conditions Actions
Special Effect - Create a special effect at (Center of (Playable map area)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl Set example_var_SpecEffect = (Last created special effect) Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl Set example_var_SpecEffect = (Last created special effect)
and probably in most cases and this
Example
Events Conditions Actions
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl Set example_var_SpecEffect = (Last created special effect) Hashtable - Save Handle Ofexample_var_SpecEffect as 0 of 0 in (Last created hashtable)
or
Example
Events Conditions Actions
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl Hashtable - Save Handle Of(Last created special effect) as 0 of 0 in (Last created hashtable)
SpecFXSystem
Jass:
// How to install?//----------------------------------// Copy the code in the map header// Copy the variable "TimedSFXHash"// If you do not want to copy,simply create a new variable with this name "TimedSFXHash"// Variable Type is: "hashtable"// That's it.// Very simply.//----------------------------------// How to use this system?//----------------------------------// For example://----------------------------------// If you want to use a static or non-static effect at points X,Y// For example, suppose that x = GetSpellTargetX() and y = GetSpellTargetY()// or that x = GetUnitX(your unit) and y = GetUnitY(your unit)// In this case we should call this function// "AddStaticTimedSFX" or "AddNonStaticTimedSFX"// call AddStaticTimedSFX(modelPath,yourunit,timeinterval,durationofeffect,x,y)// call AddNonStaticTimedSFX(modelPath,yourunit,timeinterval,durationofeffect,x,y)// Explanation:// (modelPath)// "Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorTarget.mdl"// (yourunit)// GetTriggerUnit(),GetFilterUnit(),GetEnumUnit(),GetAttacker()...and so on// (timeinterval)// 0.03,0.04,0.05...bla,bla...and so on// (durationofeffect)// 1.00,2.00,3.00 or 1.5+(1.5*level)...and so on// (x)// GetSpellTargetX() or GetUnitX(yourunit)// (y)// GetSpellTargetY() or GetUnitY(yourunit)// A few simple examples:// local// call AddStaticTimedSFX(modelPath,yourunit,timeinterval,durationofeffect,GetSpellTargetX(),GetSpellTargetY())// global// call AddStaticTimedSFX(udg_modelPath,udg_yourunit,udg_timeinterval,udg_durationofeffect,GetSpellTargetX(),GetSpellTargetY())// func// call AddStaticTimedSFX(modelPath(),yourunit(),timeinterval(),durationofeffect(),GetSpellTargetX(),GetSpellTargetY())// directly// call AddStaticTimedSFX("Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorTarget.mdl",GetTriggerUnit(),0.03125,3.00,GetSpellTargetX(),GetSpellTargetY())// As for other functions,all based on the same principle// call AddStaticTimedSFXTarget(yourmodelPath,yourunit,yourattachpoint,youttimerint,yourdurationofeffect)// call AddNonStaticTimedSFXTarget(yourmodelPath,yourunit,yourattachpoint,youttimerint,yourdurationofeffect)// call AddStaticTimedSFXLoc(yourmodelPath,yourunit,timeinterval,durationofeffect,yourlocation)// call AddNonStaticTimedSFXLoc(yourmodelPath,yourunit,timeinterval,durationofeffect,yourlocation)//--------------------------------------------------------// Static Non-Static Special Effect Timed System//--------------------------------------------------------function TimedSFXSystemTimer takesnothingreturnsnothinglocaltimer t=GetExpiredTimer()localinteger id=GetHandleId(t)localboolean nonstatic=LoadBoolean(udg_TimedSFXHash,id,0)localboolean whichEffect=LoadBoolean(udg_TimedSFXHash,id,1)localstring modelPath=LoadStr(udg_TimedSFXHash,id,2)localreal x=LoadReal(udg_TimedSFXHash,id,3)localreal y=LoadReal(udg_TimedSFXHash,id,4)localunit u=LoadUnitHandle(udg_TimedSFXHash,id,5)localstring pointPath=LoadStr(udg_TimedSFXHash,id,6)localreal effectduration=LoadReal(udg_TimedSFXHash,id,7)localeffect sfx=LoadEffectHandle(udg_TimedSFXHash,id,8)localreal timesec=LoadReal(udg_TimedSFXHash,id,9)if(effectduration<=0.00)orIsUnitType(u,UNIT_TYPE_DEAD)thencallDestroyEffect(sfx)callFlushChildHashtable(udg_TimedSFXHash,id)callPauseTimer(t)callDestroyTimer(t)elsecallSaveReal(udg_TimedSFXHash,id,7,effectduration-timesec)if nonstatic thenif whichEffect thencallDestroyEffect(AddSpecialEffect(modelPath,x,y))elsecallDestroyEffect(AddSpecialEffectTarget(modelPath,u,pointPath))endifendifendifset t=nullset u=nullset sfx=nullendfunctionfunction RegisterTimedSFXSystem takesstring modelPath,unit u,string pointPath,real timesec,real dur,real x,real y,boolean nonststic,boolean whichEffect returnsnothinglocaltimer t=CreateTimer()localinteger id=GetHandleId(t)localeffect sfx
if nonststic thencallSaveBoolean(udg_TimedSFXHash,id,0,nonststic)if whichEffect thencallSaveBoolean(udg_TimedSFXHash,id,1,whichEffect)endifelseif whichEffect thenset sfx=AddSpecialEffect(modelPath,x,y)callSaveAgentHandle(udg_TimedSFXHash,id,8,sfx)set sfx=nullelsecallSaveAgentHandle(udg_TimedSFXHash,id,8,AddSpecialEffectTarget(modelPath,u,pointPath))endifendifcallSaveStr(udg_TimedSFXHash,id,2,modelPath)callSaveReal(udg_TimedSFXHash,id,3,x)callSaveReal(udg_TimedSFXHash,id,4,y)callSaveReal(udg_TimedSFXHash,id,7,dur)callSaveAgentHandle(udg_TimedSFXHash,id,5,u)callSaveStr(udg_TimedSFXHash,id,6,pointPath)callSaveReal(udg_TimedSFXHash,id,9,timesec)callTimerStart(t,timesec,true,function TimedSFXSystemTimer)set t=nullendfunctionfunction AddStaticTimedSFX takesstring s,unit u,real t,real r,real x,real y returnsnothingcall RegisterTimedSFXSystem(s,u,null,t,r,x,y,false,true)endfunctionfunction AddNonStaticTimedSFX takesstring s,unit u,real t,real r,real x,real y returnsnothingcall RegisterTimedSFXSystem(s,u,null,t,r,x,y,true,true)endfunctionfunction AddStaticTimedSFXTarget takesstring s,unit u,string s1,real t,real r returnsnothingcall RegisterTimedSFXSystem(s,u,s1,t,r,0.00,0.00,false,false)endfunctionfunction AddNonStaticTimedSFXTarget takesstring s,unit u,string s1,real t,real r returnsnothingcall RegisterTimedSFXSystem(s,u,s1,t,r,0.00,0.00,true,false)endfunctionfunction AddStaticTimedSFXLoc takesstring s,unit u,real t,real r,location l returnsnothingcall RegisterTimedSFXSystem(s,u,null,t,r,GetLocationX(l),GetLocationY(l),false,true)endfunctionfunction AddNonStaticTimedSFXLoc takesstring s,unit u,real t,real r,location l returnsnothingcall RegisterTimedSFXSystem(s,u,null,t,r,GetLocationX(l),GetLocationY(l),true,true)endfunction
StaticTimedSpecialEffect
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to StaticTimedSpecialEffect
Actions
-------- - -------- -------- ONLY FOR TEST -------- -------- - -------- Custom script: local real x=GetSpellTargetX() Custom script: local real y=GetSpellTargetY() Set StaticSFX_Path = Abilities\Spells\Undead\FrostArmor\FrostArmorTarget.mdl Set StaticSFX_Unit = (Triggering unit) Set StaticSFX_RealTime = 0.03 Set StaticSFX_EffectDuration = 1.50 -------- - -------- -------- - -------- Custom script: call AddStaticTimedSFX(udg_StaticSFX_Path,udg_StaticSFX_Unit,udg_StaticSFX_RealTime,udg_StaticSFX_EffectDuration,x,y) -------- - -------- -------- - --------
NonStaticTimedSpecialEffect
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to NonStaticTimedSpecialEffect
Actions
-------- - -------- -------- ONLY FOR TEST -------- -------- - -------- Custom script: local real x=GetSpellTargetX() Custom script: local real y=GetSpellTargetY() Set NonStaticSFX_Path = Abilities\Spells\Undead\FreezingBreath\FreezingBreathMissile.mdl Set NonStaticSFX_Unit = (Triggering unit) Set NonStaticSFX_Time = 0.35 Set NonStaticSFX_Dur = 3.00 -------- - -------- -------- - -------- Custom script: call AddNonStaticTimedSFX(udg_NonStaticSFX_Path,udg_NonStaticSFX_Unit,udg_NonStaticSFX_Time,udg_NonStaticSFX_Dur,x,y) -------- - -------- -------- - --------
StaticTimedSpecialEffectTarget
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to StaticTimedSpecialEffectTarget
Actions
-------- - -------- -------- ONLY FOR TEST -------- -------- - -------- Set StaticSFXTarget_Path = Abilities\Spells\NightElf\Immolation\ImmolationTarget.mdl Set StaticSFXTarget_Path2 = origin Set StaticSFXTarget_Unit = (Triggering unit) Set StaticSFXTarget_Time = 0.10 Set StaticSFXTarget_Dur = 4.00 -------- - -------- -------- - -------- Custom script: call AddStaticTimedSFXTarget(udg_StaticSFXTarget_Path,udg_StaticSFXTarget_Unit,udg_StaticSFXTarget_Path2,udg_StaticSFXTarget_Time,udg_StaticSFXTarget_Dur) -------- - -------- -------- - --------
NonStaticTimedSpecialEffectTarget
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to NonStaticTimedSpecialEffectTarget
Actions
-------- - -------- -------- ONLY FOR TEST -------- -------- - -------- Set NonStaticSFXTarget_Path = Abilities\Spells\Undead\FreezingBreath\FreezingBreathMissile.mdl Set NonStaticSFXTarget_Path2 = origin Set NonStaticSFXTarget_Unit = (Triggering unit) Set NonStaticSFXTarget_Time = 0.75 Set NonStaticSFXTarget_Dur = 4.00 -------- - -------- -------- - -------- Custom script: call AddNonStaticTimedSFXTarget(udg_NonStaticSFXTarget_Path,udg_NonStaticSFXTarget_Unit,udg_NonStaticSFXTarget_Path2,udg_NonStaticSFXTarget_Time,udg_NonStaticSFXTarget_Dur) -------- - -------- -------- - --------
comment and rate
And do not touch anything if you do not know what you doing
If you find any bugs <-> Report them.
v 1.0b
Added importing instructions.
Rating - 5.00 (1 vote)
(Hover and click)
Moderator Comments
Useful
19th July 2012
Magtheridon96:
I'll approve this on grounds that there are no standard JASS timer
recyclers that function in the WE.
It would totally be better if you would add a mini-recycler in there
though.
Tip
Jass:
set sfx=AddSpecialEffect(modelPath,x,y)callSaveAgentHandle(udg_TimedSFXHash,id,8,sfx)set sfx=null
16th Jul 2012
Bribe: I will approve this once you add importing instructions into the map.
edit
18th Jul 2012
Magtheridon96: Currently, this leaks timers.
Also, I would totally recommend putting spaces in between function arguments. It makes things a bit more readable.
One other tip:
Snippet
Jass:
set sfx2=AddSpecialEffectTarget(modelPath,u,pointPath)callSaveAgentHandle(udg_TimedSFXHash,id,8,sfx2)set sfx2=null
I will tell you what probably the moderator alone will say:
"Destroying Timers is bad, don't do it."
"UnitAlive is safer to use than GetWidgetLife() > .405"
__________________
Apheraz Lucent and -Grendel will forever live in my memory, two extraordinary persons taken away from our world before their time.
And so i dedicate my signature to them, a small sign of memory that will forever remain on my profile, for as long as it exists.
I am sad it's all i can do for them now and i hope i never did something to bring them anything but joy in their life.
World is a cruel place, but it was a better place with both of you in it. Miss you both.
Actually destroying timers in most cases proves to be quicker than recycling them.
Since all effects are handled the same, why not simply have a function to create an effect with a timer and when it elapses, destroy the effect. You shouldn't be checking if the units are dead or not because that is the user's job. You wouldn't want an effect removed on a reviveable unit would you?
Actually destroying timers in most cases proves to be quicker than recycling them.
Since all effects are handled the same, why not simply have a function to create an effect with a timer and when it elapses, destroy the effect. You shouldn't be checking if the units are dead or not because that is the user's job. You wouldn't want an effect removed on a reviveable unit would you?