• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[System, W.I.P.] Interspellar

Level 7
Joined
Apr 5, 2011
Messages
245
Interspellar
Produced by Christopher Nolan
v0.01
=)

Example of usage:
//========================
//=== SpellColdEmbrace ===
//======== v1.200 ========

library SpellColdEmbrace requires Cucumber, Support
//=== Settings ===
globals
private constant integer ABILCODE = 'X038'
private constant integer ARMOR_ABILITY = 'X039'
//----------------
private constant integer TICKS = 4
private constant real TICK_TIME = 1
private constant boolean STOP_ANIMATION = true
private constant boolean CHANGE_HEIGHT = true
private constant integer INSTANCES = 10
endglobals
static if CHANGE_HEIGHT then
globals
private constant integer HOVER_ABILITY = 'Amrf'
//----------------
private constant real HEIGHT_CHANGE_RATE = 200
endglobals
endif
struct SpellColdEmbrace extends array
private static real array HEAL_ABSOLUTE
private static real array HEAL_RELATIVE
private static method onInit takes nothing returns nothing
set HEAL_ABSOLUTE[1] = 20
set HEAL_ABSOLUTE[2] = 20
set HEAL_ABSOLUTE[3] = 20
set HEAL_ABSOLUTE[4] = 20
set HEAL_RELATIVE[1] = .03
set HEAL_RELATIVE[2] = .04
set HEAL_RELATIVE[3] = .05
set HEAL_RELATIVE[4] = .06
//================
call InitBuffConfig(TICK_TIME, TICKS, INSTANCES)
implement BeginBuffConfig
static method onTimedEffect takes nothing returns nothing
call SetWidgetLife(TimedEffect.target, GetWidgetLife(TimedEffect.target) + (HEAL_ABSOLUTE[TimedEffect.level] + GetUnitState(TimedEffect.target, UNIT_STATE_MAX_LIFE) * HEAL_RELATIVE[TimedEffect.level]) * TICK_TIME)
if TimedEffect.tick == 0 then
call UnitRemoveAbility(TimedEffect.target, ARMOR_ABILITY)
static if STOP_ANIMATION then
call SetUnitTimeScale(TimedEffect.target, 1)
endif
static if CHANGE_HEIGHT then
set Support.workReal = GetUnitDefaultFlyHeight(TimedEffect.target)
if Support.workReal > 0 then
call SetUnitFlyHeight(TimedEffect.target, Support.workReal, HEIGHT_CHANGE_RATE)
endif
endif
endif
endmethod
implement EndBuffConfig
endmethod

static method onSpellEffect takes nothing returns nothing
if GetSpellAbilityId() == ABILCODE then
set Support.workUnit = GetSpellTargetUnit()
call UnitApplyBuff(Support.workUnit, null, thisbuff, GetUnitAbilityLevel(GetTriggerUnit(), ABILCODE))
call UnitAddAbility(Support.workUnit, ARMOR_ABILITY)
static if STOP_ANIMATION then
call SetUnitTimeScale(Support.workUnit, 0)
endif
static if CHANGE_HEIGHT then
if GetUnitDefaultFlyHeight(Support.workUnit) > 0 then
call UnitAddAbility(Support.workUnit, HOVER_ABILITY)
call UnitRemoveAbility(Support.workUnit, HOVER_ABILITY)
call SetUnitFlyHeight(Support.workUnit, 0, HEIGHT_CHANGE_RATE)
endif
endif
endif
endmethod
endstruct
endlibrary

1. Indexer
JASS:
//-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-=-] Indexer [-=-=-=-
//-=-=-=-= v1.100 -=-=-=-=-

/*************************************************************************
* Functions
*     function CreateIndexer takes integer n returns integer
*          - Creates an indexer meant for n instances and returns its id
*     function IndexCount takes integer CODE returns integer
*          - Returns count of indexes used by indexer
*           (In very deed this returns the largest index used currently)
*     function Indexed takes integer CODE, integer index returns boolean
*          - Is this index of an indexer currently occupied
*     function Index takes integer CODE returns integer
*          - Occupies free index of an indexer and returns it
*     function Deindex takes integer CODE, integer index returns boolean
*          - Frees an index of an indexer
*
* Array data
*     bool: ... [Indexer N created]        ------------>    [0 indexed]   [1 indexed]   ... [Indexer N+1 created]     ...
*     int:  ... [Indexer N index count] [Freeindex address] [Freeindex 0] [Freeindex 1] ... [Indexer N+1 index count] ...
*************************************************************************/

library Indexer
    globals
        private integer count = 0
        private boolean array b
        private integer array i
    endglobals
    
    function CreateIndexer takes integer n returns integer
        local integer temp = count
        set b[count] = true
        set i[count] = 0
        set i[count + 1] = 1
        set count = count + n + 2
        return temp
    endfunction
    
    function IndexCount takes integer CODE returns integer
        return i[CODE]
    endfunction

    function Indexed takes integer CODE, integer index returns boolean
        return b[CODE + 1 + index]
    endfunction
    
    function Index takes integer CODE returns integer
        local integer j = CODE + 1
        local integer index
        if i[j] == 1 then
            set index = i[CODE]
            set i[CODE] = i[CODE] + 1
        else
            set index = i[i[j]]
            set i[j] = i[j] - 1
        endif
        set b[j + index] = true
        return index
    endfunction
    
    function Deindex takes integer CODE, integer index returns boolean
        local integer j = CODE + 1 + index
        if b[j] then
            set b[j] = false
            if i[CODE] == index + 1 then
                set i[CODE] = index
            else
                set CODE = CODE + 1
                set i[CODE] = i[CODE] + 1
                set i[i[CODE]] = index
            endif
            return true
        endif
        return false
    endfunction
endlibrary

2. Supermarker
JASS:
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-=-] Supermarker [-=-=-=-
//-=-=-=-=-= v0.900 -=-=-=-=-=-

/*******************************************************
* function InitSupermarker takes nothing returns nothing
*     (Starts supermarker wonderwork)
*******************************************************/

library Supermarker requires Support
//-=-=-=- Settings -=-=-=-
globals
    private constant real RECYCLE_TIME = 20
//-=-=-=-==-=-=-=-=-=-=-=-
    private trigger EnterTrigger = CreateTrigger()
    private trigger DeathTrigger = CreateTrigger()
    private integer IndexCount = 0
    private integer FreeindexCount = 0
    private integer array Freeindex
    private group Bathroom = CreateGroup()
endglobals

    private function Mark takes nothing returns boolean
        set Support.workUnit = GetFilterUnit()
        if FreeindexCount == 0 then
            set IndexCount = IndexCount + 1
            call SetUnitUserData(Support.workUnit, IndexCount)
        else
            set FreeindexCount = FreeindexCount - 1
            call SetUnitUserData(Support.workUnit, Freeindex[FreeindexCount])
        endif
        return false
    endfunction

    private function Wash takes nothing returns boolean
        call GroupAddUnit(Bathroom, GetTriggerUnit())
        return false
    endfunction
    
    private function Grab takes nothing returns nothing
        loop
            set Support.workUnit = FirstOfGroup(Bathroom)
            exitwhen Support.workUnit == null
            set Support.workInteger = GetUnitUserData(Support.workUnit)
            if Support.workInteger > 0 then
                call SetUnitUserData(Support.workUnit, -Support.workInteger)
            else
                call GroupRemoveUnit(Bathroom, Support.workUnit)
                set Support.workInteger = -Support.workInteger
                if Support.workInteger == IndexCount then
                    set IndexCount = IndexCount - 1
                endif
                set Freeindex[FreeindexCount] = Support.workInteger
                set FreeindexCount = FreeindexCount + 1
            endif
        endloop
    endfunction

    function InitSupermarker takes nothing returns nothing
        local region R = CreateRegion()
        set Support.workRect = GetWorldBounds()
        call RegionAddRect(R, Support.workRect)
        call GroupEnumUnitsInRect(Support.workGroup, Support.workRect, Condition(function Mark))
        call TriggerRegisterEnterRegion(EnterTrigger, R, Condition(function Mark))
        call RemoveRegion(R)
        set R = null
        //! runtextmacro TriggerRegisterAnyUnitEvent("DeathTrigger")
        call TriggerAddCondition(DeathTrigger, Condition(function Wash))
        call TimerStart(CreateTimer(), RECYCLE_TIME, true, function Grab)
    endfunction
endlibrary

3. Buffy (Buff field)
JASS:
//-=-=-=-==-=-=--=-=-=-=-
//-=-=-=-] Buffy [-=-=-=-
//-=-=-=- v0.900 =-=-=-=-

/*******************************************************
* function InitBuffy takes integer n returns nothing
*    - Inits buff field for n buffs
*     (Call it when game starts)
* function UnitHasBuff takes unit u, integer CODE returns boolean
*    - Returns true if unit has specified custom buff
* function UnitAddBuff takes unit u, integer CODE returns nothing
*    - Adds custom buff to unit
* function UnitOverlapBuff takes unit u, integer CODE returns boolean
*    - Adds custom buff to unit and returns true if overlap happened
* function UnitRemoveBuff takes unit u, integer CODE returns nothing
*    - Removes custom buff from unit
*******************************************************/

library Buffy
globals
    private integer BUFFS
    private boolean array B
endglobals
    function InitBuffy takes integer n returns nothing
        set BUFFS = n
    endfunction
    
    function UnitHasBuff takes unit u, integer CODE returns boolean
        return B[GetUnitUserData(u) * BUFFS + CODE]
    endfunction

    function UnitAddBuff takes unit u, integer CODE returns nothing
        set B[GetUnitUserData(u) * BUFFS + CODE] = true
    endfunction

    function UnitOverlapBuff takes unit u, integer CODE returns boolean
        if B[GetUnitUserData(u) * BUFFS + CODE] then
            return true
        else
            set B[GetUnitUserData(u) * BUFFS + CODE] = true
            return false
        endif
    endfunction

    function UnitRemoveBuff takes unit u, integer CODE returns nothing
        set B[GetUnitUserData(u) * BUFFS + CODE] = false
    endfunction
endlibrary

4. Quantum Timer
JASS:
//-=-=-=-=-=-=--=-=-=-=-=-=-=-=-
//-=-=-=-] QuantumTimer [-=-=-=-
//-=-=-=-=-=- v0.920 -=-=-=-=-=-

/*******************************************************
* Fields
*     readonly integer ExpiredTimer.data
*        - Returns data stored for the timer expired
* Functions
*     function SetWorldTimeSensitivity takes integer conglomerate returns integer
*        - Sets time sensitivity to quantum conglomerate (positive) / subquantum conglomerate (negative)
*     function GetWorldTimeSensitivity takes nothing returns integer
*        - Returns quantum conglomerate (positive) / subquantum conglomerate (negative)
*        ! Quantum conglomerate scales time rate by value / time by (1 / value)
*        ! Subquantum conglomerate scales time rate by (-1 / value) / time by -value
*     function StartTimer takes integer quantums, boolean periodic, boolexpr func, integer data returns integer
*        - Starts timer with specified configuration
*     function RemoveTimer takes integer timercode returns nothing
*        - Removes specified timer
*     function StopTimer takes integer timercode returns nothing
*        - Stops specified timer
*     function RestartTimer takes integer timercode returns nothing
*        - Restarts specified timer
*     function SetTimerData takes integer timercode, integer data returns nothing
*        - Set data for specified timer
*     function SetTimerTick takes integer timercode, integer quantums returns nothing
*        - Set tick quantum time for specified timer
*******************************************************/

library QuantumTimer initializer Init requires Indexer
//-=-=-=- Settings -=-=-=-
globals
    constant real TIME_QUANTUM = .03
    private constant integer MAX_TIMERS = 30
    private constant integer QUANTUMS_AVAILABLE = 2147483647
    private constant boolean SAFE = false
//-=-=-=-==-=-=-=-=-=-=-=-
    private integer Conglomerate
    private integer Count
    private boolean Pause
    private timer QuantumTimer
    private integer Indexer
    private integer array Quantums
    private boolean array Periodic
    private trigger array Trigger
    private integer array Data
    private integer array TriggerQuantum
    private integer WorkInteger
    private integer WorkInteger2
endglobals

    //! textmacro onExpireBegin takes increment, sign
        set Count = Count + $increment$
        static if SAFE then
            if Count > QUANTUMS_AVAILABLE then
                set Count = Count - QUANTUMS_AVAILABLE
            endif
        endif
        set WorkInteger = 0
        loop
            exitwhen WorkInteger == IndexCount(Indexer)
            if Trigger[WorkInteger] != null and TriggerQuantum[WorkInteger] $sign$ Count then
                set data = Data[WorkInteger]
    //! endtextmacro

    //! textmacro onExpireEnd
                if Periodic[WorkInteger] then
                    set TriggerQuantum[WorkInteger] = Count + Quantums[WorkInteger]
                    static if SAFE then
                        if TriggerQuantum[WorkInteger] > QUANTUMS_AVAILABLE then
                            set TriggerQuantum[WorkInteger] = TriggerQuantum[WorkInteger] - QUANTUMS_AVAILABLE
                        endif
                    endif
                else
                    call Deindex(Indexer, WorkInteger)
                    call TriggerClearConditions(Trigger[WorkInteger])
                endif
            endif
            set WorkInteger = WorkInteger + 1
        endloop
        if IndexCount(Indexer) == 0 then
            set Pause = true
            call PauseTimer(QuantumTimer)
        endif
    //! endtextmacro

    struct ExpiredTimer extends array
        readonly static integer data
        static method onQuantumConglomerateExpire takes nothing returns nothing
            //! runtextmacro onExpireBegin("Conglomerate", "<=")
                if Quantums[WorkInteger] > Conglomerate then
                    call TriggerEvaluate(Trigger[WorkInteger])
                else
                    set WorkInteger2 = Conglomerate / Quantums[WorkInteger]
                    if GetRandomInt(0, Quantums[WorkInteger] - 1) < Conglomerate - WorkInteger2 * Quantums[WorkInteger] then
                        set WorkInteger2 = WorkInteger2 + 1
                    endif
                    loop
                        call TriggerEvaluate(Trigger[WorkInteger])
                        exitwhen WorkInteger2 == 1
                        set WorkInteger2 = WorkInteger2 - 1
                    endloop
                endif
            //! runtextmacro onExpireEnd()
        endmethod
        static method onSubquantumConglomerateExpire takes nothing returns nothing
            //! runtextmacro onExpireBegin("1", "==")
                call TriggerEvaluate(Trigger[WorkInteger])
            //! runtextmacro onExpireEnd()
        endmethod
    endstruct
    
    //! textmacro Run
        if Pause and Conglomerate != 0 then
            set Pause = false
            if Conglomerate > 0 then
                call TimerStart(QuantumTimer, TIME_QUANTUM, true, function ExpiredTimer.onQuantumConglomerateExpire)
            else
                call TimerStart(QuantumTimer, -Conglomerate * TIME_QUANTUM, true, function ExpiredTimer.onSubquantumConglomerateExpire)
            endif
        endif
    //! endtextmacro
    
    function SetWorldTimeSensitivity takes integer conglomerate returns nothing
        if     conglomerate > 0 then
            call TimerStart(QuantumTimer, TIME_QUANTUM, true, function ExpiredTimer.onQuantumConglomerateExpire)
        elseif conglomerate < 0 then
            call TimerStart(QuantumTimer, -conglomerate * TIME_QUANTUM, true, function ExpiredTimer.onSubquantumConglomerateExpire)
        else
            if Pause == false then
                set Pause = true
                call PauseTimer(QuantumTimer)
            endif
        endif
        set Conglomerate = conglomerate
    endfunction

    function GetWorldTimeSensitivity takes nothing returns integer
        return Conglomerate
    endfunction

    //! textmacro Safe takes i
        static if SAFE then
            if $i$ > QUANTUMS_AVAILABLE then
                set $i$ = $i$ - QUANTUMS_AVAILABLE
            endif
        endif
    //! endtextmacro

    function StartTimer takes integer quantums, boolean periodic, boolexpr func, integer data returns integer
        set WorkInteger = Index(Indexer)
        set Quantums[WorkInteger] = quantums
        set TriggerQuantum[WorkInteger] = Count + quantums
        //! runtextmacro Safe("TriggerQuantum[WorkInteger]")
        set Periodic[WorkInteger] = periodic
        set Data[WorkInteger] = data
        if Trigger[WorkInteger] == null then
            set Trigger[WorkInteger] = CreateTrigger()
        endif
        call TriggerAddCondition(Trigger[WorkInteger], func)
        //! runtextmacro Run()
        return WorkInteger
    endfunction

    function RemoveTimer takes integer timercode returns nothing
        call Deindex(Indexer, timercode)
        call TriggerClearConditions(Trigger[timercode])
    endfunction

    function StopTimer takes integer timercode returns nothing
        set TriggerQuantum[timercode] = -1
    endfunction

    function RestartTimer takes integer timercode returns nothing
        set TriggerQuantum[timercode] = Count + Quantums[timercode]
        //! runtextmacro Safe("TriggerQuantum[timercode]")
        //! runtextmacro Run()
    endfunction

    function SetTimerData takes integer timercode, integer data returns nothing
        set Data[timercode] = data
    endfunction
    
    function SetTimerTick takes integer timercode, integer quantums returns nothing
        set Quantums[timercode] = quantums
    endfunction
    
    private function Init takes nothing returns nothing
        set Conglomerate = 1
        set Count = 1
        set Pause = true
        set Indexer = CreateIndexer(MAX_TIMERS)
        set QuantumTimer = CreateTimer()
    endfunction
endlibrary

5. Cucumber (Custom buff) [Deep W.I.P., Low functionality]
JASS:
//-=-=-=-==-=-=-=-=-=-=-=-=-
//-=-=-=-] Cucumber [-=-=-=-
//-=-=-=-=- v0.500 -=-=-=-=-

/*******************************************************
* Timed effect interface
*     readonly unit TimedEffect.target
*     readonly unit TimedEffect.caster
*     readonly unit TimedEffect.level
*     readonly unit TimedEffect.tick
* Functions
*     function UnitApplyBuff takes unit target, unit caster, integer buffcode, integer level returns nothing
*        - Applies custom buff to the target unit
*******************************************************/

library Cucumber requires Buffy, Indexer, QuantumTimer
globals
    private integer Buffs = 0
    private integer array QuantumPower
    private integer array Ticks
    private integer array Indexer
    private real array TimedEffectTime
    private trigger array TimedEffectTrigger

    private unit array Target
    private unit array Caster
    private integer array Buffcode
    private integer array Level
    private integer array TimedEffectTick
    private integer array TimedEffectTimer

    private integer WorkInteger
endglobals

    struct TimedEffect extends array
        readonly static unit target
        readonly static unit caster
        readonly static integer level
        readonly static integer tick
        static method onExpire takes nothing returns boolean
            set target = Target[ExpiredTimer.data]
            set caster = Caster[ExpiredTimer.data]
            set level = Level[ExpiredTimer.data]
            set TimedEffectTick[ExpiredTimer.data] = TimedEffectTick[ExpiredTimer.data] - 1
            if TimedEffectTick[ExpiredTimer.data] == 0 then
                call Deindex(Indexer[Buffcode[ExpiredTimer.data]], ExpiredTimer.data)
                set Target[ExpiredTimer.data] = null
                set Caster[ExpiredTimer.data] = null
                call RemoveTimer(TimedEffectTimer[ExpiredTimer.data])
            endif
            set tick = TimedEffectTick[ExpiredTimer.data]
            call TriggerEvaluate(TimedEffectTrigger[ExpiredTimer.data])
            return false
        endmethod
    endstruct
    
    function UnitApplyBuff takes unit target, unit caster, integer buffcode, integer level returns nothing
        local integer i = Index(Indexer[buffcode])
        set Target[i] = target
        set Caster[i] = caster
        set Level[i] = level
        set Buffcode[i] = buffcode
        if TimedEffectTrigger[buffcode] != null then
            set TimedEffectTick[i] = Ticks[buffcode]
            set TimedEffectTimer[i] = StartTimer(QuantumPower[buffcode], Ticks[buffcode] > 1, Condition(function TimedEffect.onExpire), i)
        endif
    endfunction

    module BeginBuffConfig
        endmethod
        readonly static integer thisbuff
    endmodule
    module EndBuffConfig
        static if thistype.onTimedEffect.exists then
            private static method fireTimedEffect takes nothing returns boolean
                call thistype.onTimedEffect()
                return false
            endmethod
        endif
        static method InitBuffConfig takes real DURATION, integer TICKS, integer INSTANCES returns nothing
            set QuantumPower[Buffs] = R2I(DURATION / TIME_QUANTUM)
            set Ticks[Buffs] = TICKS
            set Indexer[Buffs] = CreateIndexer(INSTANCES)
            static if thistype.onTimedEffect.exists then
                set TimedEffectTrigger[Buffs] = CreateTrigger()
                call TriggerAddCondition(TimedEffectTrigger[Buffs], Condition(function thistype.fireTimedEffect))
            endif
            set thistype.thisbuff = Buffs
            set Buffs = Buffs + 1
    endmodule
endlibrary

6. GameOn
JASS:
//-=-=-=-=-=-=-=-=-=-=-=-=
//-=-=-=-] GameOn [=-=-=-=
//-=-=-=-= v0.900 -=-=-=-=

//-=-=-=- Configuration -=-=-=-
//! runtextmacro Uses("Supermarker, Buffy")
//! textmacro GameOn
    call InitSupermarker()
    call InitBuffy(32)
//! endtextmacro
//! textmacro MapInit
    call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 6)
    call FogMaskEnable(false)
//! endtextmacro
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//! textmacro Uses takes u
library GameOn initializer MapInit requires Support, $u$
//! endtextmacro
    private function GameOn takes nothing returns nothing
        call DestroyTimer(GetExpiredTimer())
        //! runtextmacro GameOn()
    endfunction
    private function MapInit takes nothing returns nothing
        //! runtextmacro MapInit()
        call TimerStart(CreateTimer(), 0, false, function GameOn)
    endfunction
endlibrary
 
Last edited:
Level 7
Joined
Apr 5, 2011
Messages
245
Did you see example, and still not get what the heck is this?

P.S. Don't wanna see such useless feedback anymore

Edit:
Though I will explain further
This provides:
1. Custom buff
2. Timed effects
3. Unit marker
4. Timers easy to manipulate
And from the system name you could easily guess that this is designed for spell making
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
So you are saying that you are trying to submit 6 separate resources as a pack.

That's against the rules, make 6 separate submissions.


I can tell you right now though that Quantum Timer isn't going to get approved, lol

Use an existing timer system, making your own is like asking for an insta rejection, unless you discover something truly revolutionary.
 
Level 7
Joined
Apr 5, 2011
Messages
245
So you are saying that you are trying to submit 6 separate resources as a pack.

That's against the rules, make 6 separate submissions.
Ok :[
I can tell you right now though that Quantum Timer isn't going to get approved, lol

Use an existing timer system, making your own is like asking for an insta rejection, unless you discover something truly revolutionary.
I know, this Quantum Timer looks ... ridiculous ... but, what's exactly wrong with it you mean? This is not supposed to any lag until 10000 timers. :S
I mean:
- Bad interface
- Low efficiency
- Low functionality
?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Quantum Timers can't compete with existing timer systems, nor do I think it can even compete with native timers >.>. Lower performance = useless ;p.

edit
I know that ur really trying hard to make some cool stuff, but you should really learn the resources at THW so that you use all of the appropriate tools, then stuff can start to get approved =). A lot of stuff has been coded, and a lot of that stuff is very high quality made by people with years and years of programming experience =), evolved over 3 generations of wc3. A lot of the stuff can't even be improved anymore ;\.

It's best to try using the tools that exist. It'll enable you to do more, improve the quality of your stuff, and reduce how much work you're doing =).

I think that a Buff system is right up with what you want to do, so I really recommend that you focus on that. I also recommend object orientated API as objects really lend themselves to APIs like that. You use procedural for things like Ln(5), just regular functions, but you use OOP when you are manipulating an object, like instead of SetObjectProperty(object, value), you do set object.property = value, which is much more intuitive.

The OOP stuff does not add any overhead to what you are doing, it just improves organization and makes it look nicer =).
 
Level 7
Joined
Apr 5, 2011
Messages
245
Thanks!
I will reorganize it later
Btw, I updated QuantumTimer. This is still bad coded (I do not like it myself too, hard to do revolution with triggers), but has a function to scale time for all timer at once, so, if all buffs are custom, you can make some cool spell. =]
(Code needs some tricks probably)
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Quantum Timers is not ganna get approved unless you can beat out the performance of Timer Tools.

edit
and gl with that, considering that it's actually faster than native timers

Benchmarks
Natives with Empty Function @7500 timers w/ various timeouts: 63.5 fps, range 61-64 fps
Natives with Data Attachment @7500 timers w/ various timeouts: 43-45 fps
Timer Tools Across 50 methods @7500 timers w/ various timeouts w/ data attachment: 63.5 fps, range 63-64 fps
 
They aren't that complex. Take UnitIndexer for instance. Implementing it is done simply by CnPing the script into a newly created jass script file and creating an ability based on Defend in the object editor with some arbitrary raw code that should be configured in the script. Usage is simply GetUnitUserData or better yet, for the sake of hiding implementation details, GetUnitId (or was it GetUnitIndex? x-x)
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Actually the question shouldt not be why QuantumTimer is going to get rejected but why you are trying to write your own timer system. What do you expect from it, or why cant you use one of the usual systems?
If you want to write a timer system to get experience with jass coding i definitely agree its a good idea. But dont try to submit it as a resouce, just post it somewhere else in the trigger forum and nicely ask for comments.

Dont take it the wrong way, just trying to explain why everyone is flaming you..
 
Level 7
Joined
Apr 5, 2011
Messages
245
Just tested, this loses 2 fps against native timers @200 instances, and sucks as hell @7500. (No merging, 0.3125 - 1 timeouts)
Dat multiple trigger evaluations suck

Edit:
I guess, I know how to beat native timers by 10 fps :O
(28 -> 38 @7500)

Edit:
Not 10 though, but still ..
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
To do your test most effectively

Create 50 different methods, and then create 7500 timers across them with various timeouts. After that, compare it to natives under the same conditions and see how yours does.

Also, it's not natives you have to beat, it's Timer Tools

Natives with Empty Function @7500 timers w/ various timeouts: 63.5 fps, range 61-64 fps
Timer Tools Across 50 methods @7500 timers w/ various timeouts w/ data attachment: 63.5 fps, range 63-64 fps

So, I guess first beat native timers with empty functions, then try to beat Timer Tools ;). However, I don't think that you'll be able to beat native timers with empty functions if you try to hurt your resource as much as possible, play against all of its strengths. You'll probably only beat them when you play with all of your resources strengths. 50 methods and various timeouts put Timer Tools at the worst case scenario, so the 63-64 fps that beat natives was the worst possible case that you could get with Timer Tools.
 
Top