| 08-14-2007, 11:38 AM | #1 | |
Ok we all now what MUI is, it means Multi Unit Instancable, a spell that can be used by any number of units. We will examine this in a little bit detail now. Meet Bob, Bob is an experienced GUI mapper who decided it is about time to learn JASS. Bob also knows there is one kind of spells that is easily made with GUI and that is almost MUI, the MPI. (Multi Player Instancable) Bob made a lot of MPI spells in his GUI career using arrays[16] to keep spell data for each player separate, and using player numbers as array index, it was all he ever needed for his cool new AoS But this MPI spells have a problem that they are connected to the players and he learns that is bad and he learns about JESP and stuff like that. Now in JASS Bob finds out that by attaching stuff to timers, using handle-vars or any other system out there he is able to make MUI spells that can 100% be used by any unit. I finally made it thinks Bob, I am a pro Jasser now, who's da man. Meet Joe, a man who spends more than 8 hours a day on JASS forums, has rep in three digits, and probably has a couple of systems, or even tools of his own, he is generally acknowledged and respected. He tried every possible system that was ever created and finally settled with structs. (he still used handle-vars because he needs it for some old spells he created like 3 years ago because he does not want to hussle and recode them again) Now Joe knows something that Bob does not, it is the great secret of MUI, a deep dark truth kept from innocent GUI mappers by centuries and guarded by secret societies like Illuminati, Freemasons or Blizzard. It is a secret behind number 23. Warning: Tell anyone and you will die by natural causes.
|
| 08-16-2007, 10:00 PM | #2 | |
... what are you talking about? I have seen even 1000 timers works simultanouesly without deadlocks.. Quote:
-- I mean, sure no spell is actually MUI, unless of course it is one of those spells that don't require any wait or things like that, but I don't really agree with the numbers |
| 08-16-2007, 10:08 PM | #3 |
That thread is a mix of fantasy and truth, but there are some hard truths in there. I was talking about high frequency timers. On my pc when I play around 70 timers with 0.04 period it locks. As for gamecaches 256 is the limit I think, but you are right when you say not every spell has it's own gamecache, on the other hand that mission key is overused, I always wondered is there a limit to number of mission keys... |
| 08-16-2007, 10:14 PM | #4 |
We once looked for the mission key and other limits within a gamecache. They are very high... Right now I wouldn't trade using a single timer with no attaching involved with anything out there... |
| 08-16-2007, 10:22 PM | #5 | |
Quote:
How do you mean with NO attaching involved? |
| 08-16-2007, 10:46 PM | #6 |
god you keep going on and on without stopping to learn first cohadar |
| 08-16-2007, 10:53 PM | #7 |
I like going ahead of myself Now as far as I know there is no way to use gamecache in combination with timers and make a spell MUI without attaching to timer. If there is please enlighten me. (gasoline and some matches would do ) |
| 08-16-2007, 11:18 PM | #8 |
http://wc3campaigns.net/pastebint.ph...3ffd04408ae7e1 JASS:library TimedEvent initializer Init globals //*** Configuration *** private integer NumberOfTimers = 100 //*** End Configuration *** private integer array TAGS private Callback array CALLBACKS private timer array TIMERS private integer N = 0 endglobals function interface Callback takes integer tag returns boolean private function H2I takes handle h returns integer return h return 0 endfunction private function TimedEventExpires takes nothing returns nothing local timer t = GetExpiredTimer() local integer i = H2I(t)-0x100000 if not CALLBACKS[i].evaluate(TAGS[i]) then call PauseTimer(t) set N = N + 1 set TIMERS[N] = t endif endfunction function TimedEvent takes real delay, integer tag, Callback callback returns nothing local timer t local integer i if N == 0 then call BJDebugMsg("TimedEvent Error: Maximum numbers of timers ("+I2S(NumberOfTimers)+") exceeded") return else set t = TIMERS[N] set N = N-1 endif set i = H2I(t)-0x100000 set TAGS[i] = tag set CALLBACKS[i] = callback call TimerStart(t, delay, true, function TimedEventExpires) endfunction private function Init takes nothing returns nothing loop set TIMERS[N] = CreateTimer() exitwhen N == NumberOfTimers-1 set N = N + 1 endloop endfunction endlibrary |
| 08-16-2007, 11:27 PM | #9 | |
Quote:
|
| 08-16-2007, 11:41 PM | #10 |
Make periodic trigger of 0.01 frequency, and make Struct called CustomTimer. And update these custom timers in this periode trigger. And voila u have a beautiful custom timer tat works :D I use this method for my stuffs... |
| 08-17-2007, 12:08 AM | #11 |
JASS:local integer i = H2I(t)-0x100000 if not CALLBACKS[i].evaluate(TAGS[i]) then But this IS attaching to a timer, it is unsafe and system depedant and ugly. This is by far the worst method I have seen so far. Collections are superior to this in every way. EDIT: I must admit that general idea for this is interesting, but implementation is just horrible. This would work a lot better if ABC hash algorithm was used. And not all timer events need to be periodic. But on the other hand all that this does is that instead of attaching an integer to a timer you attach a callback to a timer, so it is basically unnecessary indirection. Even plain old handlevars is better than this. This method truly sux EDIT2: I did NOT double post, I just edited my previous post, forum bug? |
| 08-17-2007, 08:32 AM | #12 |
No one ever said EarthFury was correct, that system he posted is just another method of attachment. Furthermore it doesn't operate on the same basis as DataSystem, so your assumption that it has the same so-called limitation is incorrect. (I guess toadcop is clueless too) Not that DataSystem ever had a limitation to begin with, since the number of arrays it uses can be extended infinitely, or backup to GC can be used, and only leaking morons would run into a problem with the 3 default arrays. So on top of being wrong about all that: To handle a periodic thing with no attachment, a timer can loop through a given array of structs and handle all instances of a spell simultaneously. It's obviously the best method when it's available. "Attaching" to a timer is very rarely needed at all except for arbitrary length periods. |
| 08-17-2007, 08:48 AM | #13 | |
Quote:
Funny thing is that is EXACTLY what collections do, so you just said that I am wrong because my system is the best way to do it ^^ |
| 08-17-2007, 08:52 AM | #14 |
Except with a bunch of useless wrapper functions slowing it down, after all the point of the low-level approach is speed. Your system solves a non-existent problem. |
| 08-17-2007, 09:01 AM | #15 |
How about a problem of ugly and hard to understand code? Or the code that is so low level that you are not sure if you can change anything without fucking up something else? Besides even with wrapper functions it is faster than direct attachments, not to mention that it is easy to use, simple to understand, provides good encapsulation and makes pretty code. |
