DestroyEffectTimed

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
some weeks ago, we had this discussion about my lousy way of destroying effects after a certain amount of time in situations where you actually can't have TriggerSleepAction(), such as functions directly processing picked units in a group. (ref.: http://www.thehelper.net/forums/showthread.php?t=61263)

so now, I've had another go, making use of CSC and CSSafety. It still looks somewhat...maybe not ideal yet. I mean, timers are a great thing, but it's more effort to make things "clean" again as opposed to a simple wait. Either way, I'd be delighted to have some opinions and suggestions for improvement.


JASS:
function KillEffect takes nothing returns nothing
    local timer t=GetExpiredTimer()
    call DestroyEffect(GetAttachedEffect(t,"timed_effect"))
    call AttachObject(t,"timed_effect",null)
    call ReleaseTimer(t)
endfunction

function DestroyEffectTimed takes effect fx, real s returns nothing
    local timer t=NewTimer()
    call AttachObject(t, "timed_effect", fx)
    call TimerStart(t, s, false, function KillEffect)
endfunction


example:
JASS:
call DestroyEffectTimed(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIhe\\AIheTarget.mdl",u,"origin"),1.3)
 

emjlr3

Change can be a good thing
Reaction score
395
could try

JASS:

globals
  effect sfx
  real timed
endglobals
function remove_effect_time_child takes nothing returns nothing
  local effect e = sfx
  call PolledWait(timed)
  call DestroyEffect(e)
  set e = null
endfunction
function remove_effect_time takes effect e, real time returns nothing
  set sfx = e
  set timed = time
  call ExecuteFunc("remove_effect_time_child")
endfunction


not as accurate, but who really cares, not me, plus its more efficient by far

btw, in urs u dont null ur timer nor do youneed to set ur attached effect to null
 

Arkan

Nobody rides for free
Reaction score
92
Can you really pass arguments like that by using ExecuteFunc? I only thought it worked with GetEnumUnit() and such...
 

Arkan

Nobody rides for free
Reaction score
92
Ah didn't notice, well then it may screw up if 2 different calls are made in a short period of time. Maybe that's not much of a problem...
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
I'm using timers from a stack, so there shouldn't be need to null them when using ReleaseTimer instead. And I thought I better set the attached object to null, so all this attached stuff is cleaned again before the timer is released. Is that a bad idea?

I'd like to test the performance of different variations. Do you have any idea how to do that?
 

emjlr3

Change can be a good thing
Reaction score
395
i store the temp global as a local in the new function immediatly following the run, as well as call the polled wait with the other temp global, no overwriting can occur

using timers from a stack is the same as creating new ones, well not really, but as logn as you clear the stored info, no need to null anything, just clear the stored cache, i alterted the release timer function to do it for me everytime, so i dont have to manually

mine will be faster, obviosly, no GC, you can use Grim and its custom timer native to time the speeds if you want, but I dont know how it works
 

grim001

New Member
Reaction score
10
Ah didn't notice, well then it may screw up if 2 different calls are made in a short period of time. Maybe that's not much of a problem...

It's not a problem, JASS only runs 1 thread at a time, so it's impossible for this to happen
 

N-a-z-g-u-l

New Member
Reaction score
30
dont use polled wait... i used to do that with times like 20 seconds, for about 100 effects at the same time, 100 threads opened... the wait loop makes the game lagg then, now i use timers and the lagg is reduced a lot (well, i changed different things, but im pretty sure that was it^^)
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
structs are faster than gamecache, right?
any idea how to rewrite this thingy using structs?
 

emjlr3

Change can be a good thing
Reaction score
395
basically the same way I did, with a timer, and the globals replaced with a struct

JASS:

struct timed_sfx
  effect sfx
endstruct
function blarg_child takes nothing returns nothing
  local timer t = GetExpiredTimer()
  local timed_sfx data = GetData(t)

  call DestroyEffect(data.sfx)

  call data.destroy()
  call EndTimer(t)

  set t = null
endfunction
function blarg takes effect sfx, real time returns nothing
  local timer t = GetTimer()
  local timed_sfx data = timed_sfx.create()

  set data.sfx = sfx
  call TimerStart(t,time,false,function blarg_child)
  call SetData(t,data)

  set t = null
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top