| 01-01-2009, 02:36 PM | #1 |
This is an invulnerability detector library. Uses finger of death as a dummy ability, and won't fire any order events. Simply check the return value of IsUnitInvulnerable(unit). JASS:library InvulnerabilityDetector initializer init // ------------------------------------------------------------ // Invulnerability Detector // // Version: 1.1.2 // Author: Touko-Aozaki // Contact: [email protected] // http://touko.pe.kr // ------------------------------------------------------------ // How to use: // use function IsUnitInvulnerable(unit) to find out whether // the unit is invulnerable or not. // ------------------------------------------------------------ // CHANGELOGS // [1.1.2] // Changed name of the library. (won't cause incompatibility as there are no public functions) // [1.1.1] // Wards and invisible units are now properly handled. // [1.1.0] // Reduced ObjectMerger dependencies; custom dummy is no longer // used. // ------------------------------------------------------------ //! external ObjectMerger w3a Afod inv& anam "Invulnerability Detector" aart "" aani "" acat "" aeat "" atat "" alig "" amat "" atar 1 "air,ground,structure,vulnerable,ward" acas 1 3600 amcs 1 0 aran 1 99999.0 aher 0 alev 1 Nfd3 1 0 Nfd1 1 0 Nfd2 1 0.01 arac "other" atp1 1 "" aub1 1 "" ansf "" globals private constant integer INV_DETECTOR_CODE = 'inv&' private constant string INV_DETECTOR_ORDERSTR = "fingerofdeath" private constant integer DUMMY_UNIT_CODE = 'nshe' private unit dummy endglobals function IsUnitInvulnerable takes unit whichUnit returns boolean local boolean result = false // default false if whichUnit != null and GetUnitTypeId(whichUnit) != 0 then // target is valid call PauseUnit(dummy, false) // unlock to test the order if not IsUnitVisible(whichUnit, Player(15)) then // make sure not to affect any possible game states call UnitShareVision(whichUnit, Player(15), true) set result = not IssueTargetOrder(dummy, INV_DETECTOR_ORDERSTR, whichUnit) call UnitShareVision(whichUnit, Player(15), false) else set result = not IssueTargetOrder(dummy, INV_DETECTOR_ORDERSTR, whichUnit) endif call PauseUnit(dummy, true) // lock the unit; endif return result endfunction private function init takes nothing returns nothing set dummy = CreateUnit(Player(15), DUMMY_UNIT_CODE, 0, 0, bj_UNIT_FACING) call UnitAddAbility(dummy, INV_DETECTOR_CODE) call ShowUnit(dummy, false) // makes any unit-type eligible for a dummy call PauseUnit(dummy, true) // hiding the unit doesn't prevent triggering the event endfunction endlibrary Demo map attached. You can test with a set of settings, units and spells. (invisible, ward, structures, normal units, heroes, etc.) Tips for comparison with GetUnitAbilityLevel method: Blademaster: Mirror Image (use upper-left buttons to select while casting) Shadow Hunter: Big Bad Voodoo Phoenix: At the point of death; while morphing into an egg. Paladin: Divine Shield Crypt Lord: Impale (target units are temporarily invulnerable) * Testmap updated; you can now see every issued order on the screen. |
| 01-01-2009, 02:43 PM | #2 |
JASS:return GetUnitAbilityLevel(<yourUnit>,'Avul')>0 And at least if the unit witchUnit is null, it will return true. It will also return true if the unit is not visible for Player(15) |
| 01-01-2009, 03:49 PM | #3 |
JASS:return GetUnitAbilityLevel(<yourUnit>,'Avul')>0 Last time I checked, it doesn't work for SetUnitInvulnerable. EDIT: It works! lol. |
| 01-01-2009, 04:03 PM | #4 |
You should test again. |
| 01-01-2009, 04:23 PM | #5 |
I just checked it, it works. |
| 01-01-2009, 06:57 PM | #6 |
I am sorry, but this is utterly useless, so I am graveyarding it. We have IsUnitInvulnerable for a reason. And yes, chobibo, it works with SetUnitInvulnerable since it uses 'Avul' internally. |
| 01-02-2009, 09:01 AM | #7 | ||
Quote:
What do you mean? I really don't get what you're saying. Quote:
Checking 'Avul' works for most cases, but not so much reliable. Ofc it works with neutral building with the ability and units set by SetUnitInvulnerable, but I've tested and found out some cases that don't work well with it. It seems that the presence of 'Avul' cannot tell much about spell-driven invulnerabilities (e.g. Divine Shield, Big Bad Voodoo, Phoenix morphing to an egg). |
| 01-02-2009, 12:50 PM | #8 |
Well, I'll move this back to resource submissions so the discussion about the code's usefulness can be resolved. Also, couldn't you just keep the unit permanently paused, instead of pausing and unpausing it each time? |
| 01-02-2009, 02:16 PM | #9 | |
Quote:
While writing the code, I thought about that idea because I didn't want to trigger any events. However, when I tested it, it didn't work properly; it later turned out that ordering paused units always returned false. Then I just guessed wild and tried what it is now; it finally worked. |
| 01-02-2009, 03:19 PM | #10 |
Is there a case in which (GetUnitAbilityLevel(u,'Avul')>0) returns false while this method doesn't? If there isn't, this function should probably be graveyarded or modified to just check the level for 'Avul'. |
| 01-02-2009, 03:56 PM | #11 |
As he said it doesn't work for the invulnerable spells. So the other way is to check all invulnerable custom and native buffs, but personnaly i will use this i think ... @ToukoAozaki : I have tested myself, but you should add a demo witch prove why your script is usefull, and why GetUnitAbilityLevel(u,'Avul')>0 is not enough. |
| 01-02-2009, 06:38 PM | #12 | |
Quote:
|
| 01-02-2009, 07:00 PM | #13 | |
Quote:
So you can inline it with checking all the invulnerable buff, but you have to made this for all custom maps. But imho only if you have really to care about speed. With this solution you don't need to care about it. |
| 01-02-2009, 07:18 PM | #14 | |
Quote:
|
| 01-02-2009, 07:22 PM | #15 |
I mean all original spells like ToukoAozaki said. And if for some reason you use a custom buff it will also fail. EDIT : But as i said he should make a demo map witch prove this fact. |
