• 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.

Help with Save/Load Stuff

Status
Not open for further replies.
Level 8
Joined
Feb 20, 2020
Messages
207
Hello guys, its me again!!
I need help with save load code, i need to save the level of a unit ability... so like that, there is 3 attributes bonus with hidden icons in every hero in my map, strenght, inteligence and agility, with 15 levels, that will works like IV in pokemon, so what i want is to save the level of each of the attributes for the unit... so when you load that 3 specific status are the same as before when you "captured" the hero.




  • function SaveLoad_InitialSetup takes nothing returns nothing
    • local integer i = 0
    • local integer j = 0
    • loop
      • set udg_SaveLoad_Compress[i + 48] = j
      • set udg_SaveLoad_Uncompress[i] = i + 48
      • set j = j + 1
      • set i = i + 1
      • exitwhen i >= 10
    • endloop
    • set i = 0
    • loop
      • set udg_SaveLoad_Compress[i + 97] = j
      • set udg_SaveLoad_Compress[i + 65] = j + 26
      • set udg_SaveLoad_Uncompress[i + 10] = i + 97
      • set udg_SaveLoad_Uncompress[i + 26 + 10] = i + 65
      • set j = j + 1
      • set i = i + 1
      • exitwhen i >= 26
    • endloop
  • endfunction
  • function SaveLoad_Id2CId takes integer n returns integer
    • local integer i = n / (256 * 256 * 256)
    • local integer r
    • set n = n - i * (256 * 256 * 256)
    • set r = udg_SaveLoad_Compress[i]
    • set i = n / (256 * 256)
    • set n = n - i * (256 * 256)
    • set r = r * 64 + udg_SaveLoad_Compress[i]
    • set i = n / 256
    • set r = r * 64 + udg_SaveLoad_Compress[i]
    • return r * 64 + udg_SaveLoad_Compress[n - i * 256]
  • endfunction
  • function SaveLoad_CId2Id takes integer n returns integer
    • local integer i = n / (64 * 64 * 64)
    • local integer r
    • set n = n - i * (64 * 64 * 64)
    • set r = udg_SaveLoad_Uncompress[i]
    • set i = n / (64 * 64)
    • set n = n - i * (64 * 64)
    • set r = r * 256 + udg_SaveLoad_Uncompress[i]
    • set i = n / 64
    • set r = r * 256 + udg_SaveLoad_Uncompress[i]
    • return r * 256 + udg_SaveLoad_Uncompress[n - i * 64]
  • endfunction
  • function SaveLoad_Unit2Integer takes unit u returns integer
    • local integer i = 0
    • local integer n = GetUnitTypeId(u)
    • if udg_SaveLoad_Initialized == false then
      • set udg_SaveLoad_Initialized = true
      • call SaveLoad_InitialSetup()
    • endif
    • loop
      • set i = i + 1
      • exitwhen i > udg_SaveLoad_Heroes_LastIndex
      • if udg_SaveLoad_Heroes[i] == n then
        • return i
      • endif
    • endloop
    • return SaveLoad_Id2CId(n)
  • endfunction
  • function SaveLoad_Integer2Unit takes integer i returns integer
    • if udg_SaveLoad_Initialized == false then
      • set udg_SaveLoad_Initialized = true
      • call SaveLoad_InitialSetup()
    • endif
    • if i <= udg_SaveLoad_Heroes_LastIndex then
      • return udg_SaveLoad_Heroes[i]
    • endif
    • return SaveLoad_CId2Id(i)
  • endfunction
  • function SaveLoad_Item2Integer takes item t returns integer
    • local integer i = 0
    • local integer n = GetItemTypeId(t)
    • if udg_SaveLoad_Initialized == false then
      • set udg_SaveLoad_Initialized = true
      • call SaveLoad_InitialSetup()
    • endif
    • loop
      • set i = i + 1
      • exitwhen i > udg_SaveLoad_Items_LastIndex
      • if udg_SaveLoad_Items[i] == n then
        • return i
      • endif
    • endloop
    • return SaveLoad_Id2CId(n)
  • endfunction
  • function SaveLoad_Integer2Item takes integer i returns integer
    • if udg_SaveLoad_Initialized == false then
      • set udg_SaveLoad_Initialized = true
      • call SaveLoad_InitialSetup()
    • endif
    • if i <= udg_SaveLoad_Items_LastIndex then
      • return udg_SaveLoad_Items[i]
    • endif
    • return SaveLoad_CId2Id(i)
  • endfunction
  • function SaveLoad_Ability2Integer takes integer a returns integer
    • local integer i = 0
    • if udg_SaveLoad_Initialized == false then
      • set udg_SaveLoad_Initialized = true
      • call SaveLoad_InitialSetup()
    • endif
    • loop
      • set i = i + 1
      • exitwhen i > udg_SaveLoad_Abilities_LastIndex
      • if udg_SaveLoad_Abilities[i] == a then
        • return i
      • endif
    • endloop
    • return SaveLoad_Id2CId(a)
  • endfunction
  • function SaveLoad_Integer2Ability takes integer i returns integer
    • if udg_SaveLoad_Initialized == false then
      • set udg_SaveLoad_Initialized = true
      • call SaveLoad_InitialSetup()
    • endif
    • if i <= udg_SaveLoad_Abilities_LastIndex then
      • return udg_SaveLoad_Abilities[i]
    • endif
    • return SaveLoad_CId2Id(i)
  • endfunction
  • function SaveLoad_Color takes string s returns string
    • local integer i = StringLength(s)
    • local string c
    • local string r = ""
    • loop
      • set i = i - 1
      • set c = SubString(s,i,i + 1)
      • if c == "0" or c == "1" or c == "2" or c == "3" or c == "4" or c == "5" or c == "6" or c == "7" or c == "8" or c == "9" then
        • set r = "|cffffcc00" + c + "|r" + r
      • elseif c == "-" then
        • set r = "|cffdddddd-|r" + r
      • else
        • set r = c + r
      • endif
      • exitwhen i <= 0
    • endloop
    • return r
  • endfunction
  • function SaveLoad_EncodeChar takes string n returns integer
    • local integer i = 0
    • local string s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    • local string s2 = "abcdefghijklmnopqrstuvwxyz"
    • local string s3 = "0123456789"
    • loop
      • if SubString(s1,i,i + 1) == n then
        • return i
      • endif
      • if SubString(s2,i,i + 1) == n then
        • return i
      • endif
      • set i = i + 1
      • exitwhen i >= 26
    • endloop
    • set i = 0
    • loop
      • if SubString(s3,i,i + 1) == n then
        • return i
      • endif
      • set i = i + 1
      • exitwhen i >= 10
    • endloop
    • return 0
  • endfunction
  • function SaveLoad_EncodeVerify takes string buffer returns integer
    • local integer i = 0
    • local integer j = 0
    • local string name = GetPlayerName(GetTriggerPlayer())
    • if udg_SaveLoad_UsePlayername == true then
      • loop
        • set j = j + SaveLoad_EncodeChar(SubString(name,i,i + 1))
        • set i = i + 1
        • exitwhen i >= StringLength(name)
      • endloop
    • endif
    • set i = 0
    • loop
      • set j = j + SaveLoad_EncodeChar(SubString(buffer,i,i + 1))
      • set i = i + 1
      • exitwhen i >= StringLength(buffer)
    • endloop
    • return j
  • endfunction
  • function CreateTextFile takes string saveCode returns nothing
    • local integer p = GetPlayerId(GetTriggerPlayer())+1
    • local string heroName = GetUnitName(udg_TempUnit)
    • local integer heroLevel = GetHeroLevel(udg_TempUnit)
    • call PreloadGenClear()
    • call PreloadGenStart()
    • call Preload("\r\n\t\t\t\tTrainer: " + "Trainer" + "\r\n\t\t\t\t" + "Level: " + I2S(heroLevel) + "\t\t\r\n\t\t\t\t" + "Code: -load " + saveCode + "\r\n\n\t\t ")
    • call PreloadGenEnd("LegendsRPG\\Trainer" + "-" + I2S(heroLevel) + ".txt")
  • endfunction
  • function SaveLoad_EncodeValues takes nothing returns string
    • local integer i
    • local integer j
    • local integer k
    • local integer l
    • local integer m
    • local integer CodeLength = StringLength(udg_SaveLoad_Alphabet)
    • local integer array a
    • local string buffer = ""
    • local string c = ""
    • local integer skip = 0
    • local integer CONST = 1000000
    • local string abc = "0123456789"
    • set i = 0
    • loop
      • set i = i + 1
      • exitwhen i > udg_SaveCount
      • set buffer = buffer + I2S(udg_Save[i]) + "-"
    • endloop
    • set buffer = buffer + I2S(SaveLoad_EncodeVerify(buffer))
    • if udg_Save[1] == 0 then
      • set buffer = "-" + buffer
    • endif
    • set i = 0
    • loop
      • set a[i] = 0
      • set i = i + 1
      • exitwhen i >= 100
    • endloop
    • set m = 0
    • set i = 0
    • loop
      • set j = 0
      • loop
        • set a[j] = a[j] * 11
        • set j = j + 1
        • exitwhen j > m
      • endloop
      • set l = 0
      • set c = SubString(buffer,i,i + 1)
      • loop
        • exitwhen SubString(abc,l,l + 1) == c
        • set l = l + 1
        • exitwhen l > 9
      • endloop
      • set a[0] = a[0] + l
      • set j = 0
      • loop
        • set k = a[j] / CONST
        • set a[j] = a[j] - k * CONST
        • set a[j + 1] = a[j + 1] + k
        • set j = j + 1
        • exitwhen j > m
      • endloop
      • if k > 0 then
        • set m = m + 1
      • endif
      • set i = i + 1
      • exitwhen i >= StringLength(buffer)
    • endloop
    • set buffer = ""
    • loop
      • exitwhen m < 0
      • set j = m
      • loop
        • exitwhen j <= 0
        • set k = a[j] / CodeLength
        • set a[j - 1] = a[j - 1] + (a[j] - k * CodeLength) * CONST
        • set a[j] = k
        • set j = j - 1
      • endloop
      • set k = a[j] / CodeLength
      • set i = a[j] - k * CodeLength
      • set buffer = buffer + SubString(udg_SaveLoad_Alphabet,i,i + 1)
      • set a[j] = k
      • if a[m] == 0 then
        • set m = m - 1
      • endif
    • endloop
    • set i = StringLength(buffer)
    • set skip = 0
    • set c = ""
    • loop
      • set i = i - 1
      • set c = c + SubString(buffer,i,i + 1)
      • set skip = skip + 1
      • if skip == 4 and i > 0 then
        • set c = c + "-"
        • set skip = 0
      • endif
      • exitwhen i <= 0
    • endloop
    • call CreateTextFile(c)
    • return c
  • endfunction
  • function SaveLoad_DecodeValues takes string s returns boolean
    • local integer i
    • local integer j
    • local integer k
    • local integer l
    • local integer SaveCode = 0
    • local integer m
    • local integer array a
    • local string buffer = ""
    • local integer CodeLength = StringLength(udg_SaveLoad_Alphabet)
    • local integer skip = -1
    • local integer CONST = 1000000
    • local string abc = "0123456789-"
    • local string c
    • set i = 0
    • loop
      • set a[i] = 0
      • set i = i + 1
      • exitwhen i >= 100
    • endloop
    • set m = 0
    • set i = 0
    • loop
      • set j = 0
      • loop
        • set a[j] = a[j] * CodeLength
        • set j = j + 1
        • exitwhen j > m
      • endloop
      • set skip = skip + 1
      • if skip == 4 then
        • set skip = 0
        • set i = i + 1
      • endif
      • set l = CodeLength
      • set c = SubString(s,i,i + 1)
      • loop
        • set l = l - 1
        • exitwhen l < 1
        • exitwhen SubString(udg_SaveLoad_Alphabet,l,l + 1) == c
      • endloop
      • set a[0] = a[0] + l
      • set j = 0
      • loop
        • set k = a[j] / CONST
        • set a[j] = a[j] - k * CONST
        • set a[j + 1] = a[j + 1] + k
        • set j = j + 1
        • exitwhen j > m
      • endloop
      • if k > 0 then
        • set m = m + 1
      • endif
      • set i = i + 1
      • exitwhen i >= StringLength(s)
    • endloop
    • loop
      • exitwhen m < 0
      • set j = m
      • loop
        • exitwhen j <= 0
        • set k = a[j] / 11
        • set a[j - 1] = a[j - 1] + (a[j] - k * 11) * CONST
        • set a[j] = k
        • set j = j - 1
      • endloop
      • set k = a[j] / 11
      • set i = a[j] - k * 11
      • set buffer = SubString(abc,i,i + 1) + buffer
      • set a[j] = k
      • if a[m] == 0 then
        • set m = m - 1
      • endif
    • endloop
    • set i = 0
    • set j = 0
    • loop
      • loop
        • exitwhen i >= StringLength(buffer)
        • exitwhen i > 0 and SubString(buffer,i,i + 1) == "-" and SubString(buffer,i - 1,i) != "-"
        • set i = i + 1
      • endloop
      • if i < StringLength(buffer) then
        • set k = i
      • endif
      • set SaveCode = SaveCode + 1
      • set udg_Save[SaveCode] = S2I(SubString(buffer,j,i))
      • set j = i + 1
      • set i = i + 1
      • exitwhen i >= StringLength(buffer)
    • endloop
    • set j = SaveLoad_EncodeVerify(SubString(buffer,0,k))
    • set udg_SaveCount = SaveCode - 1
    • if j == udg_Save[SaveCode] then
      • return true
    • endif
    • return false
  • endfunction
  • function SaveLoad_Encode takes nothing returns string
    • if udg_SaveLoad_CaseSensitive == false then
      • set udg_SaveLoad_Alphabet = StringCase(udg_SaveLoad_Alphabet,true)
    • endif
    • return SaveLoad_EncodeValues()
  • endfunction
  • function SaveLoad_Decode takes string s returns boolean
    • if udg_SaveLoad_CaseSensitive == false then
      • set udg_SaveLoad_Alphabet = StringCase(udg_SaveLoad_Alphabet,true)
      • set s = StringCase(s,true)
    • endif
    • if SaveLoad_DecodeValues(s) then
      • call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Decoding sucessful")
      • return true
    • endif
    • call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Decoding failed")
    • return false
  • endfunction
  • SaveLoad Initialization All
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet MaxLoads[1] = 0
      • Set VariableSet MaxLoads[2] = 0
      • Set VariableSet MaxLoads[3] = 0
      • Set VariableSet MaxLoads[4] = 0
      • Set VariableSet MaxLoads[5] = 0
      • Set VariableSet MaxLoads[6] = 0
      • Set VariableSet RegioPlayer[1] = Player 1 <gen>
      • Set VariableSet RegioPlayer[2] = Player 2 <gen>
      • Set VariableSet RegioPlayer[3] = Player 3 <gen>
      • Set VariableSet RegioPlayer[4] = Player 4 <gen>
      • Set VariableSet RegioPlayer[5] = Player 5 <gen>
      • Set VariableSet RegioPlayer[6] = Player 6 <gen>
      • Set VariableSet MonstersCountforPlayer[1] = 0
      • Set VariableSet CounterMonsterList[1] = 0
      • Set VariableSet MonstersCountforPlayer[2] = 0
      • Set VariableSet CounterMonsterList[2] = 0
      • Set VariableSet MonstersCountforPlayer[3] = 0
      • Set VariableSet CounterMonsterList[3] = 0
      • Set VariableSet MonstersCountforPlayer[4] = 0
      • Set VariableSet CounterMonsterList[4] = 0
      • Set VariableSet MonstersCountforPlayer[5] = 0
      • Set VariableSet CounterMonsterList[5] = 0
      • Set VariableSet MonstersCountforPlayer[6] = 0
      • Set VariableSet CounterMonsterList[6] = 0
      • -------- List of Heroes --------
      • Set VariableSet SaveLoad_Heroes[1] = Trainer
      • Set VariableSet SaveLoad_Heroes[2] = Trainer Female
      • Set VariableSet SaveLoad_Heroes[3] = |cff0000ffAquatic|r Laqua
      • Set VariableSet SaveLoad_Heroes[4] = |cff0000ffAquatic|r Laquid
      • Set VariableSet SaveLoad_Heroes[5] = |cff0000ffAquatic|r Lydro
      • Set VariableSet SaveLoad_Heroes[6] = |cff0000ffAquatic|r / |cff008000Nature|r Lydreef
      • Set VariableSet SaveLoad_Heroes[7] = |cff0000ffAquatic|r Zeanus
      • Set VariableSet SaveLoad_Heroes[8] = |cff0000ffAquatic|r / |cff008000Nature|r Coreal
      • Set VariableSet SaveLoad_Heroes[9] = |cff008000Nature|r Trent
      • Set VariableSet SaveLoad_Heroes[10] = |cff008000Nature|r Trentop
      • Set VariableSet SaveLoad_Heroes[11] = |cff008000Nature|r Trentus
      • Set VariableSet SaveLoad_Heroes[12] = |cff008000Nature|r Lorvi
      • Set VariableSet SaveLoad_Heroes[13] = |cff008000Nature|r Lurvin
      • Set VariableSet SaveLoad_Heroes[14] = |cff008000Nature|r Capod
      • Set VariableSet SaveLoad_Heroes[15] = |cff008000Nature|r Crocun
      • Set VariableSet SaveLoad_Heroes[16] = |cff008000Nature|r / |cff00ffffAir|r Wespah
      • Set VariableSet SaveLoad_Heroes[17] = |cff008000Nature|r / |cff00ffffAir|r Moonfree
      • Set VariableSet SaveLoad_Heroes[18] = |cff0000ffAquatic|r Cruby
      • Set VariableSet SaveLoad_Heroes[19] = |cff0000ffAquatic|r Crabbo
      • Set VariableSet SaveLoad_Heroes[20] = |cff0000ffAquatic|r Kinrub
      • Set VariableSet SaveLoad_Heroes[21] = |cffff0000Flame|r Anaconas
      • Set VariableSet SaveLoad_Heroes[22] = |cffff0000Flame|r Conas
      • Set VariableSet SaveLoad_Heroes[23] = |cffff0000Flame|r Kenas
      • Set VariableSet SaveLoad_Heroes[24] = |cffd45e19Beast|r Porcus
      • Set VariableSet SaveLoad_Heroes[25] = |cffd45e19Beast|r Tuskier
      • Set VariableSet SaveLoad_Heroes[26] = |cff0000ffAquatic|r Froggy
      • Set VariableSet SaveLoad_Heroes[27] = |cff0000ffAquatic|r Froggior
      • Set VariableSet SaveLoad_Heroes[28] = |cff0000ffAquatic|r Froggan
      • -------- Number of Heroes --------
      • Set VariableSet SaveLoad_Heroes_LastIndex = 25
      • -------- List of Items --------
      • Set VariableSet SaveLoad_Items[1] = Catchball
      • Set VariableSet SaveLoad_Items[2] = Great Catchball
      • Set VariableSet SaveLoad_Items[3] = Ultra Catchball
      • Set VariableSet SaveLoad_Items[4] = Magic Key Chain
      • Set VariableSet SaveLoad_Items[5] = Kelen's Dagger of Escape
      • Set VariableSet SaveLoad_Items[6] = Rusty Mining Pick
      • -------- Number of Items --------
      • Set VariableSet SaveLoad_Items_LastIndex = 6
      • -------- List of Abilities --------
      • Set VariableSet SaveLoad_Abilities[1] = Individual Value (Dexterity)
      • Set VariableSet SaveLoad_Abilities[2] = Individual Value (Spirit)
      • Set VariableSet SaveLoad_Abilities[3] = Individual Value (Stamina)
      • -------- Number of Abilities --------
      • Set VariableSet SaveLoad_Abilities_LastIndex = 6
      • -------- These three lines may be changed if needed --------
      • Set VariableSet SaveLoad_Alphabet = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&
      • Set VariableSet SaveLoad_CaseSensitive = True
      • Set VariableSet SaveLoad_UsePlayername = True
      • -------- Required: false --------
      • Set VariableSet SaveLoad_Initialized = False
      • -------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
      • Set VariableSet Code = AceHart
      • Set VariableSet Save[1] = 0
      • Set VariableSet SaveCount = 1
      • Set VariableSet Validate = False
      • Set VariableSet SaveLoad_Compress[1] = 0
      • Set VariableSet SaveLoad_Uncompress[1] = 0
  • SaveLoad Save All
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
      • Player - Player 2 (Blue) types a chat message containing -save as An exact match
      • Player - Player 3 (Teal) types a chat message containing -save as An exact match
      • Player - Player 4 (Purple) types a chat message containing -save as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -save as An exact match
      • Player - Player 6 (Orange) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • -------- Prepare the save array with this player's Hero --------
      • Set VariableSet SaveCount = 0
      • -------- Player's Gold --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Take all Heroes --------
      • Set VariableSet UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).)
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet Save[SaveCount] = (Number of units in UnitGroup)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • -------- Save the Hero --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet TempUnit = (Picked unit)
          • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
          • -------- Hero Experience --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Abilities --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Level of Individual Value (Dexterity) for (Picked unit))
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Level of Individual Value (Spirit) for (Picked unit))
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Level of Individual Value (Stamina) for (Picked unit))
          • -------- Hero Position X --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Integer((X of (Position of (Picked unit)))))
          • -------- Hero Position Y --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Integer((Y of (Position of (Picked unit)))))
          • -------- How many items does he carry --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Number of items carried by (Picked unit))
          • -------- Add all items --------
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
                • Then - Actions
                  • -------- The actual item --------
                  • Set VariableSet SaveCount = (SaveCount + 1)
                  • Set VariableSet TempItem = (Item carried by (Picked unit) in slot (Integer A))
                  • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
                  • -------- The number of charges it has --------
                  • Set VariableSet SaveCount = (SaveCount + 1)
                  • Set VariableSet Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
                • Else - Actions
      • -------- Turn values into code --------
      • Custom script: set udg_Code = SaveLoad_Encode()
      • -------- Show code to player --------
      • Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
  • SaveLoad Load All
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
      • Player - Player 5 (Yellow) types a chat message containing -load as A substring
      • Player - Player 6 (Orange) types a chat message containing -load as A substring
    • Conditions
      • MaxLoads[(Player number of (Triggering player))] Less than or equal to 3
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Set VariableSet MonsterOutsideBall[(Player number of (Triggering player))] = 0
      • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = 0
      • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MaxLoads[(Player number of (Triggering player))] Greater than 3
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: You tryed more than...
          • Skip remaining actions
        • Else - Actions
      • Set VariableSet MaxLoads[(Player number of (Triggering player))] = (MaxLoads[(Player number of (Triggering player))] + 1)
      • -------- Try to decode what was typed --------
      • Set VariableSet Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Validate Equal to False
        • Then - Actions
          • -------- Invalid code --------
          • Game - Display to (Player group((Triggering player))) the text: wrong code..
          • Skip remaining actions
        • Else - Actions
      • -------- It worked, let's do something with it --------
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set VariableSet SaveCount = 1
      • -------- Restore Gold --------
      • Player - Set (Triggering player).Current gold to Save[SaveCount]
      • -------- For "number of Heroes", do --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • For each (Integer B) from 1 to Save[SaveCount], do (Actions)
        • Loop - Actions
          • -------- Restore Hero --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
          • Unit - Create 1 TempUnitType for (Triggering player) at (Random point in RegioPlayer[(Player number of (Triggering player))]) facing Default building facing degrees
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Unit-type of (Last created unit)) Not equal to Trainer) or ((Unit-type of (Last created unit)) Not equal to Trainer Female)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering player) Equal to Player 1 (Red)
                • Then - Actions
                  • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                  • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = (MonstersCountforPlayer[(Player number of (Triggering player))] + 1)
                  • Set VariableSet MonsterListPlayer1[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Triggering player) Equal to Player 2 (Blue)
                    • Then - Actions
                      • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = (MonstersCountforPlayer[(Player number of (Triggering player))] + 1)
                      • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                      • Set VariableSet MonsterListPlayer2[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Triggering player) Equal to Player 3 (Teal)
                        • Then - Actions
                          • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = (MonstersCountforPlayer[(Player number of (Triggering player))] + 1)
                          • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                          • Set VariableSet MonsterListPlayer3[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Triggering player) Equal to Player 4 (Purple)
                            • Then - Actions
                              • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = (MonstersCountforPlayer[(Player number of (Triggering player))] + 1)
                              • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                              • Set VariableSet MonsterListPlayer4[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Triggering player) Equal to Player 5 (Yellow)
                                • Then - Actions
                                  • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = (MonstersCountforPlayer[(Player number of (Triggering player))] + 1)
                                  • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                                  • Set VariableSet MonsterListPlayer5[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Triggering player) Equal to Player 6 (Orange)
                                    • Then - Actions
                                      • Set VariableSet MonstersCountforPlayer[(Player number of (Triggering player))] = (MonstersCountforPlayer[(Player number of (Triggering player))] + 1)
                                      • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                                      • Set VariableSet MonsterListPlayer6[(Player number of (Triggering player))] = (Last created unit)
                                    • Else - Actions
            • Else - Actions
              • Do nothing
          • -------- Set Experience --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Unit - Set level of Individual Value (Dexterity) for (Triggering unit) to Save[SaveCount]
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Unit - Set level of Individual Value (Spirit) for (Triggering unit) to Save[SaveCount]
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Unit - Set level of Individual Value (Stamina) for (Triggering unit) to Save[SaveCount]
          • -------- Move to saved position --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnitType Equal to Trainer) or (TempUnitType Equal to Trainer Female)
            • Then - Actions
              • Unit - Move (Last created unit) instantly to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)]))))
              • Camera - Pan camera for (Owner of (Last created unit)) to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)])))) over 1.00 seconds
            • Else - Actions
          • Set VariableSet SaveCount = (SaveCount + 1)
          • -------- Recreate all items --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • For each (Integer A) from 1 to Save[SaveCount], do (Actions)
            • Loop - Actions
              • -------- The actual item --------
              • Set VariableSet SaveCount = (SaveCount + 1)
              • Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
              • Hero - Create TempItemType and give it to (Last created unit)
              • -------- Number of charges --------
              • Set VariableSet SaveCount = (SaveCount + 1)
              • Item - Set charges remaining in (Last created item) to Save[SaveCount]
  • SaveLoad error
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
      • Player - Player 5 (Yellow) types a chat message containing -load as A substring
      • Player - Player 6 (Orange) types a chat message containing -load as A substring
    • Conditions
      • MaxLoads[(Player number of (Triggering player))] Greater than 3
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Game - Display to (Player group((Triggering player))) for 15.00 seconds the text: You tried more than...
 
Level 17
Joined
Mar 21, 2011
Messages
1,611
Save Trigger: Add this code

  • Set VariableSet SaveCount = (SaveCount + 1)
  • Set VariableSet Save[SaveCount] = Level of Ability(Strength)
  • //.. Do that with Agility and Intelligence too
Load Trigger: Add this code

  • Set VariableSet SaveCount = (SaveCount + 1)
  • Unit - Set Level of Ability(Strength) to Save[SaveCount]
  • //.. Do that with Agility and Intelligence too
 
Level 8
Joined
Feb 20, 2020
Messages
207
the code i posted is the code ^^
go to the save, in unit group part then abilities, you will see "dexterity, stamina and spirit" that are the name of the attribute bonus.
in the load part its after "set experience"
 
Status
Not open for further replies.
Top