1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome to the new Hive! Be advised that we're still working on the site. There are still many rough edges, so please bear with us.
    Dismiss Notice
  3. The member Kam is making HIVE coasters. Take a look. For every coaster you buy, Hive gets $1.
    Dismiss Notice
  4. The poll for Icon Contest #14 - Seven Deadly Sins is out!
    Dismiss Notice
  5. The 25th Texturing Contest has started! Contestants are to create a skin representing a dark elf person/being or any construct related to it using the vanilla models or the custom ones found on the site.
    Dismiss Notice
  6. Buy it, use it, break it, fix it, trash it, change it, mail - upgrade it. Join (Optionally) Paired Techtree Contest #11 - Techno Magic now!
    Dismiss Notice
  7. Voting squad, line up! Cast your vote on the poll for Modeling Contest #29 - Squads!
    Dismiss Notice
  8. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  9. The poll for the theme of our StarCraft II Terraining Contest is up. Cast your note now!
    Dismiss Notice
  10. The ninth Concept Art Contest has launched. Enter now!
    Dismiss Notice

[System] Timer Tools

Discussion in 'Graveyard' started by Nestharus, Aug 8, 2011.

  1. Bribe

    Bribe

    Code Moderator

    Joined:
    Sep 26, 2009
    Messages:
    7,336
    You wouldn't be using TimerTools for large timeouts anyway.
     
  2. kStiyl

    kStiyl
    Joined:
    Oct 23, 2011
    Messages:
    177
    didnt it support like 0.01 to 81.91 timeout?
     
  3. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Yeah, but it was inaccurate, so 0.03125 would instead be 0.03
     
  4. iAyanami

    iAyanami
    Joined:
    Dec 3, 2010
    Messages:
    142
    Since Tt supports 0.03125 timeout now, would it be better than using CTL?
     
  5. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    You can use either, lol. They are both close to the same speed. CTL is a little bit faster ;o. It's up to you.
     
  6. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    yay i found a test map!

    gonna test it soon... then by the time I understand it.. I'll use TT for the sake of alienation

    *kiddin

    btw.. is CTL(the deprecated one) and CTM have the same implementation?
     
  7. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    CTM doesn't require a timeout constant. If you are just using .031250000, use the third module in this.
     
  8. iAyanami

    iAyanami
    Joined:
    Dec 3, 2010
    Messages:
    142
    Just kinda confused here. Both CTT and CTTC are for constant timeouts. On what circumstances would I choose CTT over CTTC or the latter?
     
  9. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    CTTC is a constant timeout that will always merge, meaning one timer node for all timers. CTC is a constant timeout that won't always merge.

    CTC might use a timeout of 2 or 5
    CTTC might use a timeout of .03125 or .1
     
  10. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    I'm currently making some sort of spell apparently.. i can't seem to let it work with either CTM or CTTC.. and CTTC is worst 'cause the first cast will stop (if there are no enumerated units) and gives me a fatal error on second simultaneous cast (if there are any enumerated units)

    here's the code lol
    Code (vJASS):

    scope MetalShot
       
        private struct MetalShot
            unit caster
            unit array arrows[3]
            player owner
            integer lvl
            real array cos[3]
            real array sin[3]
            real dmg
            real dist
            private static constant real TIMEOUT = 0.031250000
            private static hashtable ht = InitHashtable()
            private group tmpGroup = bj_lastCreatedGroup
           
            implement CTT
                local unit f
                local integer i
                local real x
                local real y
            implement CTTExpire
                if dist > 0 then
                    set i = 0
                    loop
                        exitwhen i >= 3
                        set x = GetUnitX(this.arrows[i]) + 21 * this.cos[i]
                        set y = GetUnitY(this.arrows[i]) + 21 * this.sin[i]
                        call SetUnitX(this.arrows[i],x)
                        call SetUnitY(this.arrows[i],y)
                       
                        call GroupEnumUnitsInRange(tmpGroup,x,y,250,null)
                        loop
                            set f = FirstOfGroup(tmpGroup)
                            exitwhen f == null
                            call GroupRemoveUnit(tmpGroup,f)
                            if IsUnitEnemy(f,this.owner) and not IsUnitType(f,UNIT_TYPE_STRUCTURE) and UnitAlive(f) and not HaveSavedBoolean(ht,this,GetHandleId(f)) then
                                call UnitDamageTarget(this.caster,f,this.dmg,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,null)
                                call SaveBoolean(ht,this,GetHandleId(f),true)
                            endif
                        endloop
                        set i = i + 1
                    endloop
                    set dist = dist - 21
                else
                    set i = 0
                    loop
                        exitwhen i >= 3
                        call RemoveUnit(this.arrows[i])
                        set i = i + 1
                    endloop
                    call FlushChildHashtable(ht,this)
                    call this.destroy()
                endif
            implement CTTNull
                set f = null
            implement CTTEnd
           
            static method start takes nothing returns boolean
                local thistype this = thistype.create()
                local integer i = 0
                local real angle
                set this.caster = GetTriggerUnit()
                set this.owner = GetTriggerPlayer()
                set this.lvl = GetUnitAbilityLevel(this.caster,'A009')
                set this.dist = 700
                set this.dmg = 1000
                set angle = GetUnitFacing(this.caster)-45
                loop
                    exitwhen i >= 3
                    set this.arrows[i] = CreateUnit(Player(15),'h006',GetUnitX(this.caster),GetUnitY(this.caster),angle)
                    set this.cos[i] = Cos(angle*bj_DEGTORAD)
                    set this.sin[i] = Sin(angle*bj_DEGTORAD)
                    set angle = angle + 45
                    set i = i + 1
                endloop
                return false
            endmethod
           
            static method onInit takes nothing returns nothing
                call RegisterSpellEffectEvent('A009',function thistype.start)
            endmethod
        endstruct
    endscope
     

    To reproduce it, you must cast the spell simultaneously... or while the first cast is still in effect

    pretty bad lol
     
  11. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    And this be why
    private struct MetalShot


    it has to extend array


    whenever you use one of my modules, just assume that the struct has to extend array or it won't work =P.
     
  12. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    lol that stopped me from using arrays..
    lemme test

    EDIT:
    Yey it's working magnificently!! But i still use arrays >:D
    Also, please update the docs... it didn't say that it is required that I must extend array
    only the examples said it... o.o

    ohh well
    EDIT 2:
    Perhaps you may update your Recycle library or this library.. struct Timer is being redeclared o.o
     
    Last edited: Apr 22, 2012
  13. mckill2009

    mckill2009
    Joined:
    Mar 10, 2009
    Messages:
    4,681
    Nes, you should indicate in the documentation that a particular timer loop cannot run under 'X real', coz I've tested CTC and it cant run under 0.4, and CTTC cant run above 0.3...

    Maybe it's an option, coz I've tested it and worked just fine :)...
     
  14. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    mckill2009, they can run at whatever u want... they run based on the settings =P. You should read the documentation, because all of that was stated =).
     
  15. mckill2009

    mckill2009
    Joined:
    Mar 10, 2009
    Messages:
    4,681
    you mean they can run based on the module you implemented that is absolutely true, but running a CTT for example under 0.4 cant run...
     
  16. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,101
    yes it can... again, read the documentation and settings before you start stating that stuff

    Code (vJASS):

    ************************************************************************************
    *
    *    SETTINGS
    */
     
     
  17. Zwiebelchen

    Zwiebelchen
    Joined:
    Sep 17, 2009
    Messages:
    6,297
    Haha, thanks for pointing that out. :D
    Now I don't feel bad anymore for not using any timer system at all in Gaias Retaliation, but manually handling all timer stuff.

    Your system with the increase of speed when using one shot timers sounds neat.
    However, there is something about it that will scare away most of the mappers in my oppinion:
    It requires total recoding of almost everything as it uses a syntax that is totally different from using ordinary timers and other timer systems (with all the module stuff).
    It's not done by replacing one or two lines with a text editor, so the amount of work people would have to invest into changing from like TimerUtils or T32 to this one on higher complexity maps is insane.
    Not really your problem, though, just something I wanted to say. Maybe you can do something about it to make a switch between the systems easier? Maybe create a textmacro for compat for this?

    Other than that: awesome stuff! I really love that module syntax. Too bad I am to lazy to switch to your system. ;(

    ... then again, I probably won't use enough timers anyway to get a noticable difference in fps.
     
  18. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    The noticeable difference starts at 60-ish timers with average specs :p
     
  19. Zwiebelchen

    Zwiebelchen
    Joined:
    Sep 17, 2009
    Messages:
    6,297
    ... assuming that there is nothing in the function attached to the timers. ;)

    And 60 timers is a lot for me... I don't think I will ever reach that number. ^^
     
  20. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,027
    Actually, I got that number from a few tests I did long ago with one of my spells =P

    Of course, there was a noticeable difference with 10-20 casts, but the difference was completely noticeable when I did 60+ casts :D

    Of course, that's a bit too far-fetched :p
    What kind of game would allow you to make 60+ casts? xD