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!
You can use something like the ObjectMerger and textmacros in the Jass NewGen Pack (tutorial link) to quickly make a 101-level passive Endurance Aura that only affects the caster, where each level gives an additional 1% attack speed. You could also create the ability manually but that's a lot of object editor bologna. Then just change its level via triggers to: (100 - <%life>) + 1, as an integer. Why the +1? Your attack speed ability has 101 levels (level 1 gives 0% level 101 gives 100%) and we don't want to crash trying to set the level of the ability to 0 when he has 100% life.
Realistically you do NOT need to run your loop every 0.01 seconds-- you can get away with 0.5 or maybe even 1.0 if you want and this will significantly reduce the strain on the system. This is the WHOLE trigger:
Berserker Rage Trigger
Events
Time - Every 0.5 seconds of game time
Conditions
Actions
Unit - Set level of <BERSERKER RAGE> for <OLAF> to ((Integer((100.00 - (Percentage Life of <OLAF>)))) + 1)
No problemo dude, gl and feel free to contact me via PM if you've got any questions. Starting to do more modding again so I'm itching to solve problems.
Instead of making an ability with 100 levels, you could simply have 7 different abilities of Item Attack Speed Bonus (Gloves of Haste) with 1 level each. I'd say that's much less data needed compared to having 1 ability with 100 levels. With these 7 abilities, you could possibly reach up until 127% increased attack speed (2^7 - 1). So the 7 abilities would have the following values:
Hence, total max attack speed would be 127%. How does this work? If you know binaries, then you can skip the explanation ahead.
Now, notice that each value of the abilities are powers of 2. Ability 1 has 2^0. Ability 2 has 2^1. And so the list goes on.
So let's say you want a value of 70%. You would have Abilities 7, 3, 2 added to your hero and the rest removed (64 + 4 + 2 = 70%).
How about a value like 53%? Would be Abilities 6, 5, 3, 1 added to your hero and the rest removed (32 + 16 + 4 + 1 = 53%).
So you may understand the logic somewhat, now to convert this logic into an actual program. Essentially, what you need to do is loop the number of times equal to the number of abilities that you have. For this case, you would loop a total of 7 times. In every loop, what you would do is to take your current value and divide by the ability's value. Since it's a division between integers, you will only get a return value of 1 or 0. Recall that decimal places are truncated/cut-off for integer division. So 100/64 would be 1 and 12/16 for example would be 0. If the value is a 1, you simply add that ability to the hero. On the flip side, if it's a zero, you remove the ability from the hero. Finally, you would take your current value and minus off the ability's value, only if the division value was 1. I don't currently have my WC3 Editor with me, so will write a simple pseudo-code instead:
JASS:
int i = 6 // number of loops to be performed (including 0)
int abilityVal = 2^i // which is 64 here
int currentVal = 77 // the value which you want to set it to
// assume that we have an array of integer called ABILITIES
// set up your abilities in an array, highest index should be your highest ability value:
ABILITIES[6] = <ability id of Ability 7>
ABILITIES[5] = <ability id of Ability 6>
ABILITIES[4] = <ability id of Ability 5>
ABILITIES[3] = <ability id of Ability 4>
ABILITIES[2] = <ability id of Ability 3>
ABILITIES[1] = <ability id of Ability 2>
ABILITIES[0] = <ability id of Ability 1>
loop
if (currentVal / abilityVal == 0) then
remove ABILITIES[i] from your hero
else
add ABILITIES[i] to your hero
currentVal = currentVal - abilityVal
endif
exitwhen i == 0 // we have successfully reached the end of the loop!
i = i - 1 // decrement our loop counter by 1
abilityVal = abilityVal / 2
endloop
So let's do a step by step of the loop for let's say a value of 73% desired attack speed.
Initial:
i = 6
abilityVal = 64
currentVal = 73
Loop 1:
So we first check if currentVal divided by abilityVal is equal to zero. 73 / 64 = 1, hence we add Ability 7 to our hero and we minus currentVal by abilityVal (73 - 64). Our hero now has a total of 64% attack speed. At the end of the loop:
i = 5
currentVal = 73- 64 = 9
abilityVal = 64 / 2 = 32
Loop 2:
Same thing as the first loop, check if currentVal divided by abilityVal is equal to zero. 9 / 32 = 0, hence we remove Ability 6 from our hero, and our currentVal is unchanged. Our hero still has a total of 64% attack speed. At the end of the loop:
i = 4
currentVal = 9
abilityVal = 32 / 2 = 16
Loop 3:
9 / 16 = 0, hence we remove Ability 5 from our hero, and our currentVal is unchanged. Our hero still has a total of 64% attack speed. At the end of the loop:
i = 3
currentVal = 9
abilityVal = 16 / 2 = 8
Loop 4:
9 / 8 = 1, hence we add Ability 4 to our hero and we minus currentVal by abilityVal (9 - 8). Our hero now has a total of 72% (64 + 8) attack speed. At the end of the loop:
i = 2
currentVal = 9 - 8 = 1
abilityVal = 8 / 2 = 4
Loop 5:
1 / 4 = 0, hence we remove Ability 3 from our hero, and our currentVal is unchanged. Our hero still has a total of 72% attack speed. At the end of the loop:
i = 1
currentVal = 1
abilityVal = 4 / 2 = 2
Loop 6:
1 / 2 = 0, hence we remove Ability 2 from our hero, and our currentVal is unchanged. Our hero still has a total of 72% attack speed. At the end of the loop:
i = 0
currentVal = 1
abilityVal = 2 / 2 = 1
Loop 7:
1 / 1 = 1, hence we add Ability 1 to our hero and we minus currentVal by abilityVal (1 - 1). Our hero now has a total of 73% (64 + 8 + 1) attack speed. The loop is then exited due to the exit condition.
Although this method might be more complex than having a single ability with 100 levels, but it's way more flexible. For example, you can add another ability, Ability 8 with the value of 128 and would push the attack speed limit up to 255. With 9 Abilities, you can reach 511 attack speed, which is past the attack speed limit of Warcraft (400%). So instead of potentially having an ability with 400 levels for the attack speed cap, you could have 9 Abilities with 1 level each. Hope this helps!
A single ability with 100 levels is like 1 line of an excel sheet having 100 x as many columns filled in-- it's certainly adding some tangible data to your file, but at the end of the day it's just an SLK (text in a grid) which is not a big deal. You're right that you can do it that way and it would be more space efficient, slightly decrease your map loading time, yadda yadda yadda, but you end up with a trigger that is an order of magnitude more complex. I mean mine's literally one line.
Pick your poison, though: complex trigger or additional OE data.
Also if you were to do this sort of thing for another unit as well with say different scaling on the speed buff (20% -> 150%) then you would absolutely want to do it with additive powers of two because it will be much easier to configure.
I didn't used Endurance Aura, since samr buffs don't stack. I've used Gloves of Haste just like Pyrogasm suggested. This post is Solved but thanks anyway.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.