Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Role-Playing Game Design

Author
Message
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 14th Aug 2013 00:49
So I'm trying to figure out the best way I should start programming an RPG that I'm working on. I'm trying to make sure there is minimal amount of items hard-coded in, such as my player object, etc. This is making me *really* think hard at how to approach making this project because I don't want to be tied down by bad coding practices.

With that being said, I have a map loader and the ability to move a hard-coded player object around this map. This is great for testing but bad for building code upon. I'd like to move away from this ASAP but I'm not sure how.

Right now, I'm thinking that my best bet would be to create a blank, starter "save" file. Because, ya know, RPG's allow you to load and save progress. Starting a new game would load a "new" save file, which loads all of the data in (starting map, position, scripting) etc. The game would then move on from there, depending on the player's actions.

Does this sound like a decent idea?

Hi there. My name is Dug. I have just met you, and I love you.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 14th Aug 2013 02:36
That not only sounds like a good idea, it's actually just made me feel slightly daft. Lol. I'm working on a project that uses dozens and dozens of variables for up to 2000 units, and for the base unit that the player starts with I quite literally have a line of code setting every variable for the unit. Your idea is better, although a full save game won't work for me.

Like you though I wanted a way to allow easy content creation (in the long run, hopefully mod support will be added for the user to totally change the game!) and I found the best route was data files stored as text documents. I'm constantly changing and evolving the idea, but here's an example:

Each type of unit is capable of varying actions, chosen by clicking on an icon in a control tool bar. Now, I want a settler unit to be able to build a city, but not a swordman for example. In all, there are 20 possible actions, none of which are all availble to any one unit, of which there are 50. So, initially I had started by doing a loborious "if the unit type is 1 then build all the actions possible for this unit", and repeat for all 50 units (I got as far as two - was testing). Then, when checking for the action clicked, I had to do another huge stretch of testing to see what the icon clicked meant for that unit, again at least 50 checks.

Now, I have just finsished a far better system, using a simple array and a simple text file. As no unit can do more than 10 actions, eachtype has a flag set along the lines of "1;1;1;1;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0". In this a 1 means that action is possible for that unit, a zero means it is not. I then have a plain integer array of size ten. Now, when a unit is selected I use getstringtoken in a for:next loop to go through all 20 values, and whenever it finds a 1 it adds the loop count to the array. As a result, the array holds the actions possible only for that unit type, and the entire code is 37 lines long. When I check the control icons, if they clicked icon 1, then the action value in array place 1 is the action to be performed. This also allows me to display only the icons used. Another added advantage is that the data file can be very simply altered (in realtime if needed) in the game, allowing the user to modify any unit in game as they see fit.

This system may not work for you, but it sounds like it's not a million miles away from what you're looking to do, so maybe my rambling will help in some way.
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 14th Aug 2013 03:10
Yup! I'm going to be doing that for my enemies, later onwards (having flagged values or something along the lines in loadable text files).

I guess the thing that's getting my mind wondering, is that in an RPG the game just keeps *going*, like a boulder being rolled down from a cliff. But what gets that boulder going? In an average classic RPG, when you enter in a town, it is at always the exact same spawn location.

But what about the start of the game? Or a cutscene that transfers you to a new town or location? I mean, these are all special scenarios that need to be taken care of.

Or perhaps I'm thinking of this wrong. Perhaps when a map is loaded - but before it is rendered - I run a script for each map to test to see where the player should be positioned. The player gets created every time the map is loaded. If there's no good position, the player doesn't get created (bad). But, the player isn't hard-coded that way, allowing clean breaks between maps.

Hi there. My name is Dug. I have just met you, and I love you.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 14th Aug 2013 09:50
answerman - You want to hard-code as little as possible. So you need to create an "engine" - a kind of abstract system that can be loaded from a database and save its state. It becomes a "meta language" which is interpreted by your base code. You can add new features very easily.

Having done this kind of thing before, the very first thing to do is have a version number for your files, and if the data file version is higher than the program version, warn the user to update!

santman - You don't need those semicolons at all! You can just use the index in the string!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Aug 2013 10:06
This is interesting, I could possibly add or learn from this so just joining in for now...

Ok well... I agree with the Engine method... It has to be something while as mentioned loads META data structured content, so it only knows the type of tile, its size and then where it needs to be placed and also the corresponding actions list...

A lot on this subject really, I suggest you got a few books on the matter... I can think of a couple... But GameDev and TGCForum should carry a fair few...

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 14th Aug 2013 11:33
I love designing things like this. For users to create interactive educational exercises I wrote a whole language called Stalk which was highly targeted on rapid development. It was fun. 14 years old now, but runs fine on 64-bit Windows!

It's best to do an abstract design before writing much code. I find drawing diagrams on paper works better than writing half a novel's worth of text!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Aug 2013 13:43
Quote: "Right now, I'm thinking that my best bet would be to create a blank, starter "save" file. Because, ya know, RPG's allow you to load and save progress. Starting a new game would load a "new" save file, which loads all of the data in (starting map, position, scripting) etc. The game would then move on from there, depending on the player's actions.

Does this sound like a decent idea?"

That's exactly how my RPG "Kingdom" works currently.

I am creating my maps from a random seed and only saving the random seed as the basis of the save file. On top of that I am saving any newly created map data (such as monsters and npc's) and player data. I only create saved data for areas of a map the player has visited and each zone is created from the same original seed so they will always be created the same way. Only things that change/can change/added are "saved".

Having a randomly generated world saves a lot of work and allows you to have a virtually infinite number of worlds to play but it takes some setting up! Also it means the "story" element needs to be cleverly crafted into your world if you have a story.

"Here I am trying to do some good for the world..." - Fluffy Rabbit
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 15th Aug 2013 09:35
Well, I think I solved my problem. I create a "person template", which contains templates for ever type of person in the game. I also create an active person list, which contains all active people in a map. When a map gets loaded, the list is cleared out an the currently active player (as determined by a value in the save file) is automatically generated and placed in the map based on some script value. A flag determines if it's a movable, player controlled person.

As for loading the rest of the map, any additional people are added to this active list as player controlled. That way, if the action switches from one person to the next, all I have to do is adjust flag values and the person being controlled changes. Update the variable in th save file and we're golden.

Hi there. My name is Dug. I have just met you, and I love you.

Login to post a reply

Server time is: 2024-11-24 17:37:33
Your offset time is: 2024-11-24 17:37:33