wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 01-01-2009, 02:36 PM   #1
ToukoAozaki
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: nes1209@hotmail.com
// 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.
Attached Images
File Type: jpg WC3ScrnShot_010309_144922_01.jpg (330.8 KB, 70 views)
Attached Files
File Type: w3x InvulnerabilityDetectorDemo.w3x (16.9 KB, 22 views)

Last edited by ToukoAozaki : 01-04-2009 at 06:28 AM.
ToukoAozaki is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-01-2009, 02:43 PM   #2
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Collapse JASS:
return GetUnitAbilityLevel(<yourUnit>,'Avul')>0
is not enough ?

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)
__________________
Cool != Useful

Last edited by Troll-Brain : 01-01-2009 at 03:02 PM.
Troll-Brain is offline   Reply With Quote
Old 01-01-2009, 03:49 PM   #3
chobibo
100% Genuine Retard!
 
chobibo's Avatar
 
Join Date: Jan 2007
Posts: 796

chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)

Send a message via Yahoo to chobibo
Default

Collapse JASS:
return GetUnitAbilityLevel(<yourUnit>,'Avul')>0

Last time I checked, it doesn't work for SetUnitInvulnerable.

EDIT: It works! lol.
__________________
Where's mah sig?

Last edited by chobibo : 01-01-2009 at 04:23 PM.
chobibo is offline   Reply With Quote
Old 01-01-2009, 04:03 PM   #4
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

You should test again.
__________________
Cool != Useful
Troll-Brain is offline   Reply With Quote
Old 01-01-2009, 04:23 PM   #5
chobibo
100% Genuine Retard!
 
chobibo's Avatar
 
Join Date: Jan 2007
Posts: 796

chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)

Send a message via Yahoo to chobibo
Default

I just checked it, it works.
__________________
Where's mah sig?
chobibo is offline   Reply With Quote
Old 01-01-2009, 06:57 PM   #6
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

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.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 01-02-2009, 09:01 AM   #7
ToukoAozaki
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

Quote:
Originally Posted by Rising_Dusk
We have IsUnitInvulnerable for a reason.

What do you mean? I really don't get what you're saying.

Quote:
Originally Posted by Rising_Dusk
And yes, chobibo, it works with SetUnitInvulnerable since it uses 'Avul' internally.

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).
ToukoAozaki is offline   Reply With Quote
Old 01-02-2009, 12:50 PM   #8
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,052

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

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?
__________________
Anitarf is offline   Reply With Quote
Old 01-02-2009, 02:16 PM   #9
ToukoAozaki
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

Quote:
Originally Posted by Anitarf
Also, couldn't you just keep the unit permanently paused, instead of pausing and unpausing it each time?

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.

Last edited by ToukoAozaki : 01-02-2009 at 02:22 PM.
ToukoAozaki is offline   Reply With Quote
Old 01-02-2009, 03:19 PM   #10
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

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'.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 01-02-2009, 03:56 PM   #11
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

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.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-02-2009 at 04:01 PM.
Troll-Brain is offline   Reply With Quote
Old 01-02-2009, 06:38 PM   #12
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Vexorian
Is there a case in which (GetUnitAbilityLevel(u,'Avul')>0) returns false while this method doesn't?
Just the hardcoded cases based upon Divine Shield. It's not like you couldn't just check for that buff or something if a given mapmaker is ridiculous enough to use that instead of triggering it. This is still in the exact same position it was before, it is not useful.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 01-02-2009, 07:00 PM   #13
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Rising_Dusk
Just the hardcoded cases based upon Divine Shield. It's not like you couldn't just check for that buff or something if a given mapmaker is ridiculous enough to use that instead of triggering it. This is still in the exact same position it was before, it is not useful.
It's not only hardcoded based upon Divine shield but all abilities custom or natives with a different Invulnerable buff.

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.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-02-2009 at 07:01 PM.
Troll-Brain is offline   Reply With Quote
Old 01-02-2009, 07:18 PM   #14
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Troll-Brain
It's not only hardcoded based upon Divine shield but all abilities custom or natives with a different Invulnerable buff.
There are no other natives. And what other custom abilities, huh?
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 01-02-2009, 07:22 PM   #15
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

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.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-02-2009 at 07:33 PM.
Troll-Brain is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 09:07 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services