| 10-12-2007, 04:27 PM | #1 |
Alright, this is a tough question to search for - but possibly an easy one to answer. I have an ability (Remove Evasion) that temporarily subtracts two levels of Evasion from a target unit. After 20 seconds, the Evasion is restored. Remove Evasion has a cooldown of 10 seconds. What I can't get a good idea of how to do is how to deal with situations where the same unit has been targeted by the spell twice. Not just with this spell, but with other MUI spells that take place over time where the cooldown is lower than the duration. Is there a standard way to do this? Maybe some way using Handle Variables? All units are placed dynamically, so it's fairly trivial to store the base Evasion Level attached to each unit. Any ideas? Thanks in advance for the help. |
| 10-12-2007, 04:39 PM | #2 |
i like more the Chaos Theory it has a awesome drum&bass sound track... MUI is easy. read some tutors here... and see some examples etc. |
| 10-12-2007, 08:30 PM | #3 |
the chaos thing was beautiful, got more of those graphic videos? anyway ontopic: timer / periodic + struct |
| 10-12-2007, 08:58 PM | #4 |
http://conspiracy.hu http://theprodukkt.de they pawnz relative to them all other are sucker as for me... image what they could do with some 100 mbs ? xD |
| 10-13-2007, 07:32 AM | #5 |
Please don't hijack my thread - isn't there an off-topic forum or something? Regardless, thanks for the "help" - I took Lions advice, to an extent - though Structs don't seem to solve any problems, they just make things easier and more coherent. It is a useful thing to know about, especially since OOP theory is familiar to me. Anyway, I suppose with a struct attached to a unit that contained a timer, I would have direct access to a timer created when an ability was cast, thus only reacting to the expiration of a spell when the latest cast expired. That still seems fairly cumbersome, but it would certainly work. |
| 10-13-2007, 10:11 AM | #6 | |
He meant (from what I understood) that structs are much faster than game cache (handle vars), that would be MUI since you create local structs. And also the allow you much more flexibility in coding and allowing you to code much more efficient codes. Quote:
Attaching a timer to the caster may be a bit of a problem, I was doing the same mistake before. Avoid attaching stuff to anything that is not a local, because what if you have two spells where you attach stuff to the caster? You would have to use FlushHandleLocals on the caster and then you would lose the data you attached to the caster from the other spell, and that may be screwy. |
| 10-13-2007, 06:03 PM | #7 |
store an integer for the effect to say a string local string = I2S(H2I(targ))+"Spell Name" you can get that later, add to it, flush it, etc. to update effects accordingly attaching an expiration timer to the same string, can allow you to remove effects after x seconds hope that helps |
| 10-13-2007, 08:39 PM | #8 |
Hmm, thanks for the help. I'm going to do a bit more reading on the topic I suppose. Right now I don't understand how a local will be of any use in conjuction with a timer since you can't pass parameters to a callback function (the "code" parameter on the GetExpiredTimer) - it seems like you're going to have the same problem unless there's some way for multiple instances of the spell to know what earlier instances have done. Anyway, I'll read some more and see what I can find out, and thanks again for responding. |
| 10-15-2007, 01:01 PM | #9 |
you need to store the values using gamecache, or some other storage method globaly storing the value to the target allows you to get current effects ,storage of the timer to the targets string +"Spell Name" allows you to restart the timer if needed, and the cleanig of the leak storage of the unit to the timer can hlep you to retrieve its info during the callback function of the timer |
| 10-15-2007, 01:53 PM | #10 | |
Quote:
It is just that dealing with attaching stuff is very damn hard, if you ever need to attach stuff to a unit that is global and might need you to attach different instances of the same thing there are some tricks to do, you can use H2I() in the attachment label or now that I think of it, you could be attaching a list rather than static values, the list contains all the info of things related to every instance of the spell and when necessary you remove one of the items. I think this is the reason the aura template used attacheable sets... |
| 10-17-2007, 08:04 PM | #11 |
Thanks for all the help everyone - I've seen enough examples along with the help I've been given here to have a pretty good idea of how to do it. Thanks very much! I have one more question that I don't think deserves a new thread. If you have time to answer a leak question, I have one. I remember hearing parameters don't leak. Will this leak? JASS:function Spawn takes nothing returns unit return CreateUnitAtLoc(Player(0), 'H00I', udg_SpawnLocation, 0. ) endfunction function CreateSomeUnits takes nothing returns nothing call Spawn() endfunction I'm assuming it does, so I created an alternate Spawn function as I rarely need that return unit. JASS:function Spawn_ReturnNothing takes nothing returns nothing local unit u = CreateUnitAtLoc(Player(0), 'H00I', udg_SpawnLocation, 0. ) set u = null endfunction function CreateSomeUnits takes nothing return nothing call Spawn_ReturnNothing() endfunction I know how to fix the first solution so it won't leak (if it does), and I know these functions don't appear particularly useful but I'm only passing on relevant information so you don't have to wade through a bunch of junk. If the first function doesn't leak, I would be very happy though. Thanks for any help! |
| 10-17-2007, 10:37 PM | #12 |
it does not units only leak if you store them as a local variable |
| 10-17-2007, 11:19 PM | #13 |
Awesome, good to know. Thanks a lot. |
