I tried to make a system, that works like bonus mod, but takes less space on my map, however I can't get it to work with negative values.
At first I had 12 skills for increasing the stats (can increase unit's stats by up to 4095 pts), and about 10 skill for reducing them (could reduce up to 1023 pts).
When I was putting the skills with negative values on units - nothing was happening.
Then I read somewhere that I should add a skill which adds 0 bonus pts, level it to lvl 2, which gives 4096 pts, and then - when I remove the skill, the unit should have -4096 pts of the stat.
However, this didn't work either.... the unit retains its original stat(s) when I try to reduce them..
Can anyone help me solve this?
Here is the trigger, if you wanna see it:
I know that I can't restore the unit's stat(s) with the trigger as it is now, but as soon as I find out how to make it work with negative values - I will fix it
EDIT: I just noticed that there are "SetHeroStr/Agi/Int" functions, so I wouldn't need those.. yet I still wanna know how to reduce unit's HP/damage/armor/mana..
At first I had 12 skills for increasing the stats (can increase unit's stats by up to 4095 pts), and about 10 skill for reducing them (could reduce up to 1023 pts).
When I was putting the skills with negative values on units - nothing was happening.
Then I read somewhere that I should add a skill which adds 0 bonus pts, level it to lvl 2, which gives 4096 pts, and then - when I remove the skill, the unit should have -4096 pts of the stat.
However, this didn't work either.... the unit retains its original stat(s) when I try to reduce them..
Can anyone help me solve this?
Here is the trigger, if you wanna see it:
JASS:
library BonusStats initializer SetValues
globals
private integer array BonusAbility
constant integer damage1 = 0
constant integer armor1 = damage1 + 12
constant integer health1 = armor1 + 12
constant integer agility1 = health1 + 15
constant integer intelligence1 = agility1 + 11
constant integer strength1 = intelligence1 + 11
constant integer damage2 = strength1 + 11
constant integer armor2 = damage2 + 1
constant integer health2 = armor2 + 1
constant integer agility2 = health2 + 1
constant integer intelligence2 = agility2 + 1
constant integer strength2 = intelligence2 + 1
endglobals
//! textmacro ChangeUnitStats takes NAME_ADD, CONST, MAX, NAME_REMOVE, REDUCTION_VALUE
function $NAME_ADD$ takes unit u, integer amount returns nothing
local integer i = 0
local boolean b = amount < 0
if b then
set amount = $REDUCTION_VALUE$ + amount
endif
loop
exitwhen amount == 0
if amount - (amount/2)*2 == 1 then
call UnitAddAbility(u, BonusAbility[$CONST$1 + i])
endif
set amount = amount/2
set i = i + 1
endloop
if b then
call UnitAddAbility(u, BonusAbility[$CONST$2])
call SetUnitAbilityLevel(u, BonusAbility[$CONST$2], 2)
call UnitRemoveAbility(u, BonusAbility[$CONST$2])
endif
endfunction
function $NAME_REMOVE$ takes unit u returns nothing
local integer i = $CONST$1
loop
exitwhen i > $CONST$1 + $MAX$
call UnitRemoveAbility(u, BonusAbility[$CONST$1 + i])
set i = i + 1
endloop
endfunction
//! endtextmacro
//! runtextmacro ChangeUnitStats("UnitAddDamage","damage","11","RemoveBonusDamage","4096")
//! runtextmacro ChangeUnitStats("UnitAddArmor","armor","11","RemoveBonusArmor","4096")
//! runtextmacro ChangeUnitStats("UnitAddHealth","health","14","RemoveBonusHealth","32768")
//! runtextmacro ChangeUnitStats("HeroAddAgility", "agility","10","RemoveBonusAgility","2048")
//! runtextmacro ChangeUnitStats("HeroAddIntelligence", "intelligence","10","RemoveBonusIntelligence","2048")
//! runtextmacro ChangeUnitStats("HeroAddStrength", "strength","10","RemoveBonusStrength","2048")
private function SetValues takes nothing returns nothing
set BonusAbility[0] = 'A05H' //1
set BonusAbility[1] = 'A05I' //2
set BonusAbility[2] = 'A05J' //4
set BonusAbility[3] = 'A05K' //8
set BonusAbility[4] = 'A05L' //16
set BonusAbility[5] = 'A05M' //32
set BonusAbility[6] = 'A05N' //64
set BonusAbility[7] = 'A05O' //128
set BonusAbility[8] = 'A05P' //256
set BonusAbility[9] = 'A05Q' //516
set BonusAbility[10] = 'A05R' //1024
set BonusAbility[11] = 'A05S' //2048
set BonusAbility[armor1] = 'A05T' //1
set BonusAbility[armor1 + 1] = 'A05U' //2
set BonusAbility[armor1 + 2] = 'A05V' //4
set BonusAbility[armor1 + 3] = 'A05W' //8
set BonusAbility[armor1 + 4] = 'A05X' //16
set BonusAbility[armor1 + 5] = 'A05Y' //32
set BonusAbility[armor1 + 6] = 'A05Z' //64
set BonusAbility[armor1 + 7] = 'A060' //128
set BonusAbility[armor1 + 8] = 'A061' //256
set BonusAbility[armor1 + 9] = 'A062' //516
set BonusAbility[armor1 + 10] = 'A063' //1024
set BonusAbility[armor1 + 11] = 'A064' //2048
set BonusAbility[health1] = 'A065' //1
set BonusAbility[health1 + 1] = 'A066' //2
set BonusAbility[health1 + 2] = 'A067' //4
set BonusAbility[health1 + 3] = 'A068' //8
set BonusAbility[health1 + 4] = 'A069' //16
set BonusAbility[health1 + 5] = 'A06A' //32
set BonusAbility[health1 + 6] = 'A06B' //64
set BonusAbility[health1 + 7] = 'A06C' //128
set BonusAbility[health1 + 8] = 'A06D' //256
set BonusAbility[health1 + 9] = 'A06E' //516
set BonusAbility[health1 + 10] = 'A06F' //1024
set BonusAbility[health1 + 11] = 'A06G' //2048
set BonusAbility[health1 + 12] = 'A06H' //4096
set BonusAbility[health1 + 13] = 'A06I' //8192
set BonusAbility[health1 + 14] = 'A06J' //16384
set BonusAbility[agility1] = 'A05E' //1
set BonusAbility[agility1 + 1] = 'A05F' //2
set BonusAbility[agility1 + 2] = 'A05G' //4
set BonusAbility[agility1 + 3] = 'A06K' //8
set BonusAbility[agility1 + 4] = 'A06L' //16
set BonusAbility[agility1 + 5] = 'A06M' //32
set BonusAbility[agility1 + 6] = 'A06N' //64
set BonusAbility[agility1 + 7] = 'A06O' //128
set BonusAbility[agility1 + 8] = 'A06P' //256
set BonusAbility[agility1 + 9] = 'A06Q' //512
set BonusAbility[agility1 + 10] = 'A06R' //1024
set BonusAbility[intelligence1] = 'A06T' //1
set BonusAbility[intelligence1 + 1] = 'A06U' //2
set BonusAbility[intelligence1 + 2] = 'A06V' //4
set BonusAbility[intelligence1 + 3] = 'A06W' //8
set BonusAbility[intelligence1 + 4] = 'A06X' //16
set BonusAbility[intelligence1 + 5] = 'A06Y' //32
set BonusAbility[intelligence1 + 6] = 'A06Z' //64
set BonusAbility[intelligence1 + 7] = 'A070' //128
set BonusAbility[intelligence1 + 8] = 'A071' //256
set BonusAbility[intelligence1 + 9] = 'A072' //512
set BonusAbility[intelligence1 + 10] = 'A073' //1024
set BonusAbility[strength1] = 'A074' //1
set BonusAbility[strength1 + 1] = 'A075' //2
set BonusAbility[strength1 + 2] = 'A076' //4
set BonusAbility[strength1 + 3] = 'A077' //8
set BonusAbility[strength1 + 4] = 'A078' //16
set BonusAbility[strength1 + 5] = 'A079' //32
set BonusAbility[strength1 + 6] = 'A07A' //64
set BonusAbility[strength1 + 7] = 'A07B' //128
set BonusAbility[strength1 + 8] = 'A07C' //256
set BonusAbility[strength1 + 9] = 'A07D' //512
set BonusAbility[strength1 + 10] = 'A07E' //1024
set BonusAbility[damage2] = 'A07G' //-4096
set BonusAbility[armor2] = 'A07F' //-4096
set BonusAbility[health2] = 'A07H' //-32768
set BonusAbility[agility2] = 'A07I' //-2048
set BonusAbility[intelligence2] = 'A07K' //-2048
set BonusAbility[strength2] = 'A07J' //-2048
endfunction
endlibrary
I know that I can't restore the unit's stat(s) with the trigger as it is now, but as soon as I find out how to make it work with negative values - I will fix it
EDIT: I just noticed that there are "SetHeroStr/Agi/Int" functions, so I wouldn't need those.. yet I still wanna know how to reduce unit's HP/damage/armor/mana..
Last edited: