1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Vote on the best bounty the oceans have to offer! The poll for the 34th Modeling Contest has begun.
    Dismiss Notice
  3. Awaken what lies in the heart of your swarm. The 17th Techtree Contest has arrived!
    Dismiss Notice
  4. Check out the Staff Job Openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Viewer

iGen_x2.1.w3x
Variables
System
===================
Documentation
Readme
Changelog
API
===================
System Code
iGen x2
===================
Test
===================
Init
Nothing
Choose
GoldMax
===================
Save and Load Example
InitTypes
SNL TestScript
Save GUI
Load GUI
===================

		
Name Type Is Array Initial Value
forLOC location No
forLULZ group No
forOMG location No
Hero unit No
Hero_AbilityType abilcode Yes
Hero_AbilityTypeCount integer No
Hero_ItemType itemcode Yes
Hero_ItemTypeCount integer No
Hero_TempInt integer No
Hero_UnitType unitcode Yes
Hero_UnitTypeCount integer No
iGen_checkKey boolean No
iGen_checkParameter boolean No
iGen_Key string No
iGen_Library string No
iGen_LoadString string No
iGen_Parameter integer Yes
iGen_ParameterSize integer Yes
iGen_Size integer No
//TESH.scrollpos=-1
//TESH.alwaysfold=0
                                          'What is the iGen for?
                                         
The iGen was made to create a very own code, that can be used to store data and retrieve them when loaded. The code is supposed
to be easily understandable and yet, it is written in a very effective way.You don´t need more than 10 minutes to set this
system up.

The iGen is also possible to create an own character library for the single parameters and key. The compression strength depends
on how many characters are being  used in your custom library. For instance a library that contains 81 characters can be saved
in 10 integers signs and it afterwards compress them to a stringlength of 5 signs.

As for the security measure, the iGen was been given checksums and some other nifty functions that makes it very hard to crack.

                                           '
Why it´s named iGen?
                                           
Well I used the name because I thought it´s kinda funny. If you look in the system you´ll also find the local variable named iCook.
It´s kinda an easteregg.

                                         'It´s not working for me...
                                       
If you experience problems with the iGen or have suggestions to improve, feel free to drop me a message on the hiveworkshop or write
me a mail to "CryptHanky@live.de".

                                              '
Last words...
                                             
For all who don´t know how to work with the iGen just check the example out. Im pretty sure it´s easy to understand. Since
this will be one of my last projects for Warcraft 3 I want to say thank you to all those guys who supported me all the years.

Greetings fly out to: Darkt3mpl3r, JonNny, WaRadius, -BerZeKeR-, Paladon, xxdingo93xx, Fireeye, Eccho, Toadcop, Dynasti
                      De.Facto, Math, Anachron, Dark_Dragon, DragoonZombie, Deuterium, Kill3rbeast ... and many more =)
                     
                      Also I like to thank the Hiveworkshop and Ralle =)

                      We´ll see us in Starcraft 2 ;)
//TESH.scrollpos=-1
//TESH.alwaysfold=0
'Changelog:

    > 1.0  initial release
    > 1.0a some bug fixes
    > 1.0b added compressor
    > 1.1  added documentation -> public release
    > 1.1a added 2x protection and some more documentation
    > 1.2  bug fix
           improved compression
           more possible options
           improved name protection
           improved crc function
           functions are now easier
           added some more documentation
    > 1.2a bug fix
    > 1.2b optimized compression
    > 2.0  the whole script is rewritten and improved
    > 2.0a added an option and changed some things that maybe could lead to an incorrect save/load code
    > 2.0b just added the static if
    > 2.0c improved the example for the system
    > 2.1  fixed compression, save/load codes will be shorter from now on
    > 2.1a fixed a bug found by acomc
//TESH.scrollpos=-1
//TESH.alwaysfold=0
'IMPORTANT: For the description of every method look at the system code.

'
parameterLibrary
    'Methods:
     static method create takes nothing returns thistype
     method Int2Char takes integer i returns string
     method Char2Int takes string s returns integer
     method Hex2Int takes nothing returns nothing
     method Hex2IntEx takes string iEx returns integer
     method Int2Hex takes nothing returns nothing
     method Int2HexEx takes integer iEx returns string
     static method IsCharInLibrary takes string ch,string lib returns boolean
     method Int2CharEx takes integer i,string lib returns string
     method Char2IntEx takes string s,string lib returns integer
     method setupCRC takes nothing returns nothing
     method setupLength takes nothing returns nothing
     method setupLibrary takes string s returns nothing

'
Generator
    'Methods:
     static method create takes nothing returns thistype
     method onDestory takes nothing returns nothing
     method reset takes nothing returns nothing
     method addDelimiters takes nothing returns nothing
     method removeDelimiters takes nothing returns nothing
     method addColor takes nothing returns nothing
     method setParameter takes integer i,integer max,string lib returns nothing
     method setLoadParameter takes integer max,string lib returns nothing
     method setKey takes string s,string lib returns nothing
     method setLoadCode takes string s returns nothing
     method resetLastParameter takes nothing returns nothing
     method getParameter takes integer pos returns integer
     method getCode takes nothing returns string
     method checkParameter takes nothing returns boolean
     method checkKey takes nothing returns boolean
     method encrypt takes nothing returns nothing
     method decrypt takes nothing returns nothing
//TESH.scrollpos=0
//TESH.alwaysfold=0
//                                        ,¦¦
//                                        ¦ ¦¦¦¦                                                                
//                                        ¦    ¦¦¦¦¦                          2010 still moving on...
//                                        ¦         ¦¦            ¦¦¦¦¦¦
//                                        ¦         ¦¦      ¦¦¦¦¦¦     ¦¦¦
//                                        ¦        ¦¦     ¦¦¦            ¦¦
//                                        ¦        ¦     ¦                ¦¦     ¦¦¦¦¦¦¦¦
//                                        ¦       ¦¦¦_   ¦                 ¦¦  ¦¦¦      ¯¦.
//                                        ¦       ¦  ¦¦¦¦¦        ____      ¦¦¦¦          ¯¦
//                                        ¦       ¦     ¦¦¦_     _¦¦¦¦______¦¦        __    ¦
//                                       ¦        ¦       ¦     _¦¦¦¦¦¦¦¦¦¦¦¦¦       _¦¦,   ¯¦
//                                       ¦    ,   ¦_      ¦     ¦¦¦¦¦¦¦¦¦¦¦¦¦       _¦¦¯     ¯¦
//                                       ¦    ¦    ¯     ¦¦     ¦¦¦¦¦¦¦¦¦¦¦¦¦       ¦¦¦¦_     ¦.
//                                      ,¦    ¦          ¦      ¦¦¦¦¦¯¯¯¯¯¦¦¦       ¦¦¦¦¦      ¦
//                                      ¦     ¦          ¦      ¯¦¦¦¦     ¯¦¦_      ¦¦¦¦¦      ¦
//                                     ¦¦     ¦_         ¦         ¯¦.     ¯¦¦      ¯¦¦¦¦      ¦
//                                     ¦       ¦         ¦                  ¦¦       ¯¯¯¯      ¦
//                                    ¦¦       ¦         ¦_        _        ¦¦¦                ¦
//                                   _¦        ¦          ¦        ¦        ¦¦¦¦              _¦
//                                   #----------------------------------------------------------#
//                                   |================!NgO is sappin' ma sentry!================|
//                                   #----------------------------------------------------------#
//                      
//                                * NgO is fucking proud to present the release of the new iGen =) *
//
// ************************************************************************************************************************************
// *                                                       ~ Release ~                                                                *
// *                                                       +++++++++++                                                                *
// *                                                                                                                                  *
// *                                                   Name: iGen x2.1a                                                               *
// *                                                   Type: Code Generater                                                           *
// *                                               Language: vJass                                                                    *
// *                                                Made by: Hanky                                                                    *
// *                                                   Date: 10-04-2010                                                               *
// *                                                                                                                                  *
// *                                            Description: This system is there to make your life easier creating a MMORPG.         *
// *                                                         This system is able to create save/load codes. Also this system          *
// *                                                         is using an unique encryption method which is pretty secure.             *
// *                                                                                                                                  *
// *                                                         I can just say: Enjoy our release =)                                     *
// *                                                                                                                                  *
// ************************************************************************************************************************************
//
// ************************************************************************************************************************************
// *                                                        ~ Notes ~                                                                 *
// *                                                        +++++++++                                                                 *
// *                                                                                                                                  *
// *                                                 If you want to contact me,                                                       *
// *                                                   then just contact me?                                                          *
// *                                                                                                                                  *
// ************************************************************************************************************************************

// ************************************************************************************************************************************
// *                                                  ~ Greetings fly out to ~                                                        *
// *                                                  ++++++++++++++++++++++++                                                        *
// *                                                                                                                                  *
// *                               Darkt3mpl3r, JonNny, WaRadius, xxdingoxx93, De.Facto, Toadcop, Paladon                             *
// *                                                Eccho, -BerzeKer-, Fireeye, Bodo                                                  *
// *                                                                                                                                  *
// *                                                         NgO & HIVE                                                               *
// *                                                                                                                                  *
// ************************************************************************************************************************************

// ************************************************************************************************************************************
// *                           One of the last releases NgO will release for Warcraft 3. But we'll never die.                         *
// *                                       So we will continue making mods for Starcraft 2.                                           *
// *                                                                                                                                  *
// *                          With this release I want advice you to take a look at our latest Project Chernobyl.                     *
// *                          It's a riddle map with much stuff you can explore. A playable version will be out                       *
// *                                                              soon.                                                               *
// *                                                                                                                                  *
// ************************************************************************************************************************************
// *_____________________________________________________nfo_design_by_Hanky__________________________________________________________*
// ************************************************************************************************************************************


library iGen
  globals
    public constant boolean keyEncryption =false        //Enable an extra keyEncryption (Important: The char library of every parameter will change to the key char library.)
    public constant integer mparameterSize=20           //This is the maximal size of parameters you can enter. You can change it to your needs.
    public constant integer delimiterInt  =5            //If you use delimiters you can set the interval here.
    public constant string delimiterSign  ="-"          //Remember that the delimiter sign should be never in a library. Otherwise it can't be recogenized correctly.
   
    public constant string colorcodeNum   ="|c000080FF" //For "0..1..2"
    public constant string colorcodeabc   ="|c00008000" //For "a..b..c"
    public constant string colorcodeABC   ="|c00FFFF00" //For "A..B..C"
    public constant string colorcodeXtr   ="|c00FF0000" //For everything else
   
    public constant string signLibrary1   ="0123456789"                 //Set up the numeric characters
    public constant string signLibrary2   ="abcdefghijklmnopqrstuvwxyz" //Set up the normal characters
    public constant string signLibrary3   ="ABCDEFGHIJKLMNOPQRSTUVWXYZ" //Set up the capital characters
    public constant string signLibrary4   ="@$[_!?&%:}~*+=<>)(/-"       //Set up the extra signs/characters
  endglobals

  public struct parameterLibrary
     //==================================================
     //Vars

     //> Sign Library Vars
     string Library   //< Encryption/Decryption Library
     integer Size     //< The Size Of The Library
     integer maxHex   //< The Size Of The Last HexCode
     integer maxInt   //< The Size Of The Last Integer
     //*******************

     //> Parameter Value Vars
     string Encrypt   //< Encrypted         string
     integer Decrypt  //< Decrypted         integer
     integer Extent   //< Extent            integer
     integer Length   //< Length            integer
     integer CRC      //< Checksum          integer
     boolean Active   //< Active            boolean
     //*******************

     //==================================================
     //onStructEvent Methods
     static method create takes nothing returns thistype
       local thistype iCook=thistype.allocate()

       set iCook.Library=null
       set iCook.Size   =0x00
       
       set iCook.Encrypt=null
       set iCook.Decrypt=0x00
       set iCook.Extent =0x00
       set iCook.Length =0x00
       set iCook.CRC    =0x00
       set iCook.Active =false

       return iCook
     endmethod

     //==================================================
     //Convert Methods

     //> Int2Char
     //  > Convert an integer value to a char
     method Int2Char takes integer i returns string
       if i>=0x00 and i<=.Size then
         return SubString(.Library,i,i+0x01)
       debug else
       debug call BJDebugMsg("Error: Invalid parameter")
       endif
       return null
     endmethod

     //> Char2Int
     //  > Convert a char to an integer value
     method Char2Int takes string s returns integer
      local integer l=StringLength(s)
      local integer i=0x00
   
      if l==0x01 then
        loop
          exitwhen i==.Size
         
          if SubString(.Library,i,i+0x01)==s then
            return i
          endif
         
          set i=i+0x01
        endloop
      debug else
      debug call BJDebugMsg("ERROR: Just enter one char")
      endif
     
      debug call BJDebugMsg("ERROR: Invalid parameter")
      return -0x01
     endmethod

     //> Hex2Int
     //  > Convert the encrypt var to an integer value for the decrypt var
     method Hex2Int takes nothing returns nothing
       local integer l=StringLength(.Encrypt)
       local integer m=0x01
       local integer i=0x00
     
       if maxHex>=l then
         loop
           exitwhen 0x00==l
           set i=m*.Char2Int(SubString(.Encrypt,l-0x01,l))+i
           set m=m*.Size
           set l=l-0x01
         endloop
       debug else
       debug call BJDebugMsg("ERROR: Invalid parameter")
       endif
     
       set .Decrypt=i
     endmethod
     
     //> Hex2IntEx
     //  > Convert the encrypt var to an integer value for the decrypt var
     method Hex2IntEx takes string iEx returns integer
       local integer l=StringLength(iEx)
       local integer m=0x01
       local integer i=0x00
     
       if maxHex>=l then
         loop
           exitwhen 0x00==l
           set i=m*.Char2Int(SubString(iEx,l-0x01,l))+i
           set m=m*.Size
           set l=l-0x01
         endloop
       debug else
       debug call BJDebugMsg("ERROR: Invalid parameter")
       endif
     
       return i
     endmethod

     //> Int2Hex
     //  > Convert the decrypt var to a hex string for the encrypt var
     method Int2Hex takes nothing returns nothing
       //! textmacro 2hex
       loop
         set q=i/.Size
         set s=.Int2Char(i-(q*.Size))+s
         set k=k-0x01
         set i=q
         exitwhen k==0x00
       endloop
       //! endtextmacro
       //========================================
       local integer i=.Decrypt
       local integer q=.Size
       local integer k=0x01
       local string s =null
     
       if 0x7FFFFFFF>=.Decrypt then
         loop
           exitwhen q>=.Decrypt
           set q=q*.Size
           set k=k+0x01
         endloop
         //! runtextmacro 2hex()
       elseif .maxInt>=i then
         //Debug Maximal Int Size
         set k=.maxHex
         //! runtextmacro 2hex()
       debug else
       debug call BJDebugMsg("ERROR: Invalid parameter")
       endif
     
       set .Encrypt=s
     endmethod
     
     //> Int2HexEx
     //  > Convert the decrypt var to a hex string for the encrypt var
     method Int2HexEx takes integer iEx returns string
       local integer i=iEx
       local integer q=.Size
       local integer k=0x01
       local string s =null
     
       if 0x7FFFFFFF>=iEx then
         loop
           exitwhen q>=iEx
           set q=q*.Size
           set k=k+0x01
         endloop
         //! runtextmacro 2hex()
       elseif .maxInt>=i then
         //Debug Maximal Int Size
         set k=.maxHex
         //! runtextmacro 2hex()
       debug else
       debug call BJDebugMsg("ERROR: Invalid parameter")
       endif
     
       return s
     endmethod

     //==================================================
     //String Operators

     //> checkCharLibrary
     //  > Check if a char is in a library.
     static method IsCharInLibrary takes string ch,string lib returns boolean
       local integer l=StringLength(ch)
       local integer z=StringLength(lib)
     
       loop
         exitwhen z<l
         if ch==SubString(lib,z-l,z) then
           return true
         endif
         set z=z-0x01
       endloop
     
       return false
     endmethod
     
    //> Int2CharEx
     //  > Convert an integer value to a char
    method Int2CharEx takes integer i,string lib returns string
      if i>=0x00 and i<=.Size then
        return SubString(lib,i,i+0x01)
      debug else
      debug call BJDebugMsg("Error: Wrong char position")
      endif
      return null
    endmethod

     //> Char2IntEx
     //  > Convert an char to an integer value
    method Char2IntEx takes string s,string lib returns integer
      local integer l=StringLength(s)
      local integer i=0x00
   
      if l==1 then
        loop
          exitwhen i==.Size
         
          if SubString(lib,i,i+0x01)==s then
            return i
          endif
         
          set i=i+0x01
        endloop
      debug else
      debug call BJDebugMsg("ERROR: Just enter one char")
      endif
     
      debug call BJDebugMsg("ERROR: Invalid parameter")
      return -0x01
    endmethod

     //> setupCRC
     //  > Setup the CRC value. Remember to set before a decrypted value.
     method setupCRC takes nothing returns nothing
       local string s =I2S(.Decrypt)
       local integer l=StringLength(s)

       loop
         exitwhen l==0x00
         set .CRC=.CRC+.Char2Int(SubString(s,l-0x01,l))+R2I(Pow(0x02,l))
         set l=l-0x01
       endloop
     endmethod

     //> setupLength
     //  > Setup the length of a encrypted value. Remember to set before a decrypted value.
     method setupLength takes nothing returns nothing
       local integer i=.Extent
       local integer q=.Size
       local integer k=0x01
       local string s =null
     
       if 0x7FFFFFFF>=.Decrypt then
         loop
            exitwhen q>=.Extent
            set q=q*.Size
            set k=k+0x01
         endloop
         //! runtextmacro 2hex()
       elseif .maxInt>=i then
         //Debug Maximal Int Size
         set k=.maxHex
         //! runtextmacro 2hex()
       debug else
       debug call BJDebugMsg("ERROR: Invalid parameter")
       endif

       set .Length=StringLength(s)
     endmethod

     //> setupLibrary
     //  > This will setup the library which you'll need to decrypt/encrypt.
     method setupLibrary takes string s returns nothing
       local integer index=0x01
       local integer ltemp=0x00
       local integer temp =StringLength(s)-0x01

       set .Library=s
       set .Size   =temp

       loop
         //0x7FFFFFFF == 2147483647
         exitwhen temp>0x7FFFFFFF or temp<ltemp

         set ltemp=temp
         set temp =temp*.Size
         set index=index+0x01
       endloop
   
       set .maxHex=index
       set .maxInt=ltemp
     endmethod
  endstruct

  public struct Generator
     parameterLibrary array parameter[mparameterSize]
     parameterLibrary key

     string codeString
     integer parameterSize

     integer inParameterCRC
     integer inKeyCRC
     integer outParameterCRC
     integer outKeyCRC

     //==================================================
     //onStructEvent Methods
     static method create takes nothing returns thistype
       local thistype iCook=thistype.allocate()
       local integer i     =mparameterSize-0x01

       set iCook.codeString     =null
       set iCook.key            =parameterLibrary.create()
       set iCook.inParameterCRC =0x00
       set iCook.outParameterCRC=0x00
       set iCook.parameterSize  =0x00
       loop
         exitwhen i<0x00
         set iCook.parameter[i]=parameterLibrary.create()
         set i=i-0x01
       endloop

       return iCook
     endmethod

     method onDestory takes nothing returns nothing
       local integer i=mparameterSize-0x01

       call .key.destroy()
       loop
         exitwhen i<0x00
         call .parameter[i].destroy()
         set i=i-0x01
       endloop
     endmethod

     //==================================================
     //Standart Methods
     
     //> reset
     //  > This will reset your whole generator struct
     method reset takes nothing returns nothing
       local integer i=mparameterSize-0x01

       call .key.destroy()
       set .key=parameterLibrary.create()
       loop
         exitwhen i<0x00
         call .parameter[i].destroy()
         set .parameter[i]=parameterLibrary.create()
         set i=i-0x01
       endloop
     endmethod
     
     //> addDelemiters
     //  > Add some delimiters to your code (Hint: Just use this function after you have generated a codestring and before you added color to the string.)
     method addDelimiters takes nothing returns nothing
        local integer tl
        local integer ti
        local integer tp
        local string ts
     
        if .codeString!=null then
            set tl=StringLength(.codeString)
            set ti=0x00
            set tp=0x00
            set ts=null
            loop
                exitwhen ti==tl
                if tp==delimiterInt then
                    set ts=ts+delimiterSign
                    set tp=0x01
                else
                    set tp=tp+0x01
                endif
                set ts=ts+SubString(.codeString,ti,ti+0x01)
                set ti=ti+0x01
            endloop
            set .codeString=ts
        endif
     endmethod
     
     //> addDelemiters
     //  > Remove all delimiters from your code (Hint: Just use this function after you have generated a codestring and before you added some delimiters to the string.)
     method removeDelimiters takes nothing returns nothing
        local integer tl
        local integer ti
        local string tc
        local string ts
     
        if .codeString!=null then
            set tl=StringLength(.codeString)
            set ti=0x00
            set ts=null
            loop
                exitwhen ti==tl
                set tc=SubString(.codeString,ti,ti+0x01)
                if tc!=delimiterSign then
                    set ts=ts+tc
                endif
                set ti=ti+0x01
            endloop
            set .codeString=ts
        endif
     endmethod
   
     //> addColor
     //  > Add some color to your code (Hint: Just use this function after you have generated a codestring.)
     method addColor takes nothing returns nothing
        local integer m
        local string t
        local string d
     
        if .codeString!=null then
            set m=StringLength(.codeString)-0x01
            set t=null
           
            loop
              exitwhen m<0x00
       
              set d=SubString(.codeString,m,m+0x01)
              if .key.IsCharInLibrary(d,signLibrary1) then
                set d=colorcodeNum+d+"|r"
              elseif .key.IsCharInLibrary(d,signLibrary2) then
                set d=colorcodeabc+d+"|r"
              elseif .key.IsCharInLibrary(d,signLibrary3) then
                set d=colorcodeABC+d+"|r"
              elseif .key.IsCharInLibrary(d,signLibrary4) then
                set d=colorcodeXtr+d+"|r"
              endif
              set t=d+t
       
              set m=m-0x01
            endloop
       
            set .codeString=t
        endif
     endmethod

     //==================================================
     //Set Methods
     
     //> setParameter
     //  > Set the value of a parameter
     method setParameter takes integer i,integer max,string lib returns nothing
       if .parameterSize<mparameterSize then
         set .parameter[.parameterSize].Active =true
         set .parameter[.parameterSize].Decrypt=i
         set .parameter[.parameterSize].Extent =max
         call .parameter[.parameterSize].setupLibrary(lib)
         call .parameter[.parameterSize].setupLength()
         call .parameter[.parameterSize].setupCRC()
         set .parameterSize=.parameterSize+0x01
       debug else
       debug call BJDebugMsg("Error: Wrong size")
       endif
     endmethod
     
     //> setLoadParameter
     //  > Before you load a code you have to set the load parameter
     method setLoadParameter takes integer max,string lib returns nothing
        if .parameterSize<mparameterSize then
         set .parameter[.parameterSize].Active =true
         set .parameter[.parameterSize].Extent =max
         call .parameter[.parameterSize].setupLibrary(lib)
         call .parameter[.parameterSize].setupLength()
         set .parameterSize=.parameterSize+0x01
       debug else
       debug call BJDebugMsg("Error: Wrong size")
       endif
     endmethod

     //> setKey
     //  > Nearly for every function it's very important to have a key setted
     method setKey takes string s,string lib returns nothing
       local integer l=StringLength(s)
       local integer q=0x00
       local integer x

       call .key.setupLibrary(lib)

       loop
         exitwhen l==0
         set x=.key.Char2Int(SubString(s,l-0x01,l))
         if x!=-0x01 then
           set q=q+x
         endif
         set l=l-0x01
       endloop

       set .key.Decrypt=q
       call .key.setupCRC()
       set .outKeyCRC=.key.CRC
     endmethod
     
     //> setLoadCode
     //  > If you want to load a code you have to set the codeString first
     method setLoadCode takes string s returns nothing
        set .codeString=s
     endmethod

     //==================================================
     //Reset Methods
     
     //> resetLastParameter
     //  > If you want to reset you last setted parameter just use this function
     method resetLastParameter takes nothing returns nothing
       if .parameterSize>0x00 then
         set .parameter[.parameterSize].Encrypt=null
         set .parameter[.parameterSize].Library=null
         set .parameter[.parameterSize].Decrypt=0x00
         set .parameter[.parameterSize].Extent =0x00
         set .parameter[.parameterSize].CRC    =0x00
         set .parameterSize=.parameterSize-0x01
       debug else
       debug call BJDebugMsg("Error: Wrong Size")
       endif
     endmethod

     //==================================================
     //Get Methods
     
     //> getParameter
     //  > This function is there to get a decrypted parameter
     method getParameter takes integer pos returns integer
       return .parameter[pos].Decrypt
     endmethod
     
     //> getCode
     //  > After you have generated a code you can get with this function the code
     method getCode takes nothing returns string
        return .codeString
     endmethod

     //==================================================
     //Check Methods
     
     //> checkParameter
     //  > After you have decrypted a code you can check with this function if the checksum of the parameters is correct
     method checkParameter takes nothing returns boolean
       return .inParameterCRC==.outParameterCRC
     endmethod

     //> checkKey
     //  > After you have decrypted a code you can check with this function if the checksum of the key is correct
     method checkKey takes nothing returns boolean
       return .inKeyCRC==.outKeyCRC
     endmethod

     //==================================================
     //Generating Methods

     //> encrypt
     //  > After you have done all settings you can generate your own code
     method encrypt takes nothing returns nothing
        local integer index=.parameterSize-0x01
        local integer ti
        local integer te
        local integer tl
        local string pex
        local string tsg
        local string csg
       
        loop
            exitwhen index<0x00
            if .parameter[index].Active then
                set tsg=null
                call SetRandomSeed(index*.key.CRC)
                set .inParameterCRC=.inParameterCRC+(.parameter[index].CRC*(index+0x01))
                set .parameter[index].Decrypt=ModuloInteger(.parameter[index].Decrypt+GetRandomInt(index,R2I(Pow(index,.key.CRC))),.parameter[index].Extent)
                call .parameter[index].Int2Hex()
                set tl=StringLength(.parameter[index].Encrypt)
                if tl<.parameter[index].Length then
                    set tl =.parameter[index].Length-tl
                    set ti =0x00
                    loop
                        exitwhen ti==tl
                        call SetRandomSeed(R2I(Pow(ti,.key.CRC)))
                        set tsg=tsg+.parameter[index].Int2Char(ModuloInteger(GetRandomInt(0x00,.parameter[index].Size)-((ti+0x01)*index*(ti+0x01)),.parameter[index].Size))
                        set ti =ti+0x01
                    endloop
                else
                    set ti=0x00
                endif
                set csg=null
                set te =0x00
                loop
                    exitwhen ti==.parameter[index].Length
                    call SetRandomSeed(R2I(Pow(ti,.key.CRC)))
                    set csg=csg+.parameter[index].Int2Char(ModuloInteger(.parameter[index].Char2Int(SubString(.parameter[index].Encrypt,te,te+0x01))+GetRandomInt(0x00,.parameter[index].Size)-((ti+0x01)*index*(ti+0x01)),.parameter[index].Size))
                    set ti=ti+0x01
                    set te=te+0x01
                endloop
                set .parameter[index].Encrypt=tsg+csg
            endif
            set index=index-0x01
        endloop
        set pex  =.key.Int2HexEx(.inParameterCRC)
        set index=.parameterSize-0x01
        loop
            exitwhen index<0x00
            set .codeString=.parameter[index].Encrypt+.codeString
            set index=index-0x01
        endloop
        call .key.Int2Hex()
       
        set .codeString=.key.Encrypt+.codeString+pex
        static if keyEncryption then
            set index=StringLength(.codeString)
            set csg  =null
            loop
                exitwhen index==0x00
                call SetRandomSeed(.key.CRC*(index+0x01))
                set csg=.key.Int2Char(ModuloInteger(.key.Char2Int(SubString(.codeString,index-0x01,index))-GetRandomInt(0x00,.key.Size),.key.Size))+csg
                set index=index-0x01
            endloop
            set .codeString=csg
        endif
     endmethod

     //> decrypt
     //  > After you have done all settings you can decrypt an entered code
     method decrypt takes nothing returns nothing
        local parameterLibrary tk=parameterLibrary.create()
        local boolean filter
        local integer index
        local integer pos
        local integer te
        local integer tl
        local integer ti
        local string ts
        local string bs
       
        static if keyEncryption then
            set index=StringLength(.codeString)
            set ts   =null
            loop
                exitwhen index==0x00
                call SetRandomSeed(.key.CRC*(index+0x01))
                set ts=.key.Int2Char(ModuloInteger(.key.Char2Int(SubString(.codeString,index-0x01,index))+GetRandomInt(0x00,.key.Size),.key.Size))+ts
                set index=index-0x01
            endloop
            set .codeString=ts
        endif
       
        call .key.Int2Hex()
        call tk.setupLibrary(.key.Library)
        set tl=StringLength(.key.Encrypt)
        set tk.Encrypt=SubString(.codeString,0x00,tl)
        call tk.Hex2Int()
        call tk.setupCRC()
        set .inKeyCRC=tk.CRC
        set ts=SubString(.codeString,tl,StringLength(.codeString))
       
        if .checkKey() then
            set index=0x00
            set pos  =0x00
            loop
                exitwhen index==.parameterSize
                if .parameter[index].Active then
                    set .parameter[index].Encrypt=SubString(ts,pos,pos+.parameter[index].Length)
                    set filter=false
                    set bs=null
                    set ti=0x00
                    set te=StringLength(.parameter[index].Encrypt)
                    loop
                        exitwhen ti==te
                        call SetRandomSeed(R2I(Pow(ti,tk.CRC)))
                        set tl=ModuloInteger(.parameter[index].Char2Int(SubString(.parameter[index].Encrypt,ti,ti+0x01))-GetRandomInt(0x00,.parameter[index].Size)+((ti+0x01)*index*(ti+0x01)),.parameter[index].Size)
                        if filter or tl!=0x00 then
                            set bs    =bs+.parameter[index].Int2Char(tl)
                            set filter=true
                        endif
                        set ti=ti+0x01
                    endloop
                    if bs==null then
                        set bs=.parameter[index].Int2Char(0x00)
                    endif
                    set .parameter[index].Encrypt=bs
                    call .parameter[index].Hex2Int()
                    call SetRandomSeed(index*.key.CRC)
                    set .parameter[index].Decrypt=ModuloInteger(.parameter[index].Decrypt-GetRandomInt(index,R2I(Pow(index,.key.CRC))),.parameter[index].Extent)
                    call .parameter[index].setupCRC()
                    set .inParameterCRC=.inParameterCRC+(.parameter[index].CRC*(index+0x01))                
                    set pos=pos+.parameter[index].Length
                endif
                set index=index+0x01
            endloop
            set .outParameterCRC=tk.Hex2IntEx(SubString(ts,pos,StringLength(ts)))
        endif
       
   
        call tk.destroy()
     endmethod
  endstruct
endlibrary
Init
  Events
    Map initialization
  Conditions
  Actions
    Set VariableSet forLULZ = (Units owned by Player 2 (Blue).)
    Set VariableSet Hero = Archmage 0001 <gen>
    Game - Display to (All players) the text: Enter "-save" to save your datas and enter "-load" to load your datas again.
    Cinematic - Fade in over 2 seconds using texture Black Mask and color (0%, 0%, 0%) with 0% transparency
    Unit - Order Peasant 0012 <gen> to Harvest.Dungeon Tree Wall 0232 <gen>
    Unit - Order Peasant 0014 <gen> to Harvest.Dungeon Tree Wall 0232 <gen>
    Unit - Order Peasant 0015 <gen> to Harvest.Dungeon Tree Wall 0001 <gen>
    Unit - Order Peasant 0016 <gen> to Harvest.Dungeon Tree Wall 0263 <gen>
    Unit - Order Peasant 0017 <gen> to Harvest.Dungeon Tree Wall 0003 <gen>
    Unit - Order Peasant 0018 <gen> to Right-Click.Gold Mine 0013 <gen>
    Unit - Order Peasant 0019 <gen> to Right-Click.Gold Mine 0013 <gen>
    Unit - Order Peasant 0020 <gen> to Right-Click.Gold Mine 0013 <gen>
    Unit - Order Peasant 0021 <gen> to Right-Click.Gold Mine 0013 <gen>
Nothing
  Events
    Unit - A unit Dies
  Conditions
    ((Triggering unit) is in forLULZ.) Equal to True
  Actions
    Unit Group - Remove (Triggering unit) from forLULZ.
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Number of units in forLULZ) Equal to 0
      Then - Actions
        Set VariableSet forLOC = (Position of (Killing unit))
        Set VariableSet forOMG = (forLOC offset by -100.00 towards (Facing of (Killing unit)) degrees.)
        Custom script: call BJDebugMsg("You are sappin' ma rats! >:C")
        Unit - Create 1.Granite Golem for Player 2 (Blue) at forOMG facing Default building facing degrees
        Unit - Order (Last created unit) to Attack.(Killing unit)
        Custom script: call RemoveLocation(udg_forOMG)
        Custom script: call RemoveLocation(udg_forLOC)
      Else - Actions
Choose
  Events
    Player - Player 1 (Red) Selects a unit
  Conditions
    ((Triggering unit) is A Hero) Equal to True
    ((Triggering unit) belongs to an ally of Player 1 (Red).) Equal to True
  Actions
    Set VariableSet Hero = (Triggering unit)
    Custom script: set bj_wantDestroyGroup=true
    Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to Hero)).) and do (Actions)
      Loop - Actions
        Unit - Remove (Picked unit) from the game
    Trigger - Turn off (This trigger)
GoldMax
  Events
    Player - Player 1 (Red)'s Current gold becomes Greater than 5000.00
    Player - Player 1 (Red)'s Current lumber becomes Greater than 5000.00
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Player 1 (Red) Current gold) Greater than 5000
      Then - Actions
        Player - Set Player 1 (Red).Current gold to 5000
      Else - Actions
        Player - Set Player 1 (Red).Current lumber to 5000
InitTypes
  Events
    Map initialization
  Conditions
  Actions
    -------- DifferentItemTypes --------
    Set VariableSet Hero_ItemType[0] = (Item-type of No item)
    Set VariableSet Hero_ItemType[1] = Orb of Frost
    Set VariableSet Hero_ItemType[2] = Kelen's Dagger of Escape
    Set VariableSet Hero_ItemType[3] = Claws of Attack +15
    Set VariableSet Hero_ItemType[4] = Crown of Kings +5
    Set VariableSet Hero_ItemType[5] = Mask of Death
    Set VariableSet Hero_ItemType[6] = Ring of Protection +5
    Set VariableSet Hero_ItemType[7] = Blood Key
    Set VariableSet Hero_ItemTypeCount = 7
    -------- DifferentHeroTypes --------
    Set VariableSet Hero_UnitType[0] = (Unit-type of No unit)
    Set VariableSet Hero_UnitType[1] = Archmage
    Set VariableSet Hero_UnitType[2] = Paladin
    Set VariableSet Hero_UnitType[3] = Mountain King
    Set VariableSet Hero_UnitType[4] = Blood Mage
    Set VariableSet Hero_UnitTypeCount = 4
    -------- DifferentAbilityTypes --------
    Set VariableSet Hero_AbilityType[0] = Blizzard
    Set VariableSet Hero_AbilityType[1] = Brilliance Aura
    Set VariableSet Hero_AbilityType[2] = Summon Water Elemental
    Set VariableSet Hero_AbilityType[3] = Mass Teleport
    Set VariableSet Hero_AbilityType[4] = Holy Light
    Set VariableSet Hero_AbilityType[5] = Divine Shield
    Set VariableSet Hero_AbilityType[6] = Resurrection
    Set VariableSet Hero_AbilityType[7] = Devotion Aura
    Set VariableSet Hero_AbilityType[8] = Thunder Clap
    Set VariableSet Hero_AbilityType[9] = Storm Bolt
    Set VariableSet Hero_AbilityType[10] = Bash
    Set VariableSet Hero_AbilityType[11] = Avatar
    Set VariableSet Hero_AbilityType[12] = Flame Strike
    Set VariableSet Hero_AbilityType[13] = Banish
    Set VariableSet Hero_AbilityType[14] = Siphon Mana
    Set VariableSet Hero_AbilityType[15] = Phoenix
    Set VariableSet Hero_AbilityTypeCount = 15
//TESH.scrollpos=-1
//TESH.alwaysfold=0
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>//
//                       IMPORTANT: This is just an example how to use the iGen correctly.                                //
//                                  If you still need help to set up your own iGen then                                   //
//                                  just ask me.                                                                          //
//========================================================================================================================//
library EasySNL requires iGen
    //An example how to create a save function
    function SaveSomething takes nothing returns nothing
        //At first create an iGen_Generator var.
        local iGen_Generator gen = iGen_Generator.create()
        local integer index      = 0
       
        loop
            exitwhen index==udg_iGen_Size
            //Setup all integers you want to save.
            //Remember:
            // The first parameter is for the value.
            // The second parameter is for the maximal possible value.
            // (IMPORTANT: The maximal value should be always bigger than the value you enter in the
            //             first parameter otherwise this function won't work correct.)
            // The third parameter is for your char library.
            //
            //Hint: It's possible to have for every parameter his own char library.
           
            call gen.setParameter(udg_iGen_Parameter[index],udg_iGen_ParameterSize[index],udg_iGen_Library)
            set index=index+1
        endloop
   
        //Setup the key for your save code.
        //Hint: You should use the player name of the guy who want to save as key.
        call gen.setKey(udg_iGen_Key,udg_iGen_Library)
        //This function will create your save code.
        call gen.encrypt()
        //This function will add delimiters to your save code.
        call gen.addDelimiters()
        //This function will add color to your save code.
        call gen.addColor()
        //With this function I show the save code to the player.
        call ClearTextMessages()
        call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,9999.,"Save Code: "+gen.getCode())
        //At the end I just destroy the iGen_Generator var again.
        call gen.destroy()
    endfunction
   
    //An example how to create a load function
    function LoadSomething takes nothing returns nothing
        //At first create an iGen_Generator var.
        local iGen_Generator gen = iGen_Generator.create()
        local integer index      = 0
       
        loop
            exitwhen index==udg_iGen_Size
            //Setup all integers you want to load.
            //Remember:
            // The first parameter is for the maximal possible value.
            // The second parameter is for your char library.
            //
            //IMPORTANT: The first and second parameter need to be the same like in the parameter you have saved them in.
            call gen.setLoadParameter(udg_iGen_ParameterSize[index],udg_iGen_Library)
            set index=index+1
        endloop
   
        //Setup the key for your load code.
        //IMPORTANT: The Key have to be the same like the one you have used to create the code.
        call gen.setKey(udg_iGen_Key,udg_iGen_Library)
        //Setup the load code.
        call gen.setLoadCode(udg_iGen_LoadString)
        //If you have added delimiters to the string you have to remove them first.
        call gen.removeDelimiters()
        //Decrypt the load code.
        call gen.decrypt()
       
        //You have to check if the checksums are correct.
        set udg_iGen_checkKey=gen.checkKey()
        set udg_iGen_checkParameter=gen.checkParameter()

        if gen.checkKey() and gen.checkParameter() then
            set index=0
            loop
                exitwhen index==udg_iGen_Size
                //With this function you can get those values you saved back.
                set udg_iGen_Parameter[index]=gen.getParameter(index)
                set index=index+1
            endloop
        endif
       
        //At the end I just destroy the iGen_Generator var again.
        call gen.destroy()
    endfunction
endlibrary

 
A short description for every single parameter I use in my example:
parameter[0] = There I save the unit type of the hero.
parameter[1] - [6] = There I save the different items the hero is wearing.
parameter[7] = There I save the experience of the hero.
parameter[8] = There I save the amount of gold gathered by the owning player of the hero.
parameter[9] = There I save the amount of wood gathered by the owning player of the hero.
parameter[10] - [13] = There I save the ability levels of the hero.

Always remember that you have to set the maximal size for every single parameter otherwise it'll saved incorrect.
Save GUI
  Events
    Player - Player 1 (Red) types a chat message containing -save (stringnoformat) as An exact match
  Conditions
  Actions
    -------- The library have to be the same like when you load the hero. --------
    Set VariableSet iGen_Library = 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$[_!?&%:}~*+=<>)(/
    -------- Here you can set your key. Remember that it have to be the same like when you load the hero. --------
    Set VariableSet iGen_Key = (Name of (Triggering player))
    -------- //======================================================== --------
    -------- Save the hero unit type --------
    For each (Integer A) from 0 to Hero_UnitTypeCount, do (Actions)
      Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Hero_UnitType[(Integer A)] Equal to (Unit-type of Hero)
          Then - Actions
            Set VariableSet iGen_Parameter[0] = (Integer A)
            Set VariableSet iGen_ParameterSize[0] = (Hero_UnitTypeCount + 1)
          Else - Actions
    -------- Save the items of the hero --------
    For each (Integer A) from 1 to 6, do (Actions)
      Loop - Actions
        For each (Integer B) from 0 to Hero_ItemTypeCount, do (Actions)
          Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                Hero_ItemType[(Integer B)] Equal to (Item-type of (Item carried by Hero in slot (Integer A)))
              Then - Actions
                Set VariableSet iGen_Parameter[(Integer A)] = (Integer B)
                Set VariableSet iGen_ParameterSize[(Integer A)] = (Hero_ItemTypeCount + 1)
              Else - Actions
    -------- Save the experience of the hero --------
    Set VariableSet iGen_Parameter[7] = (Hero experience of Hero)
    Set VariableSet iGen_ParameterSize[7] = 5001
    -------- Save the gold of the owning player --------
    Set VariableSet iGen_Parameter[8] = ((Triggering player) Current gold)
    Set VariableSet iGen_ParameterSize[8] = 5001
    -------- Save the wood of the owning player --------
    Set VariableSet iGen_Parameter[9] = ((Triggering player) Current lumber)
    Set VariableSet iGen_ParameterSize[9] = 5001
    -------- Save the ability levels of the hero --------
    Set VariableSet Hero_TempInt = (4 x (iGen_Parameter[0] - 1))
    For each (Integer A) from 10 to 13, do (Actions)
      Loop - Actions
        Set VariableSet iGen_Parameter[(Integer A)] = (Level of Hero_AbilityType[(((Integer A) - 10) + Hero_TempInt)] for Hero)
        Set VariableSet iGen_ParameterSize[(Integer A)] = 4
    -------- //======================================================== --------
    -------- You have to set how many parameters are in use. Remember that you have to count "0" too. So it's +1. --------
    Set VariableSet iGen_Size = 14
    -------- This little function save the datas. --------
    Custom script: call SaveSomething()
    -------- //======================================================== --------
    -------- Not important. --------
    Player - Set (Triggering player).Current gold to 0
    Player - Set (Triggering player).Current lumber to 0
    Unit - Remove Hero from the game
A short description for every single parameter I use in my example:
parameter[0] = There I save the unit type of the hero.
parameter[1] - [6] = There I save the different items the hero is wearing.
parameter[7] = There I save the experience of the hero.
parameter[8] = There I save the amount of gold gathered by the owning player of the hero.
parameter[9] = There I save the amount of wood gathered by the owning player of the hero.
parameter[10] - [13] = There I save the ability levels of the hero.

Remember to set the maximal parameter size exactly to the one you setted in the save trigger otherwise the iGen won't be able to load your hero correct.
Load GUI
  Events
    Player - Player 1 (Red) types a chat message containing -load (stringnoformat) as A substring
  Conditions
  Actions
    -------- The library have to be the same like when you saved the hero. --------
    Set VariableSet iGen_Library = 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$[_!?&%:}~*+=<>)(/
    -------- Here you can set your key. Remember that it have to be the same like when you saved the hero. --------
    Set VariableSet iGen_Key = (Name of (Triggering player))
    -------- Just some stuff that have to be setted. --------
    Set VariableSet iGen_LoadString = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
    Set VariableSet iGen_checkKey = False
    Set VariableSet iGen_checkParameter = False
    -------- //======================================================== --------
    -------- You have to set for every single parameter the correct maximal size. --------
    Set VariableSet iGen_ParameterSize[0] = (Hero_UnitTypeCount + 1)
    For each (Integer A) from 1 to 6, do (Actions)
      Loop - Actions
        Set VariableSet iGen_ParameterSize[(Integer A)] = (Hero_ItemTypeCount + 1)
    Set VariableSet iGen_Parameter[7] = 0
    Set VariableSet iGen_Parameter[8] = 0
    Set VariableSet iGen_Parameter[9] = 0
    Set VariableSet iGen_ParameterSize[7] = 5001
    Set VariableSet iGen_ParameterSize[8] = 5001
    Set VariableSet iGen_ParameterSize[9] = 5001
    For each (Integer A) from 10 to 13, do (Actions)
      Loop - Actions
        Set VariableSet iGen_ParameterSize[(Integer A)] = 4
    -------- //======================================================== --------
    -------- You have to set how many parameters are in use. Remember that you have to count "0" too. So it's +1. --------
    Set VariableSet iGen_Size = 14
    -------- //======================================================== --------
    -------- This little function load the datas. --------
    Custom script: call LoadSomething()
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (iGen_checkKey Equal to True) and (iGen_checkParameter Equal to True)
      Then - Actions
        -------- If the iGen have loaded everything correct this actions will be executed. --------
        -------- 1.) Recreate the hero --------
        Set VariableSet forLOC = (Center of RebornArea <gen>)
        Unit - Create 1.Hero_UnitType[iGen_Parameter[0]] for Player 1 (Red) at forLOC facing Default building facing degrees
        Set VariableSet Hero = (Last created unit)
        -------- 2.) Add items to the hero --------
        For each (Integer A) from 1 to 6, do (Actions)
          Loop - Actions
            Hero - Create Hero_ItemType[iGen_Parameter[(Integer A)]] and give it to Hero
        -------- 3.) Add experience to the hero --------
        Hero - Set Hero experience to iGen_Parameter[7], Hide level-up graphics
        -------- 4.) Set the ability levels of the hero --------
        Set VariableSet Hero_TempInt = (4 x (iGen_Parameter[0] - 1))
        For each (Integer A) from 10 to 13, do (Actions)
          Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                iGen_Parameter[(Integer A)] Greater than 0
              Then - Actions
                For each (Integer B) from 1 to iGen_Parameter[(Integer A)], do (Actions)
                  Loop - Actions
                    Custom script: call SelectHeroSkill(udg_Hero,udg_Hero_AbilityType[(bj_forLoopAIndex-10)+udg_Hero_TempInt])
              Else - Actions
        -------- 5.) Add gold/wood for the owning player --------
        Player - Set (Triggering player).Current gold to iGen_Parameter[8]
        Player - Set (Triggering player).Current lumber to iGen_Parameter[9]
        Custom script: call RemoveLocation(udg_forLOC)
      Else - Actions
        -------- If something goes wrong this text will appear. --------
        Custom script: call BJDebugMsg("Wrong Code")