Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

Author Topic: InvulnerabilityChecker  (Read 2788 times)

  • Newbie - level 1
  • *
  • Posts: 13
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 0
  • Just a Man in the Back
    • View Profile
InvulnerabilityChecker
« on: September 04, 2016, 12:09:44 AM »
A simple snippet used to check if a unit is invulnerable. False positives from mana shields are also accounted for.

Code: jass  [Select]
  1. library InvulnerabilityChecker
  2.  
  3.     function CheckInvulnerability takes unit u returns boolean
  4.         local real origHP = GetWidgetLife(u)
  5.         local real origMP = GetUnitState(u, UNIT_STATE_MANA)
  6.         local boolean check
  7.         call UnitDamageTarget(u, u, 0.01, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
  8.         set check = GetWidgetLife(u) == origHP and GetUnitState(u, UNIT_STATE_LIFE) == origMP
  9.         call SetWidgetLife(u, origHP)
  10.         call SetUnitState(u, UNIT_STATE_MANA, origMP)
  11.         return check
  12.     endfunction
  13.  
  14. endlibrary
« Last Edit: September 04, 2016, 09:08:02 AM by AGD »

 

Blizzard Modding Information Center Starcraft II Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!