OpenXcom Forum

OpenXcom => Suggestions => Topic started by: bladum on August 02, 2013, 06:36:16 pm

Title: Hardcore mode - play without option to change option during game
Post by: bladum on August 02, 2013, 06:36:16 pm
My idea is simple

Run game in hardcore mode where you can:
- save in limited number of slots like 1 2 or 3
- cannot change any advanced settings during game
- hash saves not just plain text (optional, my hash code is below in lua for example)

Code: [Select]
local base = { 14,19,9,17,5,28,17,2,24,10,3,25,22,19,2,12,23,28,2,23,27,9,14,15,7,24,30,4,23,17,14,24,6,23,10,11,21,27,14,15,7,18,10,30,6,12,11,29,9,13,22,6,22,5,21,30,30,21,4,23,8,18,16,14,11,26,26,2,23,9,18,30,27,28,29,3,10,10,1,19,23,24,25,14,29,16,14,28,6,18,20,15,6,6,29,18,1,25,20,25,3 }

local base2 = { 16,26,12,24,24,28,6,10,23,8,17,14,19,11,15,29,28,19,22,4,18,0,7,4,24,4,12,4,3,30,6,15,26,18,9,19,16,15,30,9,23,16,23,12,27,8,10,25,28,2,29,16,2,5,20,27,10,1,0,14,1,7,30,27,26,8,16,11,23,15,20,16,1,13,28,28,22,8,22,19,10,21,5,13,27,25,10,7,27,10,21,29,18,20,26,13,28,12,25,21,28 }

----------------------------------------------------------
--  ENCRYPT
----------------------------------------------------------
function handler.encrypt(str)
   
    local result2 = {}
    local result = {};
    local resultString = "";
    local baseN = #base
    local baseN2 = #base2
    -- CODE
    for i=1 ,#str do
        result2[i] = strByte(str,i,i) + base[ i%baseN ~=0 and i%baseN or baseN ]
    end;
    local resN = #result2
    -- REVERSE
    for i = 1, resN do
         result[i] = result2[resN - i + 1]
    end
    -- CODE AGAIN
    for i=1 ,#str do
        result[i] = result[i] + base2[ i%baseN2 ~=0 and i%baseN2 or baseN2 ]
    end;   
    -- REVERSE
    for i = 1, resN do
         result2[i] = result[resN - i + 1]
    end   
    for key,val in ipairs (result2) do
        resultString = resultString .. strChar(val);
    end;
    return resultString;
end;
----------------------------------------------------------
--  DECRYPT
----------------------------------------------------------
function handler.decrypt(str)
    local result2 = {}
    local result = {};
    local resultString = "";
    local baseN = #base
    local baseN2 = #base2
    -- CODE
    for i=1 ,#str do
        result2[i] = strByte(str,i,i) - base[ i%baseN ~=0 and i%baseN or baseN ]
    end;
    local resN = #result2
    -- REVERSE
    for i = 1, resN do
         result[i] = result2[resN - i + 1]
    end
    -- CODE AGAIN
    for i=1 ,#str do
        result[i] = result[i] - base2[ i%baseN2 ~=0 and i%baseN2 or baseN2 ]
    end;   
    -- REVERSE
    for i = 1, resN do
         result2[i] = result[resN - i + 1]
    end   
    for key,val in ipairs (result2) do
        resultString = resultString .. strChar(val);
    end;
    return resultString;
end;