View Single Post
Old 01-01-2009, 02:36 PM   #1
extends net.wc3c.Jasser
Join Date: Jun 2008
Posts: 336

Submissions (5)

ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)

Send a message via MSN to ToukoAozaki
Default Invulnerability Detector

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).

Collapse JASS:
library InvulnerabilityDetector initializer init
// ------------------------------------------------------------
//                          Invulnerability Detector
// Version: 1.1.2
// Author: Touko-Aozaki
// Contact:
// ------------------------------------------------------------
// 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 ""
        private constant integer INV_DETECTOR_CODE      = 'inv&'
        private constant string INV_DETECTOR_ORDERSTR   = "fingerofdeath"
        private constant integer DUMMY_UNIT_CODE        = 'nshe'
        private unit dummy
    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)
                set result = not IssueTargetOrder(dummy, INV_DETECTOR_ORDERSTR, whichUnit)            
            call PauseUnit(dummy, true) // lock the unit;
        return result
    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

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.
Attached Images
File Type: jpg WC3ScrnShot_010309_144922_01.jpg (330.8 KB, 92 views)
Attached Files
File Type: w3x InvulnerabilityDetectorDemo.w3x (16.9 KB, 37 views)
ToukoAozaki is offline   Reply With Quote
Sponsored Links - Login to hide this ad!