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

I can't use 'Add Locust to Unit'?

Status
Not open for further replies.
Level 4
Joined
Nov 6, 2011
Messages
44
I am in the middle of a spell which involves making the caster untargetable and with no collision. When making the part which involves adding Locust to the casting unit, I couldn't find it.


Where is Locust?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You can't. Use the custom script.

'Aloc' is the Ability ID of Locust. And, as hard as it may be to understand, it's an integer value (a number).
  • Custom script: call UnitAddAbility(YOURUNIT, 'Aloc')
  • ------- Example -------
  • Custom script: call UnitAddAbility(GetLastCreatedUnit(), 'Aloc')
  • ------- Example -------
  • Custom script: call UnitAddAbility(GetTriggerUnit(), 'Aloc')
  • ------- Example -------
  • Set UnitVariable = (Last created unit)
  • Custom script: set udg_IntegerVariable = 'Aloc'
  • Custom script: call UnitAddAbility(udg_UnitVariable, udg_IntegerVariable)
 
Level 4
Joined
Nov 6, 2011
Messages
44
You can't. Use the custom script.

'Aloc' is the Ability ID of Locust. And, as hard as it may be to understand, it's an integer value (a number).
  • Custom script: call UnitAddAbility(YOURUNIT, 'Aloc')
  • ------- Example -------
  • Custom script: call UnitAddAbility(GetLastCreatedUnit(), 'Aloc')
  • ------- Example -------
  • Custom script: call UnitAddAbility(GetTriggerUnit(), 'Aloc')
  • ------- Example -------
  • Set UnitVariable = (Last created unit)
  • Custom script: set udg_IntegerVariable = 'Aloc'
  • Custom script: call UnitAddAbility(udg_UnitVariable, udg_IntegerVariable)

Thanks. The adding part works but now I need a way to remove 'Locust' from the unit. I tried 'UnitRemoveAbility' instead of 'UnitAddAbility', but it doesn't work. How do I remove it?
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
JASS:
native UnitRemoveAbility takes unit whichUnit, integer abilityId returns boolean

It should work...
The syntax works like this:

JASS:
call UnitRemoveAbility(udg_UnitVariable, udg_IntegerVariable)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Probably because units with locust sometimes can't be manipulated with triggers. The safest way is to add the unit to a variable, or work with the unit index, or a hashtable, or uni ID, or add the unit to a unit group and look for the unit in that group.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
To remove Locust from a unit that is already Locust;
1. Hide the unit
2. While the unit is hidden, do the JASS function of UnitRemoveAbility to remove the Locust call UnitRemoveAbility(udg_Unit, 'Aloc')
3. Unhide the unit
4. Poof, you have partially complete remove the Locust of the unit.

Try download the test map below.

NOTE: Once you have done this, there is a minor bug which will affect the unit;
- Some spell does not properly target/hit the unit
- You can no longer click the unit to select it, you must drag-select the unit
 

Attachments

  • Simple Locust Removal System.w3x
    12.3 KB · Views: 82
Status
Not open for further replies.
Top