Battle Element

Started by , Thu 25/09/2003 22:23:58

Previous topic - Next topic

Plog

I need to add a Battle Element type RPG thing to my game is there any script out there that does that or if not any ideas on how I might make the combat work?

Arcangel

#1
Hi Plog, to Create a  Battle System in AGS is a task of a lot of script, an idea to begin it could be to see the magazine AGS Ezine #2 of 4  the web page is http://www.amazing-ebooks.co.uk/ezine /  
Reference is made to the Battle System of Quest for Glory 4 1/2, Download it and studies the commands and as adapting them to your game style.

Good luck  ;)

JD

I made two kinds of RPG battle systems in AGS (a battle system like Qfg, and one like lets say Final Fantasy) and I can tell you it's not just about importing a little script. It takes a lot of scripting and a lot of time. The first thing you should do is get acquainted with the AGS scripting language.

Scorpiorus

There is no link to the battle system directly in article, but check that url: http://invis.free.anonymizer.com/http://www.geocities.com/scorpiorus82/qfgbe_v1.zip

~Cheers

Arcangel

#4
Scorpiorus, Like one makes the bar of HP.

Plog

I forgot about this topic. >_<

Now anyway. How do I actually get that URL Scorpious gave me to work its just comes out with a file I cant do anything with.

What do I do?  :-[

Scorpiorus

Quote from: DarkArcangel on Sat 27/09/2003 22:43:36
Scorpiorus, Like one makes the bar of HP.
It's like in Quest for Glory I vga.

QuoteNow anyway. How do I actually get that URL Scorpious gave me to work its just comes out with a file I cant do anything with.

What do I do?
It's a template, Plog. Just unzip the file and place it to the AGS main folder. Open Ags editor and start a new game. There is a new option (apart from blank game) I'll see.

~Cheers

Plog

Phew, You dont lie when you say its compliacated is there any way I can mae a simpler one maybe with no health bar but just taking away the numbers from something? I think I should get to grios with scripting a bit more beofre I plunge into that. =P

Scorpiorus

QuotePhew, You dont lie when you say its compliacated
Yes, the script itself a bit complex perhaps. But on the other hand you don't need to mess with the whole code but just play with some general settings and add your own graphics. The question is: do you want a battle scene like in QFG I (state-based, ie you cant move around etc) or you need something different?

Quoteis there any way I can mae a simpler one maybe with no health bar but just taking away the numbers from something?
yes, of course. When I just had started making that scene it was about 50 or 100 lines of code. But then, trying to make it more flexible, I enhanced the engine, so it turns out in what you can see.

Here some interesting tweaks you could try with that engine:

Load combat room, open interactions, Player enters screen (before fadein), edit script. You'll enter the general battle settings section.

find the next lines:

SetHumanPlayer(PLAYER1); // set human player
 //SetHumanPlayer(PLAYER2); // set human player

uncoment the second line

SetHumanPlayer(PLAYER1); // set human player
SetHumanPlayer(PLAYER2); // set human player

Now, another human can control his fighter (goblin) with: A,W,S,D keys.


Another trick set them as:

 SetHumanPlayer(PLAYER2); // set human player
 //SetHumanPlayer(PLAYER1); // set human player

Since the PLAYER2 is goblin (look at the live above, its:
 AssignPlayer(PLAYER1, HERO_FIGHTER,  100,      100,         6,        100     );
 AssignPlayer(PLAYER2, GOBLIN,        50,      100,         5,        100     ); )

you can fight against the hero.


Btw, comenting out both lines results in CPU vs CPU fight.




Also check the fighting casts subsection:

adjust the speed (spd) values for the different actions, try it out:

//------------ Caste name ----- Action ---- Spd - View - Loop -
// FIGHTER:
 ActionProps(HERO_FIGHTER, ACTION_ATTACK1,  4,     2,     1,     1,     1,    3  );




try to set the startup health and stamina points:

//------------ Player --- Caste ----- Health - Stamina -- Strength - Weapon use -
 AssignPlayer(PLAYER1, HERO_FIGHTER,  100,      100,         6,        100     );
 AssignPlayer(PLAYER2, GOBLIN,        50,      20,         5,        100     );




Finally, dont forget to check AGS ezine (issue 2). There is a tutorial with all the functions I've described.


PS. If you need any further help to go through, just post a reply.

~Cheers

Plog

Ok I read through that tutorial and I think im a bit off that kind of script at the moment there ha to be a simpler way with just attacks as dialogs and Two health bars that decrease a certain amount for a certain move like make it an object. I just would'nt know how to make that work and how to finish the battle once some one had died. If anyone could write the script or tell me how to do it I would be eternaly grateful.

Thanks, Plog.

Scorpiorus

Here is a simplier battle script. It uses dialog topic 0.
The dialog options are:
1 - Attack 1
2 - Attack 2
3 - Escape

Say box is unchecked.



Script header

import function StartFight(int, int);

Dialog script

@S  // dialog startup entry point
return
@1  // option 1
run-script 1
return
@2  // option 2
run-script 2
return
@3  // option 3
run-script 3
return

Main global script

int IsFight = 0; // whether fight in process ( 1 - yes, 0 - no)
int who_wins;    //  0 - draw(player has escaped); 1 - player; 2 - enemy

int player_HP;   // stores player's health points
int enemy_HP;    // stores enemy's health points

// starts fight (sets initial HP for both player and enemy)
function StartFight(int player_health, int enemy_health) {
 
 player_HP = player_health; // set player health
 enemy_HP = enemy_health;   // set enemy health
 IsFight = 1;               // fight begins
 RunDialog(0);              // open fight dialog
}

function dialog_request(int value) {
 
 if (IsFight == 1) {
 
   // player attacks:
   if      (value == 1) {
     AnimateCharacterEx(....);
     int damage = 5 + Random(2); // take out 5, 6 or 7 health points
     enemy_HP = enemy_HP - damage;
   }
   else if (value == 2) {
     AnimateCharacterEx(....);
     int damage = Random(10); // take out from 0 up to 10 health points
     enemy_HP = enemy_HP - damage;
   }
   else if (value == 3) {
  //player tries to escape
     AnimateCharacterEx(....);
     IsFight = 0; //end fight
     who_wins = 0; //draw
   }
 
   //show enemy's health points
   Display("Enemy HP: %d", enemy_HP);
   
   if (enemy_HP <= 0) {who_wins = 1; IsFight = 0;}
   else {
     //enemy attacks:
     AnimateCharacterEx(....);
     int damage = Random(3); // take out 0, 1, 2 or 3 HP
     player_HP = player_HP - damage;
   }
   
   
   //show player's health points
   Display("Player HP: %d", player_HP);
   if (player_HP <= 0) {who_wins = 2; IsFight = 0;}
   
   
   
   if (IsFight == 0) { // fight ends
     StopDialog();
   
     // there is a draw:
     if (who_wins == 0) {
       
       Display("draw");
     }
     // player wins:
     if (who_wins == 1) {
       Display("player wins");        
       
     }
     // enemy wins:
     if (who_wins == 2) {
       Display("enemy wins");
     
     }
   }
 }
}


You have to adjust AnimateCharacterEx() Function for your needs.

The fight start with the StartFight() function. You have to pass both player and enemy initial health points:

example:
StartFight(50,20);

starts battle (player health = 50, enemy health = 20)

~Cheers

Plog

Thankyou, thank you so much Scorpiorus.

If ther is anyway I can ever repay you I will.

Thanks again, Plog.  ;D

Klytos

Scorpiorus, I've also been playing around with your combat system, and reading through your suggestions above.

Firstly, let me say what a great job you've done with the system. Very realistic and I love the keyboard commands, as compared to QFG1VGA's mouse driven combat, which I didn't like so much.

My question is this, you have a line of code in the battle settings with sets the max values of the following four stats

FightersProps(Health_Max, Stamina_Max, Strength_Max, Weapon_Use_Max);

My game which I'm using your battle code in, uses GlobalInt's for the statistics and I obviously want to incorporate my stat system into the battle engine. If I change to above line to

FightersProps((GetGlobalInt(hlth_max)), etc

The game uses these stats for both players, I only want to use these max stats for the human player, and set a different set for the Goblin (or other evil nasty as I put them in.)

Is this possible? If so how would I do it?

Scorpiorus

Thanks for appreciating it, I am glad it comes in handy. :)

As about max stats, yes they are kinda for all players, just increase them up to the maximum value you want:

FightersProps(1000, 1000, 1000, 1000);

but use diverse (lower) values when setting stats for actual players:

HEALTH1: 700
STAMINA1: 200

HEALTH2: 300
STAMINA2: 1000

AssignPlayer(PLAYER1, HUMAN,  GetGlobalInt(HEALTH1),      GetGlobalInt(STAMINA1),         6,        100     );
 AssignPlayer(PLAYER2, GOBLIN, GetGlobalInt(HEALTH2),      GetGlobalInt(STAMINA2),         5,        100     );

~Cheers

SMF spam blocked by CleanTalk