HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

New BonusMod check it out.

07-23-2004, 02:00 AM#1
weaaddar
A new version of bonusmod. This one is simmilar to vex's version except that I added more methods and now I cache data about the hero's amount of bonus applied, this makes getBonus now a simple data access instead of a long ardous process of polling all abilities to check if the unit has it.

This varies from vex's version in that it does not care if you die from the bonus. It also will consider values greater then the BnsMax() value to be negative.

Bonus mod is a system which allows you to add arbitrary stats to units
which have no trigger methods of modifying these values. You can add both negative or positive values. In this demo map you can apply bonus values in the range of (-1024,1023)

The negative bonuses are done by a sign bit like in most C like langauges. (I.e. -1 in your 32 bit integer is actually represented as 11111111111111111111111111111111 in binary or 2^32-1 as an unsigned int). Basically I add in this demo map 2048 to your negative number to make it an unsigned value then it is buisness as ussual. The sign bit is considered in the demo map to hold a value of 1024 even though the ability actually holds a bonus of -1024.

BonusMod saving on abilities is achieved by bitflagging. Thanks to the fact that you can get any value with only one combination of 2 raised to a power you can use this to your advantage with some simple math. Item Abilities like damage bonus can stack, if they are two different abilities. So instead of creating one damage ability for a 200 bonus or a 50 bonus or a 124 bonus. I create a damage bonus for each incrementing powers (i.e. 1,2,4,8,16...) and then I add a sign bit of -1024 for my final part of the boolean unit.

When you use bonusmod it converts your amount you enter into booleans and determines which abilities it should add.

I hope you enjoy the new version.
07-29-2004, 11:21 PM#2
Vexorian
I checked it , I liked how it uses gamecache instead of that loop, just two problems:

If setBonus is called with 0 it should Flush the game cache entry.

A directly negative bonus of -300 automatically killed the 800 HP knight (that's surelly because of the order of adding the abilities
07-29-2004, 11:34 PM#3
weaaddar
you are right vex. I start the loop backward as its easier, I guess I can do it that it sets a bool if its greater then max value, then do it at the end.
09-09-2004, 07:59 PM#4
fugly
question... how can i up the max bonus?
09-09-2004, 08:55 PM#5
Raptor--
Quote:
Originally Posted by fugly
question... how can i up the max bonus?

haven't actually looked at the map, but i'm assuming create a new ability for the next power of 2 and extend the bit check + math
05-27-2005, 08:19 AM#6
EdwardSwolenToe
link is dead :(
06-02-2005, 04:15 AM#7
yuripro84
Quote:
Originally Posted by EdwardSwolenToe
link is dead :(
same for me?? Did you decide to close it and fix it or something? :(
06-03-2005, 04:03 AM#8
weaaddar
The attachment died.
I don't have a stand alone version of bonus mod any more. Just rip the one from DT4a. Its more updated then this one.
06-09-2005, 06:05 AM#9
EdwardSwolenToe
It still puzzles me how this system works. 1+2+4+8+16+32+64+128+256+512 = max value of 1023. So according to you, since these abilitys dont stack, how on earth do you get values higher than 1023?

Please dont tell me just to use the system, a whole part of learning is not copying, but actually creating your own. Ive tried to create my own, although it seems that these hp bonus abilitys arent able to be multi leveled. (eg one ability has levels up to 11 ranging from 0-1-2-4-8,.. etc.)

Your answer would be appreciated.
06-09-2005, 03:19 PM#10
weaaddar
Identical abilities don't stack. I.e. you can't add Damage Bonus +1 ('A000') twice. But you can add Damage Bonus +1 ('A000') and Damage Bonus +2 ('A001'), even though they are still the same base ability.
Secondly, using unique positive powers of two (2^0, 2^1...2^n where n is the highest power you have) you can combine them to create any value from 1 to 2^(n+1)-1. Finally, you can get negative numbers easily using a trick called the sign bit. Where you make the 2^n value negative. This keeps addition and subtraction working as you expect it, while allowing you a range of (-2^n) to -(2^(n)-1)

I still suggest using BonusMod as it handles overflows, and has an optimized getBonus method.
The proof of the effeciency of using powers of 2 for maximal range and minimal abilities, is in the jass vualt.
06-10-2005, 10:37 PM#11
Vexorian
Quote:
Originally Posted by EdwardSwolenToe
It still puzzles me how this system works. 1+2+4+8+16+32+64+128+256+512 = max value of 1023. So according to you, since these abilitys dont stack, how on earth do you get values higher than 1023?

Please dont tell me just to use the system, a whole part of learning is not copying, but actually creating your own. Ive tried to create my own, although it seems that these hp bonus abilitys arent able to be multi leveled. (eg one ability has levels up to 11 ranging from 0-1-2-4-8,.. etc.)

Your answer would be appreciated.
actually, the intention is to allow, not to directly teach, to teach it would have just been a sample script where it does that.

You would understand this if you are a programmer that wants to give the user an option to open files, you can spend your time making a whole new one or use that windows dll that allows to make one, theorically one shouldn't spend his time on making things that were already done, and should spend his time making new things that weren't done before and that's the purpose of functions withing the JASS vault or maps by weaaddar or me.