Jump to content
  • Advertisement
Sign in to follow this  
Protagoras

How to organize a part of my C++ game...

This topic is 4251 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

So, I'm having a hellish time figuring out how to organize this most efficiently. I want people in my game to have a bunch of attributes, of diverse types. Things like classic role-playing stats and skills. I want to be able to get some kind of information about the attributes without caring what kind they are; to return an apparent rating (say for figuring out what someone looking at the person might be able to tell about them) or an active score (used, say, when the combat part of the program is figuring out whether they succeed in some attack, if it's a combat skill or a stat that affects combat), or the like. But lots of details about how these are calculated will vary depending on what kind of attribute is being used. So I do this in the obvious way, by giving the character a container of pointers to an attribute base class which has the needed returning functions, and make individual attributes derived classes of that base class. Now, here are the complications. In some of the computations involving the derived attributes, they need to know about one another. What an active skill score should be at can be affected by their other skills or by their stats. So I want to be able to refer to one attribute from another as easily as possible. I haven't found a non-clunky way to do that (at present, I have the attributes call the reporting functions of the person they're attributes of, but that is certainly inelegant, and to listen to some people around here perhaps criminal. I don't wish to make all of the functions which adjust the attributes be functions of the people, because that seems to defeat the goal of having specialized things do specialized tasks; I don't want the person class to do everything itself). Second, I want to be able to make new kinds of attributes as easily as possible. Specialized forms of kinds of attributes I already have are, of course, easy; just make a further derived class of the original derived class, and make it override a virtual function or two. But I also want to make new attributes which combine features of other attributes, say a funky skill which improves both the way a certain kind of magic improves and in an ordinary skill-type way. But I only want one instance of the attibute base class in my new magic skill class. Is this a situation where I should just use virtual classes (some seem to recommend avoiding them at all costs)? Recommendations on how to structure all this?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!