Posted: 15th Jun 2007 4:00
hey guys, I'll try to keep this quick and simple. my first questions is how can I make save files that cant be easily edited by the user?? The game im making is a bit of an RGP so if I saved all the stats, xp, inventory and all that good stuff to a file then even if I used a wierd extension, anyone could open it in notepad and edit it to modify the character... right? I wondered if saving all my variables to an array first, then saving the array to the file would work. Seems like I've heard in the past that arrays saved to files sort of like... jumble themselves up or encode themselves or something wierd, but still load fine by DB.


2nd question is I wondered how I could make a large database of the characters in the same game with the same problem... I REALLY REALLY dont want to hard code all the NPCs/Enemy's stats and inventories into my code cuz that would be a HUGE pain and REALLY REALLY complicate the code. I want to have an external file that DB accesses to read the info from, that way its a little easier to make expansions, and a lot easier to keep my code straight....


Thanks all soooooo much in advance! I'm not in a huge hurry but whenever u get around to it would be awesome! thanks a lot everyone!!
Posted: 15th Jun 2007 6:03
Hmmm if you're really worried about people messing with your stats in notepad, you will probalby have to figure out a way to "encode" the data before you write it, and then decode it when you load it back up. Probably just like substitute each character with a corresponding other character, and then switch them back when you load it back up. Memblocks are probably in your future.
Posted: 15th Jun 2007 6:31
I would probably use memblocks to write dwords in such a fashion as this:

(dword)numeric representative for a stat, (dword)numeric value attributed to aforementioned stat

Then just keep going on down the line. You would use a select/case statement to determine what kind of stat was being referred to, and the use of constants would prevent the need to memorize what bytes represent what stat. Every other dword would be read as a stat, and every dword directly following each would be the attribute.

An alternative to this is to use text, and when the file is written you would simply use a memblock to write it by 1's complement, basically inverting all the 1s and 0s. You could further f@&* things up by writing every singly bit in reverse order, end to start.
Posted: 15th Jun 2007 7:07
hmm ive never even attempted to understand memblocks (i like dont even know what they are) but any RPG without a save is a really bad RPG!!

I'm also sorry to say the same about dwords

But I think what your saying is to assign a number to each stat and variable (max hp = 1 current hp = 2 etc...) and then just write it to a file like "1200 2173" (for max hp = 200, current hp = 2173 etc)? Sorry if I'm way off... but if thats what ur saying then it wont take ppl long to notice the correlation between the numbers in the file and the numbers in the game...

Also I want to store long strings (mini bios for the NPCs) along with names, so its not just numbers we're dealing with

Anyone hear the thing about Arrays before? I think that would be simplest if it actually worked.
Posted: 15th Jun 2007 19:55
First of all, memblocks are very useful - they're like a file, but held in memory rather than on the hard drive. That way you can manipulate it (so the user can't read it) before saving.

Second, when you use "write integer" or a similar number command, DBpro will write the bytes representing the integer, not a string representing the integer. So writing to integer variables will look more like this:

ì ¤]EÔPÇ

than:

1200 2173

Third, my personal suggestion would be to make your save file in the style of an ini file (try using IanM's Matrix1data plugin
+ Code Snippet
[Header]
Var1=...
Health=12

[Otherheader]
Hi=Hahaha
Test=Youshouldn'tseethis

and then encrypt it. If you search for encrypt at the bottom of the page you'll see several ideas, or you can go here for some ideas.

-Xol
Posted: 15th Jun 2007 20:16
Use LUA. It has extremely powerful data structures and string handling. Arrays can have string elements, which is nice. You can script your game with it and use its data storage abilities. Plus, you can compile your script so that it's no longer readable in Notepad.
Posted: 15th Jun 2007 21:04
If you use LUA you can compile the script/text file making it un-editable.

You can also take your AI outside the game making it easier to change and clone monsters/npcs

It also means you can make changes to the game dynamics without having to re-compile every time. This is very useful if your in a team with a level designer as the can make that monster faster, or sword do more damage, and see if its balanced well without pestering the programmer!

--

I'd be interested in a way to hide .x, .dbo and texture files. (but I think it requires buying the enhanced command pack )

I don't think it's feasable to compile them in the exe as it takes a long time for a game to strt after double clicking it.
Posted: 15th Jun 2007 22:49
Hmm... what exactly is lua? I've only ever heard of it...
Posted: 15th Jun 2007 22:55
LUA is a comercial scripting system, it's used in may of the big MMORPG titles. Ragnorak, WoW, DarkSpace, Tibia etc.

It's free in C++, http://www.lua.org

Barnski is making a free DLL, http://forum.thegamecreators.com/?m=forum_view&t=74095&b=5

i'm using Unity LUA DLL cost about £12. http://darkbasicpro.thegamecreators.com/?f=lua

I make a little example here...

http://forum.thegamecreators.com/?m=forum_view&t=76205&b=1

There is a project to alter the AI code if you read a little further down the thread.

It's true, LUA will change the way you code forever.
Posted: 16th Jun 2007 0:57
looks to be very helpful but idk... seems like a big project to undertake just to save some files what with DLLs and all... and as you say, it will change the way I code forever... not really sure its something I want to get into
Posted: 16th Jun 2007 1:06
DLL is in your exe once it's compiled. No hassel there (at least my experience of Unity LUA)

The only hassel you will have is a couple of days learning how to use it.

No-one understands how useful it is until they start using it. It does much more than just loading and saving variables