• 🏆 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!

I need some help with AceHeart's Save/Load system.

Status
Not open for further replies.
Level 15
Joined
Nov 26, 2005
Messages
1,151
Ok. I implemented AceHeart's Save/Load system.
Here's a link to it: http://www.thehelper.net/forums/sho...oad-Code-Yet-Another?highlight=save+load+code (So that u can see what I am talking about)

Now there is one small thing I need to add and doen't seem to work.

This system is deigned to save and load abilities that are 'Hero', not 'Unit'. So when u level up Holy Light from the Hero ability menu - it will be saved good.
BUT
When u pick ur hero it must choose between several bonuses avaliable which are Spellbook abilities with things inside them. So I need THEM saved.
Actually what I'd like is to replace all hero-levelable abilities with normal unit abilities, such as these spellbooks. Because u won't have to level any ability in this map.
Please help.

Here are the triggers I am using:



  • SaveLoad Initialization All
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- List of Heroes --------
      • Set SaveLoad_Heroes[1] = Blademaster
      • Set SaveLoad_Heroes[2] = Far Seer
      • Set SaveLoad_Heroes[3] = Tauren Chieftain
      • Set SaveLoad_Heroes[4] = Shadow Hunter
      • -------- Number of Heroes --------
      • Set SaveLoad_Heroes_LastIndex = 4
      • -------- List of Items --------
      • Set SaveLoad_Items[1] = Claws of Attack +15
      • Set SaveLoad_Items[2] = Cheese
      • Set SaveLoad_Items[3] = Wand of Lightning Shield
      • Set SaveLoad_Items[4] = Magic Key Chain
      • Set SaveLoad_Items[5] = Arcanite Shield
      • Set SaveLoad_Items[6] = The Heart of Searinox
      • Set SaveLoad_Items[7] = Urn of King Terenas
      • -------- Number of Items --------
      • Set SaveLoad_Items_LastIndex = 7
      • -------- List of Abilities --------
      • Set SaveLoad_Abilities[1] = Normal Skills
      • Set SaveLoad_Abilities[2] = Normal Skills_Berserk
      • Set SaveLoad_Abilities[3] = Normal Skills_CRIT
      • Set SaveLoad_Abilities[4] = Normal Skills_Net
      • Set SaveLoad_Abilities[5] = Normal Skills_SPLASH
      • Set SaveLoad_Abilities[6] = Test Bonus
      • -------- Number of Abilities --------
      • Set SaveLoad_Abilities_LastIndex = 6
      • -------- These three lines may be changed if needed --------
      • Set SaveLoad_Alphabet = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
      • Set SaveLoad_CaseSensitive = True
      • 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
      • 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
      • Player - Player 7 (Green) types a chat message containing -save as An exact match
      • Player - Player 8 (Pink) 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)
      • -------- Player's Lumber --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • -------- 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 Stats --------
          • -------- ----- Str ----- --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Strength of (Picked unit) (Exclude bonuses))
          • -------- ----- Agi ----- --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Agility of (Picked unit) (Exclude bonuses))
          • -------- ----- Int ----- --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Intelligence of (Picked unit) (Exclude bonuses))
          • -------- End Stats --------
          • -------- 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
          • -------- Add all abilities --------
          • For each (Integer A) from 1 to SaveLoad_Abilities_LastIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of SaveLoad_Abilities[(Integer A)] for (Picked unit)) Greater than 0
                • Then - Actions
                  • -------- The actual ability --------
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = (Integer A)
                  • -------- Its level --------
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = (Level of SaveLoad_Abilities[(Integer A)] for (Picked unit))
                • 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
      • Player - Player 7 (Green) types a chat message containing -load as A substring
      • Player - Player 8 (Pink) 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: Invalid Code!
          • Skip remaining actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is in Has_A_Hero) Equal to False
            • Then - Actions
              • -------- It worked, let's do something with it --------
              • Game - Display to (Player group((Triggering player))) the text: Code Accepted!
              • 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
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Unit-type of (Matching unit)) Equal to Priest)) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Player Group - Add (Triggering player) to Has_A_Hero
              • Set TempInteger = SaveCount
              • Set SaveCount = 1
              • -------- Restore Gold --------
              • Player - Set (Triggering player) Current gold to Save[SaveCount]
              • Set SaveCount = (SaveCount + 1)
              • Player - Set (Triggering player) Current lumber 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
                  • -------- Set Str --------
                  • Set SaveCount = (SaveCount + 1)
                  • Hero - Modify Strength of (Last created unit): Set to Save[SaveCount]
                  • -------- Set Agi --------
                  • Set SaveCount = (SaveCount + 1)
                  • Hero - Modify Agility of (Last created unit): Set to Save[SaveCount]
                  • -------- Set Int --------
                  • Set SaveCount = (SaveCount + 1)
                  • Hero - Modify Intelligence of (Last created unit): Set to Save[SaveCount]
                  • -------- 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]
                  • -------- Abilites Load --------
                  • For each (Integer SaveCount) from (SaveCount + 1) to TempInteger, do (Actions)
                    • Loop - Actions
                      • For each (Integer A) from 1 to Save[(SaveCount + 1)], do (Actions)
                        • Loop - Actions
                          • Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )
                      • Set SaveCount = (SaveCount + 1)
                  • Unit - Move (Last created unit) instantly to (Center of Hero Start <gen>)
                  • Camera - Pan camera for (Triggering player) to (Center of Hero Start <gen>) over 0.20 seconds
            • Else - Actions
              • Game - Display to (Player group((Triggering player))) the text: You already have a ...


Here is the part I think the solution to this problem must be:

  • -------- Abilites Load --------
  • For each (Integer SaveCount) from (SaveCount + 1) to TempInteger, do (Actions)
    • Loop - Actions
      • For each (Integer A) from 1 to Save[(SaveCount + 1)], do (Actions)
        • Loop - Actions
          • Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )
      • Set SaveCount = (SaveCount + 1)
  • Unit - Move (Last created unit) instantly to (Center of Hero Start <gen>)
  • Camera - Pan camera for (Triggering player) to (Center of Hero Start <gen>) over 0.20 seconds
  • Else - Actions
    • Game - Display to (Player group((Triggering player))) the text: You already have a ...
But no matter what I try it still doen't want to load my non-hero abilities, such as these dummy spellbooks I am using.

Thank you.
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
Well it is shown in the trigger above:

Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )

But, I tried replacing it with the GUI function Add ability. It doen't work. I think that there should be a different organisation with the Save, SaveCount stuff. I can't seem to figure that out?

Would you mind being more specific please ? :)
 
try this first... replace all integer A loops with a variable loop... coz I had errors with this save-load system a long time ago when I used successive integer A loops...

and I think the problem is that your loop is from (Integer SaveCount) from (SaveCount + 1) to TempInteger... you set TempInteger to the first SaveCount which is senseless... you should have saved the total number of abilities that unit has and use that...
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
Then what should my loop be? Cause there can be many many dummy spelllbooks which I want to add, so I can't know how many abilities the unit will have. What should my loop be and what should the add ability lines be?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I don't said anything about it will work or not, I just said GUI has that action.
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
post the new triggersssss... and oh the system has a limit on the amount of integer it can save (I think its a value rather than how many...)... which is why I stopped using it...

if you can learn vJASS, wait for Nestharus' Encoder 2.0...

1. What do u mean limited? Limited amount ? How big is it? Up to how many things can the system save?

2. I was hoping to see that Encodeer 2.0 but ... I guess we have to wait a lot more :)
 
Status
Not open for further replies.
Top