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

Add an ability to unit aslong as it has a special buff!

Status
Not open for further replies.
Level 14
Joined
Jul 19, 2007
Messages
772
Is there possible to add an ability to an unit with a special buff and remove it when it loses the buff? I would like to do an aura that gives them demolish as long as they have the buff and remove it instantly when the buff is gone. Can anyone help me with this and send me a map with the triggers so I can paste it in to mine?
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
EDIT
  • Buff Check
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (YourUnit has buff YourBuff) Equal to True
        • Then - Actions
          • Unit - Add YourAbility to YourUnit
        • Else - Actions
          • Unit - Remove YourAbility from YourUnit
YourBuff: A Buff variable, YourUnit: A Unit variable.
 
Level 14
Joined
Jul 19, 2007
Messages
772
EDIT
  • Buff Check
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (YourUnit has buff YourBuff) Equal to True
        • Then - Actions
          • Unit - Add YourAbility to YourUnit
        • Else - Actions
          • Unit - Remove YourAbility from YourUnit
YourBuff: A Buff variable, YourUnit: A Unit variable.

Many thanks! This will really help me to make my own auras! Just one question. Do I have to set those variables first? How then?
 
Level 7
Joined
Dec 19, 2008
Messages
276
Well, you must pick all units on map with checking condition and after that adding ability.

For timer i recommend 1 sec.

And it can be done better in Jass, i can write for you, if you want.

if you know what is "raw-code"...

And it's not so easy, you must add units with ability to group and with another timer check buffs, if they don't have buff - remove ability.

Also there can be levels of ability.

Well huh... it requires some knowledge about you map and much better, if you learn jass. :p

PS: Better - use TWO global timers(For adding and removing buff) than creating triggers with events and conditions.
 
Level 14
Joined
Jul 19, 2007
Messages
772
Well, you must pick all units on map with checking condition and after that adding ability.

For timer i recommend 1 sec.

And it can be done better in Jass, i can wrote for you, if you want.

if you know what is "raw-code"...

And it's not so easy, you must add units with ability to group and with another timer check buffs, if they don't have buff - remove ability.

Also there can be levels of ability.

Well huh... it requires some knowledge about you map and much better, if you learn jass. :p

Yes I know Raw-Code but I dunno JASS. Please send me the script and allow it to be on 4 lvls.
 
Level 7
Joined
Dec 19, 2008
Messages
276
JASS:
globals
timer TimerBuff=CreateTimer()
group BuffGroup
boolexpr FilterB
endglobals
// Ranger21 Code :P
function AddBuff takes nothing returns nothing
if GetUnitAbilityLevel(GetFilterUnit(), 'BUau')>0 then //Buff Raw-code ^^^
call UnitAddAbility(GetEnumUnit(),'ANb2')//Ability Raw-code !
call SetUnitAbilityLevel(GetEnumUnit(),'ANb2',level)//Ability Raw-code !
endif
endfunction

function FilterBuff takes nothing returns boolean
if IsUnitInGroup(GetFilterUnit(),BuffGroup) and GetUnitAbilityLevel(GetFilterUnit(), 'BUau') == 0 then //Buff Raw-code ^^^
call GroupRemoveUnit(BuffGroup,GetFilterUnit())
call UnitRemoveAbility(GetFilterUnit(),'ANb2')
endif
return GetUnitAbilityLevel(GetFilterUnit(), 'BUau') > 0 //Buff Raw-code ^^^
endfunction

function CheckBuff takes nothing returns nothing
call GroupEnumUnitsInRect(BuffGroup, bj_mapInitialPlayableArea, FilterB)
call ForGroup(BuffGroup,function AddBuff)
endfunction

//===========================================================================
function InitTrig_AddBuff takes nothing returns nothing
set FilterB=Condition(function FilterBuff)
call TimerStart(TimerBuff,1,true,function CheckBuff)
endfunction


That very simple script, but many raw-codes :), you need write you buff and ability raw-codes.

Enjoy, and it is leakless, requires vJass for global boolexpr!

And it is one timer-using.

Must work with all levels of buff. (IF buff have levels > 1, i dunno, maybe some buffs have only one level for all ability levels...)

Do you have Jass Gen New Pack?
 
Last edited:
Level 14
Joined
Jul 19, 2007
Messages
772
JASS:
globals
timer TimerBuff=CreateTimer()
group BuffGroup
boolexpr FilterB
endglobals
// Ranger21 Code :P
function AddBuff takes nothing returns nothing
if GetUnitAbilityLevel(GetFilterUnit(), 'BUau')>0 then //Buff Raw-code ^^^
call UnitAddAbility(GetEnumUnit(),'ANb2')//Ability Raw-code !
call SetUnitAbilityLevel(GetEnumUnit(),'ANb2',level)//Ability Raw-code !
endif
endfunction

function FilterBuff takes nothing returns boolean
if IsUnitInGroup(GetFilterUnit(),BuffGroup) and GetUnitAbilityLevel(GetFilterUnit(), 'BUau') == 0 then //Buff Raw-code ^^^
call GroupRemoveUnit(BuffGroup,GetFilterUnit())
call UnitRemoveAbility(GetFilterUnit(),'ANb2')
endif
return GetUnitAbilityLevel(GetFilterUnit(), 'BUau') > 0 //Buff Raw-code ^^^
endfunction

function CheckBuff takes nothing returns nothing
call GroupEnumUnitsInRect(BuffGroup, bj_mapInitialPlayableArea, FilterB)
call ForGroup(BuffGroup,function AddBuff)
endfunction

//===========================================================================
function InitTrig_AddBuff takes nothing returns nothing
set FilterB=Condition(function FilterBuff)
call TimerStart(TimerBuff,1,true,function CheckBuff)
endfunction


That very simple script, but many raw-codes :), you need write you buff and ability raw-codes.

Enjoy, and it is leakless, requires vJass for global boolexpr!

And it is one timer-using.

Must work with all levels of buff. (IF buff have levels > 1, i dunno, maybe some buffs have only one level for all ability levels...)

Do you have Jass Gen New Pack?

What do you mean with // Ranger21 Code ?? And do I delete the "BUau" script and insert the code of my buffs instead?
 
Level 14
Joined
Jul 19, 2007
Messages
772
I have made like this but I get error...I have taken the code of the buff I wanted and the ability I want to add to the unit if it got the buff. What's wrong? Can anyone post a map with those triggers script as working?

JASS:
globals
timer TimerBuff=CreateTimer()
group BuffGroup
boolexpr FilterB
endglobals
// Ranger21 Code :P
function AddBuff takes nothing returns nothing
if GetUnitAbilityLevel(GetFilterUnit(), 'BEar')>0 then //Buff Raw-code ^^^
call UnitAddAbility(GetEnumUnit(),'ANde')//Ability Raw-code !
call SetUnitAbilityLevel(GetEnumUnit(),'ANde',level)//Ability Raw-code !
endif
endfunction
function FilterBuff takes nothing returns boolean
if IsUnitInGroup(GetFilterUnit(),BuffGroup) and GetUnitAbilityLevel(GetFilterUnit(), 'BEar') == 0 then //Buff Raw-code ^^^
call GroupRemoveUnit(BuffGroup,GetFilterUnit())
call UnitRemoveAbility(GetFilterUnit(),'ANde')
endif
return GetUnitAbilityLevel(GetFilterUnit(), 'BEar') > 0 //Buff Raw-code ^^^
endfunction
function CheckBuff takes nothing returns nothing
call GroupEnumUnitsInRect(BuffGroup, bj_mapInitialPlayableArea, FilterB)
call ForGroup(BuffGroup,function AddBuff)
endfunction
//===========================================================================
function InitTrig_AddBuff takes nothing returns nothing
set FilterB=Condition(function FilterBuff)
call TimerStart(TimerBuff,1,true,function CheckBuff)
endfunction
 
Level 14
Joined
Jul 19, 2007
Messages
772
I got it to work now. I made like this
  • Siege Aura
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Full map region <gen>) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Siege Aura ) Equal to True
            • Then - Actions
              • Unit - Add Siege Aura (Adding Ability) to (Picked unit)
            • Else - Actions
              • Unit - Remove Siege Aura (Adding Ability) from (Picked unit)
It works fine thx for all help!
 
Level 4
Joined
Jun 16, 2009
Messages
92
Understand that... picking every unit in the entire map, depending on how many units you have out, is taxing on the system's resources. (As common sense would dictate, don't quote me on anything.)

You also leak a unit group.

If you 'have' to do it this way, at least...

Set TempUnitGroupVariable = Every unit in playable map region matching condition (Picked unit has specific buff WhateverBuffName)
Loop Actions
If Then Else
If Picked unit has buff = True & Level of Siege Aura < 1 (less than one)
Then
Add Siege Aura to picked unit
Else
Remove siege aura from picked unit

And at the end of the trigger, destroy the TempUnitGroup Variable.
I don't feel like finding the custom script for it right now, but it's in the "Things That Leak" stickie thread.

This way, you're not stacking the same ability on the unit over and over and over.
 
Level 14
Joined
Jul 19, 2007
Messages
772
Understand that... picking every unit in the entire map, depending on how many units you have out, is taxing on the system's resources. (As common sense would dictate, don't quote me on anything.)

You also leak a unit group.

If you 'have' to do it this way, at least...

Set TempUnitGroupVariable = Every unit in playable map region matching condition (Picked unit has specific buff WhateverBuffName)
Loop Actions
If Then Else
If Picked unit has buff = True & Level of Siege Aura < 1 (less than one)
Then
Add Siege Aura to picked unit
Else
Remove siege aura from picked unit

And at the end of the trigger, destroy the TempUnitGroup Variable.
I don't feel like finding the custom script for it right now, but it's in the "Things That Leak" stickie thread.

This way, you're not stacking the same ability on the unit over and over and over.
Can u please help me with this? I have played with my map with the triggers I used but it causes lag and sometimes crashes my game becase it's adding the ability over and over again. I need it to not add the ability if the unit already have it but still remove it if it loses the aura buff...
 
Status
Not open for further replies.
Top