0 Members and 1 Guest are viewing this topic.
I would really like to see the code of that function, cause, as said in another thread by me, I am using a jass-scripted attackfunction, which means that it have to handle the max-number of units on the map hitting a target at the same time (10players with a max of 12units inc. summons + 2computerplayers in dota or ts style, to be sure that I never reach the max-amount, I estimate about 200 timers would be needed JUST FOR THE ATTACKS in my current approach. With that, I estimated a max of about 150-200 timers for the spells/timed effects/some other misc stuff. Now, it have to be a very massive thing when all timers would be active at the same time, but still, 300-400 timers running can't be good on performance...
Now, as I said, by some reason, the wc3 wants to shut down if I register more than one attackfunction to the timer, probably cause it recognises some kind of loop, cause it SHOULD not run the exact same function with the exact same data in all infinity, but, well, it sure looks so..You PoC aren't protected right? Would it be ok if I downloaded it and took some inpiration from your time-functions? (:
Off-topic question; It seems to me that you, Moyack, uses struct quite a lot, now, what I wonder is, are they in some way faster than array-variables, or do u just use them to simplifie code for you?
I have created a efficient way of getting either a integer or a struct (atleast, it should work with a struct since they are just integers)Code: jasslibrary TickTack /*Timefunction "TickTack" by RVonSonSnadtz This is a simple, yet very effective timerfunction. However, it can't by itself handle things longer than 2seconds, so that is something you should learn to make in the function next. Give a PM at [url=http://www.wc3jass.com]www.wc3jass.com[/url] if you need help with that. Pros: Very fast, safe and stable, it doesn't change much even if you would throw it ALOT of stuff to do. Cons: All functions ran with this function needs to be pre-registered as a condition to a trigger. Best is to use a constant trigger for all functions that you know might run in this script. Also, it can't by itself handle stuff longer than 2secs, but on the other hand is that a simple issue to come around (:[/quote]So you need to set all the conditions at map init?? well I think it's not an issue. [quote]This is version 1.0, hopefully I found this effective enough (: */ globals constant timer HIGHQ_TIMER = CreateTimer() //Needs to be started at MapInit using the HIGHQ_TIMEOUT, TRUE to periodic and the function HIGHQ_CALL constant real HIGHQ_TIMEOUT = 0.00125 //highq stands for high-freqency, with other words, the short intervall functions constant integer HIGHQ_MAXTICKS = 1601 //1601 works for everything <= 2secs, 801 for <=1sec. A higher value lessens the CPU-usage as the long-time functions doesn't need to change their calculations-integer as often, but it increases the RAM-usage because it will store more variables in the hashtable. Nulling the values would be quite ineffective. constant real HIGHQ_MAXROOF = HIGHQ_TIMEOUT * I2R(HIGHQ_MAXTICKS) //Should NEVER be changed unless you know what you are doing. Only using for debugging purpose. constant hashtable HIGHQ_TABLE = InitHashtable() //The very heart of this system private integer array highq_nroffunctions[HIGHQ_MAXTICKS] private integer highq_whichchild = 0 private integer highq_tick = 0 endglobals function HighQ_Call takes nothing returns nothing //Needs to be used with the timer on startupif highq_nroffunctions[highq_tick] > 0 then call TriggerEvaluate(LoadTriggerHandle(HIGHQ_TABLE, highq_tick, 0)) set highq_whichchild = 0endifif highq_tick >= HIGHQ_MAXTICKS then set highq_tick = 0else set highq_tick = highq_tick + 1endifendfunction public function GetData takes nothing returns integerlocal integer i = highq_whichchildlocal integer dataif i < highq_nroffunctions[highq_tick] then set highq_whichchild = i + 1 call TriggerEvaluate(LoadTriggerHandle(HIGHQ_TABLE, highq_tick, highq_whichchild)) set highq_nroffunctions[highq_tick] = highq_nroffunctions[highq_tick] - 1else set highq_nroffunctions[highq_tick] = 0endifreturn LoadInteger(HIGHQ_TABLE, highq_tick, i)endfunction public function Register takes real time, trigger func, integer data returns nothinglocal integer tickslocal integer iif time < HIGHQ_MAXROOF then //This If/then/else - function is solely used for debugging. If you are CERTAIN that ALL functions using this is below or at the 2sec-limit, then you could remove this if and other stuff marked as For Debugging set ticks = R2I(time / HIGHQ_TIMEOUT) + highq_tick if ticks > 1600 then set ticks = ticks - HIGHQ_MAXTICKS endif set i = highq_nroffunctions[ticks] call SaveTriggerHandle(HIGHQ_TABLE, ticks, i, func) call SaveInteger(HIGHQ_TABLE, ticks, i, data) set highq_nroffunctions[ticks] = i + 1else //For debugging debug call BJDebugMsg("A function passed the 2sec limit, please check through the code") //For debuggingendif //For debuggingendfunctionendlibrary The good thing here is that it seems fast and skips all loop-stuff, for highest possible speed. Second thing, that is both good and bad, is that it can't call ordinary functions, it needs to use already-made triggers with the function attached as a condition. And one last con: when calling GetData, you need to use the trigger that the executed function is attached to. It seems fast to me, but there are probably more here who are better on this area of expertise
I realized that it is possible to just use one timer for everything, with the use of integers to recall the function after a second or 2 until it is time to expire, so this is the timer I think I will be going for (:Any feedback on this would be nice (:
PS: I belive one of the biggest losses on performance coming from the KT2 are all extra trigger code.. So for me I have to create the functions that should be called as already made triggers so that I don't need to declare them more than once at the begining of the map.(example:Code: jassglobals constant trigger EFFECTEXPIRE = CreateTrigger()endglobals function EffectExpire takes nothing returns nothinglocal SomeStruct data = TickTack_GetData() /* or just use the integer from it directly*//*do the stuff*/endfunction //===================================//At the map-init, I will link the function with the trigger: function InitTrig_Melee_Initialization takes nothing returns nothing/* the ordinary mapinit-stuff and then:*/ call TriggerAddCondition( EFFECTEXPIRE,Condition( function EffectExpire))endfunction Sure, this will lead to a small list, but in terms of RAM, this should actually be lesser than the peaks if you do this every time you needs to use a function (as one function then could be attached to several, temporary triggers that also are stored in variables = more process required)This might be a bit overanalytic for many, but I want this map to work for alot of users, and then it needs it's speed ^^'PS: The first code is not very fast, BUT still faster than KT2 when alot of things is going on, but on the other hand.. TimerUtils seems faster than KT2 when alot of things is going on..
Hmmm, still many things that are obscured to me, like the "extends array"-thing.And textmacro? What is that?Btw, I got one other way to try to, so I will be back with one more try (:
Started by Purgeandfire
Started by olofmoleman
Started by Callahan
Started by moyack
Started by Vexorian