Skip to main content
gamedev.net
🔒 Locked

OO RPG development?

Started by dakankm 4 replies 450+ views
Original Post
dakankm
dakankm
Is there an example of RPG programmed in OOP style? I’m particularly interested in interaction routine. Attack/Defend sequences. If any one has any thought they might be willing to share I will appreciate it lots. Can be in C++/VB or any similar language. Thanks, kmaxim@hotmail.com
Fruny
Fruny
You can try looking in the direction of the many MUD codebases. Some are OO.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
EbonySeraph
EbonySeraph
Im not completely sure about what you are asking for but I do know that putting a lot of RPG concepts on the OO form would make things very simple and easy to read/understand.

If you think about what goes into an attack in an RPG it considers many things - equipment opponent has, wether or not the enemy himself/herself has elemental properties, properties of the attack, power of the attack, and character level are just a few things to consider. That is a lot but it shouldn''t be apparent in the code because all of that information should be put in classes/structs.

In psuedo code I would think of a spell like this

struct spell
{
bool fire;
bool water;
bool wind;
bool earth;
int power;
}

And then you can have a list of spells defined at the beginning as an array as such:

spell spells[80];

The person striking and being struck has a few stats too:

class fighter
{
//Methods here

private:
float defense; //These are floats because they are percent
float attack; //of damage actually done by the spell
float magic;
float magic def;
int level;
}

Of course it gets more complicated as you add equipment which changes attack damage or defense, and if those equiment have elemental properties.

Your question could have been asking about the whole game including story in which case, what I said probably didn''t shed much light.

"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
"Ogun's Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
LilBudyWizer
LilBudyWizer
Just some thoughts. It would seem the starting point is that a creature has decided it is going to attack some other creature in some manner. So you have two creature objects. You would also need an object for the "some manner". The some manner is a weapon, spell, ability or similar thing. That gives you two base classes. One for creatures and one for attacks. The attack object determines whether the attack succeeds or fails as well as the damage done if it succeeds. The creatures basically just provides the statistics used in that process. With area effect spells and bombs you would spawn a creature with a limited life span that attacks everything within its radius of effect. I don''t see any particular reason to distinguish beneficial things like healing from attacks. The differance would seem to me to be in the effect and not the process. Area effects spells I think would be best done by spawning a creature with a limited life span that in turn attacks everything within its area of effect. That keeps it down to creature attacks creature. The actual spawn would have to be done as an attack.

It does require that everything be boiled down to statistics. That could get rather nasty as you have to add statistics for one creature or attack because of its unique nature. You could split the work between the attack and creature. So perhaps the attack says it succeeded, but when you go to apply it the creature rejects or modifies it further. You could also off load some of the work onto objects by by having the creature pass it through its equipment. I think you would need to be getting a bit carried away for that to me needed. It might be better than 80 statistics for each of 80 spells and another 150 statistics for every possible weapon. Whee, I have a shield of immunity on the second tuesday of odd months of even years that are not leap years from magic missiles by female orcs between the ages of 30 and 32 when they are between 30 and 40 feet from me.
Keys to success: Ability, ambition and opportunity.
dakankm
dakankm
That was exactly what I was looking for, some thoughts about developing nice interaction between objects in the RPG.
You see I have a basic Idea of what it should look like, it is similar to what you have posted, and the only thing that
stops me now is how to handle the effect model nicely. My thoughts are.
Create IEfect object that will be implemented by all other objects that cause some sort of effect.
What is the best and most elegant way to handle it?
Attacker.Effect(Defender)
Or
Defender.Rezist(Attacker.Effect())
Or
Defender = Defender + Attacker.Effect()
I don’t want to have to many IF/CASE statements and looking for a way to avoid them as much as possible, so I’m
thinking of using a granular approach. I don’t think it will be possible.
What do you guys think about it? How would you handel it (inside)?
Thanks.
beginner_directx
beginner_directx
Just start with as simple as possible Characters System , then grow . that is the most efficient way( at least for a beginner).

class hero { // you , the player
private:
float health , magic , defence , speed , experience ;
int level ;
};

maybe other related things , but **BEWARE** , dont start with complex system
http://uae-arts.host.sk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.