[AceHart] Save/Load stats help.

Zonagle

New Member
Reaction score
1
Help with saving attributes

Original problem solved. New problem.
When I pick up two potions (not the potions in the save item list), save, load, drop both potions, save again, then load. I get 1 potion in the first slot.

What would I need to put in, to prevent loading more than once per game? I'd prefer to fix the item problem, rather than limiting the amount of times you're able to save.

AceHarts Save/Load system: http://www.thehelper.net/forums/showthread.php?t=49392

The code I'm currently using.
Trigger:
  • SaveLoad Initialization All Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- List of Heroes --------
      • Set SaveLoad_Heroes[1] = |cffff0000Nature Protector|r
      • Set SaveLoad_Heroes[2] = Void Golem
      • Set SaveLoad_Heroes[3] = |cffeffa1bCarnifex|r
      • Set SaveLoad_Heroes[4] = |cffff0000Lich King|r
      • Set SaveLoad_Heroes[5] = |cff00bfffElemental Mage|r
      • Set SaveLoad_Heroes[6] = |cfff8fb68Arch Angel|r
      • Set SaveLoad_Heroes[7] = |cff7cfc00Ranger|r
      • Set SaveLoad_Heroes[8] = |cffff0000Fighter|r
      • -------- Number of Heroes --------
      • Set SaveLoad_Heroes_LastIndex = 8
      • -------- List of Items --------
      • -------- Number of Items --------
      • Set SaveLoad_Items_LastIndex = 21
      • -------- List of Abilities --------
      • Set SaveLoad_Abilities[1] = Bash
      • Set SaveLoad_Abilities[2] = Flame Strike
      • Set SaveLoad_Abilities[3] = Phoenix
      • Set SaveLoad_Abilities[4] = Siphon Mana
      • -------- Number of Abilities --------
      • Set SaveLoad_Abilities_LastIndex = 4
      • -------- 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




Trigger:
  • SaveLoad Save All Copy
    • 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
      • Set UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
      • 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 )
          • Game - Display to (All players) the text: (Save[1]= + (String(Save[SaveCount])))
          • -------- Hero level --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Player's Gold --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = ((Triggering player) Current gold)
          • -------- Savehero STR/AGI/INT --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Strength of (Picked unit) (Exclude bonuses))
          • Game - Display to (All players) the text: (STR: + (String(Save[SaveCount])))
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Agility of (Picked unit) (Exclude bonuses))
          • Game - Display to (All players) the text: (AGI: + (String(Save[SaveCount])))
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Intelligence of (Picked unit) (Exclude bonuses))
          • Game - Display to (All players) the text: (INT: + (String(Save[SaveCount])))
          • -------- 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 )
                  • Game - Display to (All players) the text: (SAVED ITEM: + (Name of TempItem))
                • 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



Trigger:
  • SaveLoad Load All Copy
    • 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 Hero --------
      • Game - Display to (All players) the text: (String(Save[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
      • -------- Position --------
      • -------- Restore Gold --------
      • Set SaveCount = (SaveCount + 1)
      • Player - Set (Triggering player) Current gold to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • -------- Set stats STR/AGI/INT --------
      • Hero - Modify Strength of (Last created unit): Set to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • Hero - Modify Agility of (Last created unit): Set to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • Hero - Modify Intelligence of (Last created unit): Set to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • -------- Recreate all items --------
      • 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)
      • 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)
      • 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)
      • 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)
      • 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)
      • 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)


As always, any help is appreciated.
 

Chaos_Knight

New Member
Reaction score
39
Strange.. It worked in my last map, which i didnt complete and deleted..
Have you changed anything more than the units?
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
You load the experience and position of the hero in the load trigger, but you never save them in the save trigger. Removing the actions for loading position and experience should fix the problem with the attributes (Unless you want the position and experience, in which case you should add them to the save trigger).
 

Zonagle

New Member
Reaction score
1
You load the experience and position of the hero in the load trigger, but you never save them in the save trigger. Removing the actions for loading position and experience should fix the problem with the attributes (Unless you want the position and experience, in which case you should add them to the save trigger).

Alright, thanks, I'll try that and edit with results.


Edit: Alright, I deleted the load position, and the stats saved fine. What do you mean I don't save the experience? Isn't that what's saved in the Hero Level part? "Set Save[SaveCount] = (Hero experience of (Picked unit))"

Edit2: New problem. When I pick up two potions (not the potions in the save item list), save, load, drop both potions, save again, then load. I get 1 potion in the first slot. What would I need to put in, to prevent loading more than once per game?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top