View Single Post
Old 09-23-2008, 07:34 PM   #1
Anitarf
Procrastination Incarnate


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

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

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

Default 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
__________________
Anitarf is offline   Reply With Quote
Sponsored Links - Login to hide this ad!