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

[Solved] Trigger to turn off chemical rage type spell prematurely

Level 30
Joined
Aug 29, 2012
Messages
1,386
I would've thought so yeah. Perhaps the "remove specific buff" function would get rid of it, but it might just be one of those abilities that don't obey the laws...

I think replacing the hero with the same unit type and transfering items would solve the issue completely albeit could pose additional challenges
 
Level 12
Joined
Jul 5, 2014
Messages
551
I would've thought so yeah. Perhaps the "remove specific buff" function would get rid of it, but it might just be one of those abilities that don't obey the laws...

I think replacing the hero with the same unit type and transfering items would solve the issue completely albeit could pose additional challenges
Maybe that would require a complete overhaul because the morphing seems to messing with trigger given abilities.
 
Level 30
Joined
Aug 29, 2012
Messages
1,386
Pardon my JASS but I think the function looks like this

  • Custom script : call UnitMakeAbilityPermanent(GetTriggerUnit(), true, AbilityID)
Where you can replace GetTriggerUnit() by a variable if your hero is stored in there (for example udg_MyHero) and you need the rawcode of your spell between ' ' for the ability ID
 
Level 12
Joined
Jul 5, 2014
Messages
551
Pardon my JASS but I think the function looks like this

  • Custom script : call UnitMakeAbilityPermanent(GetTriggerUnit(), true, AbilityID)
Where you can replace GetTriggerUnit() by a variable if your hero is stored in there (for example udg_MyHero) and you need the rawcode of your spell between ' ' for the ability ID
The ability has to be all the ability I want to be permanent? It's a bit tricky because I have 4 spellbooks, 4 placeholder abilities and each spellbook has 2 dummy abilities and by clicking on them, you learn the real ability via engineer upgrade. So, I wonder what are the stuff I need to place to the ability ID.
 
Level 14
Joined
Jan 10, 2023
Messages
256
What version are you using? Do Blz natives work for you?
This is what I use to cancel abilities, although I use it as an event response so I re-wrote it now to take arguments instead of GetTriggerStuff.
That being said, you may not be interested in the mana refund aspect, but I think that is simple to remove if you want to.

2 things I have to point out:
  1. This is not good for item abilities
  2. Almost all of my use of this has been with Channel based abilities, so I would test it to be safe.
If I wrote this for the first time today, I probably would have named my variables and functions differently, feel free to change those, you probably will want to...
JASS:
library CAS

    globals
        private timer CAS_SUA_T // Timer
        private integer CAS_SUA_N = 0 // List size
        private integer array CAS_SUA_A // SpellId
        private integer array CAS_SUA_C // Mana Cost
        private unit array CAS_SUA_U // Caster
    endglobals

//////////////////

    private function CAS_SUA_TF takes nothing returns nothing
        local integer i = 0
        loop
            call BlzUnitDisableAbility( CAS_SUA_U[i], CAS_SUA_A[i], false, false )
            if CAS_SUA_C[i] > 0 then
                call SetUnitState( CAS_SUA_U[i], UNIT_STATE_MANA, GetUnitState( CAS_SUA_U[i], UNIT_STATE_MANA ) + CAS_SUA_C[i] )
            endif
            set CAS_SUA_A[i] = 0
            set CAS_SUA_C[i] = 0
            set CAS_SUA_U[i] = null
            set i = i + 1
            exitwhen i > CAS_SUA_N
        endloop
        set CAS_SUA_N = 0
    endfunction

//////////////////

    function CAS_StopUnitAbility takes unit whichUnit, integer abilityId, boolean refund returns nothing
        local integer i = CAS_SUA_N
        call BlzUnitDisableAbility( whichUnit, abilityId, true, false )
        set CAS_SUA_U[i] = whichUnit
        set CAS_SUA_A[i] = abilityId
        if refund then
            set CAS_SUA_C[i] = BlzGetUnitAbilityManaCost( whichUnit, abilityId, GetUnitAbilityLevel( whichUnit, abilityId ) - 1 )
        endif
        set CAS_SUA_N = i + 1
        call TimerStart( CAS_SUA_T, 0.00, false, function CAS_SUA_TF )
    endfunction

endlibrary
 
Level 12
Joined
Jul 5, 2014
Messages
551
What version are you using? Do Blz natives work for you?
This is what I use to cancel abilities, although I use it as an event response so I re-wrote it now to take arguments instead of GetTriggerStuff.
That being said, you may not be interested in the mana refund aspect, but I think that is simple to remove if you want to.

2 things I have to point out:
  1. This is not good for item abilities
  2. Almost all of my use of this has been with Channel based abilities, so I would test it to be safe.
If I wrote this for the first time today, I probably would have named my variables and functions differently, feel free to change those, you probably will want to...
JASS:
library CAS

    globals
        private timer CAS_SUA_T // Timer
        private integer CAS_SUA_N = 0 // List size
        private integer array CAS_SUA_A // SpellId
        private integer array CAS_SUA_C // Mana Cost
        private unit array CAS_SUA_U // Caster
    endglobals

//////////////////

    private function CAS_SUA_TF takes nothing returns nothing
        local integer i = 0
        loop
            call BlzUnitDisableAbility( CAS_SUA_U[i], CAS_SUA_A[i], false, false )
            if CAS_SUA_C[i] > 0 then
                call SetUnitState( CAS_SUA_U[i], UNIT_STATE_MANA, GetUnitState( CAS_SUA_U[i], UNIT_STATE_MANA ) + CAS_SUA_C[i] )
            endif
            set CAS_SUA_A[i] = 0
            set CAS_SUA_C[i] = 0
            set CAS_SUA_U[i] = null
            set i = i + 1
            exitwhen i > CAS_SUA_N
        endloop
        set CAS_SUA_N = 0
    endfunction

//////////////////

    function CAS_StopUnitAbility takes unit whichUnit, integer abilityId, boolean refund returns nothing
        local integer i = CAS_SUA_N
        call BlzUnitDisableAbility( whichUnit, abilityId, true, false )
        set CAS_SUA_U[i] = whichUnit
        set CAS_SUA_A[i] = abilityId
        if refund then
            set CAS_SUA_C[i] = BlzGetUnitAbilityManaCost( whichUnit, abilityId, GetUnitAbilityLevel( whichUnit, abilityId ) - 1 )
        endif
        set CAS_SUA_N = i + 1
        call TimerStart( CAS_SUA_T, 0.00, false, function CAS_SUA_TF )
    endfunction

endlibrary
I'm on 1.26 and I have practically no clue about JASS. However, it turned out that the morphing's messing with triggered abilities is a bigger issue than the buff removal because all of the hero's abilities are added via trigger.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
The method described here is the same one I suggested in one of our first PM threads. Same logic applies: only has to be done to each ability once after it is added (and it sounds like you know exactly when each ability is added since you’re doing it yourself?).
 
Level 12
Joined
Jul 5, 2014
Messages
551
The method described here is the same one I suggested in one of our first PM threads. Same logic applies: only has to be done to each ability once after it is added (and it sounds like you know exactly when each ability is added since you’re doing it yourself?).
It seems to work now but the spellbook made things tricky because it should disappear upon choosing ability and the unit got it back during morphing and after turning back.
 
Top