vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

InvulnerabilityChecker

AGD · 4182

0 Members and 1 Guest are viewing this topic.

InvulnerabilityChecker
on: September 04, 2016, 12:09:44 AM
Category: Units
Language: vJASS

A simple snippet used to check if a unit is invulnerable. False positives from mana shields are also accounted for.

Code: jass
  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: December 19, 2017, 10:58:03 PM by moyack »



 

Power of Corruption - A Warcraft III altered melee map   Chaos Realm - The world of Game modders and wc3 addicts     WC3JASS.com - The JASS Vault   Jetcraft - A Starcraft II mod