[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > JASS Resources


JASS Resources Find JASS code snippets and functions here or write your own and post it on the Submissions sub-forum.

Reply
 
Thread Tools
Old 06-02-2012, 12:35 PM   #31 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Quote:
Originally Posted by Troll-Brain View Post
That's exactly the opposite.
There is a reason why we use set ... = null for locals.
When the local variable "dies" (end of the function), its value should be flushed, but it is not, and then when the associated handle is destroyed, its id is not recycled.
Function arguments are not concerned by this bug though (takes ...)
So how can I fix the issue? How can I null a unit when it finishes decaying?

Maybe instead I should just remove the "DEAD_UNITS_ARE_NULL" system and simply make the loop check for dead units.

I should also be using the native UnitAlive (right?)
Cokemonkey11 is offline   Reply With Quote
Old 06-02-2012, 12:54 PM   #32 (permalink)
Registered User Troll-Brain
cool != useful
 
Troll-Brain's Avatar
 
Join Date: Apr 2008
Posts: 1,940
Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)
"Modern" unit indexers can detect when an unit is removed of the game on event, exploiting a bug.

With a removed unit, or any other invalid one, GetUnitTypeId should return 0.

Jass:
        static if ENABLE_PERIODIC_CLEANUP then
                set perCleanup=CreateTrigger()
                call TriggerRegisterTimerEvent(perCleanup,PER_CLEANUP_TIMEOUT,true)
                call TriggerAddCondition(perCleanup,Condition(function ddBucket.perCleanupC))
            endif

You could directly use a timer instead.
__________________
- There are bugs with wc3, but most of time, the bug is between the keyboard and the chair.
- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.

You spam "...", "lol", and smilies such as "; p", "^)^",">.>"? You think you're the best and all other ones are stupids or at least less clever than you ? You think your errors are funny, while the other ones are incredibly lame ?
Maybe you've too much ego,or worse, you're a douchebag
Troll-Brain is online now   Reply With Quote
Old 06-02-2012, 01:03 PM   #33 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Quote:
Originally Posted by Troll-Brain View Post
"Modern" unit indexers can detect when an unit is removed of the game on event, exploiting a bug.

With a removed unit, or any other invalid one, GetUnitTypeId should return 0.
That seems quite useful. I think with my script, if the client uses RemoveUnit(), the associated bucket and trigger will never be destroyed, which is a big problem.

Can you show me how to use this exploit?

Quote:

Jass:
        static if ENABLE_PERIODIC_CLEANUP then
                set perCleanup=CreateTrigger()
                call TriggerRegisterTimerEvent(perCleanup,PER_CLEANUP_TIMEOUT,true)
                call TriggerAddCondition(perCleanup,Condition(function ddBucket.perCleanupC))
            endif

You could directly use a timer instead.
That would be more efficient, right? Because the callback function in a timer is faster than checking the conditions of a trigger?
Cokemonkey11 is offline   Reply With Quote
Old 06-02-2012, 01:13 PM   #34 (permalink)
Registered User Troll-Brain
cool != useful
 
Troll-Brain's Avatar
 
Join Date: Apr 2008
Posts: 1,940
Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)
Quote:
Originally Posted by Cokemonkey11 View Post
Can you show me how to use this exploit?
Unit indexers provide a custom event for that, such as UnitIndexer, AutoIndex, AIDS.
If you want a sample, check my UnitLL resource.

Quote:
That would be more efficient, right? Because the callback function in a timer is faster than checking the conditions of a trigger?
That should be yes, but anyway you just don't need a trigger.
__________________
- There are bugs with wc3, but most of time, the bug is between the keyboard and the chair.
- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.

You spam "...", "lol", and smilies such as "; p", "^)^",">.>"? You think you're the best and all other ones are stupids or at least less clever than you ? You think your errors are funny, while the other ones are incredibly lame ?
Maybe you've too much ego,or worse, you're a douchebag
Troll-Brain is online now   Reply With Quote
Old 06-02-2012, 01:36 PM   #35 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Quote:
Originally Posted by Troll-Brain View Post
Unit indexers provide a custom event for that, such as UnitIndexer, AutoIndex, AIDS.
If you want a sample, check my UnitLL resource.
I looked through nes' non-lua version of UnitIndexer and couldn't find anything useful. If I can't figure it out and there's no way to explain it to me I'll just make a "safeRemoveUnit" method.

Quote:
That should be yes, but anyway you just don't need a trigger.
Thanks. I've updated the script to use a timer.
Cokemonkey11 is offline   Reply With Quote
Old 06-02-2012, 06:27 PM   #36 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,918
Nestharus is a splendid one to behold (928)Nestharus is a splendid one to behold (928)Nestharus is a splendid one to behold (928)
rather than comparing to null, compare GetUnitTypeId to 0.

UnitIndexer is in a rather optimized state atm, rendering it nigh unreadable ;p.

Whenever a unit decays or is removed, 'Adef' fires two times. The second time it fires, the ability level of 'Adef' is 0. You register a trigger to fire whenever 'Adef' is used and check to see if the ability level is 0. If the ability level is 0, the unit went out of scope via decay or remove =). That is how UnitIndexer works = p. It also has a bit of other code for event registration, but that is the bug itself ; ). Things like AIDS and wc3c don't take advantage of 'Adef' being 0 on the second fire, so AIDS uses a stupid timer to check to see if the unit is gone and wc3c hooks RemoveUnit and : |.

I do not recommend building an entire unit indexer into the code. The fastest it will ever be is UnitIndexer, so if you are going to do indexing, you might as well just use UnitIndexer >.<.


One thing... I don't think hexed units are ever deindexed when they are removed via RemoveUnit as all abilities on a Hexed unit are disabled. Same with silenced unit ;o.
__________________

Anime-Planet.com - anime | manga | reviews
Nestharus is online now   Reply With Quote
Old 06-03-2012, 08:25 AM   #37 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Quote:
Originally Posted by Nestharus View Post
rather than comparing to null, compare GetUnitTypeId to 0
Oh perfect. I've updated the script (And added you and Troll-Brain in my credits :P )

Thanks for explaining this.

Quote:
UnitIndexer is in a rather optimized state atm, rendering it nigh unreadable ;p.

Whenever a unit decays or is removed, 'Adef' fires two times. The second time it fires, the ability level of 'Adef' is 0. You register a trigger to fire whenever 'Adef' is used and check to see if the ability level is 0. If the ability level is 0, the unit went out of scope via decay or remove =). That is how UnitIndexer works = p. It also has a bit of other code for event registration, but that is the bug itself ; ).
Interesting. Why don't you also use GetUnitTypeId()? Is UnitAddAbility() faster?

Quote:
Things like AIDS and wc3c don't take advantage of 'Adef' being 0 on the second fire, so AIDS uses a stupid timer to check to see if the unit is gone and wc3c hooks RemoveUnit and : |.
*cringe* what a nightmare.


Quote:
One thing... I don't think hexed units are ever deindexed when they are removed via RemoveUnit as all abilities on a Hexed unit are disabled. Same with silenced unit ;o.
But I'm sure you've documented that into UnitIndexer. Anyway, GetUnitTypeId() will not have to worry about that so I've used it.

One more thing, I've also updated the script to use the UnitAlive() native. I assume that's better. Anyone recommend reverting it to the way it was for some reason?
Cokemonkey11 is offline   Reply With Quote
Old 06-03-2012, 09:04 AM   #38 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,918
Nestharus is a splendid one to behold (928)Nestharus is a splendid one to behold (928)Nestharus is a splendid one to behold (928)
Quote:
One more thing, I've also updated the script to use the UnitAlive() native. I assume that's better. Anyone recommend reverting it to the way it was for some reason?
Use that

Quote:
Interesting. Why don't you also use GetUnitTypeId()? Is UnitAddAbility() faster?
??

The ability is added to all units as the units are created and it is never removed ;p
__________________

Anime-Planet.com - anime | manga | reviews
Nestharus is online now   Reply With Quote
Old 06-03-2012, 09:23 AM   #39 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Quote:
Originally Posted by Nestharus View Post
The ability is added to all units as the units are created and it is never removed ;p
Gotcha. Carry on.

I'm pretty happy with this system in its current state. Anyone have any questions or requests?

I'm thinking about writing a tutorial on how to use it for GUI users. Perhaps that's a waste of time.
Cokemonkey11 is offline   Reply With Quote
Old 06-03-2012, 11:22 AM   #40 (permalink)
Registered User Troll-Brain
cool != useful
 
Troll-Brain's Avatar
 
Join Date: Apr 2008
Posts: 1,940
Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)
About UnitAlive, i personnaly used IsUnitType(...UNIT_TYPE_DEAD), but i guess that the UnitAlive native have a different behavior about dead units but being under the process of resurrection.
In fact a custom function IsUnitAlive which have an extra boolean argument to consider ressurecting units alives ot not should be the best way.
__________________
- There are bugs with wc3, but most of time, the bug is between the keyboard and the chair.
- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.

You spam "...", "lol", and smilies such as "; p", "^)^",">.>"? You think you're the best and all other ones are stupids or at least less clever than you ? You think your errors are funny, while the other ones are incredibly lame ?
Maybe you've too much ego,or worse, you're a douchebag
Troll-Brain is online now   Reply With Quote
Old 06-03-2012, 11:26 AM   #41 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Quote:
Originally Posted by Troll-Brain View Post
About UnitAlive, i personnaly used IsUnitType(...UNIT_TYPE_DEAD), but i guess that the UnitAlive native have a different behavior about dead units but being under the process of resurrection.
In fact a custom function IsUnitAlive which have an extra boolean argument to consider ressurecting units alives ot not should be the best way.
Under the process of resurrection means they're not alive or dead? Seems like a really specific bug to consider.

Also, since I'm declaring "native UnitAlive ...", will everything be handled correctly if another library declares the same native or will that cause a problem?
Cokemonkey11 is offline   Reply With Quote
Old 06-03-2012, 11:30 AM   #42 (permalink)
Registered User Troll-Brain
cool != useful
 
Troll-Brain's Avatar
 
Join Date: Apr 2008
Posts: 1,940
Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)Troll-Brain is just really nice (375)
Jasshelper handle multiple native functions declaration (only consider the first and ignore the other ones).

I'm just saying i'm not sure how IsUnitType(...UNIT_TYPE_DEAD) and IsUnitAlive handle units which are being resurected, you should test it.
__________________
- There are bugs with wc3, but most of time, the bug is between the keyboard and the chair.
- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.

You spam "...", "lol", and smilies such as "; p", "^)^",">.>"? You think you're the best and all other ones are stupids or at least less clever than you ? You think your errors are funny, while the other ones are incredibly lame ?
Maybe you've too much ego,or worse, you're a douchebag
Troll-Brain is online now   Reply With Quote
Old 06-03-2012, 11:32 AM   #43 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
I'm not worried about such a tiny case. The client won't know the difference between ressurecting units being considered live or dead anyway, I just want to use the native which is faster.
Cokemonkey11 is offline   Reply With Quote
Old 06-08-2012, 02:11 PM   #44 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,995
Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)Cokemonkey11 is just really nice (346)
Bumping this thread too.

Any questions? What exactly has to happen before a thread becomes accepted or graveyarded?
Cokemonkey11 is offline   Reply With Quote
Old 06-08-2012, 02:18 PM   #45 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
To get it approved? Someone has to move the thread to the JASS Resources forum.

To get it reviewed is something different. I could approve this but it is still "another damage detection system" to join the ranks of far too many to keep track of.

Also, to respond to the Unitalive/IsUnitType thing, they both return the same when a unit is resurrecting.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is online now   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 10:36 PM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle