HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

IsUnitSpellResistant

09-23-2008, 06:34 PM#1
Anitarf
A simple function that should be very useful when making spells compatible with standard melee gameplay; I feel it's just long enough to warrant it's own library, which for the sake of completeness includes the function IsUnitSpellImmune.

Collapse JASS:
library IsUnitSpellResistant

//*****************************************************************
//*  IsUnitSpellResistant
//*
//*  written by: Anitarf
//*
//*  In WC3, most debuff and stun spells have a decreased duration
//*  against heroes, creeps with a high enough level and units with
//*  resistant skin, while other spells such as Polymorph don't
//*  even work against such units. This function checks if a unit
//*  matches any of these criteria that would make it resistant to
//*  such spells, so you can make triggered spells work that way.
//*****************************************************************

    globals
        private constant integer CREEP_RESISTANCE_LEVEL = 6 //the level at which creeps gain spell resistance
    endglobals

    function IsUnitSpellResistant takes unit u returns boolean
        return IsUnitType(u, UNIT_TYPE_HERO) or IsUnitType(u, UNIT_TYPE_RESISTANT) or (GetPlayerId(GetOwningPlayer(u))>11 and GetUnitLevel(u)>=CREEP_RESISTANCE_LEVEL)
    endfunction

    function IsUnitSpellImmune takes unit u returns boolean
        return IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)
    endfunction

endlibrary
09-24-2008, 01:57 AM#2
Here-b-Trollz
Use of or would get it inlined, and be faster.
Expand JASS:
09-24-2008, 02:06 PM#3
Anitarf
Actually, it won't get inlined by the current JassHelper, but Vex said that in the future it might be so I updated it anyway.
09-24-2008, 11:07 PM#4
Pyrogasm
I don't know if I'm overstepping my authority, but I approve.

And we need to start cleaning up the submissions here, so moving this one on its merry way should be a good thing.
05-13-2011, 11:54 PM#5
Jewel
Is there any way to change the level at which creeps become resistant? I couldn't find a gameplay constant or anything similar.

Also, does IsUnitType(u, UNIT_TYPE_RESISTANT) depend solely on whether the unit has a Resistant Skill ability?
05-14-2011, 08:00 AM#6
Anitarf
Quote:
Originally Posted by Jewel
Is there any way to change the level at which creeps become resistant? I couldn't find a gameplay constant or anything similar.
I didn't find any way to do it when I looked either, but I thought I should make it a constant anyway to make it more understandable.

Quote:
Also, does IsUnitType(u, UNIT_TYPE_RESISTANT) depend solely on whether the unit has a Resistant Skill ability?
I think that's it. I seem to remember that in an earlier version of this script, before it was published, I was checking for those abilities before I discovered the resistant classification. I am fairly sure that when I replaced ability checks with the resistant check, I tested to see if the resistant classification also covers heroes and high level creeps and it turned out it didn't, but this all happened a while ago so I don't remember it very clearly.
05-18-2011, 03:29 AM#7
DanThanh
Thank you, this script is really useful.