[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Spells


Reply
 
Thread Tools
The Hive Workshop Spells:
StaticNonStaticTimedSFXSystem_1.0c.w3x
by zv27
Images
Highslide JS
Details
Uploaded:13:50, 30th Jun 2012
Last Updated:23:04, 18th Jul 2012
Keywords:None
Type:System
Category:JASS, GUI / Triggers

Jass:
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 takes nothing returns nothing

    local timer t=GetExpiredTimer()
    local integer id=GetHandleId(t)    
    local boolean nonstatic=LoadBoolean(udg_TimedSFXHash,id,0)
    local boolean whichEffect=LoadBoolean(udg_TimedSFXHash,id,1)
    local string modelPath=LoadStr(udg_TimedSFXHash,id,2)
    local real x=LoadReal(udg_TimedSFXHash,id,3)
    local real y=LoadReal(udg_TimedSFXHash,id,4)
    local unit u=LoadUnitHandle(udg_TimedSFXHash,id,5)
    local string pointPath=LoadStr(udg_TimedSFXHash,id,6)
    local real effectduration=LoadReal(udg_TimedSFXHash,id,7)
    local effect sfx=LoadEffectHandle(udg_TimedSFXHash,id,8)
    local real timesec=LoadReal(udg_TimedSFXHash,id,9)

    if(effectduration<=0.00) or IsUnitType(u,UNIT_TYPE_DEAD) then
        call DestroyEffect(sfx)
        call FlushChildHashtable(udg_TimedSFXHash,id)
        call PauseTimer(t)
        call DestroyTimer(t)

    else

        call SaveReal(udg_TimedSFXHash,id,7,effectduration-timesec)

        if nonstatic then

            if whichEffect then
                call DestroyEffect(AddSpecialEffect(modelPath,x,y))
            else
                call DestroyEffect(AddSpecialEffectTarget(modelPath,u,pointPath))
            endif

        endif 
  
    endif

    set t=null
    set u=null
    set sfx=null 
        
endfunction

function RegisterTimedSFXSystem takes string modelPath,unit u,string pointPath,real timesec,real dur,real x,real y,boolean nonststic,boolean whichEffect returns nothing

    local timer t=CreateTimer()
    local integer id=GetHandleId(t)
    local effect sfx

    if nonststic then
        call SaveBoolean(udg_TimedSFXHash,id,0,nonststic)

        if whichEffect then                        
            call SaveBoolean(udg_TimedSFXHash,id,1,whichEffect) 
        endif

    else

        if whichEffect then
            set sfx=AddSpecialEffect(modelPath,x,y)
            call SaveAgentHandle(udg_TimedSFXHash,id,8,sfx)
            set sfx=null

        else

            call SaveAgentHandle(udg_TimedSFXHash,id,8,AddSpecialEffectTarget(modelPath,u,pointPath))

        endif

    endif

    call SaveStr(udg_TimedSFXHash,id,2,modelPath)
    call SaveReal(udg_TimedSFXHash,id,3,x)
    call SaveReal(udg_TimedSFXHash,id,4,y)
    call SaveReal(udg_TimedSFXHash,id,7,dur)
    call SaveAgentHandle(udg_TimedSFXHash,id,5,u)
    call SaveStr(udg_TimedSFXHash,id,6,pointPath)
    call SaveReal(udg_TimedSFXHash,id,9,timesec)
    call TimerStart(t,timesec,true,function TimedSFXSystemTimer) 
    set t=null

endfunction

function AddStaticTimedSFX takes string s,unit u,real t,real r,real x,real y returns nothing
    call RegisterTimedSFXSystem(s,u,null,t,r,x,y,false,true)
endfunction

function AddNonStaticTimedSFX takes string s,unit u,real t,real r,real x,real y returns nothing
    call RegisterTimedSFXSystem(s,u,null,t,r,x,y,true,true)
endfunction

function AddStaticTimedSFXTarget takes string s,unit u,string s1,real t,real r returns nothing
    call RegisterTimedSFXSystem(s,u,s1,t,r,0.00,0.00,false,false)
endfunction

function AddNonStaticTimedSFXTarget takes string s,unit u,string s1,real t,real r returns nothing
    call RegisterTimedSFXSystem(s,u,s1,t,r,0.00,0.00,true,false)
endfunction

function AddStaticTimedSFXLoc takes string s,unit u,real t,real r,location l returns nothing
    call RegisterTimedSFXSystem(s,u,null,t,r,GetLocationX(l),GetLocationY(l),false,true)
endfunction

function AddNonStaticTimedSFXLoc takes string s,unit u,real t,real r,location l returns nothing
    call 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)
call SaveAgentHandle(udg_TimedSFXHash,id,8,sfx)
set sfx=null
->
call SaveAgentHandle(udg_TimedSFXHash, id, 8, AddSpecialEffect(modelPath, x, y))


Old reviews
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)
call SaveAgentHandle(udg_TimedSFXHash,id,8,sfx2)
set sfx2=null
->
call SaveAgentHandle(udg_TimedSFXHash,id,8,AddSpecialEffectTarget(modelPath,u,pointPath))

This way, you won't need those local special effect variables.

This spell is approved and works properly.


Download StaticNonStaticTimedSFXSystem.w3x
(23.45 KB, 143 Downloads)

Old 06-30-2012, 02:06 PM   #2 (permalink)
Registered User zv27
The real me RnR forever
 
zv27's Avatar
 
Join Date: Aug 2010
Posts: 236
zv27 has disabled reputation
I forgot to say
Next version will be a full GUI without any jass code.
I am currently working on her.

In my version of the editor looks like this

__________________

Last edited by zv27; 07-03-2012 at 12:54 PM.
zv27 is offline   Reply With Quote
Old 06-30-2012, 03:40 PM   #3 (permalink)
Registered User kerber
User
 
kerber's Avatar
 
Join Date: Nov 2011
Posts: 4
kerber is an unknown quantity at this point (0)
Very useful system 5/5
kerber is offline   Reply With Quote
Old 06-30-2012, 09:20 PM   #4 (permalink)
Registered User Kingz
I don't care.
 
Kingz's Avatar
 
Join Date: Jun 2008
Posts: 2,769
Kingz is a splendid one to behold (817)Kingz is a splendid one to behold (817)Kingz is a splendid one to behold (817)Kingz is a splendid one to behold (817)
Techtree Contest #6 - Winner: Demon Race: Kingz has managed to create a WarCraft3 race without importing additional material, yet presenting something unique to the public! A race made by Kingz. 
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.
Kingz is offline   Reply With Quote
Old 06-30-2012, 09:50 PM   #5 (permalink)
Registered User maddeem
moo moo
 
maddeem's Avatar
 
Join Date: Jan 2011
Posts: 1,047
maddeem is a jewel in the rough (228)maddeem is a jewel in the rough (228)maddeem is a jewel in the rough (228)
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?
__________________
maddeem is offline   Reply With Quote
Old 06-30-2012, 09:56 PM   #6 (permalink)
Registered User zv27
The real me RnR forever
 
zv27's Avatar
 
Join Date: Aug 2010
Posts: 236
zv27 has disabled reputation
Quote:
Originally Posted by Kingz View Post
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"
ok fixed
__________________
zv27 is offline   Reply With Quote
Old 06-30-2012, 10:08 PM   #7 (permalink)
Registered User zv27
The real me RnR forever
 
zv27's Avatar
 
Join Date: Aug 2010
Posts: 236
zv27 has disabled reputation
Quote:
Originally Posted by maddeem View Post
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?
It's not a bad idea hmm...I'll have to try
__________________
zv27 is offline   Reply With Quote
Old 07-01-2012, 09:06 AM   #8 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,526
defskull has a brilliant future (1280)defskull has a brilliant future (1280)defskull has a brilliant future (1280)defskull has a brilliant future (1280)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Cool. System. Ever. Unique. Too.
defskull is offline   Reply With Quote
Old 07-01-2012, 07:04 PM   #9 (permalink)
Registered User Kgg123
User
 
Kgg123's Avatar
 
Join Date: Apr 2011
Posts: 64
Kgg123 has little to show at this moment (6)
Hmm...6/10
Kgg123 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 08:58 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle