HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detecting Buff Level

05-14-2007, 04:33 AM#1
Falitian
I'm creating an ability that will add a buff that adds +1 armor every time the hero is attacked and will stack to a certain point. Currently thing all works fine, except for the stacking part. I am unable to detect the current rank of the buff that the unit has, so that I can have a spell with a rank of (current rank) +1.

All that I need to make this work is a method of detecting the current rank of the buff that is on the unit.

I generally work in GUI, but I understand Jass well enough to implement code as well.
05-14-2007, 04:56 AM#2
MaD[Lion]
i dont think buffs has rank
05-14-2007, 04:59 AM#3
Pyrogasm
You can't get the level of a buff, even though it says "Level X" in game on the buff tooltip. The best you can do is create different buffs for each level and add them to an array where the index corresponds with the level of the buff.

Then, loop through that array until you find a match and know what buff the unit has.
05-14-2007, 05:04 AM#4
Dil999
I did an ability which stacks the same way you want it to; What I did was use an integer variable, and Set the level of the casted ability to increase armor to the integer, then increase the integer by 1.
05-14-2007, 05:20 AM#5
Pyrogasm
Quote:
Originally Posted by Dil999
I did an ability which stacks the same way you want it to; What I did was use an integer variable, and Set the level of the casted ability to increase armor to the integer, then increase the integer by 1.
Yes, but that's not MUI. Not even MPI, either.
05-14-2007, 05:32 AM#6
Dil999
You could easily make it MUI by using a unit array and integer array, and then doing a loop and checking if Attack unit equal to Unit[Integer A] and if it is, do actions.
05-15-2007, 01:52 AM#7
Falitian
What if I used a set of buffs, where each rank has a buff named the integer that it corresponds to. This way, I should be able to use the "conversion sting to integer" to find the pseudo-rank of the buff and then use that to configure what the next buff to be applied should be. Would this work? I would test it myself now, but I am unable to get to a computer running Wc3 at the moment.
05-15-2007, 06:00 AM#8
Pyrogasm
Yeah, Fatalitan, that would work. You'd probably have to use a substring so that you could have "YourBuff X", where X being the level.
05-23-2007, 07:48 PM#9
TheRipper164
You can get the lvl of a buff using Jass:
Collapse JASS:
native function GetUnitAbilityLevel takes unit witchunit, integer abilcode returns integer
this works because if you detect whether a buff from a unit, you use
Collapse JASS:
function UnitHasBuffBJ takes unit witchUnit, integer buffcode returns boolean
But this code just detect if the ability(buff)lvl is less then 0 :
Collapse JASS:
return GetUnitAbilityLevel(witchUnit, buffcode) > 0
05-23-2007, 07:56 PM#10
ThaRebel
As i did the same thing hereby some things you can do:

1. Link the buff level to a techlevel.
2. then check the (opponents)players.researchtechlevel
05-23-2007, 11:31 PM#11
Pyrogasm
Quote:
Originally Posted by TheRipper164
You can get the lvl of a buff using Jass:
Collapse JASS:
native function GetUnitAbilityLevel takes unit witchunit, integer abilcode returns integer
this works because if you detect whether a buff from a unit, you use
Collapse JASS:
function UnitHasBuffBJ takes unit witchUnit, integer buffcode returns boolean
But this code just detect if the ability(buff)lvl is less then 0 :
Collapse JASS:
return GetUnitAbilityLevel(witchUnit, buffcode) > 0
Sorry, but that is 100% false. GetUnitAbilityLevel() called on a buff's rawcode will simply return 1 if the unit has the buff and 0 if it doesn't have it.
Quote:
Originally Posted by ThaRebel
As i did the same thing hereby some things you can do:

1. Link the buff level to a techlevel.
2. then check the (opponents)players.researchtechlevel
Yes, but that only works for one unit per player.


And I'm pretty sure Fatalian got his quesion answered long ago...