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

automated save/load system

Status
Not open for further replies.
Level 9
Joined
Dec 31, 2016
Messages
320
I've been seeing a lot of maps lately with save/load system that is automated, meaning once you start the map it automatically loads your stats. (just like in starcraft 2)

I've never seen it before reforged, so I was just wondering what they changed or added to make this possible.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Codeless save and load systems have existed for a few years now.

Codeless Save and Load (Multiplayer) - v3.0.1


I attached an edited version of the above system. I cut out some of the unwanted features and made examples of autosaving/autoloading and manually typing -save/-load.

If you want more than 1 Save Slot you'll have to edit it slightly (I think it has a limit of 5 save slots).

The save slot is the Integer that is used in the custom script that you can find at the bottom of the Save/Load triggers.


This one is at the bottom of the Load triggers:
  • Custom script: call LoadSaveSlot(udg_SaveLoadEvent_Player, 1)
These are at the bottom of the Save triggers. I'm not 100% certain if you have to modify BOTH of these or not:
  • Custom script: set udg_SaveTempString = Savecode(udg_SaveTempInt).Save(udg_SaveLoadEvent_Player, 1)
  • Custom script: call SaveFile.create(udg_SaveLoadEvent_Player, "Save", 1, udg_SaveTempString)
 

Attachments

  • Save and Load Example 3.w3x
    148.1 KB · Views: 39
Last edited:
Level 9
Joined
Dec 31, 2016
Messages
320
So if I want to save 2 values like in this example "footman count" and "player gold" I need to create 2 save slots, right? I didn't manage it to work without it.
  • Autosave
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet SaveLoadEvent_Player = (Picked player)
          • -------- ------------------- --------
          • Set VariableSet SaveCount = 0
          • -------- ------------------- --------
          • Custom script: call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "Saved " + User[udg_SaveLoadEvent_Player].nameColored)
          • -------- ------------------- --------
          • -------- ------------------- --------
          • -------- PUT YOUR SAVE ACTIONS HERE: --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet SaveValue[SaveCount] = (SaveLoadEvent_Player Current gold)
          • Set VariableSet SaveMaxValue[SaveCount] = 99999
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet SaveValue[SaveCount] = footmanCount
          • Set VariableSet SaveMaxValue[SaveCount] = 99999
          • -------- STOP --------
          • -------- ------------------- --------
          • -------- ------------------- --------
          • -------- Save to disk --------
          • -------- ------------------- --------
          • Custom script: set udg_SaveTempInt = Savecode.create()
          • For each (Integer A) from 0 to SaveCount, do (Actions)
            • Loop - Actions
              • Custom script: call Savecode(udg_SaveTempInt).Encode(udg_SaveValue[bj_forLoopAIndex], udg_SaveMaxValue[bj_forLoopAIndex])
          • Set VariableSet SaveTempString = <Empty String>
          • Custom script: set udg_SaveTempString = Savecode(udg_SaveTempInt).Save(udg_SaveLoadEvent_Player, 1)
          • Custom script: call SaveFile.create(udg_SaveLoadEvent_Player, "Save", 1, udg_SaveTempString)
          • Custom script: set udg_SaveTempString = Savecode(udg_SaveTempInt).Save(udg_SaveLoadEvent_Player, 2)
          • Custom script: call SaveFile.create(udg_SaveLoadEvent_Player, "Save", 2, udg_SaveTempString)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I imagine the system isn't designed to handle something like that.

You'd probably have to run the trigger twice, with different Save Files chosen in each trigger.

It would probably be easier to test this out using the type commands. Add an Integer variable to it that is set to whatever you type, like -save 1, -save 2, -save 3, etc... Then reference this Integer in the Custom Script.

And don't forget to adjust the Custom Script in the Load triggers as well.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Oh, I misread your post. No, you don't split up what you want to save between your Save Files.

Separate Save Files are used for saving separate sets of Data. So for example, say in your RPG you wanted to save 2 Characters. You can save your Level 60 Warrior to Save File 1, and your Level 40 Mage to Save File 2.

Here's an example of Autosaving Player Gold, Lumber, and Footman Count. It's all being saved to Save File 1. When I load Save File 1, I will load these values.
  • Autosave
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet SaveLoadEvent_Player = (Picked player)
          • -------- ------------------- --------
          • Set VariableSet SaveCount = 0
          • -------- ------------------- --------
          • Custom script: call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "Saved " + User[udg_SaveLoadEvent_Player].nameColored)
          • -------- ------------------- --------
          • -------- ------------------- --------
          • -------- PUT YOUR SAVE ACTIONS HERE: --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet SaveValue[SaveCount] = (SaveLoadEvent_Player Current gold)
          • Set VariableSet SaveMaxValue[SaveCount] = 99999
          • -------- --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet SaveValue[SaveCount] = (SaveLoadEvent_Player Current lumber)
          • Set VariableSet SaveMaxValue[SaveCount] = 99999
          • -------- --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet SaveValue[SaveCount] = (Number of living Footman units owned by SaveLoadEvent_Player)
          • Set VariableSet SaveMaxValue[SaveCount] = 500
          • -------- STOP --------
          • -------- ------------------- --------
          • -------- ------------------- --------
          • -------- Save to disk --------
          • -------- ------------------- --------
          • Custom script: set udg_SaveTempInt = Savecode.create()
          • For each (Integer A) from 0 to SaveCount, do (Actions)
            • Loop - Actions
              • Custom script: call Savecode(udg_SaveTempInt).Encode(udg_SaveValue[bj_forLoopAIndex], udg_SaveMaxValue[bj_forLoopAIndex])
          • Set VariableSet SaveTempString = <Empty String>
          • Custom script: set udg_SaveTempString = Savecode(udg_SaveTempInt).Save(udg_SaveLoadEvent_Player, 1)
          • Custom script: call SaveFile.create(udg_SaveLoadEvent_Player, "Save", 1, udg_SaveTempString)
Here's how you would load that saved Data from Save File 1. You must load in the reverse order of how you saved.
  • Load Event
    • Events
      • Game - SaveLoadEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- ------------------- --------
      • -------- Validate --------
      • -------- ------------------- --------
      • Set VariableSet SaveCount = 0
      • Custom script: set udg_SaveTempInt = integer(Savecode.create())
      • Custom script: if not (Savecode(udg_SaveTempInt).Load(udg_SaveLoadEvent_Player, udg_SaveLoadEvent_Code, 1)) then
      • Game - Display to (Player group(SaveLoadEvent_Player)) the text: Invalid load code (...
      • Skip remaining actions
      • Custom script: endif
      • Custom script: call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Loaded " + User[udg_SaveLoadEvent_Player].nameColored)
      • -------- ------------------- --------
      • -------- ------------------- --------
      • -------- PUT YOUR LOAD ACTIONS HERE: --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveMaxValue[SaveCount] = 500
      • Custom script: call SaveHelper.GUILoadNext()
      • Unit - Create SaveValue[SaveCount] Footman for SaveLoadEvent_Player at (Center of (Playable map area)) facing Default building facing degrees
      • -------- --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveMaxValue[SaveCount] = 99999
      • Custom script: call SaveHelper.GUILoadNext()
      • Player - Set SaveLoadEvent_Player.Current lumber to SaveValue[SaveCount]
      • -------- --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveMaxValue[SaveCount] = 99999
      • Custom script: call SaveHelper.GUILoadNext()
      • Player - Set SaveLoadEvent_Player.Current gold to SaveValue[SaveCount]
      • -------- STOP --------
      • -------- ------------------- --------
      • -------- ------------------- --------
      • Custom script: call Savecode(udg_SaveTempInt).destroy()
Some other important things to note:

-SaveMaxValue needs to match between your Save/Load triggers. Try to keep this value on the lower side when possible. So in my example, I set the SaveMaxValue for Footman Count to 500, as i'm confident that the player won't be able to have more than 500 Footman. When I load this data, I need to set the SaveMaxValue to 500 as well.

-You must Load your Saved Data in the reverse order of how you Saved it. So in my example, I would need to load Footman Count 1st, Lumber 2nd, and Gold 3rd.

-This ones weird but extremely IMPORTANT. The Codeless Save/Load System relies on the Aerial Shackles ability as part of its's design. This ability needs to have TWO levels otherwise it won't work. If you're already using this ability in your map then I recommend creating a copy of it and using that copy instead.
 
Last edited:
Status
Not open for further replies.
Top