Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Scripts (http://www.wc3c.net/forumdisplay.php?f=737)
-   -   IsUnitSpellResistant (http://www.wc3c.net/showthread.php?t=102721)

Anitarf 09-23-2008 07:34 PM

IsUnitSpellResistant
 
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

Here-b-Trollz 09-24-2008 02:57 AM

Use of or would get it inlined, and be faster.
Expand JASS:

Anitarf 09-24-2008 03:06 PM

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.

Pyrogasm 09-25-2008 12:07 AM

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.

Jewel 05-14-2011 12:54 AM

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?

Anitarf 05-14-2011 09:00 AM

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.

DanThanh 05-18-2011 04:29 AM

Thank you, this script is really useful.


All times are GMT. The time now is 05:28 AM.

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