| 09-23-2008, 06:34 PM | #1 |
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. 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 |
Use of or would get it inlined, and be faster. JASS: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 |
| 09-24-2008, 02:06 PM | #3 |
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 |
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 |
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 | ||
Quote:
Quote:
|
| 05-18-2011, 03:29 AM | #7 |
Thank you, this script is really useful. |
