CRPGS:
A programmer's view
by Nathan Smith
Contents:
-
Introduction.
-
What is a CRPG?
-
What components go in to a
CRPG?
-
Maps to look at.
-
Creatures to kill.
-
NPCs to meet and talk
to, maybe kill?
-
Items to pick up.
-
Making a world seem real.
1.Introduction.
This document is a collection of ideas on RPG programing.
Not all the ideas are mine, but I'd like to think that most are. I made
this in the hope that it might help someone else with there own projects.
If you have any more ideas to add or feedback please feel free to email
me at white_door@yahoo.com.
Return to Contents
2. What is a CRPG?
Computer role playing game.
And what is that?
Well its a RPG on a computer instead of how a RPG is played normally.
Ok so what is a RPG?
Basically a group of people get together and play the roles of characters
in an some type of fantasy world. The idea
is that you explore a world and interact with it and the other players in the hope of changing it in some way.
How does one person play a game on a computer that group of people do?
Well... in normal RPGs there is one person called the Dungeon Master
or some other name, and the DM guides the rest of the group on the journey
through the game as well as controls the creatures and characters not controlled
by the players (i.e.. friendly people the players meet) that the group
meets on the way. So in a CRPG the computer itself is the DM. As for a
group of people some games let the player control more than one character
to try to make up for it. There are some internet games that do have multi-player. Also in the future AI will play a part in creating computer controlling characters.
The important thing is the story, at the base of all rpgs there is a story, there's not always a great story, but always some type of story. With RPG played with a human DM the story is more flexible as the DM can bend the story or change depending on the players, how much a computer is able to do this affects how locked-in to the plot the player is.
Return to Contents
3. What
components go in to a CRPG?
One way of dividing the a RPG up into parts would be:
The Map |
This is the world which the player must explore. |
Creatures |
Men and beasts that try to stop the player from completing his/her quest. |
NPCs |
Non playing characters they are characters played by the computer they
are used to help the player and as part of the plot. |
Items |
Things to pick up on the way to help the player, i.e. swords, armour,
or even special item to help the quest or a puzzle on the way. |
Scripting |
Lets face it you can't hard code a game so it must have a script engine to provide control over the game with having to hand encode each event. |
This is how I divided up a RPG in to programmable
parts. I did however make one change, I had no difference between NPCs
and creatures. As I wanted friendly NPCs that search the dungeon for treasure
not with the player and non friendly townspeople that you can talk to,
but they will attack you later in the plot, but there is still a difference
in the ideas of NPCs and creature so I left them apart in this document.
Return to Contents
3.1. Maps to look
at.
Mountains, forests, swamps, plains, oceans, caves and
dungeons. These are all apart of what the player must travel through to
complete the RPG. Whether the RPG is 2-d or 3-d you must still have a map
of the land the player will explore. Towns and cities must have place on
the map where they lie so the player can visit them.
Some RPGs use pre drawn maps while others randomly
generate them as the player finds new areas. I myself like something done
between with a pre drawn map of the land, but randomly generated dungeons,
caves, and mazes.
Mazes:
I have seen two ways of making a maze each works from opposite directions.
-
You can start with a map full of rock/walls with no paths and you can start
on one place and knock down walls randomly until every odd square has being
reached.
-
Or you can start with no walls and build walls from a random even square
in a random direction until it hits another wall, and do this until there
are no more empty even squares.
For example here is some code in C for making a maze using the first method:
A good thing to do after building the maze is to randomly knock down
some of the wals so that there is more than one way through it.
Dungeons:
Randomly generated dungeons are fairly easy to do here is a method I made:
-
Start with a map full of rock, and add the first room at a random location
with a random size by removing the rock from map. Set the current number
of rooms to 1.
-
Add a new room to the map at a random location with a random size, but
check that it does not touch any empty squares and that there is at least
one empty square directly north, south, east or west of it.
-
Build at least one path out to any other empty square directly north, south,
east and/or west of this room. Build up to four paths in this way.
-
Add 1 to the current number of rooms.
-
Repeat steps 2-4 until you have enough rooms or the steps are completed
30 times with out finding a new room.
Over world Maps: ( water, earth, grass ... etc. )
These are harder to randomly generate, but there are
still many ways to do it. Here one way I worked out: (its not very fast)
-
Set the the height of all the squares on the map to 0 (sea level).
-
Set the total land mass to zero
-
Chose five random locations on the board and add randomly 5-10 to them.
-
Now for each of the squares on the map do the following:
-
Add the square to each of its 8 neighbours.
-
Make the square equal to that number divided by 8 (or shift right 3)
-
If that number was greater than 0 add randomly 0-2 on to that square.
-
Add the square to the total land mass.
-
Repeat steps 2-4 until the land mass high enough for the map. (The higher
the more land the lower the more water).
-
Now to smooth the map out do the following for each square on the map:
-
Make the square equal to itself plus each of its neighbours divided by
9.
Another way is to do it:
-
Start with a map filled up to half the max. height.
-
Make random circle on the map then either raise or lower the heights of
squares inside the circle by a small amount.
-
Repeat 2 about 100-1000 times. (Depends of the area of the map.)
Fractal Maps:
These can be slightly hard
to put together. You need an array for you map, with all the hieghts on
in the array start at zero.
Start by randomly setting
hieghts of the four counters of the map. Note: They must be greater
than zero.
Then call the main fractal
function with the (0,0) and (width_of_map,hieght_of_map).
With the input values as
(x1,y1) and (x2,y2), The main fractal function go something this:
-
First check the difference between them so if x1 and x2 are 1 square or
less apart or y1 and y2 are 1 square or less apart the function should
exit.
-
Check the point halfway between (x1,y1) and (x2,y1) where (x1,y1) and (x2,y2)
are the input values. Now if the point is zero call the second fracal function
with the values of (x1,y1) and (x2,y1), setting the point with the return
value.
-
Repeat 1. with (x1,y2)-(x2,y2), (x1,y1)-(x1,y2), and (x2,y1)-(x2,y2).
-
Now if the point between (x1,y1) and (x2,y2) is zero make it equal to the
average the last four points.
-
Using hx as (x1+x2)/2 and hy as (y1+y2)/2 call the main fractal function
four times using:
-
(x1,y1) and (hx,hy)
-
(x1,hy) and (hx,y2)
-
(hx,y1) and (x2,hy)
-
(hx,hy) and (x2,y2)
If the input values are (x1,y1)
and (x2,y2), second fractal function go like this:
-
Start a variable named h make it equil to a random value between -half_max_map_hieght
and +half_max_map_hieght
-
Muliply h by the sum of:
-
The absulute value of x1-x2 divided by a scaling factor. (The lower the
value of the scaling factor the rougher the look of the map.)
-
The absulute value of y1-y1 divided by a scaling factor. (They don't have
to be the same factor.)
-
Add to h average of the map hieght of (x1,y1) and the map hieght of (x2,y2)
-
Return h after making certain h is between 1 and map_map_hieght.
Return to Contents
3.2. Creatures to
kill.
What RPG would be complete with out horde beasts to
slay and armies of evil humans to conquest, but on the programming side
there are many points which need to be worked out even before one get stuck
up to draw and designing up the army of darkness or light for that matter.
The main point is what type of combat system to use.
Three types of combat systems:
Arcade: The player must work as quick as he/she can to chop the enemies
in to small pieces.
Rogue: The player's character is walking on the map and step by step
the enemy moves closer and then fights on the map, the players attacks
then the emery and so on.
Turn based: Player's character is walking on the map and then is game
zooms in to the current square to show the battle the player picks his/her
move then her character and all the enemies do one move each then the player
pick again and so on.
There is a big difference in the creatures one can have
depending on what kind of system you use. For example on Turn based combat
system you want to have strong creatures but less of them, as the player
has to wait to move again, but on Rogue game the creatures are never very
big in size as each creature has one square on the map. And in arcade games
creature use more hack and slash than strategy to beat the player.
Another point one should look out for is reason
to having creatures in locations. I have regions on the map where creatures
live so the player will meet those creature there. I do it for two reason:
One as the player get through the game in new area I can put harder creature
in those locations and two I have all ways felt that the creatures should
have a reason for being on the map to attack the player whether as a army
getting ready for war or thief waiting in ambush, creatures don't just
walk around try to find people to kill.
Return to Contents
3.3. NPCs
to meet and talk to, maybe kill?
The term Non Playing Characters comes from the RPGs
done with out computers. They were controlled be the DM and used to help
the player on their journey. They were full characters in the game but
were not controlled by any one person playing the game. In CRPGs NPCs are
computer players that help fill in the plot of a game some will join the
player to help them others will give items or information or even a quest
for the player to go on, but they can not be controlled by the player and
there is every NPC is different in the world unlike creatures where there
could be any number of the same type of creature.
Where are NPC found? Any where the player can go,
but mostly in towns and cities. Some games do not let the player attack
NPCs unless it is a part of the plot while some say this restricts the
player I feel this is a unless the game is flexible enough to allow the
plot to change because of the death of a key NPC all games should be like
this too.
Talking to NPCs
In RPGs the player must be able to choose what to say to a NPC, but
how to do this can be hard as you do not want the player to have to type
questions and sentences in to the keyboard as then the RPG would have to
understand them. However here is three ways used commonly in CRPGs:
-
Multi-choice: Let the player pick from a list of full sentences to say.
-
Keywords: Let the player pick from a list of keywords to talk about then
the computer will choose what to say about them.
-
Keywords with attitude: Same as above but player decide whether the character
is friendly or not.
Return to Contents
3.4. Items to pick
up.
Weapons, armour, gold, keys, and so on. And where
are these? In shops in towns, and in dungeons and on the bodies of creatures
slayed by the players character. There must be enough of these for the
player to win the game before running out of food and dieting. When designing
a game I must also be careful not to make the item to powerful.
The way I join the items to the map is to have linked
link for each square on the board so the player can pickup and drop items
up and down the map and they will still always be there.
Return to Contents
4. Making
a world seem real.
In order to make a good CRPG the world in which the
game is set must seem like complete world in order to get the player in
to the plot and through the game. In normal RPGs players use their imaginations
but in CRPGs the game must do it for the player. It is very important to
have more to a game than level after level of dungeons until it seems stupid.
The player must have the freedom to explore and even get lost, but must
hold its plot together. Having a shop in the middle of a dark dungeon full
of monsters all by itself is dumb, if you don't want the player to walk
all the way back to the beginning of the dungeon then make a spell or at
least have a lost town in the dungeon not just a single shop where there
is NO business.
If you have a town don't just have shop's, have
towns people to talk to and other adventures in a tavern. Another good
idea is to allow the player to work in the town for money, or just to make
items to help him/herself out in the game.
Return to Contents
Well that all I have time for now, there is a lot I've missed that I
wanted to put in, Maybe next time.