| 02-07-2007, 01:20 PM | #1 | |
This is an utupy, sending delayed events with a lot of info WITHOUT attaching information to timers, without even creating new timers and without recycling them. (no H2I , no sorcery/abuse of bugs) There are a lot of improvements to be done to it yet though.
Something I must say is that it is a little slower than real timers, yes it is. With 100 active events it may even drop fps by 3. Example: This is a temporary special effect function made with this approach JASS:struct timedfxtimer extends timerlistener effect fx method OnExpire takes nothing returns boolean call DestroyEffect( .fx) return true endmethod endstruct function AddSpecialEffectTargetWithDuration takes string fxpath, widget tar, string attach, real duration returns nothing local timedfxtimer t= timedfxtimer.create() set t.fx=AddSpecialEffectTarget(fxpath,tar,attach) call AddExpirationEvent(t, duration) endfunction globals constant string wantedeffect="units\\human\\GryphonRider\\GryphonRider.mdl" endglobals function Trig_Random_Timed_Effect_Actions takes nothing returns nothing call AddSpecialEffectTargetWithDuration(wantedeffect,GetTriggerUnit(),"overhead",5.0) endfunction //=========================================================================== function InitTrig_Random_Timed_Effect takes nothing returns nothing set gg_trg_Random_Timed_Effect = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Random_Timed_Effect, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerAddAction( gg_trg_Random_Timed_Effect, function Trig_Random_Timed_Effect_Actions ) endfunction Note: For animation timers (those that usually take between 0.01 and 0.04) It is better to use this approach but without this set of functions, just have a unique timer that calls objects in an array and expires each 0.04? seconds. (Like the way missiles work in the caster system) This was just for those delayed actions with random(as in any) periods of time. It allows looping if you don't return true in the expire function (so it doesn't auto destroy the listener) and send the event back. |
| 02-07-2007, 02:59 PM | #2 |
How fast is this compared to attaching a struct to a timer using a global var system like CSData? If it is not faster I don't see what the advantage of this method is. |
| 02-07-2007, 03:37 PM | #3 |
Speed for a one-time deal in an expiration event that is not animation-related is not really a priority but well: For adding an events: It depends of the number of active events and if it is not a last-first event, worst case scenario it requires to go through the whole array and assign stuff when adding an event. These are the things added for the expiration: - array access - Variable value increase. - TriggerEvaluate (one function call it seems) - struct destruction (optional (you would still have to destroy the struct if you used CSData, etc?)) CSData requires 2 function calls in total, 1 for H2I and the CSData call itself. It also requires an array access. Gamecache requires H2I, I2S and gamecache. Griffen's timerattach requires TimerGetRemaining, R2I and an operation and somehow also a function call unless you do stuff directly. Pool based ones require an H2I afaik, so it is like CSData with out without a function call. Notice that this also does not need to recycle/destroy the timer. In other words: THERE IS NO CONCLUSSION --- Speed was far from being the objective when making this system. |
| 02-07-2007, 03:49 PM | #4 |
maybe I don't have much of an imagination, but could you elaborate on the potential uses for this? what is made more convenient by this system compared to attaching a struct to a timer? |
| 02-07-2007, 07:17 PM | #5 |
Using timers is a hassle. It requires getting a timer and releasing a timer, both of which just suck due to JASS bugs. This contains all the event thinking into a couple lines of code which are right next to each other instead of spread out over a couple hundred lines for a nasty spell. So it's easier to use and easier to teach people how to use. |
| 02-08-2007, 02:04 AM | #6 |
Hmm, I can see how this would clean up the organization of large spells. ![]() |
