Save/Load

1337NlNJA

New Member
Reaction score
2
I've searched the forums but i couldn't find a valid answer to what I want for my save/load in my rpg...

I'll need:
- Hero Level
- Hero Type
- Items in Hero's Inventory
- Gold
- Lumber
- Hero EXP (if possible)

Basically, I want the save/load code system from "Defi4nc3's ORPG". It rox. :D

I know this topic has been posted alot...but none of them save lumber... :(
 

Chocobo

White-Flower
Reaction score
409
R

R3velati0n

Guest
I got a good one off CaptGriffen :p

This is what it does -

Storage Features:

- Up to 31 heroes.
- Up to 255 items.
- Up to 2,500,000 xp (to accuracy of 10).
- Up to 4,000 lumber.
- Up to 40,000 gold (to accuracy of 10).
- Connected with the player's name. (this is a bit weak; though 99.9% won't be able to use each other's codes, it is possible)
- Cannot easily be guessed a valid code. (1 in more than 4000 chance)

--------------------------------------------------------------------------

Make sure you add this jass part :p
Code:
function I2B takes integer n, integer max returns string
    local string s
    local integer i = 2
    local integer c = 0
    local string a
    local string b
    local string array sa
    if udg_SLBinaryFlip == "0" then
        set a = "1"
        set b = "0"
    else
        set a = "1"
        set b = "0"
    endif
    loop
        exitwhen n == 0 or c == max
        if ModuloInteger(n, i) == 0 then
            set sa[c] = b
            set c = c + 1
        else
            set sa[c] = a
            set n = n - (i/2)
            set c = c + 1
        endif
        set i = i * 2
    endloop
    loop
        exitwhen c >= max
        set sa[c] = b
        set c = c + 1
    endloop
    loop

This is the setup trigger, edit this. Add your heros and items here. Remeber to edit the alphabets in it, mix it up but make sure it has all of the same chars in it.
Code:
SL Setup
    Events
        Map initialization
    Conditions
    Actions
        Set SLLoadPoint = (Center of (Playable map area))
        Set SLReplacementChar = 1234567890acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-
        Set SLReplacementArray[0] = 1234567890acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-
        Set SLReplacementArray[1] = 1234567890acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-
        Set SLReplacementArray[2] = 1234567890acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-
        Set SLReplacementArray[3] = 1234567890acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-
        Set SLSetupHeroes[1] = Paladin
        Set SLSetupHeroesNumber = 1
        Set SLSetupItems[1] = Claws of Attack +15
        Set SLSetupItems[2] = Heart of Aszune
        Set SLSetupItems[3] = Mask of Death
        Set SLSetupItemsNumber = 3

The Saving Trigger
Code:
SL Save
    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
    Conditions
    Actions
        Set TempGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
        Custom script:   set udg_SLUnit = FirstOfGroup(udg_TempGroup)
        Custom script:   call DestroyGroup(udg_TempGroup)
        Set SLBinaryFlip = (String((Random integer number between 0 and 1)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 0 and 1) Equal to 0
            Then - Actions
                Set SLBinaryCheck = 0
            Else - Actions
                Set SLBinaryCheck = 1
        Set TempInt = (Random integer number between 0 and 3)
        Custom script:   set udg_SLBinaryEncrypt = I2B(udg_TempInt, 2)
        Set SLCurrentReplacement = SLReplacementArray[TempInt]
        Set TempInt = 0
        For each (Integer A) from 1 to SLSetupHeroesNumber, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of SLUnit) Equal to SLSetupHeroes[(Integer A)]
                    Then - Actions
                        Custom script:   set udg_SLBinaryHero = I2B(bj_forLoopAIndex, 5)
                        Set TempInt = 1
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TempInt Equal to 0
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: Invalid Hero.
                Skip remaining actions
            Else - Actions
        For each (Integer B) from 1 to 6, do (Actions)
            Loop - Actions
                Set TempInt = 0
                For each (Integer A) from 1 to SLSetupItemsNumber, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-type of (Item carried by SLUnit in slot (Integer B))) Equal to SLSetupItems[(Integer A)]
                            Then - Actions
                                Custom script:   set udg_SLBinaryItems[bj_forLoopBIndex] = I2B(bj_forLoopAIndex, 8)
                                Set TempInt = 1
                            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        TempInt Equal to 0
                    Then - Actions
                        Set SLBinaryItems[(Integer B)] = 00000000
                    Else - Actions
        Set TempInt = (((Triggering player) Current gold) / 10)
        Custom script:   set udg_SLBinaryGold = I2B(udg_TempInt, 12)
        Set TempInt = ((Triggering player) Current lumber)
        Custom script:   set udg_SLBinaryLumber = I2B(udg_TempInt, 12)
        Set TempInt = (Length of (Name of (Triggering player)))
        Custom script:   set udg_SLBinaryLength = I2B(udg_TempInt, 4)
        Set TempInt = ((Hero experience of SLUnit) / 10)
        Custom script:   set udg_SLBinaryXP = I2B(udg_TempInt, 18)
        Set SLCurrentCodeA = ((SLBinaryCheck + SLBinaryEncrypt) + ((SLBinaryCheck + SLBinaryFlip) + (SLBinaryCheck + (SLBinaryHero + SLBinaryLength))))
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set SLCurrentCodeA = ((SLCurrentCodeA + SLBinaryCheck) + SLBinaryItems[(Integer A)])
        Set SLCurrentCodeA = (SLCurrentCodeA + ((SLBinaryCheck + SLBinaryGold) + (SLBinaryCheck + (SLBinaryLumber + (SLBinaryCheck + SLBinaryXP)))))
        Set SLCurrentCodeB = <Empty String>
        Set TempString = (Substring(SLCurrentCodeA, 1, 6))
        Custom script:   set udg_TempInt = B2I(udg_TempString) + 1
        Set SLCurrentCodeB = (SLCurrentCodeB + (Substring(SLReplacementArray[0], TempInt, TempInt)))
        For each (Integer A) from 2 to 19, do (Actions)
            Loop - Actions
                Set TempString = (Substring(SLCurrentCodeA, ((6 x (Integer A)) - 5), (6 x (Integer A))))
                Custom script:   set udg_TempInt = B2I(udg_TempString) + 1
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Integer A) mod 4) Equal to 0
                    Then - Actions
                        Set SLCurrentCodeB = (SLCurrentCodeB + ((Substring(SLCurrentReplacement, TempInt, TempInt)) + /))
                    Else - Actions
                        Set SLCurrentCodeB = (SLCurrentCodeB + (Substring(SLCurrentReplacement, TempInt, TempInt)))
        Set TempString = (Substring((Name of (Triggering player)), 1, 1))
        For each (Integer A) from 1 to 63, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        TempString Equal to (Substring(SLReplacementChar, (Integer A), (Integer A)))
                    Then - Actions
                        Set SLCurrentCodeB = (SLCurrentCodeB + (Substring(SLCurrentReplacement, (Integer A), (Integer A))))
                        Set TempString = <Empty String>
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TempString Not equal to <Empty String>
            Then - Actions
                Set SLCurrentCodeB = (SLCurrentCodeB + (Substring(SLCurrentReplacement, 64, 64)))
            Else - Actions
        Game - Display to (Player group((Triggering player))) for 120.00 seconds the text: SLCurrentCodeB

The Load Trigger
Code:
SL Load
    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
    Conditions
    Actions
        Set SLCurrentCodeA = <Empty String>
        Set SLCurrentCodeB = ((Substring((Entered chat string), 7, 10)) + ((Substring((Entered chat string), 12, 15)) + ((Substring((Entered chat string), 17, 20)) + ((Substring((Entered chat string), 22, 25)) + (Substring((Entered chat string), 27, 30))))))
        Set TempString = (Substring(SLCurrentCodeB, 1, 1))
        For each (Integer A) from 1 to 64, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        TempString Equal to (Substring(SLReplacementArray[0], (Integer A), (Integer A)))
                    Then - Actions
                        Custom script:   set udg_SLCurrentCodeA = I2B(GetForLoopIndexA() - 1, 6)
                    Else - Actions
        Set SLBinaryCheck = (Substring(SLCurrentCodeA, 1, 1))
        Set SLBinaryEncrypt = (Substring(SLCurrentCodeA, 2, 3))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                SLBinaryEncrypt Equal to 00
            Then - Actions
                Set SLCurrentReplacement = SLReplacementArray[0]
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        SLBinaryEncrypt Equal to 10
                    Then - Actions
                        Set SLCurrentReplacement = SLReplacementArray[1]
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                SLBinaryEncrypt Equal to 01
                            Then - Actions
                                Set SLCurrentReplacement = SLReplacementArray[2]
                            Else - Actions
                                Set SLCurrentReplacement = SLReplacementArray[3]
        For each (Integer A) from 2 to 20, do (Actions)
            Loop - Actions
                For each (Integer B) from 1 to 64, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Substring(SLCurrentCodeB, (Integer A), (Integer A))) Equal to (Substring(SLCurrentReplacement, (Integer B), (Integer B)))
                            Then - Actions
                                Custom script:   set udg_SLCurrentCodeA = udg_SLCurrentCodeA+I2B(GetForLoopIndexB() - 1, 6)
                            Else - Actions
        Custom script:   if BinaryCheck(udg_SLCurrentCodeA, udg_SLBinaryCheck) == false then
        Game - Display to (All players) the text: Incorrect code.
        Skip remaining actions
        Custom script:   endif
        Set TempInt = 0
        Set TempString = (Substring((Name of (Triggering player)), 1, 1))
        For each (Integer A) from 1 to 63, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        TempString Equal to (Substring(SLReplacementChar, (Integer A), (Integer A)))
                    Then - Actions
                        Set TempString = (Substring(SLCurrentReplacement, (Integer A), (Integer A)))
                        Set TempInt = 1
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TempInt Equal to 0
            Then - Actions
                Set TempString = (Substring(SLCurrentReplacement, 64, 64))
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Substring(SLCurrentCodeB, 20, 20)) Not equal to TempString
            Then - Actions
                Game - Display to (All players) the text: Incorrect code.
                Skip remaining actions
            Else - Actions
        Set TempString = (Substring(SLCurrentCodeA, 12, 15))
        Custom script:   set udg_TempInt = B2II(udg_TempString, 4)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Length of (Name of (Triggering player))) Not equal to TempInt
            Then - Actions
                Game - Display to (All players) the text: Incorrect code.
                Skip remaining actions
            Else - Actions
        Set TempString = (Substring(SLCurrentCodeA, 7, 11))
        Custom script:   set udg_TempInt = B2II(udg_TempString, 5)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TempInt Greater than 0
            Then - Actions
                Unit - Create 1 SLSetupHeroes[TempInt] for (Triggering player) at SLLoadPoint facing Default building facing degrees
            Else - Actions
                Game - Display to (All players) the text: Incorrect code.
                Skip remaining actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set TempString = (Substring(SLCurrentCodeA, (8 + ((Integer A) x 9)), (15 + ((Integer A) x 9))))
                Custom script:   set udg_TempInt = B2II(udg_TempString, 8)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        TempInt Greater than 0
                    Then - Actions
                        Hero - Create SLSetupItems[TempInt] and give it to (Last created unit)
                    Else - Actions
        Set TempString = (Substring(SLCurrentCodeA, 71, 82))
        Custom script:   set udg_TempInt = B2II(udg_TempString, 12)
        Player - Set (Triggering player) Current gold to (TempInt x 10)
        Set TempString = (Substring(SLCurrentCodeA, 84, 95))
        Custom script:   set udg_TempInt = B2II(udg_TempString, 12)
        Player - Set (Triggering player) Current lumber to TempInt
        Set TempString = (Substring(SLCurrentCodeA, 97, 114))
        Custom script:   set udg_TempInt = B2II(udg_TempString, 18)
        Hero - Set (Last created unit) experience to (TempInt x 10), Hide level-up graphics

If you cant be bothered typing it all in search the forums, he posted a map with it in in one of my posts :p

Hope it helps
 

1337NlNJA

New Member
Reaction score
2
Thanks alot!

Meh, probably wont be using more than 255 items...i hope :eek:


EDIT: I couldn't find the post with the map
 
R

R3velati0n

Guest
Edit :

Post been deleted =/
Download map here, lame website makes you wait 30 seconds lol
Download
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top