Announcement

Collapse
No announcement yet.

What is the logic behind ranking score?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    What is the logic behind ranking score?

    Im probably making this more difficult than it is.I need to understand the logic/simple order of doings of having a top score.I am using this kismet script to save the score when i finish a level.:
    https://forums.unrealengine.com/lega...ve-load-kismet


    So.. I am killing a bunch of enemies, and the int values are converted to strings so that i can see the score while i play.>Also with each enemy death I am saving the int value (it just adds to it self) >>The level ends and I save the total int value which is my final score.So its a bin file called ''score LV1'' and it is saved.

    I return to my menu, i see the score I go back to play the same level and the score I make now is added to the save of the first time I played instead of generating a new score and keeping the old one for compare.I know it is my fault as obviously level one is only generating ONE save only with its designated name.


    What do I have to do? I dont think I can generate a unique save name each time I play the level and after that compare the scores in order to have them at first and last place.
    Or i can continue to have one and only save in level one, but before it makes the final save, i have to transfer that score to another name save and save that??

    My head hurts.Please, simple words on how to do it in the correct order .


    Here is a simple example of shooting at something,generating its score and save it with each shot to a final file ,and after that, loading the file so that i can see it in my menu level.(Just bits and pieces as i don't think the rest was important)


    Click image for larger version

Name:	1.jpg
Views:	104
Size:	145.0 KB
ID:	1755456





    #2
    Wish I could help you with the kismet solution but I really can't, I've never used kismet like that.

    You can have the code I used for a simple scoreboard made in unrealscript if it helps.

    Code:
    class UDNScoreboardLocal extends Actor;
    
    var float scoremultiplier;
    var UDNGame game;
    var UDNScoreboardLocalObj saveobj;
    var string all_replays_text; // for menu view
    var UDNReplay rep, rep2;
    var int ts1, ts2;
    var array<string> names;
    var array<int> timestamps;
    
    function InitScoreboard()
    {
    
    }
    
    function int get_ts(string name)
    {
        local int i;
    
        for(i=0; i<names.length; i++)
            if(names[i] == name)
                return timestamps[i];
    }
    
    function int cmp(string a, string b)
    {
        ts1 = get_ts(a);
        ts2 = get_ts(b);
    
        if(ts1 < ts2)
            return -1;
        else
            return 0;
    }
    
    
    function DisplayScores(int start_from, int game_mode)
    {
        local int i, k, next_exists, previous_exists;
        k = 0;
        all_replays_text = "";
        saveobj = new class'UDNScoreboardLocalObj';
    
        `log("LOAD: " $ start_from);
    
        LoadScores();
        saveobj.Sort();
    
        if(start_from > 0)
            previous_exists = 1;
    
        for(i=0; i<saveobj.scores.length; i++)
        {
            if(saveobj.scores[i].mode == game_mode)
            {
                if(k >= start_from)
                {
                    if(k >= 13)
                        next_exists = 1;
                    else            
                    {
                        all_replays_text $= saveobj.scores[i].name $ "," $ (k+1) $ "," $ saveobj.scores[i].score $ "," $ saveobj.scores[i].tech $ "," $ saveobj.scores[i].level_reached $ "," $ saveobj.scores[i].level_route $ "," $ saveobj.scores[i].date $ "," $ saveobj.scores[i].filename $ "," $ saveobj.scores[i].mode;                
                        all_replays_text $= ";";
                    }
                }
    
                k++;
            }
        }
    
        all_replays_text = Left(all_replays_text, Len(all_replays_text)-1);
        all_replays_text $= "#" $ previous_exists $ ";" $ next_exists;
    
        `log("full score text: " $ all_replays_text);
        //
        UDNGame(WorldInfo.Game).HUDWrapper.HUDGFX.LocalScoresView.UpdateScores(all_replays_text);
    }
    
    function AddScore(string replay_filename, string date, string id, string name, int score, int tech, int grazes, int kills, int mode, int level_reached, string level_route, int multiplayer, int ghost_mode_used)
    {
        saveobj = new class'UDNScoreboardLocalObj';
    
        LoadScores(); 
    
        saveobj.tempscore.id = id;
        saveobj.tempscore.name = name;
        saveobj.tempscore.filename = replay_filename;
        saveobj.tempscore.level_route = level_route;
        saveobj.tempscore.date = date;
        saveobj.tempscore.score = score;
        saveobj.tempscore.tech = tech;
        saveobj.tempscore.grazes = grazes;
        saveobj.tempscore.kills = kills;
        saveobj.tempscore.mode = mode;
        saveobj.tempscore.level_reached = level_reached;
        saveobj.tempscore.multiplayer = multiplayer;
    
        saveobj.scores.AddItem(saveobj.tempscore);
    
        SaveScores();
    }
    
    function SaveScores()
    {
        class'Engine'.static.BasicSaveObject(saveobj, "Scoreboard.s", true, 1);
    }
    
    function LoadScores()
    {
        class'Engine'.static.BasicLoadObject(saveobj, "Scoreboard.s", true, 1);
    }
    Code:
    class UDNScoreboardLocalObj extends Object;
    
    //
    struct score
    {
        var string id, name, filename, level_route, date;
        var int score, tech, grazes, kills, mode, level_reached, multiplayer, ghost_mode_used, timestamp;
    };
    
    var array<score> scores;
    var score tempscore;
    
    
    function int sort_scores(score a, score b)
    {
        if(a.score < b.score)
            return -1;
        else
            return 0;
    }
    
    function Sort()
    {
        scores.Sort(sort_scores);
    }

    Comment

    Working...
    X