Zalinian
New Member
- Reaction score
- 0
For some reason jass doesn't like multiple IF statements next to each other if they involve similar comparison types. I can't seem to get this working properly. Can anyone fix this or does anyone know of a better way to split a number's digits(ex: 1234 would become 1, 2 ,3 ,4 with each set to its own variable. This way I can measure ones, tens, hundreds, thousands, etc)
This my coding for a bonus system btw. Once the abilities are set up, simply call the function with the target unit, the number, and the bonus type (damage, armor, etc) and bam. Currently only damage is added in. It's also set to cap at 9999.
This my coding for a bonus system btw. Once the abilities are set up, simply call the function with the target unit, the number, and the bonus type (damage, armor, etc) and bam. Currently only damage is added in. It's also set to cap at 9999.
JASS:
// Bonus System
function bonus_add takes unit target, integer bonus_num, string bonus_type returns nothing
local integer num
local integer thousand
local integer hundred
local integer ten
local integer one
local integer array skill
if bonus_type == "damage" then
set skill[1] = 039;A00U039;
set skill[2] = 039;A00V039;
set skill[3] = 039;A00P039;
set skill[4] = 039;A00I039;
endif
if bonus_num < 10000 then
set num = bonus_num
if num >= 1000 then
set thousand = num / 1000
set num = num - (thousand * 1000)
endif
if num >= 100 then
set hundred = num / 100
set num = num - (hundred * 100)
endif
if num >= 10 then
set ten = num / 10
set num = num - (ten * 10)
endif
if num >= 1 then
set one = num / 1
set num = num - (one * 1)
endif
else
set thousand = 9
set hundred = 9
set ten = 9
set one = 9
endif
call BJDebugMsg(I2S(thousand))
call BJDebugMsg(I2S(hundred))
call BJDebugMsg(I2S(ten))
call BJDebugMsg(I2S(one))
if thousand > 0 then
call UnitAddAbility(target, skill[4])
call SetUnitAbilityLevel(target, skill[4], thousand)
call UnitMakeAbilityPermanent(target, true, skill[4])
endif
if hundred > 0 then
call UnitAddAbility(target, skill[3])
call SetUnitAbilityLevel(target, skill[3], hundred)
call UnitMakeAbilityPermanent(target, true, skill[3])
endif
if ten > 0 then
call UnitAddAbility(target, skill[2])
call SetUnitAbilityLevel(target, skill[2], ten)
call UnitMakeAbilityPermanent(target, true, skill[2])
endif
if one > 0 then
call UnitAddAbility(target, skill[1])
call SetUnitAbilityLevel(target, skill[1], one)
call UnitMakeAbilityPermanent(target, true, skill[1])
endif
endfunction