Sign in to follow this  

RPG implementation questions

This topic is 3047 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone! In the RPG I'm programming, there is going to be a myriad (possibly in the order of thousands) of different items, all with different effects. The same with all the different attacks and spells, and NPCs. I'm having a little trouble visualizing how all that would work out in code. The approach I'm currently thinking of involves: A) several large resource files with all the info for the attacks, characters, and items, divided up by what is available in each level. B) a bunch of functions divided up in different namespaces based on their properties C) either some huge switch/case if/else decision trees to decide which function to run (e.g. when an item is activated or when an enemy attacks) or use a function pointer in the class to point to the proper function as mentioned above. I'm not sure if this model would work, and I'm even more unsure about how I should go about making such large resource files. (excel perhaps?) Thanks in advance for the help, it's always apprecated!

Share this post


Link to post
Share on other sites
What you are describing is a quite common (afaik) problem, and solvable in so
many ways.

<sword>
<name>Longsword</name>
<minlevel>1</minlevel>
<damage>1,8</damage>
<speed>5</speed>
<texture>\items\swords\longsword.jpg</texture>
</sword>
<sword>
<name>Great scimitar</name>
<minlevel>3</minlevel>
<damage>2,12</damage>
<speed>8</speed>
<texture>\items\swords\greatscimitar.jpg</texture>
</sword>


The XML above will be located in a big file and will mostly be manipulated using an itemgenerator application you write.

Since the XML has a tag '<damage>' we know the item does damage and we can input the value of the tag '1,8'.
If it was an armor it might have a tag '<armorrating>100</armorrating>' and we would know that it could protect. We don't need to know anything else.

The textures are placed in a folder, or you can write a custom file structure to contain this as well (Like Homeworld's .big files).

The best here is that it's very easy to add new items, new spells, new graphics and so forth without having to recompile everything.

Say you introduce a new <fireresistance> tag, just add this to some items and the relevant tag will be taken into consideration when protection is beeing calculated.

Share this post


Link to post
Share on other sites

This topic is 3047 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this