• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] AceHarts Save and Load System

Status
Not open for further replies.
Level 4
Joined
Aug 16, 2013
Messages
75
Hello, I'm having trouble with this save and load system. It's a pretty easy read one but what I don't understand is why I can't save 10 heroes/units (per player), and why I can't save more than 6 items (per player). Abilities learned also aren't saved/loaded in this version, there were around 3-4 save/load versions that he had, but this "save all" doesn't save and load abilities. I made changes to it, but then reverted back to how it was(mostly) because when I type in -save the code doesn't show up. If anybody could help, that'd be great because I don't know much about save and load systems, other than basic knowledge like how they save/load array variables.

I only want the following in the system to be saved, (every time I try and edit it and make it do what I want it to do, the -save command doesn't show the save code in-game)

1. Hero

2. Experience Percentage

3. Items and item stacks

(All items saved, not just 6), (Each player will have units that will act like inventory backpacks, you'll be able to switch from inventory with them with an ability)

(Once the units that act like bags are loaded, I need them to be usable by the ability which switches inventorys.

4. Around 10+ heroes/units saved.

5. Gold and Lumber

That's all I want, I can't get this to work with those 5 things. This would be really good for my map, but I don't have a clue other than the code might be getting to long for it to appear/create.

  • SaveLoad Initialization All
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- List of Heroes --------
      • Set SaveLoad_Heroes[1] = Paladin
      • -------- Number of Heroes --------
      • Set SaveLoad_Heroes_LastIndex = 1
      • -------- List of Items --------
      • Set SaveLoad_Items[1] = Rusty Watering Can
      • Set SaveLoad_Items[2] = Rusty Hoe
      • Set SaveLoad_Items[3] = Rusty Axe
      • Set SaveLoad_Items[4] = Turnip Seed
      • Set SaveLoad_Items[5] = Strawberry Seed
      • -------- Number of Items --------
      • Set SaveLoad_Items_LastIndex = 5
      • -------- List of Abilities --------
      • Set SaveLoad_Abilities[1] = Holy Light
      • -------- Number of Abilities --------
      • Set SaveLoad_Abilities_LastIndex = 1
      • -------- These three lines may be changed if needed --------
      • Set SaveLoad_Alphabet = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
      • Set SaveLoad_CaseSensitive = False
      • Set SaveLoad_UsePlayername = True
      • -------- Required: false --------
      • Set SaveLoad_Initialized = False
      • -------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
      • Set Code = AceHart
      • Set Save[1] = 0
      • Set SaveCount = 1
      • Set Validate = False
      • Set SaveLoad_Compress[1] = 0
      • Set 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
    • Conditions
    • Actions
      • -------- Prepare the save array with this player's Hero --------
      • Set SaveCount = 0
      • -------- Player's Gold --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Take all Heroes --------
      • Set UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Number of units in UnitGroup)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • -------- Save the Hero --------
          • Set SaveCount = (SaveCount + 1)
          • Set TempUnit = (Picked unit)
          • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
          • -------- Hero Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Hero Position X --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Integer((X of (Position of (Picked unit)))))
          • -------- Hero Position Y --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Integer((Y of (Position of (Picked unit)))))
          • -------- How many items does he carry --------
          • Set SaveCount = (SaveCount + 1)
          • Set 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 SaveCount = (SaveCount + 1)
                  • Set 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 SaveCount = (SaveCount + 1)
                  • Set 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
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • -------- Try to decode what was typed --------
      • Set 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: There's some error ...
          • 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 SaveCount = 1
      • -------- Restore Gold --------
      • Player - Set (Triggering player) Current gold to Save[SaveCount]
      • -------- For "number of Heroes", do --------
      • Set SaveCount = (SaveCount + 1)
      • For each (Integer B) from 1 to Save[SaveCount], do (Actions)
        • Loop - Actions
          • -------- Restore Hero --------
          • Set SaveCount = (SaveCount + 1)
          • Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
          • Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
          • -------- Set Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
          • -------- Move to saved position --------
          • Set SaveCount = (SaveCount + 1)
          • Unit - Move (Last created unit) instantly to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)]))))
          • Set SaveCount = (SaveCount + 1)
          • -------- Recreate all items --------
          • Set SaveCount = (SaveCount + 1)
          • For each (Integer A) from 1 to Save[SaveCount], do (Actions)
            • Loop - Actions
              • -------- The actual item --------
              • Set 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 SaveCount = (SaveCount + 1)
              • Item - Set charges remaining in (Last created item) to Save[SaveCount]


I'd like it if the hero would spawn randomly in a region instead of the system saving its X and Y coordinates. Also, the bags that will be saved will be in a certain region as well.
 

Attachments

  • SaveLoad_Demo_AceHart.w3x
    31.4 KB · Views: 75
Level 31
Joined
Jul 10, 2007
Messages
6,306
Honestly, I don't recommend the use of AceHart's save/load system. It is among the worst Save/Load systems of all of the save/load systems of all of the sites, lol.

Anyways, the main points are the init area, where you set up heroes etc, should be self explanatory. Add all heroes you want to save etc to that area.

Next you have the onSave

This is what is saving the hero position. If you don't want it saved, just delete these lines

  • -------- Hero Position X --------
  • Set SaveCount = (SaveCount + 1)
  • Set Save[SaveCount] = (Integer((X of (Position of (Picked unit)))))
  • -------- Hero Position Y --------
  • Set SaveCount = (SaveCount + 1)
  • Set Save[SaveCount] = (Integer((Y of (Position of (Picked unit)))))
If you want to save bags, just iterate over items in bags and then save item details by adding it to the array with SaveCount = SaveCount + 1 and Save[SaveCount] = item type id, etc.

I can't save 10 heroes/units (per player)

This is likely because you are running into the string input limit for wc3, which is like 120 characters, or 127, w/e. A player can't input an infinitely sized code, there's a limit. If you want to save that much data, you might want to look into compressing it further with things like Catalog and BigInt (found on this site). It'll reduce your code size by a lot, and enable you to save those heroes ;). Furthermore, look into conditional save/load.

Let me link you to a save/load tutorial I wrote so that you learn stuffs. Just run the map in wc3 and go through it. You don't have to go through all of it as the stuff starts to get pretty complicated, but you definitely want to hit on conditional save/load, lossy compression techniques, and catalog techniques.

http://www.hiveworkshop.com/forums/...ading-interactive-saving-loading-tutorial.w3m

As for security, don't save the player name because AceHart's player unique code stuff is garbage. Don't enable any of the security for AceHart's really, it's all crap, lol. The best security right now that will also give you the smallest code sizes are Scrambler/AES (AES will be a minimum code size, both player unique) along with KnuthChecksum. There is MD5, but that'll be pretty big.


I really recommend that you learn vJASS, srsly. Save/Load is so easy to do in vJASS :D. There is also a codeless save/load library, but I don't recommend its usage because syncing in wc3 is sooooooo freaking slow, :p.
 
Status
Not open for further replies.
Top