• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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