saving random item stats

emootootoo

Top Banana
Reaction score
51
edited:
alright i've updated it so now it only requires the actual stats to be saves and nothing else

but still, i'm getting 40 character codes when i save 5 items with 4 random stats each
is there any way to further shorten the code? is there some way to compress all the stat values so they don't take up as many characters?

at the moment it pushes a value between 0 and 2^7 (the variation of the random stat) for every random stat on your items
so if you have 5 items with 4 random stats each, that will mean 20 2^7 values saved

JASS:
//Save random stats
    set i = 0
    loop
        exitwhen i >= 6
        set ri = 0
        set m = UnitItemInSlot(u,i)
        call ItemVariationToArray(m)
        if m != null then
            loop
                exitwhen ri >= 21
                if ItemVariation[ri] > 0 then
                    call push_progressive_int(ItemVariation[ri],2,7)
                endif
                set ri = ri + 1
            endloop
        endif
        set i = i + 1
    endloop


JASS:
//Load random stats
    set i = item_count-1
    loop
        exitwhen i < 0
        call ClearItemVariationArray()
        set tempInt = FindRItem(GetItemTypeId(items<i>))
        set ranCount = 6
        if tempInt != -1 then
            loop   
                exitwhen ranCount &lt; 1
                if ItemIndexes[tempInt][ranCount] != 0 then
                    set ItemVariation[ItemIndexes[tempInt][ranCount]] = pop_progressive_int(2,7)
                endif
                set ranCount = ranCount - 1
            endloop
            call ArrayToItemVariation(items<i>)
        endif
        set i = i - 1
    endloop</i></i>


i put no more than 6 random stats on an item with this code
 

SerraAvenger

Cuz I can
Reaction score
234
Code:
                    call push_progressive_int(ItemVariation[ri],2,8)
                    call push_int(ri,20)
How large is the value you're pushing?
If it is too big, just put that stuff into arrays
then push the friggin index, not the value : D
 

emootootoo

Top Banana
Reaction score
51
sadly i have to push the value since it's a random value that gets saved

edit:
ok i've changed it a bit now...

had to change some systems around and use a 2d array to figure out where saved stats are to go when loaded

but i'm down to just saving the actual random values for the random stats
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top