function AsciiCharToInteger takes string char returns integer local string charMap = " !\"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" local string u = SubString(char, 0, 1) local string c local integer i = 0 loop set c = SubString(charMap, i, i + 1) exitwhen c == "" if c == u then return i + 32 endif set i = i + 1 endloop return 0 endfunction function IdStringToIdInteger takes string value returns integer return AsciiCharToInteger(SubString(value, 0, 1)) * 0x1000000 + AsciiCharToInteger(SubString(value, 1, 2)) * 0x10000 + AsciiCharToInteger(SubString(value, 2, 3)) * 0x100 + AsciiCharToInteger(SubString(value, 3, 4)) endfunction function makeAdvancedUnit takes player who, string id, location where, real angle, string life, string mana, string abil returns unit local integer unitid = S2I(id) local integer spellmnt = StringLength(abil)/4 local unit u = null local integer i = 0 if unitid == 0 then set unitid = IdStringToIdInteger(id) endif set u = CreateUnit(who, unitid, GetLocationX(where), GetLocationY(where), angle) loop exitwhen i>=spellmnt call UnitAddAbility(u, IdStringToIdInteger(SubString(abil,i*4,(i+1)*4)) ) set i = i + 1 endloop if StringCase(SubString(life,StringLength(life)-1,StringLength(life) ),false) == "p" then call SetUnitLifePercentBJ(u,S2R(SubString(life,0,String Length(life)) )) else call SetUnitLifeBJ(u, S2R(life) ) endif if StringCase(SubString(mana,StringLength(mana)-1,StringLength(mana) ),false) == "p" then call SetUnitManaPercentBJ(u,S2R(SubString(mana,0,String Length(mana)) )) else call SetUnitManaBJ(u, S2R(mana) ) endif return u endfunction