Been set a task at university to create a project in either java or C++ over the next three months. One of the suggested projects was an RPG game, which intrigued me.
Playing about with some basic ideas, the vast majority of the concept seems quite easy to implement just some stats and a random number generator. However, the one area where I am having some difficulty is creating a solid method to produce a turn-based combat system, specifically a the turn-based aspect.
The outline is your standard RPG affair - encounter creature, you hit creature, creature hits you and so on until the fight is over. All I need is a way to ensure that for every action the player takes, the NPC will perform an action before the players next turn.
Any ideas welcome, thanks in advance.
3 replies to this topic
#1
Posted 08 February 2011 - 10:10 AM
|
|
|
#2
Posted 08 February 2011 - 02:03 PM
Well since the NPC is the computer, I don't understand why it would be difficult? His action would simply trigger the reaction?
Pseudo Codeish:
Pseudo Codeish:
private method hitMonster() {
this.monster[0].strength -= 5;
this.monster[0].attackBack();
}
#3
Posted 08 February 2011 - 03:50 PM
I'd use a queue to determine which character's turn it is (the computer opponent or opponents are characters). This way you could add more enemies in an encounter as well as add more heroes, and perhaps even add "pseudo-turns" like if your character is affected by poison or a "turn" to indicate the beginning of a round of combat. This queue would be relatively easy to implement, depending on how much code you want to put in the "Turn" objects in the queue. When a turn ends, add that character's Turn object back to the end of the queue and keep using that to determine which turn it is. Simple really. :)
Wow I changed my sig!
#4
Posted 08 February 2011 - 04:46 PM
Cheers guys.
Ive been playing about with an object that keeps track of the objectives / available abilities for a turn. Ive been mainly using loops but Im gonna look into implementing a queue within the object, make things run a bit smoother. Also may use the idea of enemies automatically attacking directly back as a sort of special abiltity on some mobs.
Ive been playing about with an object that keeps track of the objectives / available abilities for a turn. Ive been mainly using loops but Im gonna look into implementing a queue within the object, make things run a bit smoother. Also may use the idea of enemies automatically attacking directly back as a sort of special abiltity on some mobs.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










