Text RPG: Help with assigning separate moves to enemies

Hey there. I'm a bit of a newbie at C++ (roughly 2 months of experience) and my current college class is progressing slowly so I'm going ahead and doing my own thing.

I know a Text RPG is out of my league but it doesn't help to learn.

Basically, if I want to assign different moves to their respective type of enemy, what's the best way to take on that approach? I want to keep a hold of information such as:

-move damage
-resource cost
-various effects
-output message

I've considered doing things like:

-Using arrays to store the information
-.ini files
-Classes (though I need to study this more)
-Functions for each move

I'm just not sure what the most efficient way to do this is, or if there is even a better way.

Thanks.
Last edited on
Definitely study more on object oriented programming (OOP). If I was doing this project, I would use classes to describe the RPG characters and store status info. There are a lot of good tutorials online. Try checking out this page as a basic overview: http://www.cplusplus.com/doc/tutorial/classes/ . There are many ways to use OOP in your program, so do some research before you jump right into coding.
Thanks, will do. However it doesn't completely answer my question as to how I should handle enemy + player attacks.

Should I assign each attack to its own function? I can't make a single function for them all as there will be dynamic effects that some of them have. Any suggestions would be appreciated.
Yep, make separate classes for each type of enemy and the player. Then add functions for attacks within those classes and then make a completely different function where the player takes damage (say if you have armour it may affect the real damage)

Also you should learn about vectors, they come in handy, eventually.
Last edited on
Thank you! That's exactly what I needed :). Appreciate it, guys.
I'm stumped. If I have separate classes for each type of enemy, is there a way to call them based on a variable? The majority of fights would be random encounters, and I think it would get excessive using IF statements for each enemy to call each class and its objects.
Last edited on
You can use switches and cases instead of if conditions, but I'm not really into random encounters so I can't tell you anything more...
Last edited on
Hm, okay. I'm going to experiment a bit and come back here later.
Topic archived. No new replies allowed.