• 🏆 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!

[vJASS] UnitAddAbility and UnitRemoveAbility

Status
Not open for further replies.
Level 9
Joined
Aug 26, 2010
Messages
573
Guy, I have a problem :|
Every such piece of code doesn't add second ability...
Both abilities with such IDs exist in my map but after this code execution first ability is deleted and second isn't added.
JASS:
call UnitRemoveAbility(GetSpellAbilityUnit(), 'SFiE')
call UnitAddAbility(GetSpellAbilityUnit(), 'DFiE')
I need this working to make a toggling spell.
 
Level 10
Joined
Mar 31, 2009
Messages
732
I wonder that the GetSpellAbilityUnit() is changing. Could you test this by changing that function to:

JASS:
  private function EnrageCast takes nothing returns nothing
       local unit caster = GetSpellAbilityUnit()
    set hPlayerHero[GetPlayerId(GetOwningPlayer(caster))].damageModifier = SCOPE_PRIVATE + "Enrage"
    call UnitRemoveAbility(caster, 'SFiE')
    call UnitAddAbility(caster, 'DFiE')
  endfunction

and let me know if anything changes. If not, when running your map, how do I test this?
 
Level 9
Joined
Aug 26, 2010
Messages
573
LOL, it works now.
About description - changed "loose" to "spend". Sorry, eng isn't my native language :D

Without any providen code i'm not going to believe you (you probably don't care though)
Look this maps code.
You are free to try it.
To change class change variable in the bottom of onInit function. They are listed just before hero creation.
 
Status
Not open for further replies.
Top