• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Problems with Adding and Removing locust using Trigger

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
349
I creating an ability that it takes to charge towards a target unit thus I add locust to the unit. Then remove it after casting.
The problem is after I remove the locust ability, I can't select the caster but the enemies able to the caster. Weird!

I used the following functions because I can't find the locust ability in adding ability through trigger. Thus, I used trigger and then convert it to custom text and then I change the ability ID.
  • Custom script: call UnitAddAbilityBJ( 'Aloc', udg_C_caster[udg_C_index2] )
  • Custom script: call UnitRemoveAbilityBJ( 'Aloc', udg_C_caster[udg_C_index3] )
Is there any wrong with the above functions?
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
For removing use:
  • Unit - Hide C_caster[C_index3]
  • Custom script: call UnitRemoveAbilityBJ( 'Aloc', udg_C_caster[udg_C_index3] )
  • Unit - Unhide C_caster[C_index3]
However, I do not recommend unit Locust this way, it makes recastering any spell on given unit buggy.
 
Last edited:
Level 22
Joined
Nov 14, 2008
Messages
3,256
Test with

if UnitAddAbility(udg_C_caster[udg_C_index3], 'Aloc') then
call UnitRemoveAbility(udg_C_caster[udg_C_index3], 'Aloc')
endif

I think locust is autoremoved if I remember correctly if you just hid the unit and unhid it instantly afterwards. Try with that instead of the solution above.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
To completely remove the effects of locust, you must also use a transformation ability. You can base it on bear form. Set the alternate unit to some other hero.

  • Untitled Trigger 113
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set u = Paladin 0031 <gen>
      • Custom script: call UnitAddAbility(udg_u, 'Aloc')
      • Wait 1.00 seconds
      • Unit - Hide u
      • Custom script: call UnitRemoveAbility(udg_u, 'Aloc')
      • Unit - Unhide u
      • Unit - Add Bear Form Rem Loc to u
      • Unit - Order u to Night Elf Druid Of The Claw - Bear Form
      • Unit - Remove Bear Form Rem Loc from u
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Whats wrong? I gave a good egzample of removing locust, except Maker once again proofs to know how to fix every glich.

My bad, I meant my if state above that sentence :D

Maker didn't use the BJ, he used the native instead. The BJ calls the native so it's just a performance loss if you use it but in GUI it doesn't matter. (If you use custom script ofc you should avoid this.)
 
Status
Not open for further replies.
Top