Tutorial Guide for Save Load Code

Chocobo

White-Flower
Reaction score
409
This is the guide which will be frequently updated because the lot of questions given in the thread 29952 (http://www.thehelper.net/forums/showthread.php?t=29952&page=6&pp=15).

It will be on 9 parts, the 3 first for 0.18f and 0.19a Versions, and the 3 nexts for 0.19h Version (Coming), and the 3 lasts for 0.20c Version (Coming). I also "publicize" Effane's tutorial, so less threads will be created because the most of threads that wants Save Load Codes. The Guide will be splited into 3 parts (Which contains 3 Consecutive Posts) mentionned at the top of the post.
To all who wants to ask a question about the Save Load Code map, post it here.
*Little Indian Order, mentionned at the end of this post, mean the Inverse Order. Example : 1 2 3 4 = 4 3 2 1

I make a Mini-Tutorial for Save Load Code 0.18f/0.19a and 0.19h due to the lot of "I don't know what to do", or "What must I modify", or "How it works?".
If you want a Save Load code that saves Gold and Wood, I recommand you to read the Tutorial and to use Effane's Triggers located here :
http://www.thehelper.net/forums/showthread.php?t=37153&page=1
http://www.thehelper.net/forums/attachment.php?attachmentid=5830

The Little Hard Mode
1. High Protection Code (0.18f/0.19a) (Post 1)
1.1 Source Code (Post 1)
1.2 How Save works? (Post 1)
1.3 How Load works? (Post 2)
1.4 What to modify? (Post 2)
1.5 How works Base10 to Base32 and what is it? (Post 2)
1.6 Dummy Functions inside the map. How it works? (Post 3)
1.7 Variable List Used (Post 3)
1.8 Frequently Asked Questions (Post 3)

The Easiest Mode
2. Unprotected Code (0.19h) (LATER, Post 4)
2.1 Source Code (LATER, Post 4)
2.2 Save Code Work (LATER, Post 4)
2.3 Load Code Work (LATER, Post 5)
2.4 What to modify there? (LATER, Post 5)
2.5 Frequently Asked Questions (LATER, Post 6)

The Hardest Mode Possible (LATER, Post 7, REALLY LATER)
3 Unproteted Code (LATER, Post 7, REALLY LATER)
3.1 Source Code (LATER, Post 7, REALLY LATER)
3.2 Save Code in JASS Scripts (LATER, Post 7, REALLY LATER)
3.3 Load Code in JASS Scripts (LATER, Post 8, REALLY LATER)
3.4 How to modify it (LATER, Post 8, REALLY LATER)
3.5 Frequently Asked Questions (LATER, Post 9, REALLY LATER)


1. High Protection Code (0.18f/0.19a)

Save Load Codes 0.18f/0.19a uses a heavy name protection inside the code, randomizing one digit or more for the code.

Saves :
Level (Max of 999)
6 Items Carried
1 Hero Type
Player Name Protection

1.1 Source Code

Code:
Detect Hero
    Events
        Unit - Summoner 0001 <gen> Finishes training a unit
    Conditions
        ((Trained unit) is A Hero) Equal to True
    Actions
        Set Hero[(Player number of (Owner of (Trained unit)))] = (Trained unit)

This detect when a Hero is trained by the unit "Summoner 0001 <gen>". It sets the Hero to the Variable Hero[Player number of owner of the hero].


Code:
Randomize
    Events
    Conditions
    Actions
        Set Playername = (Substring(Playername, 1, 1))
        Set RandomizeCode = 17
        If (Playername Equal to a) then do (Set RandomizeCode = 17) else do (Do nothing)
        If (Playername Equal to b) then do (Set RandomizeCode = 5) else do (Do nothing)
        If (Playername Equal to c) then do (Set RandomizeCode = 16) else do (Do nothing)
        If (Playername Equal to d) then do (Set RandomizeCode = 8) else do (Do nothing)
        If (Playername Equal to e) then do (Set RandomizeCode = 4) else do (Do nothing)
        If (Playername Equal to f) then do (Set RandomizeCode = 7) else do (Do nothing)
        If (Playername Equal to g) then do (Set RandomizeCode = 1) else do (Do nothing)
        If (Playername Equal to h) then do (Set RandomizeCode = 15) else do (Do nothing)
        If (Playername Equal to i) then do (Set RandomizeCode = 10) else do (Do nothing)
        If (Playername Equal to j) then do (Set RandomizeCode = 12) else do (Do nothing)
        If (Playername Equal to k) then do (Set RandomizeCode = 9) else do (Do nothing)
        If (Playername Equal to l) then do (Set RandomizeCode = 3) else do (Do nothing)
        If (Playername Equal to m) then do (Set RandomizeCode = 6) else do (Do nothing)
        If (Playername Equal to n) then do (Set RandomizeCode = 11) else do (Do nothing)
        If (Playername Equal to o) then do (Set RandomizeCode = 2) else do (Do nothing)
        If (Playername Equal to p) then do (Set RandomizeCode = 14) else do (Do nothing)
        If (Playername Equal to q) then do (Set RandomizeCode = 13) else do (Do nothing)
        If (Playername Equal to r) then do (Set RandomizeCode = 11) else do (Do nothing)
        If (Playername Equal to s) then do (Set RandomizeCode = 6) else do (Do nothing)
        If (Playername Equal to t) then do (Set RandomizeCode = 5) else do (Do nothing)
        If (Playername Equal to u) then do (Set RandomizeCode = 1) else do (Do nothing)
        If (Playername Equal to v) then do (Set RandomizeCode = 8) else do (Do nothing)
        If (Playername Equal to w) then do (Set RandomizeCode = 17) else do (Do nothing)
        If (Playername Equal to x) then do (Set RandomizeCode = 15) else do (Do nothing)
        If (Playername Equal to y) then do (Set RandomizeCode = 9) else do (Do nothing)
        If (Playername Equal to z) then do (Set RandomizeCode = 16) else do (Do nothing)
        If (Playername Equal to A) then do (Set RandomizeCode = 14) else do (Do nothing)
        If (Playername Equal to B) then do (Set RandomizeCode = 13) else do (Do nothing)
        If (Playername Equal to C) then do (Set RandomizeCode = 10) else do (Do nothing)
        If (Playername Equal to D) then do (Set RandomizeCode = 4) else do (Do nothing)
        If (Playername Equal to E) then do (Set RandomizeCode = 12) else do (Do nothing)
        If (Playername Equal to F) then do (Set RandomizeCode = 2) else do (Do nothing)
        If (Playername Equal to G) then do (Set RandomizeCode = 3) else do (Do nothing)
        If (Playername Equal to H) then do (Set RandomizeCode = 7) else do (Do nothing)
        If (Playername Equal to I) then do (Set RandomizeCode = 8) else do (Do nothing)
        If (Playername Equal to J) then do (Set RandomizeCode = 7) else do (Do nothing)
        If (Playername Equal to K) then do (Set RandomizeCode = 13) else do (Do nothing)
        If (Playername Equal to L) then do (Set RandomizeCode = 12) else do (Do nothing)
        If (Playername Equal to M) then do (Set RandomizeCode = 10) else do (Do nothing)
        If (Playername Equal to N) then do (Set RandomizeCode = 16) else do (Do nothing)
        If (Playername Equal to O) then do (Set RandomizeCode = 17) else do (Do nothing)
        If (Playername Equal to P) then do (Set RandomizeCode = 11) else do (Do nothing)
        If (Playername Equal to Q) then do (Set RandomizeCode = 14) else do (Do nothing)
        If (Playername Equal to R) then do (Set RandomizeCode = 1) else do (Do nothing)
        If (Playername Equal to S) then do (Set RandomizeCode = 4) else do (Do nothing)
        If (Playername Equal to T) then do (Set RandomizeCode = 5) else do (Do nothing)
        If (Playername Equal to U) then do (Set RandomizeCode = 6) else do (Do nothing)
        If (Playername Equal to V) then do (Set RandomizeCode = 15) else do (Do nothing)
        If (Playername Equal to W) then do (Set RandomizeCode = 9) else do (Do nothing)
        If (Playername Equal to X) then do (Set RandomizeCode = 2) else do (Do nothing)
        If (Playername Equal to Y) then do (Set RandomizeCode = 3) else do (Do nothing)
        If (Playername Equal to Z) then do (Set RandomizeCode = 4) else do (Do nothing)

Information
Takes string Playername
Returns int RandomizeCode


All is in the Information : It takes the variable string Playername, and returns an integer variable RandomizeCode.


Code:
Base10 to Base32
    Events
    Conditions
    Actions
        For each (Integer A) from 0 to 2, do (Set Base32Int[(Integer A)] = 0)
        Set Base10Convert = Base10Input
        For each (Integer WhileLoop) from 1 to 31, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Base10Convert Greater than or equal to 1024
                    Then - Actions
                        Set Base10Convert = (Base10Convert - 1024)
                        Set Base32Int[2] = (Base32Int[2] + 1)
                    Else - Actions
                        For each (Integer WhileLoop) from 1 to 31, do (Actions)
                            Loop - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Base10Convert Greater than or equal to 32
                                    Then - Actions
                                        Set Base10Convert = (Base10Convert - 32)
                                        Set Base32Int[1] = (Base32Int[1] + 1)
                                    Else - Actions
                                        Set Base32Int[0] = Base10Convert
                                        Set WhileLoop = 31
                        Set WhileLoop = 31
        For each (Integer A) from 0 to 2, do (Actions)
            Loop - Actions
                If (Base32Int[(Integer A)] Equal to 23) then do (Set Base32String[(Integer A)] = 0) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 26) then do (Set Base32String[(Integer A)] = 1) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 17) then do (Set Base32String[(Integer A)] = 2) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 24) then do (Set Base32String[(Integer A)] = 3) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 6) then do (Set Base32String[(Integer A)] = 4) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 5) then do (Set Base32String[(Integer A)] = 5) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 11) then do (Set Base32String[(Integer A)] = 6) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 4) then do (Set Base32String[(Integer A)] = 7) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 10) then do (Set Base32String[(Integer A)] = 8) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 13) then do (Set Base32String[(Integer A)] = 9) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 0) then do (Set Base32String[(Integer A)] = a) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 9) then do (Set Base32String[(Integer A)] = b) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 18) then do (Set Base32String[(Integer A)] = c) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 31) then do (Set Base32String[(Integer A)] = d) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 1) then do (Set Base32String[(Integer A)] = e) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 21) then do (Set Base32String[(Integer A)] = f) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 30) then do (Set Base32String[(Integer A)] = g) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 27) then do (Set Base32String[(Integer A)] = h) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 25) then do (Set Base32String[(Integer A)] = i) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 3) then do (Set Base32String[(Integer A)] = k) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 8) then do (Set Base32String[(Integer A)] = m) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 2) then do (Set Base32String[(Integer A)] = n) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 14) then do (Set Base32String[(Integer A)] = p) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 22) then do (Set Base32String[(Integer A)] = r) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 16) then do (Set Base32String[(Integer A)] = s) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 7) then do (Set Base32String[(Integer A)] = t) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 12) then do (Set Base32String[(Integer A)] = u) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 15) then do (Set Base32String[(Integer A)] = v) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 28) then do (Set Base32String[(Integer A)] = w) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 20) then do (Set Base32String[(Integer A)] = x) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 29) then do (Set Base32String[(Integer A)] = y) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 19) then do (Set Base32String[(Integer A)] = z) else do (Do nothing)

Information
Pre:Base10Input contains value to be convert, value is in range 0 - 1048575
Post:Base32String[] contains converted value, with digit 1=[2], 2=[1], 3=[0]


All is again on the Information. Base10Input has values to convert in a range of 0-1048575, the Trigger convert it to Base32String[..] with converted values, with only 3 values : 1=2, 2=1, 3=0, in a range from 000-zzz


Code:
Base32 to Base10
    Events
    Conditions
    Actions
        Set Base32String[2] = (Substring(Base32Input, 1, 1))
        Set Base32String[1] = (Substring(Base32Input, 2, 2))
        Set Base32String[0] = (Substring(Base32Input, 3, 3))
        For each (Integer A) from 0 to 2, do (Actions)
            Loop - Actions
                If (Base32String[(Integer A)] Equal to 0) then do (Set Base32Int[(Integer A)] = 23) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 1) then do (Set Base32Int[(Integer A)] = 26) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 2) then do (Set Base32Int[(Integer A)] = 17) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 3) then do (Set Base32Int[(Integer A)] = 24) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 4) then do (Set Base32Int[(Integer A)] = 6) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 5) then do (Set Base32Int[(Integer A)] = 5) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 6) then do (Set Base32Int[(Integer A)] = 11) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 7) then do (Set Base32Int[(Integer A)] = 4) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 8) then do (Set Base32Int[(Integer A)] = 10) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 9) then do (Set Base32Int[(Integer A)] = 13) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to a) then do (Set Base32Int[(Integer A)] = 0) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to b) then do (Set Base32Int[(Integer A)] = 9) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to c) then do (Set Base32Int[(Integer A)] = 18) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to d) then do (Set Base32Int[(Integer A)] = 31) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to e) then do (Set Base32Int[(Integer A)] = 1) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to f) then do (Set Base32Int[(Integer A)] = 21) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to g) then do (Set Base32Int[(Integer A)] = 30) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to h) then do (Set Base32Int[(Integer A)] = 27) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to i) then do (Set Base32Int[(Integer A)] = 25) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to k) then do (Set Base32Int[(Integer A)] = 3) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to m) then do (Set Base32Int[(Integer A)] = 8) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to n) then do (Set Base32Int[(Integer A)] = 2) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to p) then do (Set Base32Int[(Integer A)] = 14) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to r) then do (Set Base32Int[(Integer A)] = 22) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to s) then do (Set Base32Int[(Integer A)] = 16) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to t) then do (Set Base32Int[(Integer A)] = 7) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to u) then do (Set Base32Int[(Integer A)] = 12) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to v) then do (Set Base32Int[(Integer A)] = 15) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to w) then do (Set Base32Int[(Integer A)] = 28) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to x) then do (Set Base32Int[(Integer A)] = 20) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to y) then do (Set Base32Int[(Integer A)] = 29) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to z) then do (Set Base32Int[(Integer A)] = 19) else do (Do nothing)
        Set Base10Output = (((Base32Int[2] x 1024) + (Base32Int[1] x 32)) + Base32Int[0])

Information
Pre:Base32Input contains string to be convert in range 000-zzz
Post:Base10Output contains Int value
23, 26, 17, 24, 6, 5, 11, 4, 10, 13, 0, 9, 18, 31, 1, 21, 30, 27, 25, 3, 8, 2, 14, 22, 16, 7, 12, 15, 28, 20, 29, 19


All and again all is in the Information. Base32Input contains what to convert, from a range to 000-zzz. The Trigger transforms it from Base32Input to Base10Output which contains a Integer value, from 0 to 31.


Code:
Save Char
    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
        Player - Player 9 (Gray) types a chat message containing -save as An exact match
        Player - Player 10 (Light Blue) types a chat message containing -save as An exact match
        Player - Player 11 (Dark Green) types a chat message containing -save as An exact match
    Conditions
        (Substring((Entered chat string), 1, 5)) Equal to -save
    Actions
        Trigger - Turn off (This trigger)
        Set Part1 = NONE
        Set LevelCode = (Hero level of Hero[(Player number of (Triggering player))])
        For each (Integer A) from 1 to MaxSavableHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        HeroType[(Integer A)] Equal to (Unit-type of Hero[(Player number of (Triggering player))])
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Less than 10
                            Then - Actions
                                Set Part1 = (0 + (String((Integer A))))
                            Else - Actions
                                Set Part1 = (String((Integer A)))
                    Else - Actions
        If (Part1 Not equal to NONE) then do (Set SavingHero = Hero[(Player number of (Triggering player))]) else do (Do nothing)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Part1 Equal to NONE
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR:No Hero Found...
                Trigger - Turn on (This trigger)
                Skip remaining actions
            Else - Actions
        Set Playername = (Name of (Triggering player))
        Trigger - Run Randomize <gen> (ignoring conditions)
        Set Base10Input = ((Integer(Part1)) x RandomizeCode)
        Trigger - Run Base10 to Base32 <gen> (ignoring conditions)
        Set SaveCode[0] = (Base32String[1] + Base32String[0])
        Set Base10Input = ((LevelCode x RandomizeCode) x (((Integer(Part1)) mod 9) + 1))
        Trigger - Run Base10 to Base32 <gen> (ignoring conditions)
        Set SaveCode[1] = ((Base32String[2] + Base32String[1]) + Base32String[0])
        For each (Integer A) from 0 to 5, do (Set CarriedItems[(Integer A)] = 500)
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                For each (Integer A) from 100 to 499, do (Actions)
                    Loop - Actions
                        If ((Item-type of (Item carried by SavingHero in slot ((Integer B) + 1))) Equal to InitializeItems[(Integer A)]) then do (Set CarriedItems[(Integer B)] = (Integer A)) else do (Do nothing)
        For each (Integer WhileLoop) from 0 to 4, do (Actions)
            Loop - Actions
                For each (Integer B) from (WhileLoop + 1) to 5, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                CarriedItems[WhileLoop] Greater than CarriedItems[(Integer B)]
                            Then - Actions
                                Set SortTempInt = CarriedItems[WhileLoop]
                                Set CarriedItems[WhileLoop] = CarriedItems[(Integer B)]
                                Set CarriedItems[(Integer B)] = SortTempInt
                            Else - Actions
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                Set Base10Input = (((Integer(Part1)) + (Integer B)) + ((CarriedItems[(Integer B)] - 100) x ((RandomizeCode mod 2) + 1)))
                Trigger - Run Base10 to Base32 <gen> (ignoring conditions)
                Set SaveCode[((Integer B) + 2)] = (Base32String[1] + Base32String[0])
        Set FinalCode = (((SaveCode[0] + SaveCode[1]) + (SaveCode[2] + SaveCode[3])) + ((SaveCode[4] + SaveCode[5]) + (SaveCode[6] + SaveCode[7])))
        Game - Display to (Player group((Triggering player))) for 200.00 seconds the text: (((Character:  + (Proper name of Hero[(Player number of (Triggering player))])) +  - ) + (Loading Code:  + FinalCode))
        Trigger - Turn on (This trigger)

This is the code to Save your hero. I will explain later what it exactly does.


Code:
Load Char
    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
        Player - Player 9 (Gray) types a chat message containing -load as A substring
        Player - Player 10 (Light Blue) types a chat message containing -load as A substring
        Player - Player 11 (Dark Green) types a chat message containing -load as A substring
    Conditions
        (Substring((Entered chat string), 1, 5)) Equal to -load
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Length of (Entered chat string)) Not equal to 23
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR: Code Length ...
                Skip remaining actions
            Else - Actions
        Trigger - Turn off (This trigger)
        Set Playername = (Name of (Triggering player))
        Set LoadString = (abcde + (Entered chat string))
        Trigger - Run Randomize <gen> (ignoring conditions)
        Set Base32Input = (a + (Substring(LoadString, 12, 13)))
        Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
        Set UnitNumber = (Base10Output / RandomizeCode)
        Set Base32Input = (Substring(LoadString, 14, 16))
        Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
        Set LoadLevel = (Base10Output / (RandomizeCode x ((UnitNumber mod 9) + 1)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Or - Any (Conditions) are true
                    Conditions
                        UnitNumber Greater than MaxSavableHeroes
                        UnitNumber Less than 1
                        LoadLevel Greater than MaxLevel
                        LoadLevel Less than 0
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR: Error Loadin...
                Trigger - Turn on (This trigger)
                Skip remaining actions
            Else - Actions
                Do nothing
        For each (Integer A) from 1 to MaxSavableHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        UnitNumber Equal to (Integer A)
                    Then - Actions
                        Unit - Create 1 HeroType[(Integer A)] for (Triggering player) at (Point(0.00, 0.00)) facing 0.00 degrees
                        Set Hero[(Player number of (Triggering player))] = (Last created unit)
                    Else - Actions
        Hero - Set (Last created unit) Hero-level to LoadLevel, Show level-up graphics
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Hero - Drop the item from slot (Integer A) of (Last created unit)
                Item - Remove (Last dropped item)
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                Set Base32Input = (a + (Substring(LoadString, (17 + ((Integer B) x 2)), (18 + ((Integer B) x 2)))))
                Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
                Set ItemNumber = ((Base10Output - (UnitNumber + (Integer B))) / ((RandomizeCode mod 2) + 1))
                Set ItemNumber = (ItemNumber + 100)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (ItemNumber Less than 100) or (ItemNumber Greater than 499)
                                InitializeItems[ItemNumber] Equal to Unknown Item
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ItemNumber Equal to 500
                            Then - Actions
                                Do nothing
                            Else - Actions
                                Game - Display to (Player group((Triggering player))) the text: ((|c00ff0000ERROR:Code Error Bit |r + (String(((Integer B) + 3)))) +  Continuing Load...)
                    Else - Actions
                        Hero - Create InitializeItems[ItemNumber] and give it to (Last created unit)
        Trigger - Turn on (This trigger)

This is the code to load your hero. I will again explain how it works later.


Code:
Initialize Items
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        For each (Integer A) from 100 to 499, do (Set InitializeItems[(Integer A)] = Unknown Item)
        Set InitializeItems[100] = Healing Scepter
        Set InitializeItems[101] = Ring of Protection
        Set InitializeItems[102] = Claws of Attack
        Set InitializeItems[103] = Heavy Axe
        Set InitializeItems[104] = Sacred Relic
        Set InitializeItems[105] = Spellbook
        Set InitializeItems[106] = Drek'thar Book
        Set InitializeItems[107] = Flag
        Set InitializeItems[108] = Flame Cloak
        Set InitializeItems[109] = War Drums
        Set InitializeItems[110] = Shadow Cloak
        Set MaxSavableHeroes = 3
        Set MaxLevel = 999
        Set HeroType[1] = Paladin Test
        Set HeroType[2] = Arch Mage Test
        Set HeroType[3] = Mountain King Test

Information
Define items and heroes type there.
Up to 399 items from 100 to 499. Below or after makes some bads things.


You have to define what there are to save. I will explain later what to modify here.


1.2 How Save works?

We will learn how the Save Trigger works.

Code:
Save Char
    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
        Player - Player 9 (Gray) types a chat message containing -save as An exact match
        Player - Player 10 (Light Blue) types a chat message containing -save as An exact match
        Player - Player 11 (Dark Green) types a chat message containing -save as An exact match
    Conditions
        (Substring((Entered chat string), 1, 5)) Equal to -save

This first part detect when a player write exactly -save. The Condition is really useless because -save is -save.


Code:
        Trigger - Turn off (This trigger)
        Set Part1 = NONE
        Set LevelCode = (Hero level of Hero[(Player number of (Triggering player))])
        For each (Integer A) from 1 to MaxSavableHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        HeroType[(Integer A)] Equal to (Unit-type of Hero[(Player number of (Triggering player))])
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Less than 10
                            Then - Actions
                                Set Part1 = (0 + (String((Integer A))))
                            Else - Actions
                                Set Part1 = (String((Integer A)))
                    Else - Actions
        If (Part1 Not equal to NONE) then do (Set SavingHero = Hero[(Player number of (Triggering player))]) else do (Do nothing)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Part1 Equal to NONE
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR:No Hero Found...
                Trigger - Turn on (This trigger)
                Skip remaining actions
            Else - Actions

We will work a little in that part.


Code:
        Set Part1 = NONE
        Set LevelCode = (Hero level of Hero[(Player number of (Triggering player))])
        For each (Integer A) from 1 to MaxSavableHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        HeroType[(Integer A)] Equal to (Unit-type of Hero[(Player number of (Triggering player))])
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Less than 10
                            Then - Actions
                                Set Part1 = (0 + (String((Integer A))))
                            Else - Actions
                                Set Part1 = (String((Integer A)))
                    Else - Actions

This request take the Hero, and if the HeroType[Integer A] is equal to the Unit type of the Hero that should be saved (Hero[Player number of (Triggering Player)]), it sets the Part1 to a number from a range to 1-99. Number of Savable Heroes is defined in Initialize Items.


Code:
        If (Part1 Not equal to NONE) then do (Set SavingHero = Hero[(Player number of (Triggering player))]) else do (Do nothing)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Part1 Equal to NONE
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR:No Hero Found...
                Trigger - Turn on (This trigger)
                Skip remaining actions
            Else - Actions

If Part1 returns the base value (NONE), it fixes the Hero to SavingHero. But will ever fail. It is equal you have No Hero here. Then the trigger looks if Part1 equal to NONE, and if yes, it gives an error message and Skip all next actions.


Code:
        Set Playername = (Name of (Triggering player))
        Trigger - Run Randomize <gen> (ignoring conditions)
        Set Base10Input = ((Integer(Part1)) x RandomizeCode)
        Trigger - Run Base10 to Base32 <gen> (ignoring conditions)
        Set SaveCode[0] = (Base32String[1] + Base32String[0])
        Set Base10Input = ((LevelCode x RandomizeCode) x (((Integer(Part1)) mod 9) + 1))
        Trigger - Run Base10 to Base32 <gen> (ignoring conditions)
        Set SaveCode[1] = ((Base32String[2] + Base32String[1]) + Base32String[0])

This is the Player Name protection. It defines the Playername variable to the Triggering Player, detect its 1st letter, fixes a value of Base10Input to Part1 x RandomizeCode, converts it to Base32, fixes a value to SaveCode[0], fixes a new protection to Base10Input equal to the (LevelCode x RandomizeCode) x ((Part1 mod 9) + 1), convert it to Base32, then fixes a value to SaveCode[1].
This heavy protection adds 6 digits to the save code.


Code:
        For each (Integer A) from 0 to 5, do (Set CarriedItems[(Integer A)] = 500)
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                For each (Integer A) from 100 to 499, do (Actions)
                    Loop - Actions
                        If ((Item-type of (Item carried by SavingHero in slot ((Integer B) + 1))) Equal to InitializeItems[(Integer A)]) then do (Set CarriedItems[(Integer B)] = (Integer A)) else do (Do nothing)
        For each (Integer WhileLoop) from 0 to 4, do (Actions)
            Loop - Actions
                For each (Integer B) from (WhileLoop + 1) to 5, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                CarriedItems[WhileLoop] Greater than CarriedItems[(Integer B)]
                            Then - Actions
                                Set SortTempInt = CarriedItems[WhileLoop]
                                Set CarriedItems[WhileLoop] = CarriedItems[(Integer B)]
                                Set CarriedItems[(Integer B)] = SortTempInt
                            Else - Actions

This defines a value to the integer CarriedItems variable to 500, in a array range from 0 to 5. Then it detects in a loop what item the Hero has, and if the Item is equal to InitializeItems[Integer A], it changes the value of CarriedItems[Looked Slot Item - 1]. I will explain what there is after, it is extremly hard to understand if you look only like that.

Code:
[B]        For each (Integer WhileLoop) from 0 to 4, do (Actions)
            Loop - Actions
                For each (Integer B) from (WhileLoop + 1) to 5, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                CarriedItems[WhileLoop] Greater than CarriedItems[(Integer B)]
                            Then - Actions
                                Set SortTempInt = CarriedItems[WhileLoop]
                                Set CarriedItems[WhileLoop] = CarriedItems[(Integer B)]
                                Set CarriedItems[(Integer B)] = SortTempInt
                            Else - Actions[/B]

Lets get a Look. Lets say we have CarriedItems[0] = 135, [1] = 120, [2] = 116, [3] = 147, [4] = 169, and [5] = 138.
We start a Loop. Integer WhileLoop = 0. Then we have a Second Loop. Integer B = WhileLoop + 1 = 1. It checks if CarriedItems[0] is greater than CarriedItems[1]. If it is true, it sets SortTempInt to CarriedItems[0], sets CarriedItems[0] = CarriedItems[1], and CarriedItems[1] = SortTempInt. Else it does nothing.

So we have:
SortTempInt = CarriedItems[0] = 135
CarriedItems[0] = CarriedItems[1] = 120
CarriedItems[1] = SortTempInt = 135

Lets say we loop until end. We will calculate anything.

Condition = True
SortTempInt = CarriedItems[0] = 135
CarriedItems[0] = CarriedItems[1] = 120
CarriedItems[1] = SortTempInt = 135
Condition = True
SortTempInt = CarriedItems[1] = 120
CarriedItems[1] = CarriedItems[2] = 116
CarriedItems[2] = SortTempInt = 120
Condition = False
Nothing is Done
CarriedItems[3] = 147
Condition = True
SortTempInt = CarriedItems[3] = 147
CarriedItems[3] = CarriedItems[4] = 169
CarriedItems[4] = SortTempInt = 147
Condition = False
Nothing is Done
CarriedItems[5] = 138

So we have :
[0] = 135
[1] = 116
[2] = 120
[3] = 147
[4] = 169
[5] = 138

Understand it?


Code:
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                Set Base10Input = (((Integer(Part1)) + (Integer B)) + ((CarriedItems[(Integer B)] - 100) x ((RandomizeCode mod 2) + 1)))
                Trigger - Run Base10 to Base32 <gen> (ignoring conditions)
                Set SaveCode[((Integer B) + 2)] = (Base32String[1] + Base32String[0])
        Set FinalCode = (((SaveCode[0] + SaveCode[1]) + (SaveCode[2] + SaveCode[3])) + ((SaveCode[4] + SaveCode[5]) + (SaveCode[6] + SaveCode[7])))
        Game - Display to (Player group((Triggering player))) for 200.00 seconds the text: (((Character:  + (Proper name of Hero[(Player number of (Triggering player))])) +  - ) + (Loading Code:  + FinalCode))
        Trigger - Turn on (This trigger)

This is the last part of the Save.
We have a Loop from 0 to 5. Base10Input's value is defined to (Part1) + (Integer B) + ((CarriedItems[Integer B] - 100) x (RandomizeCode modulo 2) + 1)), then it converts it to Base32, and after defines a value to SaveCode[Integer B + 2]. Each item takes 2 digits. All SaveCode[0 to 7] are set to the FinalCode in the normal order (Not Little Indian Order, which is the inverse)
At end, it displays to the player the message. And voila! Its the Save Trigger finished.
 

Chocobo

White-Flower
Reaction score
409
1.3 How Load works?

Code:
Load Char
    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
        Player - Player 9 (Gray) types a chat message containing -load as A substring
        Player - Player 10 (Light Blue) types a chat message containing -load as A substring
        Player - Player 11 (Dark Green) types a chat message containing -load as A substring
    Conditions
        (Substring((Entered chat string), 1, 5)) Equal to -load

This detects when a player write -load, and if -load is the 5 first letters.


Code:
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Length of (Entered chat string)) Not equal to 23
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR: Code Length ...
                Skip remaining actions
            Else - Actions

This is supposed to detect the length of the entered chat. The code is 17 digits, with the space between -load and the code, and the -load, it results 17 digits. -load xxxxxxxxxxxxxxxxx


Code:
        Trigger - Turn off (This trigger)
        Set Playername = (Name of (Triggering player))
        Set LoadString = (abcde + (Entered chat string))
        Trigger - Run Randomize <gen> (ignoring conditions)
        Set Base32Input = (a + (Substring(LoadString, 12, 13)))
        Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
        Set UnitNumber = (Base10Output / RandomizeCode)
        Set Base32Input = (Substring(LoadString, 14, 16))
        Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
        Set LoadLevel = (Base10Output / (RandomizeCode x ((UnitNumber mod 9) + 1)))

This is a little tricky. First, it checks for the Player Name, it saves the string in a Variable called LoadString with abcde before the code, and it runs the trigger Randomize, which returns an integer depending on the player's name. Then it sets Base32Input string Variable to a + 12'st + 13'st digit of LoadString (-load abcdexxxxxxxxxxxxxxxxx), and convert it to Base10. It returns the Variable Base10Output, and then UnitNumber is set to (Base10Output / RandomizeCode). Base32Input is set to the 14st, 15st, and 16st digit of the LoadString ((-load abcdexxxxxxxxxxxxxxxxx), and convert it to Base10. The level of the hero is after calculated, resulting of the Algorithm (Base10Output / RandomizeCode x ((UnitNumber modulo 9) + 1))).


Code:
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Or - Any (Conditions) are true
                    Conditions
                        UnitNumber Greater than MaxSavableHeroes
                        UnitNumber Less than 1
                        LoadLevel Greater than MaxLevel
                        LoadLevel Less than 0
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: ERROR: Error Loadin...
                Trigger - Turn on (This trigger)
                Skip remaining actions
            Else - Actions
                Do nothing

This detects if the UnitNumber is a classified hero, it must be between the 1 and the Value of the Integer MaxSavableHeroes. In the demo map, it is 4, so if UnitNumber is greater than 4, or lesser than 1, it interrupts the loading. And so does for Level, if it is greater than MaxLevel, or less than 0, it stops the loading.


Code:
        For each (Integer A) from 1 to MaxSavableHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        UnitNumber Equal to (Integer A)
                    Then - Actions
                        Unit - Create 1 HeroType[(Integer A)] for (Triggering player) at (Point(0.00, 0.00)) facing 0.00 degrees
                        Set Hero[(Player number of (Triggering player))] = (Last created unit)
                    Else - Actions
        Hero - Set (Last created unit) Hero-level to LoadLevel, Show level-up graphics

This part creates a Hero for the player. It checks if UnitNumber is equal to the Integer A while the loop from 1 to MaxSavableHeroes, then it creates the Hero if the Condition is true. After the loop, it sets the Level of the hero to LoadLevel.


Code:
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Hero - Drop the item from slot (Integer A) of (Last created unit)
                Item - Remove (Last dropped item)

Some bugs may appears during the loading because other triggers that adds items if a hero spawns, this part has been added to remove all items carried by the Hero.


Code:
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                Set Base32Input = (a + (Substring(LoadString, (17 + ((Integer B) x 2)), (18 + ((Integer B) x 2)))))
                Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
                Set ItemNumber = ((Base10Output - (UnitNumber + (Integer B))) / ((RandomizeCode mod 2) + 1))
                Set ItemNumber = (ItemNumber + 100)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (ItemNumber Less than 100) or (ItemNumber Greater than 499)
                                InitializeItems[ItemNumber] Equal to Unknown Item
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ItemNumber Equal to 500
                            Then - Actions
                                Do nothing
                            Else - Actions
                                Game - Display to (Player group((Triggering player))) the text: ((|c00ff0000ERROR:Code Error Bit |r + (String(((Integer B) + 3)))) +  Continuing Load...)
                    Else - Actions
                        Hero - Create InitializeItems[ItemNumber] and give it to (Last created unit)
        Trigger - Turn on (This trigger)

Lastest part of the load code. If the code for items is wrong, it doesn't interrupt the loading. We will analyze this more clearly.


Code:
        For each (Integer B) from 0 to 5, do (Actions)
            Loop - Actions
                Set Base32Input = (a + (Substring(LoadString, (17 + ((Integer B) x 2)), (18 + ((Integer B) x 2)))))
                Trigger - Run Base32 to Base10 <gen> (ignoring conditions)
                Set ItemNumber = ((Base10Output - (UnitNumber + (Integer B))) / ((RandomizeCode mod 2) + 1))
                Set ItemNumber = (ItemNumber + 100)

Here we have a Loop from 0 to 5. The Variable Base32Input is set to 2 digits. (a + (LoadString (17 + (Integer B x 2))'st digit to (18 + (Integer B x 2))'st digit).
Here what it results digits with the loop : 17-18, 19-20, 21-22, 23-24, 25-26, 26-27
-load abcdexxxxxxxxxxxxxxxxx
After, it converts it into Base10, returning Base10Output. ItemNumber is set to ((Base10Output - (UnitNumber + (Integer B))) / (RandomizeCode modulo 2) + 1)), and then add it 100.


Code:
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (ItemNumber Less than 100) or (ItemNumber Greater than 499)
                                InitializeItems[ItemNumber] Equal to Unknown Item
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ItemNumber Equal to 500
                            Then - Actions
                                Do nothing
                            Else - Actions
                                Game - Display to (Player group((Triggering player))) the text: ((|c00ff0000ERROR:Code Error Bit |r + (String(((Integer B) + 3)))) +  Continuing Load...)
                    Else - Actions
                        Hero - Create InitializeItems[ItemNumber] and give it to (Last created unit)
        Trigger - Turn on (This trigger)

This last part of the trigger is inside the Integer B loop. It checks if ItemNumber is less than 100, or greater than 499, or equal to Unknown Item (Returns a weird number unused).
If the Condition is true, it checks if the ItemNumber is equal to 500, and if not, it does nothing, else it gives to the player a Error Message that gives an error at the bit (Integer B + 3), and continue load without this slot.
If the Condition is false, it directly creates a item to the hero, the item type is InitializeItems[ItemNumber].
The Load trigger is finished.


1.4 What to modify?

There is a lot of things to modify, I will post here all to modify.

Code:
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (ItemNumber Less than 100) or (ItemNumber Greater than 499)
                                InitializeItems[ItemNumber] Equal to [B][U]Unknown Item[/U][/B]
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ItemNumber Equal to 500
                            Then - Actions
                                Do nothing
                            Else - Actions
                                Game - Display to (Player group((Triggering player))) the text: ((|c00ff0000ERROR:Code Error Bit |r + (String(((Integer B) + 3)))) +  Continuing Load...)
                    Else - Actions
                        Hero - Create InitializeItems[ItemNumber] and give it to (Last created unit)
        Trigger - Turn on (This trigger)

You have seen it in the last CODE. It is at the end of the Load Trigger. You must create a dummy item called Unknown Item with the Unknown Icon, and costing 0 gold. It must be this, else it can be sold.


Code:
        For each (Integer A) from 1 to MaxSavableHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        UnitNumber Equal to (Integer A)
                    Then - Actions
                        [B][U]Unit - Create 1 HeroType[(Integer A)] for (Triggering player) at (Point(0.00, 0.00)) facing 0.00 degrees[/U][/B]
                        Set Hero[(Player number of (Triggering player))] = (Last created unit)
                    Else - Actions
        Hero - Set (Last created unit) Hero-level to LoadLevel, Show level-up graphics

It is again on the Load Trigger. You must modify the Location where the Hero will spawn. (The at (Point(0.00, 0.00)))


Code:
Initialize Items
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
[B][U]        For each (Integer A) from 100 to 499, do (Set InitializeItems[(Integer A)] = Unknown Item)
        Set InitializeItems[100] = Healing Scepter
        Set InitializeItems[101] = Ring of Protection
        Set InitializeItems[102] = Claws of Attack
        Set InitializeItems[103] = Heavy Axe
        Set InitializeItems[104] = Sacred Relic
        Set InitializeItems[105] = Spellbook
        Set InitializeItems[106] = Drek'thar Book
        Set InitializeItems[107] = Flag
        Set InitializeItems[108] = Flame Cloak
        Set InitializeItems[109] = War Drums
        Set InitializeItems[110] = Shadow Cloak
        Set MaxSavableHeroes = 3
        Set MaxLevel = 999
        Set HeroType[1] = Paladin Test
        Set HeroType[2] = Arch Mage Test
        Set HeroType[3] = Mountain King Test[/U][/B]

Again, Unknown Item must be modified to its equivalent. Also, it is here where you must define values of InitializeItems, MaxSavableHeroes, MaxLevel, and HeroType.
InitializeItems handles Item types, that can be saved.
MaxSavableHeroes handles the Maximal number of "hero types" that can be saved. Not the Amount of number of saved heroes. It can not be greater than 99.
MaxLevel handles the maximal level possible. It can not be greater than 999.
HeroType handles Hero types, that can be saved.


All the rest is automatized, you have only to modify these part to get the save load feature to work perfectly.
The Save Code can not work if Hero[(Player number (Triggering player))] Variable is not defined.


1.5 How works Base10 to Base32 and what is it?

Base10 to Base32 (And vice-versa) is an encryption from "Base10", to "Base32". I can't really explain what is it, but I can show you how it really works.

Code:
Base10 to Base32
    Events
    Conditions
    Actions
        For each (Integer A) from 0 to 2, do (Set Base32Int[(Integer A)] = 0)
        Set Base10Convert = Base10Input
        For each (Integer WhileLoop) from 1 to 31, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Base10Convert Greater than or equal to 1024
                    Then - Actions
                        Set Base10Convert = (Base10Convert - 1024)
                        Set Base32Int[2] = (Base32Int[2] + 1)
                    Else - Actions
                        For each (Integer WhileLoop) from 1 to 31, do (Actions)
                            Loop - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Base10Convert Greater than or equal to 32
                                    Then - Actions
                                        Set Base10Convert = (Base10Convert - 32)
                                        Set Base32Int[1] = (Base32Int[1] + 1)
                                    Else - Actions
                                        Set Base32Int[0] = Base10Convert
                                        Set WhileLoop = 31
                        Set WhileLoop = 31
        For each (Integer A) from 0 to 2, do (Actions)
            Loop - Actions
                If (Base32Int[(Integer A)] Equal to 23) then do (Set Base32String[(Integer A)] = 0) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 26) then do (Set Base32String[(Integer A)] = 1) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 17) then do (Set Base32String[(Integer A)] = 2) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 24) then do (Set Base32String[(Integer A)] = 3) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 6) then do (Set Base32String[(Integer A)] = 4) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 5) then do (Set Base32String[(Integer A)] = 5) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 11) then do (Set Base32String[(Integer A)] = 6) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 4) then do (Set Base32String[(Integer A)] = 7) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 10) then do (Set Base32String[(Integer A)] = 8) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 13) then do (Set Base32String[(Integer A)] = 9) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 0) then do (Set Base32String[(Integer A)] = a) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 9) then do (Set Base32String[(Integer A)] = b) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 18) then do (Set Base32String[(Integer A)] = c) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 31) then do (Set Base32String[(Integer A)] = d) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 1) then do (Set Base32String[(Integer A)] = e) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 21) then do (Set Base32String[(Integer A)] = f) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 30) then do (Set Base32String[(Integer A)] = g) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 27) then do (Set Base32String[(Integer A)] = h) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 25) then do (Set Base32String[(Integer A)] = i) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 3) then do (Set Base32String[(Integer A)] = k) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 8) then do (Set Base32String[(Integer A)] = m) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 2) then do (Set Base32String[(Integer A)] = n) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 14) then do (Set Base32String[(Integer A)] = p) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 22) then do (Set Base32String[(Integer A)] = r) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 16) then do (Set Base32String[(Integer A)] = s) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 7) then do (Set Base32String[(Integer A)] = t) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 12) then do (Set Base32String[(Integer A)] = u) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 15) then do (Set Base32String[(Integer A)] = v) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 28) then do (Set Base32String[(Integer A)] = w) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 20) then do (Set Base32String[(Integer A)] = x) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 29) then do (Set Base32String[(Integer A)] = y) else do (Do nothing)
                If (Base32Int[(Integer A)] Equal to 19) then do (Set Base32String[(Integer A)] = z) else do (Do nothing)

Lets say Base10Input is 1200 (It can up to 31743). The trigger sets Base10Convert to Base10Input. The Condition during the 1 to 31 loop is true one time, Base10Convert = 1200-1024 = 176. During loop, if the condition is true, it adds to Base32Int[2] 1. Here, Base32Int[2] = 1.
Then it does again a loop between 1 to 31. It checks if Base10Convert is greater than 32, and if yes, it removes 32 from the Variable until it the condition returns false. For that, we have 5 loops, Base10Convert = 176 - 32*5 = 176 - 160 = 16. While looping, Base32Int[1] is set to its value + 1, like Base32Int[2]. Here, Base32Int[1] = 5. If the condition returned false, Base32Int[0] is set to the value of Base10Convert, which is lesser than to 32. Here, Base32Int[0] = 16.
After that, it does a loop from 0 to 2. It checks if the Integer in Base32Int[Integer A] is equal to <a fixed value between 0 to 31>, and if the condition is true, it sets Base32String[Integer A] to <a fixed value between 0 to z>.
Here, we had [0] = 16, [1] = 5, and [2] = 1.
16 = s = Base32String[0]
5 = 5 = Base32String[1]
1 = e = Base32String[2]
And voilà! It is finished!


But, how to convert it back?! Here is the trigger!

Code:
Base32 to Base10
    Events
    Conditions
    Actions
        Set Base32String[2] = (Substring(Base32Input, 1, 1))
        Set Base32String[1] = (Substring(Base32Input, 2, 2))
        Set Base32String[0] = (Substring(Base32Input, 3, 3))
        For each (Integer A) from 0 to 2, do (Actions)
            Loop - Actions
                If (Base32String[(Integer A)] Equal to 0) then do (Set Base32Int[(Integer A)] = 23) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 1) then do (Set Base32Int[(Integer A)] = 26) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 2) then do (Set Base32Int[(Integer A)] = 17) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 3) then do (Set Base32Int[(Integer A)] = 24) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 4) then do (Set Base32Int[(Integer A)] = 6) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 5) then do (Set Base32Int[(Integer A)] = 5) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 6) then do (Set Base32Int[(Integer A)] = 11) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 7) then do (Set Base32Int[(Integer A)] = 4) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 8) then do (Set Base32Int[(Integer A)] = 10) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to 9) then do (Set Base32Int[(Integer A)] = 13) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to a) then do (Set Base32Int[(Integer A)] = 0) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to b) then do (Set Base32Int[(Integer A)] = 9) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to c) then do (Set Base32Int[(Integer A)] = 18) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to d) then do (Set Base32Int[(Integer A)] = 31) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to e) then do (Set Base32Int[(Integer A)] = 1) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to f) then do (Set Base32Int[(Integer A)] = 21) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to g) then do (Set Base32Int[(Integer A)] = 30) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to h) then do (Set Base32Int[(Integer A)] = 27) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to i) then do (Set Base32Int[(Integer A)] = 25) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to k) then do (Set Base32Int[(Integer A)] = 3) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to m) then do (Set Base32Int[(Integer A)] = 8) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to n) then do (Set Base32Int[(Integer A)] = 2) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to p) then do (Set Base32Int[(Integer A)] = 14) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to r) then do (Set Base32Int[(Integer A)] = 22) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to s) then do (Set Base32Int[(Integer A)] = 16) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to t) then do (Set Base32Int[(Integer A)] = 7) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to u) then do (Set Base32Int[(Integer A)] = 12) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to v) then do (Set Base32Int[(Integer A)] = 15) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to w) then do (Set Base32Int[(Integer A)] = 28) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to x) then do (Set Base32Int[(Integer A)] = 20) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to y) then do (Set Base32Int[(Integer A)] = 29) else do (Do nothing)
                If (Base32String[(Integer A)] Equal to z) then do (Set Base32Int[(Integer A)] = 19) else do (Do nothing)
        Set Base10Output = (((Base32Int[2] x 1024) + (Base32Int[1] x 32)) + Base32Int[0])

The trigger that fires this had defined Base32Input value. Lets say we use the old value : s5e. In the save trigger, it is inversed, so s5e = e5s.
Base32String[2] = s
Base32String[1] = 5
Base32String[0] = e
After defining values, it starts a loop from 0 to 2, and does a lot of conditions, if Base32String[Integer A] is equal to <a value between 0 to z>, and if yes, it returns a Integer assigned to Base32Int.
s = 16 = Base32Int[2]
5 = 5 = Base32Int[1]
e = 1 = Base32Int[0]
Then, it sets Base10Output to (((Base32Int[2] x 1024) + (Base32Int[1] x 32)) + (Base32Int[0])))
Here it does : 1 x 1024 + 5 x 32 + 16 = 1024 + 160 + 16 = 1200
Finished! It returned the old value!
 

Chocobo

White-Flower
Reaction score
409
1.6 Dummy Functions inside the map. How it works?


Code:
Revival
    Events
        Unit - A unit Dies
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Custom script: local integer udg_zz_level
        Hero - Add ((Point-value of (Triggering unit)) x (Hero level of (Triggering unit))) experience to (Killing unit), Show level-up graphics
        Set zz_level = (Hero level of (Killing unit))
        Wait 5.00 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Owner of (Triggering unit)) Not equal to Neutral Hostile
            Then - Actions
                Hero - Instantly revive (Triggering unit) at (Point(0.00, 0.00)), Show revival graphics
            Else - Actions
                Unit - Remove (Triggering unit) from the game
                Unit - Create 1 HeroType[(Random integer number between 1 and MaxSavableHeroes)] for Neutral Hostile at (Point(400.00, 0.00)) facing 0.00 degrees
                Hero - Set (Last created unit) Hero-level to (zz_level + (Random integer number between -20 and 5)), Show level-up graphics
                Set zz_TargetHero = (Last created unit)

This Multi-Instaceable trigger is supposed to respawn a hero. When a Hero dies, the trigger fires. It initializes a local variable, which is used only for the trigger. The udg_ means User Defined Global. The trigger adds to the killing unit (Point value of (Triggering unit)) * (Hero Level of (Triggering unit))) Experiance. After 5 seconds of waiting, if the dying hero belongs to Neutral Hostile, it removes it, create a hero for Neutral Hostile that is in the Savable Heroes list (HeroType Variable), at a fixed point, and gives it a level between (Killer Level -20) and (Killer Level +5).


Code:
Set Level
    Events
        Player - Player 1 (Red) types a chat message containing -level as A substring
    Conditions
        (Substring((Entered chat string), 1, 6)) Equal to -level
    Actions
        Custom script: local integer zz_level
        Set zz_level = (Integer((Substring((Entered chat string), 7, 10))))
        Hero - Set Hero[(Player number of (Triggering player))] Hero-level to zz_level, Show level-up graphics
        Unit - Set life of Hero[(Player number of (Triggering player))] to 100.00%
        Unit - Remove zz_TargetHero from the game
        Unit - Create 1 HeroType[(Random integer number between 1 and MaxSavableHeroes)] for Neutral Hostile at (Point(400.00, 0.00)) facing 0.00 degrees
        Hero - Set (Last created unit) Hero-level to (zz_level + (Random integer number between -20 and 5)), Show level-up graphics
        Set zz_TargetHero = (Last created unit)

Whenever a player says -level <whatever>, the trigger checks if the player has wrote -level as 6 first letters, then it sets the level of the Hero to <whatever>, and heals it to 100% of its hit points. After, it creates a hero for Neutral Hostile like in the Revival Trigger.

Code:
Remove
    Events
        Player - Player 1 (Red) types a chat message containing -remove as An exact match
    Conditions
    Actions
        Unit - Remove Hero[(Player number of (Triggering player))] from the game

This is easy to understand : It cleans up your hero from the game.


Code:
Kill
    Events
        Player - Player 1 (Red) types a chat message containing -kill as An exact match
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Hero[(Player number of (Triggering player))] is alive) Equal to True
            Then - Actions
                Unit - Cause Hero[(Player number of (Triggering player))] to damage zz_TargetHero, dealing 999999.00 damage of attack type Chaos and damage type Unknown
            Else - Actions
                Unit - Remove zz_TargetHero from the game
                Unit - Create 1 HeroType[(Random integer number between 1 and MaxSavableHeroes)] for Neutral Hostile at (Point(400.00, 0.00)) facing 0.00 degrees
                Set zz_TargetHero = (Last created unit)

When your hero is alive, this weird trigger is able to cause to the Enemy Hero (variable zz_TargetHero) 99999 damage of type Chaos. Else it cleans up him and create a Hero for Neutral Hostile like in the Revival Trigger, but without level up.


1.7 Variable List Used

Here is the whole list of Variable used by the Save Load Code.
Code:
Base10Convert, Integer
Base10Input, Integer
Base10Output, Integer
Base32Input, String
Base32Int, Integer (Array)
Base32String, Integer (Array)
CarriedItems, Integer (Array)
FinalCode, String
Hero, Unit (Array)
HeroType, Unit-Type (Array)
InitializeItems, Item-Type (Array)
ItemNumber, Integer
LevelCode, Integer
LoadLevel, Integer
LoadString, String
MaxLevel, Integer
MaxSavableHeroes, Integer
Part1, String
Playername, String
RandomizeCode, Integer
SaveCode, String (Array)
SavingHero, Unit
SortTempInt, Integer
UnitNumber, Integer
WhileLoop, Integer/String


1.8 Frequently Asked Questions

There is no question asked already.
 

Attachments

  • Save Load Code v0.19a.w3x
    26.9 KB · Views: 529

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> Is it allowed to have 3/9 succesive posts for a Guide?

If it makes sense...

However, adding a post now for example... there's replies already...
 
S

Solidhadriel

Guest
The Save Code can not work if Hero[(Player number (Triggering player))] Variable is not defined.

Ok, I get your tutorial in all, however - I'm still very confused on this part. I have setup and declared all the proper variables, put the triggers into my map, setup my items and heros. There is no breaking triggers in my map...

So i went to test my map, and i type '-save' it says: ERROR:No Hero Found to save

...So im guessing it has to do with your quote, can you help me on this one please?

I would be greatly appreciated.


Edit: Is the 'Detect Hero' Trigger the reason why im getting this? Im using a tavern to create the unit. Not sure if this matters?
 
X

x_Phoenix_x

Guest
Save/Load HELP!!!

Im sorry >< im a nub... can someone plz make a premade save/load code and send it to either one of my email address's?
[email protected] and [email protected]

Im making a pokemon orpg map and i need a save/load for badges and the pokemon and the levels.

If you do send a save/load plz give me an example of where i am supposed to put things in.

i REALLY need help... just anything will do... but a premade save/load would ROCK!
 
N

NuBy

Guest
ok solidhadriel.. u copy and pasted it, which means u have to go to the initialize items trigger, then set your hero type as the hero u want it.. this must work cause it was wat i first realised and tried

and my question is.. how can u make the codes neater? like in defi4nc3 orpg :D, i must admit its a bit crowded, and no im not gay
 
N

NuBy

Guest
umm.. thats not part of the tutorial.. mayb post a thread somewhere.. ppl mite noe how to help ;)
 
D

deathtomato

Guest
AAGGHHH thats one long tutorial..
gave me something to think about :p congrats
 
S

Solidhadriel

Guest
NuBy said:
ok solidhadriel.. u copy and pasted it, which means u have to go to the initialize items trigger, then set your hero type as the hero u want it.. this must work cause it was wat i first realised and tried

and my question is.. how can u make the codes neater? like in defi4nc3 orpg :D, i must admit its a bit crowded, and no im not gay

No. Did you read my thread?

I have setup and declared all the proper variables, put the triggers into my map, setup my items and heros. There is no breaking triggers in my map...

I did read the 'Areas to Change' in the trigger for it to work. However, It still says ERROR when i go to do -Save. Chocobo, any ideas? =(
 
X

x_Phoenix_x

Guest
Omigawd Im So Confused

Chocobo said:
This is the guide which will be frequently updated because the lot of questions given in the thread 29952


-The very first one...
(http://www.thehelper.net/forums/showthread.php?t=29952&page=6&pp=15).

yeah.. i tried to copy this... and it didn't really.... work... i have no idea what im doing >< so.. can someone plz like.. premake this or maybe.. just simplify this like... make it very easy to understand.. just put in [player name] or whatever is supposed to be in that area.. becuz i have very little clue of what im doing for my pokemon orpg save/load....
>.> ill add you to credits? (your wc3 name)
 
N

NuBy

Guest
dude solidhadriel i tried to help ok? u dont need to respond like i owe u :mad: now im not gonna help
 
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