• 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.

[General] Selectable and Unselectable Units

Status
Not open for further replies.
Level 8
Joined
Sep 10, 2013
Messages
372
How do I make a unit unselectable?
Let's say a dummy unit that I don't want to be selected, or a unit that's hiding in the background and not supposed to be clickable yet. What do I do?
Edit: I want this also to include its health bar not appearing when I press Alt or hover my mouse over that unit. What should I do?
 
Level 13
Joined
Jan 2, 2016
Messages
978
Add "Locust" ability to the unit.
And remove it when you want it to become selectable (tho, in another thread, there was something 'interesting', suggesting that units still can't be selected even after removing the Locust, but I still haven't tested that)
 
Level 8
Joined
Sep 10, 2013
Messages
372
Okay it works fine, but here's something more interesting... It cannot be removed by triggers. It won't show up in the 'remove ability' ability list.
 
Level 8
Joined
Sep 10, 2013
Messages
372
I don't know how to use the unit in the trigger. I don't have much knowledge of custom scripts. Can you tell/teach me how?

EDIT: I tried some thing with the custom script error, and this is what I came up with: call UnitRemoveAbility(gg_unit_n614_0068, 'Aloc')
And that works. Can I learn or read about custom scripts?

EDIT2: Nevermind... Still unselectable even after using the custom script to remove the ability and getting the 'code' for the unit...
 
Ok, so this is how it works. A custom script is Jass but you are using it in the GUI form. Jass is the language of wc3. It stands for Just Another Scripting Syntax. The GUI version is

  • Unit - Add Locust to (triggering unit)
The Custom Script version looks like this:

  • Custom script: call UnitAddAbility(GetTriggerUnit(), 'Aloc')
Since we have no Locust in GUI we need the custom script.

So here we have (triggering unit) in the GUI which is translated to GetTriggerUnit() in Jass.

Also, the ability Locust has an ID number which is Aloc.

You can set these thing to variables like so:

  • Set UnitVariable = (Last created unit)
  • Custom script: set udg_IntegerVariable = 'Aloc'
udg stands for undeclared global. This is a variable. A variable can be anything. Like x is a variable in Algebra.
the prefix "udg_" must be used before a variable in Jass.

The Custom Script I showed you has 3 parts. Some scripts have fewer or more parts.

1. The call. This is what the function will do. Here is it "UnitAddAbility" pretty simple right?
2. The subject. This is the thing which the call will act upon. Here is it a unit.
3. The object. This is the object which will be added by the call to the subject. Here it is a number or "integer." (yes even though it is letters it is an integer, don't ask me why.)

In sum, Custom Script: call TheCall(TheSubject, TheObject).

  • Custom script: call UnitAddAbility(udg_UnitVariable, 'Aloc')
  • ------- Example using the variable -------
  • Custom script: call UnitAddAbility(GetLastCreatedUnit(), 'Aloc')
  • ------- Example using (last created unit) in Jass -------
  • Custom script: call UnitAddAbility(GetTriggerUnit(), 'Aloc')
  • ------- Example using (triggering unit) in Jass -------
  • Custom script: call UnitAddAbility(udg_UnitVariable, udg_IntegerVariable)
  • ------- Example using both variables -------
  • Custom script: call UnitRemoveAbility(udg_UnitVariable, udg_IntegerVariable)
  • ------- Example removing using both variables -------
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
About removing locust...
  • Actions
    • Set Unit = Footman 0001 <gen>
    • -------- - --------
    • -------- Here we add the locust ability: --------
    • Custom script: call UnitAddAbility(udg_Unit, 'Aloc')
    • -------- - --------
    • -------- Now we remove the locust ability: --------
    • Unit - Hide Unit
    • Custom script: call UnitRemoveAbility(udg_Unit, 'Aloc')
    • Unit - Unhide Unit
If you want to still be able to attack and/or target that unit and make it fight back, you need a slightly more advanced method to make it unselectable.
 
Status
Not open for further replies.
Top