• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] seting unit lvl doesnt work right

Status
Not open for further replies.
hello for some reason this isnt setting the unit spawned to lvl 10,000 and yes i did change max lvl in the gameplay constant lvl to 10,000 it worked fine b4 but for some reason it stopped working i may of messed something up when redoing the multiboards in my map but i cant see it atm also it always lvls the unit to 3754 not sure y hopefully someone can spot a stupid mistake or a screw up lol and thx to anyone tht helps

JASS:
globals
    trigger array trg_Run_Unit_Damage_Test_Player
    real array Damage_Test_Life_Red_Reg
endglobals

function Trig_Run_Damage_Test_Red_Actions takes nothing returns nothing
    local real rx = GetRectCenterX(gg_rct_red_start)
    local real ry = GetRectCenterY(gg_rct_red_start)
    local string color = "|r"
    local multiboarditem mbi
    local integer row
    set Unit_Damage_Test_Player[0] = CreateUnit(Player(11), 'E001', rx, ry, 0 )
    call SetHeroLevel( Unit_Damage_Test_Player[0], 10000, true )
    call GroupAddUnit(Unit_Damage_Test_Group_Player[0], Unit_Damage_Test_Player[0])
    set Number_of_Damage_Test_Player[0] = ( Number_of_Damage_Test_Player[0] + 1 )
    set row = 1
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + I2S(Number_of_Damage_Test_Player[0]) + color )
    call EnableTrigger( trg_Damage_Test_DPS_Timer_Player[0] )
    call DisableTrigger( trg_Run_Unit_Damage_Test_Player[0] )
    set Unit_Spawns_Player[0] = false
    //setting dps for the regions 
    set DPS_Red_Region[1] = 0.00
    set row = 6
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[1]) + color )
    set DPS_Red_Region[2] = 0.00
    set row = 7
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[2]) + color )
    set DPS_Red_Region[3] = 0.00
    set row = 8
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[3]) + color )
    set DPS_Red_Region[4] = 0.00
    set row = 9
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[4]) + color )
    set DPS_Red_Region[5] = 0.00
    set row = 10
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[5]) + color )
    set DPS_Red_Region[6] = 0.00
    set row = 11
    set mbi = MultiboardGetItem( damagebossMultiboard, row, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[6]) + color )
    set Income_Boolean_Player[0] = false //turning off income timer
    set mbi = null
    set color = null
endfunction

//===========================================================================
function InitTrig_Run_Damage_Test_Red takes nothing returns nothing
    set trg_Run_Unit_Damage_Test_Player[0] = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( trg_Run_Unit_Damage_Test_Player[0], Player(0), "-damage test", true )
    call TriggerRegisterPlayerChatEvent( trg_Run_Unit_Damage_Test_Player[0], Player(0), "-dt", true )
    call TriggerAddAction( trg_Run_Unit_Damage_Test_Player[0], function Trig_Run_Damage_Test_Red_Actions )
endfunction

note: if i change the lvl from 10,000 it is doing really weird things if set to 8000 it sets the lvl as 1 if set to 9999 it sets the lvl to 3751 if set to 3755 it sets to 3755 umm not sure wat is going on here ?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
WC3 uses 32 bit integers, so the greatest number you can have is 2^32. You have to divide that by 2 since negative numbers are there. And zero is the first number so subtract one.

Anyway, the exp required for level 10000 is so high that it can't be represented with 32 bit numbers.

An example of overflow with 4 bit numbers. The max number that you can have with 4 bits is 2^4 / 2 - 1 = 7 if you want to have negative numbers. Using two's complement method.
0111 = 7
1000 = -8


0111 + 0001 | 7+1

0111
0001
1000

We get -8 when it should be 8. 8 can't be represented with 4 bits, an overflow happens.
 
Status
Not open for further replies.
Top