Help - Search - Members - Calendar
Full Version: RPG Actor scripts
RPG RPG Revolution Forums > Game Engines > RPG Maker 2000 / 2003 > General Game Engines Discussion
Rukiri
RPGs are one of the hardest genre's to work with because of how much writing goes into the game, planning, plotting, and programming.

This is just 1 script that takes care of a RPG party, and how to remove, add, and correct slots after a member has left the party.

First things first we need an initialization script.

CODE
globalvar actor, level, party_member_removed, main_actor, a_add, add_actor;
add_actor = true;
scr_actor();


Second we need a database for all the characters in the game and their starting stats.

CODE
// Party Script
// This simple script controls your stats and data

global.maxparty = 0; // Max party variable.

// Son Goku
actor[0,0] = "Son Goku"; // Name
actor[0,1] = 3; // Level
actor[0,2] = 75; // HP
actor[0,3] = actor[0,2] // Max HP
actor[0,4] = 24; // Ki
actor[0,5] = actor[0,4] // Max Ki
actor[0,6] = 260; // Battle Power
actor[0,7] = 27; // Attack
actor[0,8] = 56; // Defense
actor[0,9] = 28; // Power
actor[0,10] = 22; // Speed
actor[0,11] = 15; // Evade
actor[0,12] = 0; // Slot #

// Vegeta
actor[1,0] = "Vegeta"; // Name
actor[1,1] = 5; // Level
actor[1,2] = 88; // HP
actor[1,3] = actor[1,2] // Max HP
actor[1,4] = 36; // Ki
actor[1,5] = actor[1,4] // Max Ki
actor[1,6] = 700; // Battle Power
actor[1,7] = 43; // Attack
actor[1,8] = 66; // Defense
actor[1,9] = 44; // Power
actor[1,10] = 37; // Speed
actor[1,11] = 23; // Evade
actor[1,12] = 0; // Slot #


Now stats are generally used in game formulas for your battle system, it tells the computer how much damage a enemy can take, whether or not your can dodge or counter your enemy.

1 stat in particular is Battle Power, this is not a normal stat in RPGs it's generally used in card games, or a few anime's in reference. Now the higher it is the better because say Goku Vs Raditz at a BP of 206 won't do any damage at all, now you might be able to scratch him at a level of 6-700. But BP is really just another term for Attack power, ignore this stat if you're not having a Battle Power system in your game.

Now let's continue on how to add and remove a player.

CODE
/*
    Usage:
    scr_goku_add();
*/

//check to see if Goku is already in your party
if global.maxparty < 3 // make sure you can't add more than 3 party members at a time.
{
  if actor[0,12] >= 1
  {
    actor[0.12] = actor[0,12] // keep the same slot number
  }
  else
  {
  // check other slots.
  // Vegeta
  if actor[1,12] = 0
  {
    actor[0,12] = 1
  }
  else if actor[1,12] = 1
  {
    actor[0,12] = 2
  }
  else if actor[1,12] = 2
  {
    actor[0,12] = 3
  }
    global.maxparty = global.maxparty + 1; // add to the maxparty variable, so you can't cheat. Muahahaha!

    scr_main_actor();
    if global.maxparty >= 3
    {
      global.maxparty = 3;
    }
  }
}


This code will run and add the Player Goku to the party, making him either the only person in the party or just making him an additional player to play with.

Let's work on removing a player.

CODE
/*
    Usage:
    scr_goku_remove();
*/
party_member_removed = true;
if global.maxparty < 3 // make sure you can't add more than 3 party members at a time.
{
  if actor[0,12] >= 1
  {
    actor[0,12] = 0 // remove the player
  }
    global.maxparty = global.maxparty - 1; // add to the maxparty variable, so you can't cheat. Muahahaha!
    if global.maxparty < 0
    {
      global.maxparty = 0;
    }
}


This code sets the player's slot # to 0 as he/she is no longer in your party, and the variable party_member_removed will run and correct the other members of the parties slot numbers for you with the obj_party.

Now the code below will correct the persons slot # generally it'll only correct those who're in the party, it's not well documented as I personally have only coded 2 players so I have not added any additional players. But it's pretty straight forward on how doing it. if you find it easier just follow the current code on adding additional member slot checks.

CODE
/*
    This script does nothing more than correct a players slot
    For example, if goku was in the 2nd slot and vegeta was in the 1st slot
    than if you removed Vegeta from your party than Goku's slot would be 1
    as Goku is the only one left in your party, if goku was 3, and vegeta was 2
    and say Kuririn was 1. Remove Kuririn than Vegeta is 1 and Goku is 2.
    
    This script uses simple logic and only retains and corrects the player's slots
    after a person has been removed from a party.
    
    Please refer to scr_actor for who's who in the arrays
*/

if party_member_removed = true
{
   if actor[1,12] = 1
   {
     actor[1,12] = 1;
   }
   else
   {
     if actor[0,12] <= 1
     {
       actor[1,12] -= 1;
       party_member_removed = false;
     }
     if actor[0,12] >=1
     {
       actor[1,12] -= 1;
       party_member_removed = false;
     }
   }
   if actor[0,12] = 1
   {
     actor[0,12] = 1;
   }
   else
   {
     if actor[1,12] <= 1
     {
       actor[0,12] -= 1;
       party_member_removed = false;
     }
     if actor[1,12] >=1
     {
       actor[0,12] -= 1;
       party_member_removed = false;
     }
}
// make slots "0" if they were slot 1.
if actor[0,12] < 0
{
  actor[0,12] = 0;
}
if actor[1,12] < 0
{
  actor[1,12] = 0;
}
}


The bottom of the code is simple, if the player is not in the party he/she will be set to 0 even though you set so in the scr_member_remove script. This is just another code check to correct the problem.


Also now that you know how to get and set party slot #s, how to create a actor database, and how to add or remove a player. Making a menu for just showing the stats(take Final fantasy for example) should be easy.

For arrays with the usage of the for command I recommend checking up on array tutorials.

Well hope this helps some people out, until my next script cya!

- Rukiri

TheBen
Nice, but I would prefer to simply use a ds_list for party order instead of just a bunch of arrays. Of course, yours is Lite-friendly, so it's definitely a good enough idea.
Rukiri
Problem is, ds_list is game maker only. This can be transfered to C#, C++, etc.
Final Fantasy 6(Japanese version) used similar order code. Though just in C or C++.
Also RPG Maker XP/VX/2k/3 use similar ordering code as well.

For reference, how would you do a ds_list ordering?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.