[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums | Starcraft II |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Resources > JASS Functions

JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum.

Reply
 
LinkBack Thread Tools
Old 07-02-2009, 02:09 PM   #1 (permalink)
Registered User xD.Schurke
Working on EditorX
 
xD.Schurke's Avatar
 
Join Date: Feb 2006
Posts: 714
xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)
Hero Contest #2 - Winner: Archmaiden 
OverTimeEffectSystem v2.0

Because my old version is outdated and also the thread is closed I release a new version (it's totally recoded, there is nearly no equivalent to the old version)

Requires:
- JassHelper

Credits:
- Vexorian


Jass:
This system was started some time ago. It wasn not that efficient
but now I decided to totally rework it. It is much more 
comfortable now. The usage of an function interface gives the user
endless possibilities of creating timed effects.
 
An example usage:
call OverTimeEffect.create(<unit>caster,<unit>target,<real>interval,<real>duration,<real>damage,<OTEffect>functionInterface)

The function interface OTEffect takes <unit>caster,<unit>target,<real>value and returns boolean
  
The function should allways return true if you do not want the struct to be destroyed.
If the struct should be destroyed just return false, then the struct automaticly gets destroyed.

To use this system, just copy it into your map. The knowledge of how to use function interfaces would be good but you also could read through the JassHelper Manual

Script
Jass:
/****************************************************************************************************************************************
 *  OverTimeEffectSystem v2.0 by xD.Schurke
 *  ---------------------------------------
 *  
 *  Requires:
 *          - JassHelper (0.9.H.3)
 *          
 *  Credits:
 *          - Vexorian
 *
 *  This system was started some time ago. It wasn not that efficient
 *  but now I decided to totally rework it. It is much more 
 *  comfortable now. The usage of an function interface gives the user
 *  endless possibilities of creating timed effects.
 *  
 *  An example usage:
 *  call OverTimeEffect.create(<unit>caster,<unit>target,<real>interval,<real>duration,<real>damage,<OTEffect>functionInterface)
 *
 *  The function interface OTEffect takes <unit>caster,<unit>target,<real>value and returns boolean
 *  
 *  The function should allways return true if you do not want the struct to be destroyed.
 *  If the struct should be destroyed just return false, then the struct automaticly gets destroyed.
 *
 *  To use this system, just copy it into your map. The knowledge of how to use function interfaces would be good.
 *  but you also could read through the JassHelper Manual
 *
 *
 ****************************************************************************************************************************************/
library OverTimeEffectSystem
globals
    private constant    real    timerInterval   =   0.03125 //Interval of the timer
endglobals

function interface OTEffect takes unit caster, unit target, real value returns boolean

struct OverTimeEffect
    private         unit                caster          =   null
    private         unit                target          =   null
    private         real                interval        =   0.0
    private         real                fullDuration    =   0.0
    private         real                duration        =   0.0
    private         real                curTime         =   0.0
    private         real                value           =   0.0
    private         OTEffect            executeFunc     =   0
    //used for struct stacking
    private static  timer               tim             =   null
    private static  thistype    array   data
    private static  integer             total           =   0
    //core method, calls the function interface and evaluates the "stored" function if the function returns false the struct will be destroyed
    private static method callback takes nothing returns nothing
        local thistype this
        local integer i = 0
        local real damage = 0.0
        loop
            exitwhen i >= thistype.total
            set this = thistype.data[i]
            set this.curTime = this.curTime + timerInterval
            set this.duration = this.duration - timerInterval
            if this.curTime >= this.interval then //check if user chosed interval is reached
                set damage = this.value/(this.fullDuration/this.interval)
                if this.executeFunc.evaluate(this.caster,this.target, damage) != true then //destroy it baby
                    set this.total = this.total - 1
                    set this.data[i] = this.data[this.total]
                    set i = i - 1                                
                    call this.destroy()                      
                endif
                set this.curTime = 0.0
            endif
            if this.duration <= 0.0 then
                set this.total = this.total - 1
                set this.data[i] = this.data[this.total]
                set i = i - 1                                
                call this.destroy()                            
            endif
            set i = i + 1
        endloop
        //if there are no structs left, we should pause the timer, because it's not needed
        if thistype.total == 0 then
            call PauseTimer(thistype.tim)
        endif
    endmethod
    //setting all vars needed and also starting timer
    static method create takes unit caster, unit target, real interval, real duration, real value, OTEffect executeFunc returns thistype
        local thistype this = thistype.allocate()
        set this.caster = caster
        set this.target = target
        if interval < timerInterval then
            set this.interval = timerInterval
        else
            set this.interval = interval
        endif
        set this.fullDuration = duration
        set this.duration = duration
        set this.value = value
        set this.executeFunc = executeFunc
        if this.total == 0 then
            call TimerStart(this.tim,timerInterval, true,function thistype.callback)
        endif
        set this.data[this.total] = this
        set this.total = this.total + 1
        return this
    endmethod
    //initializing timer
    private static method onInit takes nothing returns nothing
        set thistype.tim = CreateTimer()
    endmethod
    //cleaning leaks
    private method onDestroy takes nothing returns nothing
        set this.caster = null
        set this.target = null
    endmethod
endstruct
endlibrary



Changelog

v2.0
- Released new version
Attached Files
File Type: w3x OverTimeEffectSystem v2.0.w3x (18.8 KB, 82 views)
__________________
My Spells & Systems


xD.Schurke is offline   Reply With Quote
Old 07-02-2009, 02:28 PM   #2 (permalink)
Registered User hvo-busterkomo
'Cos I had some sense
 
Join Date: Jun 2007
Posts: 1,267
hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)
Former Staff Member: This user used to be on the Hive Workshop staff. 
You could just initialize the timer in the globals block instead of the onInit method. I'm also pretty sure that struct members don't need to be nulled.
hvo-busterkomo is offline   Reply With Quote
Old 07-02-2009, 02:35 PM   #3 (permalink)
Registered User xD.Schurke
Working on EditorX
 
xD.Schurke's Avatar
 
Join Date: Feb 2006
Posts: 714
xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)
Hero Contest #2 - Winner: Archmaiden 
I prefere the onInit method, it gives a better overview
also struct members always have to be nulled oO you should know this
__________________
My Spells & Systems


xD.Schurke is offline   Reply With Quote
Old 07-02-2009, 03:20 PM   #4 (permalink)
Registered User hvo-busterkomo
'Cos I had some sense
 
Join Date: Jun 2007
Posts: 1,267
hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)
Former Staff Member: This user used to be on the Hive Workshop staff. 
You don't need to null struct members since they're global arrays.
hvo-busterkomo is offline   Reply With Quote
Old 07-02-2009, 03:48 PM   #5 (permalink)
Registered User xD.Schurke
Working on EditorX
 
xD.Schurke's Avatar
 
Join Date: Feb 2006
Posts: 714
xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)
Hero Contest #2 - Winner: Archmaiden 
u have to null struct members oO
__________________
My Spells & Systems


xD.Schurke is offline   Reply With Quote
Old 07-02-2009, 04:50 PM   #6 (permalink)
Forum Moderator Dr Super Good
Back to normal again. . .
 
Dr Super Good's Avatar
 
Join Date: Jan 2005
Posts: 6,552
Dr Super Good has much of which to be proud (1103)Dr Super Good has much of which to be proud (1103)Dr Super Good has much of which to be proud (1103)Dr Super Good has much of which to be proud (1103)Dr Super Good has much of which to be proud (1103)
You do not have to null struct members if you recycle them quickly, otherwise you do.

This is purly to free up more handle indexes quicker and remember that nulling takes near no time at all. Basically globals do not automatically free the handle index like locals, however they can not leak handle indexes unlike locals. Thus nulling them lets the indexes be recycled, while otherwise if the value of a handle in an array is never overwritten, it clogs up that handle index forever (eg if for some reason you used 30 structs at one point in the game while after that the max you used only was 10, 20 indexes worth of handles would be clogged up unnescescarily).
Dr Super Good is offline   Reply With Quote
Old 07-03-2009, 04:35 PM   #7 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
Meh, I don't really like the name of the struct, but w/e. Approved.
aznricepuff is offline   Reply With Quote
Old 07-03-2009, 04:44 PM   #8 (permalink)
Registered User xD.Schurke
Working on EditorX
 
xD.Schurke's Avatar
 
Join Date: Feb 2006
Posts: 714
xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)
Hero Contest #2 - Winner: Archmaiden 
the struct name fits the system I think^^
__________________
My Spells & Systems


xD.Schurke is offline   Reply With Quote
Old 07-03-2009, 04:45 PM   #9 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
Yea, but I still dont like it. :P
aznricepuff is offline   Reply With Quote
Old 07-09-2009, 04:26 AM   #10 (permalink)
Registered User hvo-busterkomo
'Cos I had some sense
 
Join Date: Jun 2007
Posts: 1,267
hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)
Former Staff Member: This user used to be on the Hive Workshop staff. 
Uses a global timer + indexing structs is awful for this.
hvo-busterkomo is offline   Reply With Quote
Old 07-09-2009, 11:25 AM   #11 (permalink)
Registered User xD.Schurke
Working on EditorX
 
xD.Schurke's Avatar
 
Join Date: Feb 2006
Posts: 714
xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)
Hero Contest #2 - Winner: Archmaiden 
Quote:
Originally Posted by hvo-busterkomo View Post
Uses a global timer + indexing structs is awful for this.
give one good argument.... timer stack is ok for this
__________________
My Spells & Systems


xD.Schurke is offline   Reply With Quote
Old 07-09-2009, 02:20 PM   #12 (permalink)
Registered User hvo-busterkomo
'Cos I had some sense
 
Join Date: Jun 2007
Posts: 1,267
hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)
Former Staff Member: This user used to be on the Hive Workshop staff. 
You can use the damage interval as the timer's interval.
hvo-busterkomo is offline   Reply With Quote
Old 07-09-2009, 07:41 PM   #13 (permalink)
Registered User xD.Schurke
Working on EditorX
 
xD.Schurke's Avatar
 
Join Date: Feb 2006
Posts: 714
xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)xD.Schurke is just really nice (270)
Hero Contest #2 - Winner: Archmaiden 
Quote:
Originally Posted by hvo-busterkomo View Post
You can use the damage interval as the timer's interval.
ehm there is no big diffrence in it oO
__________________
My Spells & Systems


xD.Schurke is offline   Reply With Quote
Old 07-09-2009, 09:31 PM   #14 (permalink)
Registered User hvo-busterkomo
'Cos I had some sense
 
Join Date: Jun 2007
Posts: 1,267
hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)
Former Staff Member: This user used to be on the Hive Workshop staff. 
There is if you have a damage interval of 4 seconds. That's 128 checks that could be avoided.
hvo-busterkomo is offline   Reply With Quote
Old 07-10-2009, 08:14 AM   #15 (permalink)
Registered User Anachron
^ That guy is awesome
 
Anachron's Avatar
 
Join Date: Sep 2007
Posts: 4,213
Anachron is a name known to all (641)Anachron is a name known to all (641)
Hosted Project of the Year - 2009: Diablo III Warcraft 
But do you really need it? With more uses (lets say casting it 100 times, thats not that hard in bigger maps) you have about 100 timers which run every X seconds, thats to much.

Edit: Umm, the struct name is really ugly. I would prefer TEffectData or something like that.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Howto [install JNGP.]
Anachron 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 On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:55 AM.






Hosting by SliceHost 
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.1
Copyright©Ralle