P
Paul
Guest
Would this save and load system work, if u can be bothered reading it 0_o
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function I2T takes integer i returns trigger
return i
return null
endfunction
function NumAndNum takes integer i1,integer i2 returns string
local integer num = i1*6+i2+1
if ((i1 == 5) and (i2 == 6)) then
set num = 2
endif
return SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",num,num)
endfunction
function Num2Numbers takes string s returns integer
local integer i = 1
loop
exitwhen i > 36
if (s==SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i,i)) then
return i-1
endif
set i = i + 1
endloop
return 0
endfunction
function Num2S takes integer i returns string
if (i > 57) then
return SubStringBJ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", i-64, i-64)
endif
return I2S(i-48)
endfunction
function S2Num takes string s returns integer
local integer i = 1
loop
exitwhen i > 36
if (s==SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i,i)) then
if (i < 11) then
return i + 47
else
return i + 54
endif
endif
set i = i + 1
endloop
return 0
endfunction
function IncDecNum takes string num, string incdec returns string
if (incdec == "+") then
if (num == "0") or (num == "1") or (num == "2") or (num == "3") or (num == "4") or (num == "5") or (num == "6") or (num == "7") or (num == "8") or (num == "9") then
if (num=="9") then
return "A"
else
return I2S(S2I(num) + 1)
endif
else
if (num=="Z") then
return "0"
else
return Num2S(S2Num(num)+1)
endif
endif
else
if (num == "0") or (num == "1") or (num == "2") or (num == "3") or (num == "4") or (num == "5") or (num == "6") or (num == "7") or (num == "8") or (num == "9") then
if (num=="0") then
return "Z"
else
return I2S(S2I(num) - 1)
endif
else
if (num=="A") then
return "9"
else
return Num2S(S2Num(num)-1)
endif
endif
endif
return ""
endfunction
function BigNum2S takes integer i returns string
local integer array n
set n[1] = R2I(i / 1296)
set n[2] = R2I((i-n[1]*1296) / 36)
set n[3] = (i-n[1]*1296)-(n[2]*36)
return IncDecNum(SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n[2]+1,n[2]+1),"-")+IncDecNum(SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n[1]+1,n[1]+1),"+")+IncDecNum(SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n[3]+1,n[3]+1),"-")
endfunction
function S2BigNum takes string s returns integer
local integer array n
set n[1] = Num2Numbers(IncDecNum(SubStringBJ(s,2,2),"-"))
set n[2] = Num2Numbers(IncDecNum(SubStringBJ(s,1,1),"+"))
set n[3] = Num2Numbers(IncDecNum(SubStringBJ(s,3,3),"+"))
return n[1] * 1296 + n[2] * 36 + n[3]
endfunction
function GetSaveCodeGameCache takes nothing returns gamecache
return gg_trg_SaveGame_Should_work
return null
endfunction
function SaveCodeGameCache2Trigger takes gamecache g returns trigger
return g
return null
endfunction
function MatchTable takes string ID,string sID,string storetype returns nothing
//All Abilities: 763 normal + 360 custom
local gamecache g = GetSaveCodeGameCache()
local integer i
if (storetype == "Spells") then
set i = 1+GetStoredInteger(g,"i1","i1")
call StoreString(g,"SsID2ID",sID,ID)
call StoreString(g,"SID2sID",ID,sID)
call StoreString(g,"SNum2ID",I2S(i),ID)
call StoreString(g,"SNum2sID",I2S(i),sID)
call StoreInteger(g,"i1","i1",i)
elseif (storetype == "Heros") then
set i = 1+GetStoredInteger(g,"i2","i2")
call StoreString(g,"HsID2ID",sID,ID)
call StoreString(g,"HID2sID",ID,sID)
call StoreString(g,"HNum2ID",I2S(i),ID)
call StoreString(g,"HNum2sID",I2S(i),sID)
call StoreInteger(g,"i2","i2",i)
elseif (storetype == "Items") then
set i = 1+GetStoredInteger(g,"i3","i3")
call StoreString(g,"IsID2ID",sID,ID)
call StoreString(g,"IID2sID",ID,sID)
call StoreString(g,"INum2ID",I2S(i),ID)
call StoreString(g,"INum2sID",I2S(i),sID)
call StoreInteger(g,"i3","i3",i)
endif
endfunction
function MatchHeroes takes integer num returns nothing
local integer i = 0
local integer array x
local integer counter = 0
local gamecache g = GetSaveCodeGameCache()
set x[1] = 48 // 0
set x[2] = 48 // 0
set x[3] = GetStoredInteger(g,"x3","x3")
set x[4] = GetStoredInteger(g,"x4","x4")
loop
exitwhen i > 200
set counter = counter + 1
if (((counter < 11) or ((counter > 17) and (counter < 44))) and (UnitId2String(num+256*x[2]+x[1]) != null) and ( IsUnitIdType(num+256*x[2]+x[1], UNIT_TYPE_HERO) == true ) ) then
call MatchTable(I2S(num+256*x[2]+x[1]), Num2S(x[4]) + Num2S(x[3]), "Heros")
set x[3] = x[3] + 1
if (x[3] == 58) then
set x[3] = 65
elseif (x[3] == 91) then
set x[3] = 48
set x[4] = x[4] + 1
if (x[4] == 58) then
set x[4] = 65
elseif (x[4] == 91) then
set x[4] = 48
endif
endif
elseif (counter > 43) then
set counter = 0
set x[1] = 47
set x[2] = x[2] + 1
endif
set x[1] = x[1] + 1
set i = i + 1
endloop
call StoreInteger(g,"x3","x3",x[3])
call StoreInteger(g,"x4","x4",x[4])
endfunction
function SaveCode_InitItems takes nothing returns nothing
local integer i = 0
local integer array x
local integer counter = 0
local gamecache g = GetSaveCodeGameCache()
call MatchTable(I2S('ckng'), "01", "Items")
call MatchTable(I2S('modt'), "02", "Items")
call MatchTable(I2S('tkno'), "03", "Items")
call MatchTable(I2S('ratf'), "04", "Items")
call MatchTable(I2S('rde4'), "05", "Items")
call MatchTable(I2S('ofro'), "06", "Items")
call MatchTable(I2S('fgdg'), "07", "Items")
call MatchTable(I2S('infs'), "08", "Items")
call MatchTable(I2S('shar'), "09", "Items")
call MatchTable(I2S('sand'), "0A", "Items")
call MatchTable(I2S('sres'), "0B", "Items")
call MatchTable(I2S('wild'), "0C", "Items")
call MatchTable(I2S('srrc'), "0D", "Items")
call MatchTable(I2S('rej6'), "0E", "Items")
call MatchTable(I2S('odef'), "0F", "Items")
call MatchTable(I2S('rde3'), "0G", "Items")
call MatchTable(I2S('pmna'), "0H", "Items")
call MatchTable(I2S('rhth'), "0I", "Items")
call MatchTable(I2S('ssil'), "0J", "Items")
call MatchTable(I2S('spsh'), "0K", "Items")
call MatchTable(I2S('desc'), "0L", "Items")
call MatchTable(I2S('ankh'), "0M", "Items")
call MatchTable(I2S('pdiv'), "0N", "Items")
call MatchTable(I2S('pres'), "0O", "Items")
call MatchTable(I2S('whwd'), "0P", "Items")
call MatchTable(I2S('rej5'), "0Q", "Items")
call MatchTable(I2S('hcun'), "0R", "Items")
call MatchTable(I2S('hval'), "0S", "Items")
call MatchTable(I2S('mcou'), "0T", "Items")
call MatchTable(I2S('belv'), "0U", "Items")
call MatchTable(I2S('bgst'), "0V", "Items")
call MatchTable(I2S('ciri'), "0W", "Items")
call MatchTable(I2S('ajen'), "0X", "Items")
call MatchTable(I2S('clfm'), "0Y", "Items")
call MatchTable(I2S('ratc'), "0Z", "Items")
call MatchTable(I2S('ward'), "10", "Items")
call MatchTable(I2S('kpin'), "11", "Items")
call MatchTable(I2S('crys'), "12", "Items")
call MatchTable(I2S('totw'), "13", "Items")
call MatchTable(I2S('fgfh'), "14", "Items")
call MatchTable(I2S('fgrd'), "15", "Items")
call MatchTable(I2S('fgrg'), "16", "Items")
call MatchTable(I2S('fgsk'), "17", "Items")
call MatchTable(I2S('wcyc'), "18", "Items")
call MatchTable(I2S('hlst'), "19", "Items")
call MatchTable(I2S('mnst'), "1A", "Items")
call MatchTable(I2S('rej4'), "1B", "Items")
call MatchTable(I2S('ram4'), "1C", "Items")
call MatchTable(I2S('lhst'), "1D", "Items")
call MatchTable(I2S('afac'), "1E", "Items")
call MatchTable(I2S('lgdh'), "1F", "Items")
call MatchTable(I2S('sbch'), "1G", "Items")
call MatchTable(I2S('brac'), "1H", "Items")
call MatchTable(I2S('rwiz'), "1I", "Items")
call MatchTable(I2S('dsum'), "1J", "Items")
call MatchTable(I2S('pghe'), "1K", "Items")
call MatchTable(I2S('pgma'), "1L", "Items")
call MatchTable(I2S('pnvu'), "1M", "Items")
call MatchTable(I2S('sror'), "1N", "Items")
call MatchTable(I2S('woms'), "1O", "Items")
call MatchTable(I2S('rej3'), "1P", "Items")
call MatchTable(I2S('ofir'), "1Q", "Items")
call MatchTable(I2S('ocor'), "1R", "Items")
call MatchTable(I2S('oli2'), "1S", "Items")
call MatchTable(I2S('oven'), "1T", "Items")
call MatchTable(I2S('ram3'), "1U", "Items")
call MatchTable(I2S('evtl'), "1V", "Items")
call MatchTable(I2S('penr'), "1W", "Items")
call MatchTable(I2S('prvt'), "1X", "Items")
call MatchTable(I2S('rat9'), "1Y", "Items")
call MatchTable(I2S('rde2'), "1Z", "Items")
call MatchTable(I2S('rlif'), "20", "Items")
call MatchTable(I2S('tret'), "21", "Items")
call MatchTable(I2S('tgrh'), "22", "Items")
call MatchTable(I2S('will'), "23", "Items")
call MatchTable(I2S('wlsd'), "24", "Items")
call MatchTable(I2S('wswd'), "25", "Items")
call MatchTable(I2S('rej2'), "26", "Items")
call MatchTable(I2S('gemt'), "27", "Items")
call MatchTable(I2S('ram2'), "28", "Items")
call MatchTable(I2S('stel'), "29", "Items")
call MatchTable(I2S('cnob'), "2A", "Items")
call MatchTable(I2S('gcel'), "2B", "Items")
call MatchTable(I2S('rat6'), "2C", "Items")
call MatchTable(I2S('rde1'), "2D", "Items")
call MatchTable(I2S('bspd'), "2E", "Items")
call MatchTable(I2S('tdx2'), "2F", "Items")
call MatchTable(I2S('texp'), "2G", "Items")
call MatchTable(I2S('tin2'), "2H", "Items")
call MatchTable(I2S('tpow'), "2I", "Items")
call MatchTable(I2S('tst2'), "2J", "Items")
call MatchTable(I2S('pnvl'), "2K", "Items")
call MatchTable(I2S('stwp'), "2L", "Items")
call MatchTable(I2S('wneg'), "2M", "Items")
call MatchTable(I2S('sneg'), "2N", "Items")
call MatchTable(I2S('wneu'), "2O", "Items")
call MatchTable(I2S('shea'), "2P", "Items")
call MatchTable(I2S('sman'), "2Q", "Items")
call MatchTable(I2S('rej1'), "2R", "Items")
call MatchTable(I2S('pspd'), "2S", "Items")
call MatchTable(I2S('dust'), "2T", "Items")
call MatchTable(I2S('ram1'), "2U", "Items")
call MatchTable(I2S('clsd'), "2V", "Items")
call MatchTable(I2S('rag1'), "2W", "Items")
call MatchTable(I2S('rin1'), "2X", "Items")
call MatchTable(I2S('rst1'), "2Y", "Items")
call MatchTable(I2S('manh'), "2Z", "Items")
call MatchTable(I2S('tdex'), "30", "Items")
call MatchTable(I2S('tint'), "31", "Items")
call MatchTable(I2S('tstr'), "32", "Items")
call MatchTable(I2S('pinv'), "33", "Items")
call MatchTable(I2S('phea'), "34", "Items")
call MatchTable(I2S('pman'), "35", "Items")
call MatchTable(I2S('spro'), "36", "Items")
call MatchTable(I2S('hslv'), "37", "Items")
call MatchTable(I2S('moon'), "38", "Items")
call MatchTable(I2S('shas'), "39", "Items")
call MatchTable(I2S('skul'), "3A", "Items")
call MatchTable(I2S('mcri'), "3B", "Items")
call MatchTable(I2S('rnec'), "3C", "Items")
call MatchTable(I2S('tsct'), "3D", "Items")
call MatchTable(I2S('azhr'), "3E", "Items")
call MatchTable(I2S('bzbe'), "3F", "Items")
call MatchTable(I2S('bzbf'), "3G", "Items")
call MatchTable(I2S('ches'), "3H", "Items")
call MatchTable(I2S('cnhn'), "3I", "Items")
call MatchTable(I2S('glsk'), "3J", "Items")
call MatchTable(I2S('gopr'), "3K", "Items")
call MatchTable(I2S('k3m1'), "3L", "Items")
call MatchTable(I2S('k3m2'), "3M", "Items")
call MatchTable(I2S('k3m3'), "3N", "Items")
call MatchTable(I2S('ktrm'), "3O", "Items")
call MatchTable(I2S('kybl'), "3P", "Items")
call MatchTable(I2S('kygh'), "3Q", "Items")
call MatchTable(I2S('kymn'), "3R", "Items")
call MatchTable(I2S('kysn'), "3S", "Items")
call MatchTable(I2S('ledg'), "3T", "Items")
call MatchTable(I2S('phlt'), "3U", "Items")
call MatchTable(I2S('sehr'), "3V", "Items")
call MatchTable(I2S('engs'), "3W", "Items")
call MatchTable(I2S('sorf'), "3X", "Items")
call MatchTable(I2S('gmfr'), "3Y", "Items")
call MatchTable(I2S('jpnt'), "3Z", "Items")
call MatchTable(I2S('shwd'), "40", "Items")
call MatchTable(I2S('skrt'), "41", "Items")
call MatchTable(I2S('thle'), "42", "Items")
call MatchTable(I2S('pomn'), "43", "Items")
call MatchTable(I2S('wshs'), "44", "Items")
call MatchTable(I2S('fgun'), "45", "Items")
call MatchTable(I2S('lure'), "46", "Items")
call MatchTable(I2S('olig'), "47", "Items")
call MatchTable(I2S('amrc'), "48", "Items")
call MatchTable(I2S('ccmd'), "49", "Items")
call MatchTable(I2S('flag'), "4A", "Items")
call MatchTable(I2S('gobm'), "4B", "Items")
call MatchTable(I2S('gsou'), "4C", "Items")
call MatchTable(I2S('nflg'), "4D", "Items")
call MatchTable(I2S('nspi'), "4E", "Items")
call MatchTable(I2S('oflg'), "4F", "Items")
call MatchTable(I2S('pams'), "4G", "Items")
call MatchTable(I2S('pgin'), "4H", "Items")
call MatchTable(I2S('rat3'), "4I", "Items")
call MatchTable(I2S('rde0'), "4J", "Items")
call MatchTable(I2S('rnsp'), "4K", "Items")
call MatchTable(I2S('soul'), "4L", "Items")
call MatchTable(I2S('tels'), "4M", "Items")
call MatchTable(I2S('tgxp'), "4N", "Items")
call MatchTable(I2S('uflg'), "4O", "Items")
call MatchTable(I2S('anfg'), "4P", "Items")
call MatchTable(I2S('brag'), "4Q", "Items")
call MatchTable(I2S('drph'), "4R", "Items")
call MatchTable(I2S('iwbr'), "4S", "Items")
call MatchTable(I2S('jdrn'), "4T", "Items")
call MatchTable(I2S('lnrn'), "4U", "Items")
call MatchTable(I2S('mlst'), "4V", "Items")
call MatchTable(I2S('oslo'), "4W", "Items")
call MatchTable(I2S('sbok'), "4X", "Items")
call MatchTable(I2S('sksh'), "4Y", "Items")
call MatchTable(I2S('sprn'), "4Z", "Items")
call MatchTable(I2S('tmmt'), "50", "Items")
call MatchTable(I2S('vddl'), "51", "Items")
call MatchTable(I2S('spre'), "52", "Items")
call MatchTable(I2S('sfog'), "53", "Items")
call MatchTable(I2S('sor1'), "54", "Items")
call MatchTable(I2S('sor2'), "55", "Items")
call MatchTable(I2S('sor3'), "56", "Items")
call MatchTable(I2S('sor4'), "57", "Items")
call MatchTable(I2S('sor5'), "58", "Items")
call MatchTable(I2S('sor6'), "59", "Items")
call MatchTable(I2S('sor7'), "5A", "Items")
call MatchTable(I2S('sor8'), "5B", "Items")
call MatchTable(I2S('sor9'), "5C", "Items")
call MatchTable(I2S('sora'), "5D", "Items")
call MatchTable(I2S('fwss'), "5E", "Items")
call MatchTable(I2S('shtm'), "5F", "Items")
call MatchTable(I2S('esaz'), "5G", "Items")
call MatchTable(I2S('btst'), "5H", "Items")
call MatchTable(I2S('gold'), "5I", "Items")
call MatchTable(I2S('lmbr'), "5J", "Items")
call MatchTable(I2S('gfor'), "5K", "Items")
call MatchTable(I2S('guvi'), "5L", "Items")
call MatchTable(I2S('rspl'), "5M", "Items")
call MatchTable(I2S('rre1'), "5N", "Items")
call MatchTable(I2S('rre2'), "5O", "Items")
call MatchTable(I2S('gomn'), "5P", "Items")
call MatchTable(I2S('rsps'), "5Q", "Items")
call MatchTable(I2S('rspd'), "5R", "Items")
call MatchTable(I2S('rman'), "5S", "Items")
call MatchTable(I2S('rma2'), "5T", "Items")
call MatchTable(I2S('rres'), "5U", "Items")
call MatchTable(I2S('rreb'), "5V", "Items")
call MatchTable(I2S('rhe1'), "5W", "Items")
call MatchTable(I2S('rhe2'), "5X", "Items")
call MatchTable(I2S('rhe3'), "5Y", "Items")
call MatchTable(I2S('rdis'), "5Z", "Items")
call MatchTable(I2S('rwat'), "60", "Items")
call MatchTable(I2S('sclp'), "61", "Items")
call MatchTable(I2S('pclr'), "62", "Items")
call MatchTable(I2S('plcl'), "63", "Items")
call MatchTable(I2S('silk'), "64", "Items")
call MatchTable(I2S('vamp'), "65", "Items")
call MatchTable(I2S('sreg'), "66", "Items")
call MatchTable(I2S('ssan'), "67", "Items")
call MatchTable(I2S('tcas'), "68", "Items")
call MatchTable(I2S('tbsm'), "69", "Items")
call MatchTable(I2S('tfar'), "6A", "Items")
call MatchTable(I2S('tlum'), "6B", "Items")
call MatchTable(I2S('tbar'), "6C", "Items")
call MatchTable(I2S('tbak'), "6D", "Items")
call MatchTable(I2S('gldo'), "6E", "Items")
call MatchTable(I2S('wtlg'), "6F", "Items")
call MatchTable(I2S('wolg'), "6G", "Items")
call MatchTable(I2S('mgtk'), "6H", "Items")
call MatchTable(I2S('stre'), "6I", "Items")
call MatchTable(I2S('horl'), "6J", "Items")
call MatchTable(I2S('hbth'), "6K", "Items")
call MatchTable(I2S('blba'), "6L", "Items")
call MatchTable(I2S('rugt'), "6M", "Items")
call MatchTable(I2S('frhg'), "6N", "Items")
call MatchTable(I2S('gvsm'), "6O", "Items")
call MatchTable(I2S('crdt'), "6P", "Items")
call MatchTable(I2S('arsc'), "6Q", "Items")
call MatchTable(I2S('scul'), "6R", "Items")
call MatchTable(I2S('tmsc'), "6S", "Items")
call MatchTable(I2S('dtsb'), "6T", "Items")
call MatchTable(I2S('grsl'), "6U", "Items")
call MatchTable(I2S('arsh'), "6V", "Items")
call MatchTable(I2S('shdt'), "6W", "Items")
call MatchTable(I2S('shhn'), "6X", "Items")
call MatchTable(I2S('shen'), "6Y", "Items")
call MatchTable(I2S('thdm'), "6Z", "Items")
call MatchTable(I2S('stpg'), "70", "Items")
call MatchTable(I2S('shrs'), "71", "Items")
call MatchTable(I2S('bfhr'), "72", "Items")
call MatchTable(I2S('cosl'), "73", "Items")
call MatchTable(I2S('shcw'), "74", "Items")
call MatchTable(I2S('srbd'), "75", "Items")
call MatchTable(I2S('frgd'), "76", "Items")
call MatchTable(I2S('envl'), "77", "Items")
call MatchTable(I2S('rump'), "78", "Items")
call MatchTable(I2S('mort'), "79", "Items")
call MatchTable(I2S('srtl'), "7A", "Items")
call MatchTable(I2S('stwa'), "7B", "Items")
call MatchTable(I2S('klmm'), "7C", "Items")
call MatchTable(I2S('rots'), "7D", "Items")
call MatchTable(I2S('axas'), "7E", "Items")
call MatchTable(I2S('mnsf'), "7F", "Items")
call MatchTable(I2S('schl'), "7G", "Items")
call MatchTable(I2S('asbl'), "7H", "Items")
call MatchTable(I2S('kgal'), "7I", "Items")
call MatchTable(I2S('dphe'), "7J", "Items")
call MatchTable(I2S('dkfw'), "7K", "Items")
call MatchTable(I2S('dthb'), "7L", "Items")
set i = 0
set x[1] = 48 // 0
set x[2] = 48 // 0
set x[3] = 56 // 8
set x[4] = 76 // L
loop
exitwhen i > 438
set counter = counter + 1
if ((counter < 11) or ((counter > 17) and (counter < 44))) then
call MatchTable(I2S(1227882496+256*x[2]+x[1]), Num2S(x[4]) + Num2S(x[3]), "Items")
set x[3] = x[3] + 1
if (x[3] == 58) then
set x[3] = 65
elseif (x[3] == 91) then
set x[3] = 48
set x[4] = x[4] + 1
if (x[4] == 58) then
set x[4] = 65
elseif (x[4] == 91) then
set x[4] = 48
endif
endif
elseif (counter > 43) then
set counter = 0
set x[1] = 47
set x[2] = x[2] + 1
endif
set x[1] = x[1] + 1
set i = i + 1
endloop
endfunction
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function I2T takes integer i returns trigger
return i
return null
endfunction
function NumAndNum takes integer i1,integer i2 returns string
local integer num = i1*6+i2+1
if ((i1 == 5) and (i2 == 6)) then
set num = 2
endif
return SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",num,num)
endfunction
function Num2Numbers takes string s returns integer
local integer i = 1
loop
exitwhen i > 36
if (s==SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i,i)) then
return i-1
endif
set i = i + 1
endloop
return 0
endfunction
function Num2S takes integer i returns string
if (i > 57) then
return SubStringBJ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", i-64, i-64)
endif
return I2S(i-48)
endfunction
function S2Num takes string s returns integer
local integer i = 1
loop
exitwhen i > 36
if (s==SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i,i)) then
if (i < 11) then
return i + 47
else
return i + 54
endif
endif
set i = i + 1
endloop
return 0
endfunction
function IncDecNum takes string num, string incdec returns string
if (incdec == "+") then
if (num == "0") or (num == "1") or (num == "2") or (num == "3") or (num == "4") or (num == "5") or (num == "6") or (num == "7") or (num == "8") or (num == "9") then
if (num=="9") then
return "A"
else
return I2S(S2I(num) + 1)
endif
else
if (num=="Z") then
return "0"
else
return Num2S(S2Num(num)+1)
endif
endif
else
if (num == "0") or (num == "1") or (num == "2") or (num == "3") or (num == "4") or (num == "5") or (num == "6") or (num == "7") or (num == "8") or (num == "9") then
if (num=="0") then
return "Z"
else
return I2S(S2I(num) - 1)
endif
else
if (num=="A") then
return "9"
else
return Num2S(S2Num(num)-1)
endif
endif
endif
return ""
endfunction
function BigNum2S takes integer i returns string
local integer array n
set n[1] = R2I(i / 1296)
set n[2] = R2I((i-n[1]*1296) / 36)
set n[3] = (i-n[1]*1296)-(n[2]*36)
return IncDecNum(SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n[2]+1,n[2]+1),"-")+IncDecNum(SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n[1]+1,n[1]+1),"+")+IncDecNum(SubStringBJ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n[3]+1,n[3]+1),"-")
endfunction
function S2BigNum takes string s returns integer
local integer array n
set n[1] = Num2Numbers(IncDecNum(SubStringBJ(s,2,2),"-"))
set n[2] = Num2Numbers(IncDecNum(SubStringBJ(s,1,1),"+"))
set n[3] = Num2Numbers(IncDecNum(SubStringBJ(s,3,3),"+"))
return n[1] * 1296 + n[2] * 36 + n[3]
endfunction
function GetSaveCodeGameCache takes nothing returns gamecache
return gg_trg_SaveGame_Should_work
return null
endfunction
function SaveCodeGameCache2Trigger takes gamecache g returns trigger
return g
return null
endfunction
function MatchTable takes string ID,string sID,string storetype returns nothing
//All Abilities: 763 normal + 360 custom
local gamecache g = GetSaveCodeGameCache()
local integer i
if (storetype == "Spells") then
set i = 1+GetStoredInteger(g,"i1","i1")
call StoreString(g,"SsID2ID",sID,ID)
call StoreString(g,"SID2sID",ID,sID)
call StoreString(g,"SNum2ID",I2S(i),ID)
call StoreString(g,"SNum2sID",I2S(i),sID)
call StoreInteger(g,"i1","i1",i)
elseif (storetype == "Heros") then
set i = 1+GetStoredInteger(g,"i2","i2")
call StoreString(g,"HsID2ID",sID,ID)
call StoreString(g,"HID2sID",ID,sID)
call StoreString(g,"HNum2ID",I2S(i),ID)
call StoreString(g,"HNum2sID",I2S(i),sID)
call StoreInteger(g,"i2","i2",i)
elseif (storetype == "Items") then
set i = 1+GetStoredInteger(g,"i3","i3")
call StoreString(g,"IsID2ID",sID,ID)
call StoreString(g,"IID2sID",ID,sID)
call StoreString(g,"INum2ID",I2S(i),ID)
call StoreString(g,"INum2sID",I2S(i),sID)
call StoreInteger(g,"i3","i3",i)
endif
endfunction
function MatchHeroes takes integer num returns nothing
local integer i = 0
local integer array x
local integer counter = 0
local gamecache g = GetSaveCodeGameCache()
set x[1] = 48 // 0
set x[2] = 48 // 0
set x[3] = GetStoredInteger(g,"x3","x3")
set x[4] = GetStoredInteger(g,"x4","x4")
loop
exitwhen i > 200
set counter = counter + 1
if (((counter < 11) or ((counter > 17) and (counter < 44))) and (UnitId2String(num+256*x[2]+x[1]) != null) and ( IsUnitIdType(num+256*x[2]+x[1], UNIT_TYPE_HERO) == true ) ) then
call MatchTable(I2S(num+256*x[2]+x[1]), Num2S(x[4]) + Num2S(x[3]), "Heros")
set x[3] = x[3] + 1
if (x[3] == 58) then
set x[3] = 65
elseif (x[3] == 91) then
set x[3] = 48
set x[4] = x[4] + 1
if (x[4] == 58) then
set x[4] = 65
elseif (x[4] == 91) then
set x[4] = 48
endif
endif
elseif (counter > 43) then
set counter = 0
set x[1] = 47
set x[2] = x[2] + 1
endif
set x[1] = x[1] + 1
set i = i + 1
endloop
call StoreInteger(g,"x3","x3",x[3])
call StoreInteger(g,"x4","x4",x[4])
endfunction
function SaveCode_InitItems takes nothing returns nothing
local integer i = 0
local integer array x
local integer counter = 0
local gamecache g = GetSaveCodeGameCache()
call MatchTable(I2S('ckng'), "01", "Items")
call MatchTable(I2S('modt'), "02", "Items")
call MatchTable(I2S('tkno'), "03", "Items")
call MatchTable(I2S('ratf'), "04", "Items")
call MatchTable(I2S('rde4'), "05", "Items")
call MatchTable(I2S('ofro'), "06", "Items")
call MatchTable(I2S('fgdg'), "07", "Items")
call MatchTable(I2S('infs'), "08", "Items")
call MatchTable(I2S('shar'), "09", "Items")
call MatchTable(I2S('sand'), "0A", "Items")
call MatchTable(I2S('sres'), "0B", "Items")
call MatchTable(I2S('wild'), "0C", "Items")
call MatchTable(I2S('srrc'), "0D", "Items")
call MatchTable(I2S('rej6'), "0E", "Items")
call MatchTable(I2S('odef'), "0F", "Items")
call MatchTable(I2S('rde3'), "0G", "Items")
call MatchTable(I2S('pmna'), "0H", "Items")
call MatchTable(I2S('rhth'), "0I", "Items")
call MatchTable(I2S('ssil'), "0J", "Items")
call MatchTable(I2S('spsh'), "0K", "Items")
call MatchTable(I2S('desc'), "0L", "Items")
call MatchTable(I2S('ankh'), "0M", "Items")
call MatchTable(I2S('pdiv'), "0N", "Items")
call MatchTable(I2S('pres'), "0O", "Items")
call MatchTable(I2S('whwd'), "0P", "Items")
call MatchTable(I2S('rej5'), "0Q", "Items")
call MatchTable(I2S('hcun'), "0R", "Items")
call MatchTable(I2S('hval'), "0S", "Items")
call MatchTable(I2S('mcou'), "0T", "Items")
call MatchTable(I2S('belv'), "0U", "Items")
call MatchTable(I2S('bgst'), "0V", "Items")
call MatchTable(I2S('ciri'), "0W", "Items")
call MatchTable(I2S('ajen'), "0X", "Items")
call MatchTable(I2S('clfm'), "0Y", "Items")
call MatchTable(I2S('ratc'), "0Z", "Items")
call MatchTable(I2S('ward'), "10", "Items")
call MatchTable(I2S('kpin'), "11", "Items")
call MatchTable(I2S('crys'), "12", "Items")
call MatchTable(I2S('totw'), "13", "Items")
call MatchTable(I2S('fgfh'), "14", "Items")
call MatchTable(I2S('fgrd'), "15", "Items")
call MatchTable(I2S('fgrg'), "16", "Items")
call MatchTable(I2S('fgsk'), "17", "Items")
call MatchTable(I2S('wcyc'), "18", "Items")
call MatchTable(I2S('hlst'), "19", "Items")
call MatchTable(I2S('mnst'), "1A", "Items")
call MatchTable(I2S('rej4'), "1B", "Items")
call MatchTable(I2S('ram4'), "1C", "Items")
call MatchTable(I2S('lhst'), "1D", "Items")
call MatchTable(I2S('afac'), "1E", "Items")
call MatchTable(I2S('lgdh'), "1F", "Items")
call MatchTable(I2S('sbch'), "1G", "Items")
call MatchTable(I2S('brac'), "1H", "Items")
call MatchTable(I2S('rwiz'), "1I", "Items")
call MatchTable(I2S('dsum'), "1J", "Items")
call MatchTable(I2S('pghe'), "1K", "Items")
call MatchTable(I2S('pgma'), "1L", "Items")
call MatchTable(I2S('pnvu'), "1M", "Items")
call MatchTable(I2S('sror'), "1N", "Items")
call MatchTable(I2S('woms'), "1O", "Items")
call MatchTable(I2S('rej3'), "1P", "Items")
call MatchTable(I2S('ofir'), "1Q", "Items")
call MatchTable(I2S('ocor'), "1R", "Items")
call MatchTable(I2S('oli2'), "1S", "Items")
call MatchTable(I2S('oven'), "1T", "Items")
call MatchTable(I2S('ram3'), "1U", "Items")
call MatchTable(I2S('evtl'), "1V", "Items")
call MatchTable(I2S('penr'), "1W", "Items")
call MatchTable(I2S('prvt'), "1X", "Items")
call MatchTable(I2S('rat9'), "1Y", "Items")
call MatchTable(I2S('rde2'), "1Z", "Items")
call MatchTable(I2S('rlif'), "20", "Items")
call MatchTable(I2S('tret'), "21", "Items")
call MatchTable(I2S('tgrh'), "22", "Items")
call MatchTable(I2S('will'), "23", "Items")
call MatchTable(I2S('wlsd'), "24", "Items")
call MatchTable(I2S('wswd'), "25", "Items")
call MatchTable(I2S('rej2'), "26", "Items")
call MatchTable(I2S('gemt'), "27", "Items")
call MatchTable(I2S('ram2'), "28", "Items")
call MatchTable(I2S('stel'), "29", "Items")
call MatchTable(I2S('cnob'), "2A", "Items")
call MatchTable(I2S('gcel'), "2B", "Items")
call MatchTable(I2S('rat6'), "2C", "Items")
call MatchTable(I2S('rde1'), "2D", "Items")
call MatchTable(I2S('bspd'), "2E", "Items")
call MatchTable(I2S('tdx2'), "2F", "Items")
call MatchTable(I2S('texp'), "2G", "Items")
call MatchTable(I2S('tin2'), "2H", "Items")
call MatchTable(I2S('tpow'), "2I", "Items")
call MatchTable(I2S('tst2'), "2J", "Items")
call MatchTable(I2S('pnvl'), "2K", "Items")
call MatchTable(I2S('stwp'), "2L", "Items")
call MatchTable(I2S('wneg'), "2M", "Items")
call MatchTable(I2S('sneg'), "2N", "Items")
call MatchTable(I2S('wneu'), "2O", "Items")
call MatchTable(I2S('shea'), "2P", "Items")
call MatchTable(I2S('sman'), "2Q", "Items")
call MatchTable(I2S('rej1'), "2R", "Items")
call MatchTable(I2S('pspd'), "2S", "Items")
call MatchTable(I2S('dust'), "2T", "Items")
call MatchTable(I2S('ram1'), "2U", "Items")
call MatchTable(I2S('clsd'), "2V", "Items")
call MatchTable(I2S('rag1'), "2W", "Items")
call MatchTable(I2S('rin1'), "2X", "Items")
call MatchTable(I2S('rst1'), "2Y", "Items")
call MatchTable(I2S('manh'), "2Z", "Items")
call MatchTable(I2S('tdex'), "30", "Items")
call MatchTable(I2S('tint'), "31", "Items")
call MatchTable(I2S('tstr'), "32", "Items")
call MatchTable(I2S('pinv'), "33", "Items")
call MatchTable(I2S('phea'), "34", "Items")
call MatchTable(I2S('pman'), "35", "Items")
call MatchTable(I2S('spro'), "36", "Items")
call MatchTable(I2S('hslv'), "37", "Items")
call MatchTable(I2S('moon'), "38", "Items")
call MatchTable(I2S('shas'), "39", "Items")
call MatchTable(I2S('skul'), "3A", "Items")
call MatchTable(I2S('mcri'), "3B", "Items")
call MatchTable(I2S('rnec'), "3C", "Items")
call MatchTable(I2S('tsct'), "3D", "Items")
call MatchTable(I2S('azhr'), "3E", "Items")
call MatchTable(I2S('bzbe'), "3F", "Items")
call MatchTable(I2S('bzbf'), "3G", "Items")
call MatchTable(I2S('ches'), "3H", "Items")
call MatchTable(I2S('cnhn'), "3I", "Items")
call MatchTable(I2S('glsk'), "3J", "Items")
call MatchTable(I2S('gopr'), "3K", "Items")
call MatchTable(I2S('k3m1'), "3L", "Items")
call MatchTable(I2S('k3m2'), "3M", "Items")
call MatchTable(I2S('k3m3'), "3N", "Items")
call MatchTable(I2S('ktrm'), "3O", "Items")
call MatchTable(I2S('kybl'), "3P", "Items")
call MatchTable(I2S('kygh'), "3Q", "Items")
call MatchTable(I2S('kymn'), "3R", "Items")
call MatchTable(I2S('kysn'), "3S", "Items")
call MatchTable(I2S('ledg'), "3T", "Items")
call MatchTable(I2S('phlt'), "3U", "Items")
call MatchTable(I2S('sehr'), "3V", "Items")
call MatchTable(I2S('engs'), "3W", "Items")
call MatchTable(I2S('sorf'), "3X", "Items")
call MatchTable(I2S('gmfr'), "3Y", "Items")
call MatchTable(I2S('jpnt'), "3Z", "Items")
call MatchTable(I2S('shwd'), "40", "Items")
call MatchTable(I2S('skrt'), "41", "Items")
call MatchTable(I2S('thle'), "42", "Items")
call MatchTable(I2S('pomn'), "43", "Items")
call MatchTable(I2S('wshs'), "44", "Items")
call MatchTable(I2S('fgun'), "45", "Items")
call MatchTable(I2S('lure'), "46", "Items")
call MatchTable(I2S('olig'), "47", "Items")
call MatchTable(I2S('amrc'), "48", "Items")
call MatchTable(I2S('ccmd'), "49", "Items")
call MatchTable(I2S('flag'), "4A", "Items")
call MatchTable(I2S('gobm'), "4B", "Items")
call MatchTable(I2S('gsou'), "4C", "Items")
call MatchTable(I2S('nflg'), "4D", "Items")
call MatchTable(I2S('nspi'), "4E", "Items")
call MatchTable(I2S('oflg'), "4F", "Items")
call MatchTable(I2S('pams'), "4G", "Items")
call MatchTable(I2S('pgin'), "4H", "Items")
call MatchTable(I2S('rat3'), "4I", "Items")
call MatchTable(I2S('rde0'), "4J", "Items")
call MatchTable(I2S('rnsp'), "4K", "Items")
call MatchTable(I2S('soul'), "4L", "Items")
call MatchTable(I2S('tels'), "4M", "Items")
call MatchTable(I2S('tgxp'), "4N", "Items")
call MatchTable(I2S('uflg'), "4O", "Items")
call MatchTable(I2S('anfg'), "4P", "Items")
call MatchTable(I2S('brag'), "4Q", "Items")
call MatchTable(I2S('drph'), "4R", "Items")
call MatchTable(I2S('iwbr'), "4S", "Items")
call MatchTable(I2S('jdrn'), "4T", "Items")
call MatchTable(I2S('lnrn'), "4U", "Items")
call MatchTable(I2S('mlst'), "4V", "Items")
call MatchTable(I2S('oslo'), "4W", "Items")
call MatchTable(I2S('sbok'), "4X", "Items")
call MatchTable(I2S('sksh'), "4Y", "Items")
call MatchTable(I2S('sprn'), "4Z", "Items")
call MatchTable(I2S('tmmt'), "50", "Items")
call MatchTable(I2S('vddl'), "51", "Items")
call MatchTable(I2S('spre'), "52", "Items")
call MatchTable(I2S('sfog'), "53", "Items")
call MatchTable(I2S('sor1'), "54", "Items")
call MatchTable(I2S('sor2'), "55", "Items")
call MatchTable(I2S('sor3'), "56", "Items")
call MatchTable(I2S('sor4'), "57", "Items")
call MatchTable(I2S('sor5'), "58", "Items")
call MatchTable(I2S('sor6'), "59", "Items")
call MatchTable(I2S('sor7'), "5A", "Items")
call MatchTable(I2S('sor8'), "5B", "Items")
call MatchTable(I2S('sor9'), "5C", "Items")
call MatchTable(I2S('sora'), "5D", "Items")
call MatchTable(I2S('fwss'), "5E", "Items")
call MatchTable(I2S('shtm'), "5F", "Items")
call MatchTable(I2S('esaz'), "5G", "Items")
call MatchTable(I2S('btst'), "5H", "Items")
call MatchTable(I2S('gold'), "5I", "Items")
call MatchTable(I2S('lmbr'), "5J", "Items")
call MatchTable(I2S('gfor'), "5K", "Items")
call MatchTable(I2S('guvi'), "5L", "Items")
call MatchTable(I2S('rspl'), "5M", "Items")
call MatchTable(I2S('rre1'), "5N", "Items")
call MatchTable(I2S('rre2'), "5O", "Items")
call MatchTable(I2S('gomn'), "5P", "Items")
call MatchTable(I2S('rsps'), "5Q", "Items")
call MatchTable(I2S('rspd'), "5R", "Items")
call MatchTable(I2S('rman'), "5S", "Items")
call MatchTable(I2S('rma2'), "5T", "Items")
call MatchTable(I2S('rres'), "5U", "Items")
call MatchTable(I2S('rreb'), "5V", "Items")
call MatchTable(I2S('rhe1'), "5W", "Items")
call MatchTable(I2S('rhe2'), "5X", "Items")
call MatchTable(I2S('rhe3'), "5Y", "Items")
call MatchTable(I2S('rdis'), "5Z", "Items")
call MatchTable(I2S('rwat'), "60", "Items")
call MatchTable(I2S('sclp'), "61", "Items")
call MatchTable(I2S('pclr'), "62", "Items")
call MatchTable(I2S('plcl'), "63", "Items")
call MatchTable(I2S('silk'), "64", "Items")
call MatchTable(I2S('vamp'), "65", "Items")
call MatchTable(I2S('sreg'), "66", "Items")
call MatchTable(I2S('ssan'), "67", "Items")
call MatchTable(I2S('tcas'), "68", "Items")
call MatchTable(I2S('tbsm'), "69", "Items")
call MatchTable(I2S('tfar'), "6A", "Items")
call MatchTable(I2S('tlum'), "6B", "Items")
call MatchTable(I2S('tbar'), "6C", "Items")
call MatchTable(I2S('tbak'), "6D", "Items")
call MatchTable(I2S('gldo'), "6E", "Items")
call MatchTable(I2S('wtlg'), "6F", "Items")
call MatchTable(I2S('wolg'), "6G", "Items")
call MatchTable(I2S('mgtk'), "6H", "Items")
call MatchTable(I2S('stre'), "6I", "Items")
call MatchTable(I2S('horl'), "6J", "Items")
call MatchTable(I2S('hbth'), "6K", "Items")
call MatchTable(I2S('blba'), "6L", "Items")
call MatchTable(I2S('rugt'), "6M", "Items")
call MatchTable(I2S('frhg'), "6N", "Items")
call MatchTable(I2S('gvsm'), "6O", "Items")
call MatchTable(I2S('crdt'), "6P", "Items")
call MatchTable(I2S('arsc'), "6Q", "Items")
call MatchTable(I2S('scul'), "6R", "Items")
call MatchTable(I2S('tmsc'), "6S", "Items")
call MatchTable(I2S('dtsb'), "6T", "Items")
call MatchTable(I2S('grsl'), "6U", "Items")
call MatchTable(I2S('arsh'), "6V", "Items")
call MatchTable(I2S('shdt'), "6W", "Items")
call MatchTable(I2S('shhn'), "6X", "Items")
call MatchTable(I2S('shen'), "6Y", "Items")
call MatchTable(I2S('thdm'), "6Z", "Items")
call MatchTable(I2S('stpg'), "70", "Items")
call MatchTable(I2S('shrs'), "71", "Items")
call MatchTable(I2S('bfhr'), "72", "Items")
call MatchTable(I2S('cosl'), "73", "Items")
call MatchTable(I2S('shcw'), "74", "Items")
call MatchTable(I2S('srbd'), "75", "Items")
call MatchTable(I2S('frgd'), "76", "Items")
call MatchTable(I2S('envl'), "77", "Items")
call MatchTable(I2S('rump'), "78", "Items")
call MatchTable(I2S('mort'), "79", "Items")
call MatchTable(I2S('srtl'), "7A", "Items")
call MatchTable(I2S('stwa'), "7B", "Items")
call MatchTable(I2S('klmm'), "7C", "Items")
call MatchTable(I2S('rots'), "7D", "Items")
call MatchTable(I2S('axas'), "7E", "Items")
call MatchTable(I2S('mnsf'), "7F", "Items")
call MatchTable(I2S('schl'), "7G", "Items")
call MatchTable(I2S('asbl'), "7H", "Items")
call MatchTable(I2S('kgal'), "7I", "Items")
call MatchTable(I2S('dphe'), "7J", "Items")
call MatchTable(I2S('dkfw'), "7K", "Items")
call MatchTable(I2S('dthb'), "7L", "Items")
set i = 0
set x[1] = 48 // 0
set x[2] = 48 // 0
set x[3] = 56 // 8
set x[4] = 76 // L
loop
exitwhen i > 438
set counter = counter + 1
if ((counter < 11) or ((counter > 17) and (counter < 44))) then
call MatchTable(I2S(1227882496+256*x[2]+x[1]), Num2S(x[4]) + Num2S(x[3]), "Items")
set x[3] = x[3] + 1
if (x[3] == 58) then
set x[3] = 65
elseif (x[3] == 91) then
set x[3] = 48
set x[4] = x[4] + 1
if (x[4] == 58) then
set x[4] = 65
elseif (x[4] == 91) then
set x[4] = 48
endif
endif
elseif (counter > 43) then
set counter = 0
set x[1] = 47
set x[2] = x[2] + 1
endif
set x[1] = x[1] + 1
set i = i + 1
endloop
endfunction


