Results 1 to 7 of 7
  1. #1

    Post C# and DLL Bind Based Checkpoint System Part 1 - The Checkpoint Class (C#)

    The following tutorials will show you how to implemnt a complete checkpoint and save based system using C# and Unrealscript. Most functionallity will be in C# to allow complex features which can be called by Unrealscript.

    The system will allow:
    • The creation of a checkpoint object which will store information that can be used to revert the state of the game to how it was when the checkpoint was created
    • An object cache to keep the most recently created checkpoint in memory to increase performance
    • Automatic sorting to return the most recent checkpoint to create an "Autoload" system
    • Search routines to return checkpoints that reach certain requirments
    • Cloning of checkpoints for "Autosave" purposes
    • Saving of checkpoints to create a full saving system
    • Encyption to stop the player from hex editing the file and cheating


    Part one : The checkpoint Object, C#

    Please Note: This Section is C# code and must be compiled and referenced through the DLL bind feature of the UDK, Unrealscript intergration will be discussed in a later tutorial

    The core of the checkpoint system will focus on the checkpoint object, a class that can take "snapshots" of data and store them to later revert to the state stored. Access classes, known as "caretakers" (Under the "Memento" design pattern, which this system uses) will allow the storage of a single checkpoint object to revert to. "The multi-caretaker" class will allow multiple checkpoints to be saved and restored through the use of an internal Array List

    The code for the checkpoint class:

    Code:
    using system
    using system.collections
    
    public class Checkpoint
    {
    
    public Checkpoint() {}
    
    public Checkpoint(string Somedata, int Somenumber)
    {
    
    //The data that you need to save goes here
    
    this.Somedata = data;
    this.Somenumber = number;
    
    }
    
    //Default Values
    
    private string Somedata = "Data";
    private int Somenumber = 1;
    
    //Get and Set accessors
    
    public string Somedata
    {
    
    get{return(Somedata);}
    set{Somedata = value;}
    
    }
    public void ChangeSomenumber(int newNumber)
    {
    
    Somenumber = newNumber;
    
    }
    
    public void display()
    {
    
    //Replace with method to pass values to Unrealscript (Possibly as a structure) - Covered in later tutorial
    
    Console.Writeline("Somenumber: " + Somenumber);
    Console.Writeline("Somedata: " + Somedata);
    
    }
    
    //Nested Memento class to save outer class' state
    
    internal class Memento
    {
    
    internal Memento(Checkpoint data)
    {
    
    this.Somedata = data.Somedata;
    this.Somenumber = data.Somenumber;
    originator = data;
    
    }
    
    private Checkpoint originator = null;
    private string Somedata = "data";
    private int Somenumber = 1;
    
    internal void Rollback()
    {
    
    originator.Somedata = this.Somedata;
    originator.Somenumber = this.Somenumber;
    
    }
    
    }
    
    }
    The code for the checkpoint caretaker class:

    Code:
    public class CheckpointCaretaker
    {
    private Checkpoint.Memento Savedstate = null;
    
    internal Checkpoint.Memento Memento
    {
    get{return(Savedstate);}
    set{Savedstate = value;}
    }
    
    }
    The code for the multi-checkpoint cartaker class:

    Code:
    public class MultiCheckpointCaretaker
    {
    private Arraylist Savedstate = new Arraylist();
    
    internal Checkpoint.Memento this[int index]
    {
    get{return((Checkpoint.Memento)Savedstate[index]);}
    set{Savedstate[index] = (Checkpoint.Memento)value;}
    }
    
    internal void Add(Checkpoint.Memento Memento)
    {
    Savedstate.Add(Memento)
    }
    
    internal int count
    {
    get{return(Savedstate.count);}
    }
    
    }
    To be continued...
    Last edited by MortisEquilibrium; 05-29-2012 at 08:19 AM. Reason: Adding "code" tages and internal int count method

  2. #2

  3. #3
    MSgt. Shooter Person
    Join Date
    Apr 2011
    Posts
    403

    Default

    Thanks for this tutorial , but there is no Checkpoint or Save System into UDK ? i'm very surprised

  4. #4
    Palace Guard
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    3,940

    Default

    Quote Originally Posted by Spoof View Post
    You can place the code in [ code] [ /code] tags (remove the space).
    You can prevent BB-code from being parsed by using the [noparse][/noparse] tags.

    [code]testimonial[/code]



    SCNR
    Our Loop, which art in source code, hallowed be thy keyword.
    Thy condition come, thy instruction be done, in RAM as it is in cache.
    Increment us this day our daily counter,
    and forgive us our typos, as we also have forgiven our compilers.
    And lead us not to the nullpointer but deliver us from bugs.
    For thine is the API, the GUI, and the CLI while(true).
    Semicolon;
    Please don't send me questions about how to do something in the UDK via PM. That is better discussed in the forums and we only have limited PM storage.

  5. #5

    Default

    @danath

    Not that I know of, I think there is simple ini based save systems built in but I have seen a few systems about the forums to add this functionallity using SQL and DLL But I thought this might be overkill for checkpoint systems so I designed a system completly in C# and Unrealscript. This system (http://sql2udk.sourceforge.net/) looks promising if you want that kind of system

    @Spoof,Crusha K. Rool

    Thanks for the tips

  6. #6
    MSgt. Shooter Person
    Join Date
    Apr 2011
    Posts
    403

    Default

    Quote Originally Posted by MortisEquilibrium View Post
    @danath

    Not that I know of, I think there is simple ini based save systems built in but I have seen a few systems about the forums to add this functionallity using SQL and DLL But I thought this might be overkill for checkpoint systems so I designed a system completly in C# and Unrealscript. This system (http://sql2udk.sourceforge.net/) looks promising if you want that kind of system

    @Spoof,Crusha K. Rool

    Thanks for the tips
    Thanks a lot you rock man !

    I have 5 questions then :

    1. If i have a GameOver , is that possible to restart at a point further than restartingLevel without your system ?
    2. What Software do you recommend to do C# i never coded in C# , also where do you put the file ?
    3. Integration is like Scaleform UI ? do you use external.interfaces library ?
    4. Does it work on multiplayer or does it only work as single player ?
    5. Is that possible to build a server in C# to have more than 64 player in a map ?

    Thanks !

  7. #7

    Default

    @danath

    This is an ongoing tutorial and, as of yet, is not complete. I recomend using some of the other systems such as Crusha K. Rool's Ultimate Save System(http://forums.epicgames.com/threads/...-using-DLLBind) especially if you do not know C#

    1. Like restore the game to a point after the level loaded? Eg - Halfway through a FPS map
    I dont think this is possible without external systems as I don't think the UDk saves information about past events. I am trying to create a oblivion like save/checkpoint system where eveything is saved, even what direction the player is looking.

    2.Visual Studio 2010 Express from Microsoft. It's quite complex but supports useful features such as Intellisense to make programming easier. (If you are a Student like me, you can get the Ultimate version for free through the Dreamspark program too!)

    3.I haven't currently written the intergration system but it will be imjplemented through the DLL Bind (http://udn.epicgames.com/Three/DLLBind.html)feature of the UDK and inported functions. This might take some time to write but I will post it in the future.

    4.The system will not work for anything at the moment as there is no way to interact with Unrealscript but I will try to make it work for multiplayer but single player is my priority

    5.I don't think so, without editing the actual UDK DLL and EXE files which is against the EULA or without source code access which is quite a lot pricier than the UDK! It might be possilble to have hacky solutions with multiple Unreal Engine instances running with (Up to) 64 players each and players from one actions replicated across to AI in the others through C# but I might be talking nonsense and I would have no idea how to build a system like this


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.