12 Replies - 4929 Views - Last Post: 26 January 2007 - 03:40 PM Rate Topic: -----

#1 jstephens   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

RPG fight sequence design.

Posted 20 January 2007 - 02:22 PM

I am doing my research on building an rpg. However I am kinda of lost on how I could create a fight sequence. I gues what I would like is a good book or link to find out how to make the monster choose between attacking or using a spell. And based on the character stats what the attack will do in damage.
Is This A Good Question/Topic? 0
  • +

Replies To: RPG fight sequence design.

#2 rockstar_   User is offline

  • D.I.C Head
  • member icon

Reputation: 34
  • View blog
  • Posts: 189
  • Joined: 16-October 06

Re: RPG fight sequence design.

Posted 22 January 2007 - 04:53 PM

View Postjstephens, on 20 Jan, 2007 - 02:22 PM, said:

I am doing my research on building an rpg. However I am kinda of lost on how I could create a fight sequence. I gues what I would like is a good book or link to find out how to make the monster choose between attacking or using a spell. And based on the character stats what the attack will do in damage.

Hm, I don't think a book would necessarily help you, although I've been reading a few e-books on generating AI, so it couldn't hurt.

One of the projects the guys work on in this office (although I don't personally do the work) is building a slot machine game. It's all software based, and really the entire thing is based on math.

What I would suggest is to create a randomizer of sorts, and have it pick a number between 1 and 3. If the number is 1 or 2, the monster attacks. If it is 3, the monster casts a spell. You can then build from there, creating higher probabilities, etc.

Gosh, I miss stats class now that I'm out, but shoot, I hated it when I was there...

rockstar_
Was This Post Helpful? 0
  • +
  • -

#3 jstephens   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

Re: RPG fight sequence design.

Posted 22 January 2007 - 05:13 PM

That is sort of what I was leaning toward. Like choosing a range. If between say 1 and 5 then attack else use magic. Then having it generate another random number if more than one spell exists. That doesn't sound bad about looking into a book on AI.
Was This Post Helpful? 0
  • +
  • -

#4 Trogdor   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: RPG fight sequence design.

Posted 24 January 2007 - 08:36 AM

What you can do is define possible behaviour in a table
Say that you give every type of action a code, like
A = Attack
R = Defend
C = Cast a spell
R = Run away

etc

then for each creature you can make a table with say 10 slots.
In each slot you denote one action code.
Your random generator will then pick an action from 1 to 10, and depending on the values in the table for this specific monster it will do some action.

Once you got something like that working you can think about adding intelligence.
Was This Post Helpful? 0
  • +
  • -

#5 Shinilolz   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 238
  • Joined: 30-November 06

Re: RPG fight sequence design.

Posted 24 January 2007 - 01:03 PM

To give you an example piece of AI code for battle sequence it would help if you would give what language you are coding the game in.
Was This Post Helpful? 0
  • +
  • -

#6 jstephens   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

Re: RPG fight sequence design.

Posted 24 January 2007 - 03:31 PM

Sorry, I guess that would make life easier If I had posted that earlier. I am writing this in c++.
Was This Post Helpful? 0
  • +
  • -

#7 Trogdor   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: RPG fight sequence design.

Posted 25 January 2007 - 05:24 AM

I disagree. The language used is irellevant for the application of an algorithm.
Was This Post Helpful? 0
  • +
  • -

#8 Shinilolz   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 238
  • Joined: 30-November 06

Re: RPG fight sequence design.

Posted 25 January 2007 - 12:50 PM

View PostTrogdor, on 25 Jan, 2007 - 05:24 AM, said:

I disagree. The language used is irellevant for the application of an algorithm.


Alright, ill just tidy it up and put the actual code for it in a snippet when i have time, good idea =) anyways

I stil dont know what exactly your looking for but theres a idea

an outline for Random 5
1=attack1
2=attack2
3= if monsterhp > 50% of its hp then heal
4=harmful mag atk 1
5= if yourhp < 10% Final Attack Spell

This post has been edited by Shinigami: 25 January 2007 - 12:51 PM

Was This Post Helpful? 0
  • +
  • -

#9 jstephens   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

Re: RPG fight sequence design.

Posted 25 January 2007 - 03:49 PM

View PostShinigami, on 25 Jan, 2007 - 01:50 PM, said:

View PostTrogdor, on 25 Jan, 2007 - 05:24 AM, said:

I disagree. The language used is irellevant for the application of an algorithm.


Alright, ill just tidy it up and put the actual code for it in a snippet when i have time, good idea =) anyways

I stil dont know what exactly your looking for but theres a idea

an outline for Random 5
1=attack1
2=attack2
3= if monsterhp > 50% of its hp then heal
4=harmful mag atk 1
5= if yourhp < 10% Final Attack Spell


Something to that effect. I was thinking of about it like this.

1 = Attack
2 = Magic
Then for magic if the monster has more then 1 spell to do another random. set
3 = If monster can heal then at a certain percentage of health to initate heal spell.

Also I know that most games won't let the opponent cast a spell if he doesn't have enough MP. I was thinking about giving the user and monster the ability to cast the spell but bringing up a message that says not enough MP to cast spell. Causing the Person to pay a little more attention to details. Most rpg's like final fantasy just grey out the spell.

I figure if I do it that way it would hold some realistic value meaning like you or the creature is tiring down.
Was This Post Helpful? 0
  • +
  • -

#10 jstephens   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

Re: RPG fight sequence design.

Posted 25 January 2007 - 04:35 PM

Well I have so far got a start on it. It works just fine. This is just an extremely rough work on it so it does not have much.

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main()
{
 	srand(time(0)); 		// Seed the randomizer so results will be truly random
 	
 	int fight = (rand()% 2) + 1;
 	int damage;
 	int player_health = 100;
 	int orc_health = 32;
 	
 	// char option;
 	
 	if(fight == 1)
 	{
	 		 cout << "Orc says: human you will die\n";
	 		 cout << "Orc attacks.\n";
	 		 damage = 10;
 			 player_health -= damage;
	 }
	if(fight == 2)
	{
			   cout << "Orc says: Human you shall burn.\n";
 			 cout << "Orc cast blaze.\n";
 			 damage = 15;
 			 player_health -= damage;
	 }
	 
 cout << "Health: " << player_health;
 cout << "\nOrc's Health: " << orc_health << endl;
 
 system("pause");
 return(0);
}



I am trying to decide if I should use a enum for the player or go with the char option that I have in the sequence but not activate.

I kinda of like the enum.
enum option(Attack, Magic, Summon, Defend, Item, Run);


Was This Post Helpful? 0
  • +
  • -

#11 Shinilolz   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 238
  • Joined: 30-November 06

Re: RPG fight sequence design.

Posted 26 January 2007 - 04:32 AM

Loods good, wondering is this game going to be with graphics or text
Was This Post Helpful? 0
  • +
  • -

#12 jstephens   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

Re: RPG fight sequence design.

Posted 26 January 2007 - 09:11 AM

View PostShinigami, on 26 Jan, 2007 - 05:32 AM, said:

Loods good, wondering is this game going to be with graphics or text



I plan on making it with graphics. Right now I just want to get the foundation correct. I have a friend that is very good with drawing. So I think he will draw the characters and we will both try and learn blender3d or maybe use something like 3ds Max. We are still trying to develop a good story. One that is not about crystals or his father was killed, or some other BS like that. I was thinking about reasearching some folk lore from Scottland or doing something like a knockoff of Bleach or Naruto.
Was This Post Helpful? 0
  • +
  • -

#13 WolfCoder   User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 828
  • View blog
  • Posts: 7,696
  • Joined: 05-May 05

Re: RPG fight sequence design.

Post icon  Posted 26 January 2007 - 03:40 PM

You should also see how RPG Maker 2003/XP handles monster behavioral patterns. For example, they have a list of things the monster can do, and when they can do them.

Of the conditions that are met, the one with the highest priority is selected. If there are more than one with the same priority, then one is selected randomly from them.

Attack Normally Usually 5
Run Away Average Party Level > 10 6
Defend HP < 50% 5

From that example, the monster will run if the user's party is much too powerful. If not, then it will attack. If it is low on HP (HP < 50%), then it MIGHT defend or it MIGHT attack (since both have the same priority number).

This method makes it easier to create enemy behaviors. In fact, it might look like a struct.

#define ATTACK_NORMAL 1
#define RUN_AWAY 2
#define DEFEND 3

// Probably not this long in macro name...
#define USUALLY 0
#define IF_AVERAGE_PARTY_LEVEL_IS 1
#define IF_MY_HP_IS_LESS_THAN 2

typedef struct
{
  int action_type; // Use pre-defined ID variables for this
  int priority; // Action priority
  int condition; // Condition type
  int operand; // Condition type parameter (how less HP, how high LV, ect)
}enemy_action;

typedef struct
{
  // You have all whatever else enemies are made of replace this comment
  enemy_action my_action[20]; // Or however much more you need
}enemy;



Further development, when you have the basic engine down in much more detail, should involve you writing a tool to define enemies. Part of that tool should allow you to set all of those easily and quickly to create many enemies.

If you want to weight something more heavily, just include it twice (have two slots filled with the Defend action).

This post has been edited by WolfCoder: 26 January 2007 - 03:46 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1