RPG fight engine.

M

Malcolm

I'm writing a fight engine for a fantasy role-playing game.

The program involves monsters of various types as well as player characters,
using different weapons and also casting spells. There will also be objects
in the game which the characters can interact with, for instance if a spear
is thrown it will lie on the ground, ready to be picked up.
The problem is that the program needs to be extended so that everytime
someone come up with a new idea, say a new monster or a moving platform, it
can be easily incorporated.

I have to use either C or C++, and I've decided to do with C.

Has anyone designed a similar program? Any advice on how to go about it?
 
M

Michael Mair

Malcolm said:
I'm writing a fight engine for a fantasy role-playing game.

The program involves monsters of various types as well as player characters,
using different weapons and also casting spells. There will also be objects
in the game which the characters can interact with, for instance if a spear
is thrown it will lie on the ground, ready to be picked up.
The problem is that the program needs to be extended so that everytime
someone come up with a new idea, say a new monster or a moving platform, it
can be easily incorporated.

I have to use either C or C++, and I've decided to do with C.

Has anyone designed a similar program? Any advice on how to go about it?

The header of your message seems authentic, so I really wonder
what you smok^H how you contracted the idea to ask this question
here. It is certainly off-topic.
Please find some more appropriate place.

<OT>
In case you are not kidding: Fake object orientation in order to
make enough room for the unpredictable; this means that the add-ons
can go into a library and can be described either in terms of the
default capabilities or can bring capabilities of their own.
</OT>

Cheers
Michael
 
R

Richard Bos

Malcolm said:
I'm writing a fight engine for a fantasy role-playing game.

The program involves monsters of various types as well as player characters,
using different weapons and also casting spells. There will also be objects
in the game which the characters can interact with, for instance if a spear
is thrown it will lie on the ground, ready to be picked up.
The problem is that the program needs to be extended so that everytime
someone come up with a new idea, say a new monster or a moving platform, it
can be easily incorporated.

Let me guess. It should also be user-friendly, _and_ it should allow
complete freedom. Forget it. You can have either, but not both. If you
merely want new sets of objects with different parameters, you can do
that with a simple realloc()able array of structs, and a structured text
file, but you're only going to get variations on existing elements that
way. If you want to allow completely new behaviour, you will have to
implement a whole new script language layer; and if you do _that_, you
will be up to your ears in users complaining that this is tooo
haaard!!1!. Still perfectly possible in C, of course.

Richard
 
M

Malcolm

Richard Bos said:
Let me guess. It should also be user-friendly, _and_ it should allow
complete freedom. Forget it. You can have either, but not both. If you
merely want new sets of objects with different parameters, you can do
that with a simple realloc()able array of structs, and a structured text
file, but you're only going to get variations on existing elements that
way. If you want to allow completely new behaviour, you will have to
implement a whole new script language layer; and if you do _that_, you
will be up to your ears in users complaining that this is tooo
haaard!!1!. Still perfectly possible in C, of course.
What is really wanted of course is a reality simulator. So if the designer
specifies Yetis with icicles the engine automatically models fur, refraction
to make the icicle look realistic, and invesre kinematics as it runs down
the mountain.
That's beyond my skills to provide.

I'm considering three basic options.

1) hard code everything, and add more code as the designers add more
elements. This is easy, but the problem is that the structre of the program
will steadily degrade as we hack about with the location routines to add in
the moving platform.

2) fake up object-orientation by providing an interface system. This is what
I'm currently thinking of doing. The problem is that the syntax gets really
horrid because C isn't designed to do this.

3) Implement a scripting language. Effectively the program will no longer be
in C at all, but it still acceptable because I can run it through a C
compiler, which will be the interpreter. The problem is, can the scripting
language be powerful and flexible and stable enough to do what I want?

Which would you go for?
 
T

Tobias Blomkvist

Malcolm sade:
3) Implement a scripting language. Effectively the program will no longer be
in C at all, but it still acceptable because I can run it through a C
compiler, which will be the interpreter. The problem is, can the scripting
language be powerful and flexible and stable enough to do what I want?

Which would you go for?

The script can be C as well. Look at a TinyC-parser and just add an
interpreter. Otherwise, as I pointed out before, look at Lua, a
script language that some major game developers use to extend
functionality; it's completely free and apparently powerful. Or if
you want something more similar to C, AngelScript.

http://www.lua.org
http://www.angelcode.com/angelscript/

Tobias
 
M

Malcolm

Tobias Blomkvist said:
The script can be C as well. Look at a TinyC-parser and just add an
interpreter. Otherwise, as I pointed out before, look at Lua, a
script language that some major game developers use to extend
functionality; it's completely free and apparently powerful. Or if
you want something more similar to C, AngelScript.

http://www.lua.org
http://www.angelcode.com/angelscript/
Thanks. Lua may well be the answer to this one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top