• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Condition: Unit is invulrneable

Status
Not open for further replies.
Level 25
Joined
Jul 10, 2006
Messages
3,315
Got a working script:
  • CheckInvulnerabilityConfig
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set InvulnerableChecker = Peasant 0002 <gen>
      • Unit - Hide InvulnerableChecker
  • CheckInvulnerability
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Unit - Order InvulnerableChecker to Right-Click (Triggering unit)
      • Custom script: call SetUnitX(udg_InvulnerableChecker, GetUnitX(GetTriggerUnit()))
      • Custom script: call SetUnitY(udg_InvulnerableChecker, GetUnitY(GetTriggerUnit()))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of InvulnerableChecker) Equal to (Order(smart))
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of (Triggering unit)) + is vulnerable)
        • Else - Actions
          • Game - Display to (All players) the text: ((Name of (Triggering unit)) + is invulnerable)
      • Unit - Order InvulnerableChecker to Stop
Checks all forms of invulnerability.

I'm making this into both a GUI system and a callable vJASS snippet.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
rulerofiron99, are you sure it will work? because order smart is right click not only attack order(Im not going to test it but wonder if you tested it)

Yes I did test it. Quite thoroughly, actually.

Attached is the GUI system, it's a single trigger that you use by setting a unit variable to the unit you want to test, and then running a trigger which sets a boolean.

Below is the vJASS script:
JASS:
library InvulnerabilityCheck initializer Init
    globals
        private unit InvulnerabilityChecker //unit we'll use to test targets
    endglobals
    
    private function Init takes nothing returns nothing //create our checking unit
        set InvulnerabilityChecker = CreateUnit(Player(12), 'hpea', 0, 0, 0)
        call ShowUnit(InvulnerabilityChecker, false)
    endfunction
    
    function IsUnitInvulnerable takes unit u returns boolean
        call IssueTargetOrder(InvulnerabilityChecker, "smart", u)
        if (GetUnitCurrentOrder(InvulnerabilityChecker) == 851971) then
            call IssueImmediateOrder(InvulnerabilityChecker, "stop" )
            return false
        else
            call IssueImmediateOrder(InvulnerabilityChecker, "stop" )
            return true
        endif
    endfunction
endlibrary

And the script that also checks for neutral passive invulnerability:
JASS:
library InvulnerabilityCheck initializer Init
    globals
        private unit InvulnerabilityChecker //unit we'll use to test targets
    endglobals
    
    private function Init takes nothing returns nothing //create our checking unit
        set InvulnerabilityChecker = CreateUnit(Player(12), 'hpea', 0, 0, 0)
        call ShowUnit(InvulnerabilityChecker, false)
    endfunction
    
    function IsUnitInvulnerable takes unit u returns boolean
        if (GetOwningPlayer(u) == Player(15)) then //for neutral passive compatibility
            call SetPlayerAlliance( Player(12), Player(15), ALLIANCE_PASSIVE, false)
        endif
        call IssueTargetOrder(InvulnerabilityChecker, "smart", u)
        if (GetUnitCurrentOrder(InvulnerabilityChecker) == 851971) then
            call IssueImmediateOrder(InvulnerabilityChecker, "stop" )
            if (GetOwningPlayer(u) == Player(15)) then
                call SetPlayerAlliance( Player(12), Player(15), ALLIANCE_PASSIVE, true)
            endif
            return false
        else
            call IssueImmediateOrder(InvulnerabilityChecker, "stop" )
            if (GetOwningPlayer(u) == Player(15)) then
                call SetPlayerAlliance( Player(12), Player(15), ALLIANCE_PASSIVE, true)
            endif
            return true
        endif
    endfunction
endlibrary

IMPORTANT:
Neutral Hostile must be hostile towards the owner of the unit you are checking.

EDIT: Whoops, forgot to attach. Attached now.
 

Attachments

  • CheckInvulnerability.w3x
    17.8 KB · Views: 70
Last edited:
Level 25
Joined
Jul 10, 2006
Messages
3,315
What Kitabatake did there, was sufficient enough to check invulnerabilities.
You don't have to overcomplicate things, though.

Checking the level of an ability doesn't check:
  • Divine Shield / Potion of Invulnerability
  • Big Bad Voodoo
  • Units in cyclone

Surprisingly, that method does check for units made invulnerable using
  • Unit - Make unit invulnerable
Well we don't know exactly what OP will be using this for; if he's just checking for units that are normally invulnerable then yes this is overcomplicated for his purposes, but you say that as if my method is a waste of time.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
The simple way is checking for buff and abilities do often suffice.


But there is 2 ways of complete invulnerability detection.

  1. Make a quick order/ability cast check like rulerofiron99 showed you here.

  2. The other instant solution would be instant 1 normal damage, and if target doesn't have 1 life less, its invulnerable. WC3 minimum damage is 1. However does would disable sleep and other temporary conditions.

  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to PhaseWave (Damage)
    • Actions
      • Set Temp_Point = (Position of (Triggering unit))
      • Set Temp_Group = (Units within 700.00 of Temp_Point)
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Unit = (Picked unit)
          • Set Temp_Real = (Life of Temp_Unit)
          • Unit - Cause (Triggering unit) to damage Temp_Unit, dealing 1.00 damage of attack type Chaos and damage type Normal
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real Greater than (Life of Temp_Unit)
            • Then - Actions
              • Unit Group - Add Temp_Unit to TargetGroup
            • Else - Actions
          • Unit - Set life of Temp_Unit to ((Life of Temp_Unit) + 1.00)
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • Unit Group - Pick every unit in TargetGroup and do (Actions)
        • Loop - Actions
          • Do your setup HERE reffering to picked unit
 
Status
Not open for further replies.
Top