//
// Neo-Jaguar Entertainment
//
// Attempt 0001 at programming The Stone of Reikai
//
// Project:       Rebirth
// Title:         The Stone of Reikai
// Developer:     Neo-Jaguar Entertainment
// Version:       1.3.2.1.0 (ReleasEvent.MajorChangEvent.EnginEvent.Design.MinorChange)
// Date Started:  ?
// Date Created:  20.3.01 Tuesday, March 20th 2001
// Date Finished:
// Copyright:     (C)2001 Neo-Jaguar Entertainment Pending
// Programmers:   Tony J. Slater
// 
// Version Information:
//
// Battle Engine: 2.6
// Battle Setup Engine: 2.2
// Enemy AI: 1.3
// Map Exploration Engine: 2.2
// Cut-Scene Engine: 2.0.1
//
// Files used:
//
// cutscenEvent.dba Contains information on images to be used for cut-scenes
// cutscenEvent.dbe Contains information on text to be used for cut-scenes
// *.wld (* = Location) Contains information about the region
// *.map (* = Location) Pinpoits obstacles and impassible areas on the map
// *.nmy (* = Enemy) Contains information about each Enemy

// Object Creation

// Main Objects
import java.awt.Graphics;
import java.awt.Color;
import java.awt.*;
import java.applet.*;
import java.lang.System;
import java.lang.reflect.Array;
import java.math.*;
import java.util.Random;
import java.io.*;
// myMath = New Math();          // The math object will allow us to use advanced mathemtical functions.
//myMessageBox = New MessageBox();    // myMessageBox will allow us to display Pop-Up Message boxes, if neccessary.
//myIni = New Ini();            // myIni will allow us to read and write data from INI files, which is a very important part of the gamEvent.
//myWindow = New Window();        // Creates a window for us to use
//myWindow.SetFullScreenMode(320, 200);  // Set the window we just created to run in fullscreen, with the window area being 320x200.
//myBinary = New Binary("L6");

public class tsorgi5 extends java.applet.Applet {
  FileInputStream myBinary = new FileInputStream("L6.map");
  byte[] binaryMap = new byte[1200];
  // Storyline Variables
  String fakeIniFile = "loading.dat--";
  String tempStr = "loading";
  int Mode = 1;                // Tells if the player is in a cut-scene, battle, battle menu, map exploration, question, etc..
  int Progress = 1;              // Tells where the player is in the overall storyline
  int Timers = 0;                // Tells the progress ON the modEvent.  in battle, it helps us figure out who should be attacking.  in cut-scenes it helps us Display the frames in order.
  int Location = 6;
  int MapX = 5;
  int MapY = 0;
  int NavMap = 15;
  int CurrChar = 1;
  int battling = 1;
  int[][] BMenu = new int[3][5];
  int HeroNextAttack = 1;
  int HeroNextAttackType = 1;
  int HeroNextAttacke = 1;
  int tempVar = 0;
  int tempVarA = 0;
  int CurrEnemy = 0;
  int BMenuSubjectSelection = 1;
  int EnemyLose = 0;
  int HeroLose = 0;
  int LocationEnemies = 0;

  int[] pauseInt = new int[9];

  // Items
  int[] Item = new int[12];
  int Gold = 0;    // Tells how much Gold the party has.

  // Charecter Variables (Shunketsu)

  // Charecter Status
  int[][][] CharInfo = new int[5][5][13];

  // Current Weapon
  int[][][] WeaponInfo = new int[5][11][4];

  // Current Shield
  int[][][] ShieldInfo = new int[5][11][4];

  // Current Armour
  int[][][] ArmorInfo = new int[5][11][4];

  // Charecter's Weapons

  // Charecter's Shields

  // Charecter's Armour

  // Charecter's Magic

  // Charecter's Special Moves

  // Charecter's Points

  // Charecter's Attack Modifications
  int[][] Attacks = new int[2][11];

  // Enemy Variables (Enemy 1)
  int[][] Enemy = new int[1][17];

  // Statistics
  int StatGold = 0;              // Biggest ammount of gold in possesion at one time
  int StatHeroHP = 500;            // Most Hitpoints at the end of a major battle for Shunketsu
  int StatHeroEP = 7;              // Most Energy Points at the end of a major battle for Shunketsu
  int StatHeroMP = 7;              // Most Magic Points at the end of a major battle for Shunketsu
  int StatBattles = 0;            // Total Battles
  int StatHeroBattles = 0;
  int StatBattlesWon = 0;            // Battles Won
  int StatHeroBattlesWon = 0;
  int StatBattlesRun = 0;            // Battles Run from
  int StatHeroBattlesRun = 0;
  int StatTreasures = 0;            // Treasures found
  int StatSecrets = 0;            // Secrets found
  int StatCheats = 0;              // Number of Cheats used
  int StatAbility = 0;            // A combination of all of the above used to determine the ability of a player.
                    // Note to self: use this variable to perhaps program a system where the game's difficulty adapts to the player's abilities so it won't be too hard for some and too easy for others.

  int[] ShopDat = new int[8];
  int CurrShop = 0;

  Random randVal = new Random();

  // Images
  Image imgBg = getImage(getCodeBase(), "sLoading.gif");        // Background image used whenever relevant.
  //Image imgBg.SetAntiAliasing(TRUE);
  //Image imgBg.SetTransparent(OFF);
  Image imgMapChar = getImage(getCodeBase(), "mP-1.gif");
  //Image imgMapChar.SetAntiAliasing(TRUE);
  //Image imgMapChar.SetTransparent(ON);
  //Image imgMapChar.Hide();
  // Bottom panel in Cut-Scenes
  Image imgCsbot = getImage(getCodeBase(), "sCsbot");
  //Image imgCsbot.SetAntiAliasing(TRUE);
  //Image imgCsbot.SetTransparent(OFF);
  // Bottom panel in Battle Engine
  Image imgBattleA = getImage(getCodeBase(), "sBattlebot");
  //Image imgBattleA.SetAntiAliasing(TRUE);
  //Image imgBattleA.SetTransparent(OFF);
  // Picture of the charecter currently speaking in a cut-scene
  Image imgCsChar = getImage(getCodeBase(), "charb-6");
  //Image imgCsChar.SetAntiAliasing(TRUE);
  //Image imgCsChar.SetTransparent(OFF);
  // Picture of the current charecter in the party
  Image imgBattleB = getImage(getCodeBase(), "chars-1");
  //Image imgBattleB.SetAntiAliasing(TRUE);
  //Image imgBattleB.SetTransparent(OFF);
  // Picture of the current enemy in the party
  Image imgBattleC = getImage(getCodeBase(), "sEnemy1");
  //Image imgBattleC.SetAntiAliasing(TRUE);
  //Image imgBattleC.SetTransparent(OFF);
  // Picture of the charecter/enemy that the move is being made on
  Image imgBattleD = getImage(getCodeBase(), "sLoading");
  //Image imgBattleD.SetAntiAliasing(TRUE);
  //Image imgBattleD.SetTransparent(OFF);
  // Animation of the attack or move being made
  Image imgBattleE = getImage(getCodeBase(), "sLoading");
  //Image imgBattleEvent.SetAntiAliasing(TRUE);
  //Image imgBattleEvent.SetTransparent(ON);

  // Picture of the current charecter
  Image imgBMenuA = getImage(getCodeBase(), "chars-1");
  //Image imgBMenuA.SetAntiAliasing(TRUE);
  //Image imgBMenuA.SetTransparent(OFF);
  // Picture of the subject the user has selected to use the move on
  //Image imgBMenuB = getImage(getCodeBase(), "sEnemy1");
  //Image imgBMenuB.SetAntiAliasing(TRUE);
  //Image imgBMenuB.SetTransparent(OFF);

  // Picture of the shop
  Image imgShopA = getImage(getCodeBase(), "chars-6");
  //Image imgShopA.SetAntiAliasing(TRUE);
  //Image imgShopA.SetTransparent(OFF);
  // Picture of the item
  Image imgShopB = getImage(getCodeBase(), "chars-6");
  //Image imgShopB.SetAntiAliasing(TRUE);
  //Image imgShopB.SetTransparent(OFF);
  //Image imgShopA.Hide();
  //Image imgShopB.Hide();

  // Fonts
  //fntNorm = New Font("Arial", 10);  // Font used for normal text, such as StatusText
  //fntEmph = New Font("Arial", 10);    // Font used for special text, such as charecter names in battle engine
  // fntEmph.BOLD();
  //fntSmal = New Font("Arial", 10);  // Font used for small messages or text, such as the HP and EP displays in the battle engine
  // fntSmal.ITALIC();
  //fntSys = New Font("fixedsys", 9);  // Font used for system messages, such as errors.  Not used often because most System messages have been altered to display via message boxes.

  // Text Objects
  String strStatusText = "Loading...";
  int[] StatusText = new int[2];
  // Name of the current charecter
  int[][] Battle = new int[6][2];
  // Name of the current enemy
  //int Battle[3] = New StaticText("BattleEnemy", myWindow, 163, 145, 116, 14);  // Enemy's name displayed in battle engine
  // Charecter's HP
  //int Battle[1] = New StaticText("BattleCharHP", myWindow, 54, 162, 40, 14);  // Charecter's HP displayed in battle engine
  // Enemy's HP
  //int Battle[4] = New StaticText("BattleEnemyHP", myWindow, 178, 162, 40, 14);
  // Charecter's EP
  //int Battle[2] = New StaticText("BattleCharEP", myWindow, 115, 162, 41, 14);
  // Enemy's EP
  //int Battle[5] = New StaticText("BattleEnemyEP", myWindow, 238, 162, 41, 14);

  // First line in available moves
  //int BMenuTxt[0] = New StaticText("Attack (0)", myWindow, 4, 72, 152, 14);
  int[][] BMenuTxt = new int[13][2];
  // Second line in available moves
  //int BMenuTxt[1] = New StaticText("Attack (0)", myWindow, 4, 86, 152, 14);
  // Third line in available moves
  //int BMenuTxt[2] = New StaticText("Attack (0)", myWindow, 4, 100, 152, 14);
  // Fourth line in available moves
  //int BMenuTxt[3] = New StaticText("Attack (0)", myWindow, 4, 114, 152, 14);
  //int BMenuTxt[0].Hide();
  //int BMenuTxt[1].Hide();
  //int BMenuTxt[2].Hide();
  //int BMenuTxt[3].Hide();

  // Current charecter
  //int BMenuTxt[4] = New StaticText("Shunketsu", myWindow, 40, 4, 117, 14);    // Charecter's name displayed in battle engine
  // Subject selected
  //int BMenuTxt[8] = New StaticText("Enemy", myWindow, 161, 4, 117, 14);  // Enemy's name displayed in battle engine
  // Current Charecter's HP
  //int BMenuTxt[5] = New StaticText("HP", myWindow, 40, 22, 36, 14);  // Charecter's HP displayed in battle engine
  // HP of Subject
  //int BMenuTxt[9] = New StaticText("HP", myWindow, 162, 22, 36, 14);
  // CurrChar's EP
  //int BMenuTxt[6] = New StaticText("EP", myWindow, 80, 22, 36, 14);
  // EP of Subject
  //int BMenuTxt[10] = New StaticText("EP", myWindow, 202, 22, 36, 14);
  // CurrChar's MP
  //int BMenuTxt[7] = New StaticText("MP", myWindow, 120, 22, 36, 14);
  //int BMenuTxt[11] = New StaticText("MP", myWindow, 242, 22, 36, 14);
  //int BMenuTxt[12] = New StaticText("Desc", myWindow, 5, 153, 151, 41);

  //
  // NOTE
  /////////
  //
  // The following string position variables are commented out so that Java may compile without errors.  (hopefully)  Should finish these on final day.
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Name of the shop
int[][] Shop = new int[15][2];
//int Shop[0] = New StaticText("Shop Name", myWindow, 38, 3, 159, 14);
//int Shop[0].SetColor(GetRGB(255, 255, 255));
//int Shop[0].SetBackColor(GetRGB(63,31,0));
//int Shop[0].Hide();
// The shopkeeper's greeting, perhaps announcing a discounted item
//int Shop[1] = New StaticText("Shop Name", myWindow, 200, 3, 115, 32);
//int Shop[1].SetColor(GetRGB(255, 255, 255));
//int Shop[1].SetBackColor(GetRGB(63,31,0));
//int Shop[1].Hide();
// Name of the item which the user has selected
//int Shop[2] = New StaticText("Shop Name", myWindow, 38, 42, 118, 14);
//int Shop[2].SetColor(GetRGB(255, 255, 255));
//int Shop[2].SetBackColor(GetRGB(63,31,0));
//int Shop[2].Hide();
// Value of the item selected
//int Shop[3] = New StaticText("Shop Name", myWindow, 63, 60, 93, 14);
//int Shop[3].SetColor(GetRGB(255, 255, 255));
//int Shop[3].SetBackColor(GetRGB(63,31,0));
//int Shop[3].Hide();
// Ammount of that item owned
//int Shop[4] = New StaticText("Shop Name", myWindow, 77, 78, 79, 14);
//int Shop[4].SetColor(GetRGB(255, 255, 255));
//int Shop[4].SetBackColor(GetRGB(63,31,0));
//int Shop[4].Hide();
// Description of item selected
//int Shop[5] = New StaticText("Shop Name", myWindow, 3, 95, 153, 14);
//int Shop[5].SetColor(GetRGB(255, 255, 255));
//int Shop[5].SetBackColor(GetRGB(63,31,0));
//int Shop[5].Hide();
// Ammount of item to purchase
//int Shop[6] = New StaticText("Shop Name", myWindow, 78, 159, 44, 14);
//int Shop[6].SetColor(GetRGB(255, 255, 255));
//int Shop[6].SetBackColor(GetRGB(63,31,0));
//int Shop[6].Hide();
// Ammount of Gold possesed by the party
//int Shop[7] = New StaticText("Shop Name", myWindow, 222, 144, 93, 14);
//int Shop[7].SetColor(GetRGB(255, 255, 255));
//int Shop[7].SetBackColor(GetRGB(63,31,0));
//int Shop[7].Hide();
// Gold being transferred in transaction
//int Shop[8] = New StaticText("Shop Name", myWindow, 222, 161, 93, 14);
//int Shop[8].SetColor(GetRGB(255, 255, 255));
//int Shop[8].SetBackColor(GetRGB(63,31,0));
//int Shop[8].Hide();
// Gold party will posses after transaction is made
//int Shop[9] = New StaticText("Shop Name", myWindow, 223, 181, 92, 14);
//int Shop[9].SetColor(GetRGB(255, 255, 255));
//int Shop[9].SetBackColor(GetRGB(63,31,0));
//int Shop[9].Hide();
// First line in items list
//int Shop[10] = New StaticText("ln 1", myWindow, 162, 54, 153, 14);
//int Shop[10].SetColor(GetRGB(255, 255, 255));
//int Shop[10].SetBackColor(GetRGB(63,31,0));
//int Shop[10].OnClick = textClick;
//int Shop[10].Hide();
// Second line in items list
//int Shop[11] = New StaticText("ln 2", myWindow, 162, 68, 153, 14);
//int Shop[11].SetColor(GetRGB(255, 255, 255));
//int Shop[11].SetBackColor(GetRGB(63,31,0));
//int Shop[11].OnClick = textClick;
//int Shop[11].Hide();
// Third line in items list
//int Shop[12] = New StaticText("ln 3", myWindow, 162, 82, 153, 14);
//int Shop[12].SetColor(GetRGB(255, 255, 255));
//int Shop[12].SetBackColor(GetRGB(63,31,0));
//int Shop[12].OnClick = textClick;
//int Shop[12].Hide();
// Fourth line in items list
//int Shop[13] = New StaticText("ln 4", myWindow, 162, 96, 153, 14);
//int Shop[13].SetColor(GetRGB(255, 255, 255));
//int Shop[13].SetBackColor(GetRGB(63,31,0));
//int Shop[13].OnClick = textClick;
//int Shop[13].Hide();
// Fifth line in items list
//int Shop[14] = New StaticText("ln 5", myWindow, 162, 110, 153, 14);
//int Shop[14].SetColor(GetRGB(255, 255, 255));
//int Shop[14].SetBackColor(GetRGB(63,31,0));
//int Shop[14].OnClick = textClick;
//int Shop[14].Hide();

int[][] pauseTxt = new int[21][2];
//int pauseTxt[0] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[0].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[0].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[0].Hide();
//int pauseTxt[1] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[1].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[1].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[1].Hide();
//int pauseTxt[2] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[2].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[2].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[2].Hide();
//int pauseTxt[3] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[3].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[3].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[3].Hide();
//int pauseTxt[4] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[4].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[4].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[4].Hide();
//int pauseTxt[5] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[5].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[5].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[5].Hide();
//int pauseTxt[6] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[6].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[6].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[6].Hide();
//int pauseTxt[7] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[7].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[7].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[7].Hide();
//int pauseTxt[8] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[8].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[8].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[8].Hide();
//int pauseTxt[9] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[9].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[9].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[9].Hide();
//int pauseTxt[10] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[10].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[10].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[10].Hide();
//int pauseTxt[11] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[11].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[11].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[11].Hide();
//int pauseTxt[12] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[12].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[12].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[12].Hide();
//int pauseTxt[13] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[13].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[13].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[13].Hide();
//int pauseTxt[14] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[14].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[14].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[14].Hide();
//int pauseTxt[15] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[15].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[15].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[15].Hide();
//int pauseTxt[16] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[16].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[16].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[16].Hide();
//int pauseTxt[17] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[17].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[17].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[17].Hide();
//int pauseTxt[18] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[18].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[18].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[18].Hide();
//int pauseTxt[19] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[19].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[19].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[19].Hide();
//int pauseTxt[20] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[20].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[20].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[20].Hide();
//pauseTxt[0].OnClick = textClick;
//pauseTxt[1].OnClick = textClick;
//pauseTxt[2].OnClick = textClick;
//pauseTxt[3].OnClick = textClick;
//pauseTxt[4].OnClick = textClick;
//pauseTxt[5].OnClick = textClick;
//for (int ln = 0; ln < 6; ln++)
//{
//  pauseTxt[ln].OnClick = textClick;
//}

int[][][] ExpGain = new int[5][6][2];
String ExpGainAB = "";
//int ExpGain[0,1] = New StaticText("Charecter 1 Name", myWindow, 38, 3, 120, 14);
//int ExpGain[0,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,1].Hide();
String ExpGainAC = "";
//int ExpGain[0,2] = New StaticText("Ex until next level", myWindow, 50, 21, 45, 14);
//int ExpGain[0,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,2].Hide();
String ExpGainAD = "";
//int ExpGain[0,3] = New StaticText("Mx until next level", myWindow, 113, 21, 45, 14);
//int ExpGain[0,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,3].Hide();
String ExpGainAE = "";
//int ExpGain[0,4] = New StaticText("LvlUp ln 1", myWindow, 161, 5, 154, 14);
//int ExpGain[0,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,4].Hide();
String ExpGainAF = "";
//int ExpGain[0,5] = New StaticText("LvlUp ln 2", myWindow, 161, 19, 154, 14);
//int ExpGain[0,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,5].Hide();
//int ExpGain[1,1] = New StaticText("Charecter 2 Name", myWindow, 38, 42, 120, 14);
//int ExpGain[1,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,1].Hide();
//int ExpGain[1,2] = New StaticText("Ex until next level", myWindow, 50, 60, 45, 14);
//int ExpGain[1,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,2].Hide();
//int ExpGain[1,3] = New StaticText("Mx until next level", myWindow, 113, 60, 45, 14);
//int ExpGain[1,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,3].Hide();
//int ExpGain[1,4] = New StaticText("LvlUp ln 1", myWindow, 161, 44, 154, 14);
//int ExpGain[1,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,4].Hide();
//int ExpGain[1,5] = New StaticText("LvlUp ln 2", myWindow, 161, 58, 154, 14);
//int ExpGain[1,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,5].Hide();
//int ExpGain[2,1] = New StaticText("Charecter 3", myWindow, 38, 81, 120, 14);
//int ExpGain[2,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,1].Hide();
//int ExpGain[2,2] = New StaticText("Ex until next level", myWindow, 50, 99, 45, 14);
//int ExpGain[2,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,2].Hide();
//int ExpGain[2,3] = New StaticText("Mx until next level", myWindow, 113, 99, 45, 14);
//int ExpGain[2,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,3].Hide();
//int ExpGain[2,4] = New StaticText("LvlUp ln 1", myWindow, 161, 83, 154, 14);
//int ExpGain[2,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,4].Hide();
//int ExpGain[2,5] = New StaticText("LvlUp ln 2", myWindow, 161, 97, 154, 14);
//int ExpGain[2,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,5].Hide();
//int ExpGain[3,1] = New StaticText("Charecter 4", myWindow, 38, 120, 120, 14);
//int ExpGain[3,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,1].Hide();
//int ExpGain[3,2] = New StaticText("Ex until next level", myWindow, 50, 138, 45, 14);
//int ExpGain[3,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,2].Hide();
//int ExpGain[3,3] = New StaticText("Mx until next level", myWindow, 113, 138, 45, 14);
//int ExpGain[3,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,3].Hide();
//int ExpGain[3,4] = New StaticText("LvlUp ln 1", myWindow, 161, 122, 154, 14);
//int ExpGain[3,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,4].Hide();
//int ExpGain[3,5] = New StaticText("LvlUp ln 2", myWindow, 161, 136, 154, 14);
//int ExpGain[3,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,5].Hide();
//int ExpGain[4,1] = New StaticText("Charecter 5", myWindow, 38, 159, 120, 14);
//int ExpGain[4,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,1].Hide();
//int ExpGain[4,2] = New StaticText("Ex until next level", myWindow, 50, 177, 45, 14);
//int ExpGain[4,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,2].Hide();
//int ExpGain[4,3] = New StaticText("Mx until next level", myWindow, 113, 177, 45, 14);
//int ExpGain[4,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,3].Hide();
//int ExpGain[4,4] = New StaticText("LvlUp ln 1", myWindow, 161, 161, 154, 14);
//int ExpGain[4,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,4].Hide();
//int ExpGain[4,5] = New StaticText("LvlUp ln 2", myWindow, 161, 175, 154, 14);
//int ExpGain[4,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,5].Hide();

int NaishiActive = 0;
int KingActive = 0;
int QueenActive = 0;
int KahiActive = 0;
int ln = 0;

// Program.DebugBreak();
//Event.OnKey() = keyDown;
//myWindow.OnClick = mouseClick;
//BMenuTxt[0].OnClick = textClick;
//BMenuTxt[1].OnClick = textClick;
//BMenuTxt[2].OnClick = textClick;
//BMenuTxt[3].OnClick = textClick;
//Program.OnError = DoError;

  public void init() {
    BMenu[0][0] = 1;  // BMenuCharOption
    BMenu[0][1] = 1;  // BMenuCharSelection
    BMenu[0][2] = 1;  // BMenuSubjectOption
    BMenu[0][3] = 1;  // BMenuSubjectSelection
    BMenu[0][4] = 0; // BMenuAreaFocus
    BMenu[2][0] = 0;
    BMenu[2][1] = 1;
    BMenu[2][2] = 2;
    BMenu[2][3] = 3;

    pauseInt[0] = 0;  // Offsets
pauseInt[1] = 1;
pauseInt[2] = 2;
pauseInt[3] = 3;
pauseInt[4] = 4;
pauseInt[5] = 5;
pauseInt[6] = 0;  // Primary Menu Option (Current charecter in Charecter Screen)
pauseInt[7] = 0;  // Secondary Menu Option (Menu for that current charecter in Charecter Screen)
pauseInt[8] = 0;  // Menu selection

// Items
Item[0] = 5;  // Holy Crystal
Item[1] = 0;  // Holy Water
Item[2] = 0;  // Holy Dust
Item[3] = 0;  // Magic Crystal
Item[4] = 0;  // Magic Water
Item[5] = 0;  // Magic Dust
Item[6] = 0;  // Energy Crystal
Item[7] = 0;  // Energy Water
Item[8] = 0;  // Energy Dust
Item[9] = 0;  // Tokubetsu Crystal
Item[10] = 0;  // Tokubetsu Water
Item[11] = 0;  // Tokubetsu Dust

// Charecter Variables (Shunketsu)

// Charecter Status
CharInfo[1][0][0] = 1;  // Is Shunketsu in the party?
CharInfo[1][0][1] = 1;  // Is Shunketsu conscious?

// Current Weapon
CharInfo[1][1][0] = 1;              // Tells which weapon is equipped.
WeaponInfo[1][1][1] = 1;            // Tells the DP modification of the current weapon.
WeaponInfo[1][1][2] = 1;            // Tells the AP modification of the current weapon.
WeaponInfo[1][1][3] = 1;            // Tells the AG modification of the current weapon.

// Current Shield
CharInfo[1][1][1] = 1;              // Tells which shield is equipped.
ShieldInfo[1][1][1] = 1;            // Tells the DP modification of the current shield.
ShieldInfo[1][1][2] = 1;            // Tells the AP modification of the current shield.
ShieldInfo[1][1][3] = 1;            // Tells the AG modification of the current shield.

// Current Armour
CharInfo[1][1][2] = 1;              // Tells which armour is equipped.
ArmorInfo[1][1][1] = 1;            // Tells the DP modification of the current armour.
ArmorInfo[1][1][2] = 1;            // Tells the AP modification of the current armour.
ArmorInfo[1][1][3] = 1;            // Tells the AG modification of the current armour.

// Charecter's Weapons
WeaponInfo[1][1][0] = 1;              // Shunketsu's Axe
WeaponInfo[1][2][0] = 0;              // Shunketsu's Sword
WeaponInfo[1][3][0] = 0;            // The Trident
WeaponInfo[1][4][0] = 0;              // Yamoan Spear
WeaponInfo[1][5][0] = 0;          // The Crystal Sword
WeaponInfo[1][6][0] = 0;            // The Magic Sword
WeaponInfo[1][7][0] = 0;            // The Kami Sword

// Charecter's Shields
ShieldInfo[1][1][0] = 1;            // Shunketsu's Wooden Shield
ShieldInfo[1][2][0] = 0;            // Anabanese Battle Shield
ShieldInfo[1][3][0] = 0;          // Yamanaran Crystal Shield
ShieldInfo[1][4][0] = 0;          // The Magic Shield
ShieldInfo[1][5][0] = 0;            // The Kami Shield

// Charecter's Armour
ArmorInfo[1][1][0] = 1;            // Shunketsu's Hunting Clothes
ArmorInfo[1][2][0] = 0;            // Anabanese Battle Armour
ArmorInfo[1][3][0] = 0;          // Yamanaran Crystal Armour
ArmorInfo[1][4][0] = 0;            // The Magic Armour
ArmorInfo[1][5][0] = 0;            // The Kami Armour

// Charecter's Magic
CharInfo[1][2][0] = 0;              // Lunar Attack
CharInfo[1][2][1] = 100;            // Fukenzen
CharInfo[1][2][2] = 500;              // Shinu
CharInfo[1][2][3] = 10000;              // Fire

// Charecter's Special Moves
CharInfo[1][3][0] = 0;        // Normal Attack
CharInfo[1][3][1] = 0;        // Legendary Attack
CharInfo[1][3][2] = 500;        // Spiritual Attack
CharInfo[1][3][3] = 1000;            // Naitote
CharInfo[1][3][4] = 2000;            // Earthquake

// Charecter's Points
CharInfo[1][4][0] = 1;    // Level of the charecter
CharInfo[1][4][1] = 500;    // Maximum Hit Points
CharInfo[1][4][2] = 500;    // Hit Points
CharInfo[1][4][3] = 2;    // Maximum magic Points
CharInfo[1][4][4] = 2;    // Magic Points
CharInfo[1][4][5] = 7;    // Maximum Energy Points
CharInfo[1][4][6] = 1;    // Energy Points
CharInfo[1][4][7] = 1;    // Energy points gained each turn in battle
CharInfo[1][4][8] = 100;    // Experience points left until next level is reached
CharInfo[1][4][9] = 10;    // Defense Points
CharInfo[1][4][10] = 20;    // Attack Points
CharInfo[1][4][11] = 5;    // Agility Points
CharInfo[1][4][12] = 5;    // Speed Points

// Charecter's Attack Modifications
Attacks[0][0] = 1;    // Enemy's Attack ID
Attacks[1][0] = 1;            // The next move being made
Attacks[1][1] = 1;  // Attack Type
Attacks[1][2] = 1;  // Charecter to be attacked
Attacks[1][3] = 1;  // SP Mod
Attacks[1][4] = 1;  // AG Mod
Attacks[1][5] = 1;  // DP Mod
Attacks[1][6] = 1;  // EP Gain
Attacks[1][7] = 1;          // AP modification of next move
Attacks[1][8] = 1;          // MP modification of next move
Attacks[1][9] = 1;          // HP modification of next move
Attacks[1][10] = 1;          // EP modification of next move (How much the move takes)

// Enemy Variables (Enemy 1)
Enemy[0][0] = 1;    // Current Enemy
Enemy[0][1] = 100;  // Hit points
Enemy[0][2] = 100;  // Maximum Hit points
Enemy[0][3] = 50;  // Attack Points
Enemy[0][4] = 20;  // Defense Points
Enemy[0][5] = 1;    // Agility Points
Enemy[0][6] = 1;    // Energy Points
Enemy[0][7] = 7;    // Maximum Energy Points
Enemy[0][8] = 1;    // Energy Points gained each turn
Enemy[0][9] = 5;    // SP
Enemy[0][10] = 0;  // EnemyGold
Enemy[0][11] = 0;  // MP
Enemy[0][12] = 0;  // TMP
Enemy[0][13] = 0;
Enemy[0][14] = 0;
Enemy[0][15] = 0;
Enemy[0][16] = 0;

// Statistics

ShopDat[0] = 0;    // Offset of first line in list
ShopDat[1] = 1;
ShopDat[2] = 2;
ShopDat[3] = 3;
ShopDat[4] = 4;
int CurrShop = 0;
ShopDat[5] = 0;    // Current list selection
ShopDat[6] = 0;    // Current shop mode (Purchase / Sell)
ShopDat[7] = 0;    // Quanity selected by the user

// Fonts
//fntNorm = New Font("Arial", 10);  // Font used for normal text, such as StatusText
//fntEmph = New Font("Arial", 10);    // Font used for special text, such as charecter names in battle engine
// fntEmph.BOLD();
//fntSmal = New Font("Arial", 10);  // Font used for small messages or text, such as the HP and EP displays in the battle engine
// fntSmal.ITALIC();
//fntSys = New Font("fixedsys", 9);  // Font used for system messages, such as errors.  Not used often because most System messages have been altered to display via message boxes.

// Text Objects
String strStatusText = "Loading...";
StatusText[0] = 0;
StatusText[1] = 0;
// Name of the current charecter
Battle[0][0] = 39;
Battle[0][1] = 145;
// Name of the current enemy
//int Battle[3] = New StaticText("BattleEnemy", myWindow, 163, 145, 116, 14);  // Enemy's name displayed in battle engine
Battle[3][0] = 163;
Battle[3][1] = 145;
// Charecter's HP
//int Battle[1] = New StaticText("BattleCharHP", myWindow, 54, 162, 40, 14);  // Charecter's HP displayed in battle engine
Battle[1][0] = 54;
Battle[1][1] = 162;
// Enemy's HP
//int Battle[4] = New StaticText("BattleEnemyHP", myWindow, 178, 162, 40, 14);
Battle[4][0] = 178;
Battle[4][1] = 162;
// Charecter's EP
//int Battle[2] = New StaticText("BattleCharEP", myWindow, 115, 162, 41, 14);
Battle[2][0] = 115;
Battle[2][1] = 162;
// Enemy's EP
//int Battle[5] = New StaticText("BattleEnemyEP", myWindow, 238, 162, 41, 14);
Battle[5][0] = 238;
Battle[5][1] = 162;

// First line in available moves
//int BMenuTxt[0] = New StaticText("Attack (0)", myWindow, 4, 72, 152, 14);
BMenuTxt[0][0] = 4;
BMenuTxt[0][1] = 72;
BMenu[1][0] = 0;    // Offset
// Second line in available moves
//int BMenuTxt[1] = New StaticText("Attack (0)", myWindow, 4, 86, 152, 14);
BMenuTxt[1][0] = 4;
BMenuTxt[1][1] = 86;
BMenu[1][1] = 1;
// Third line in available moves
//int BMenuTxt[2] = New StaticText("Attack (0)", myWindow, 4, 100, 152, 14);
BMenuTxt[2][0] = 4;
BMenuTxt[2][1] = 100;
BMenu[1][2] = 2;
// Fourth line in available moves
//int BMenuTxt[3] = New StaticText("Attack (0)", myWindow, 4, 114, 152, 14);
BMenuTxt[3][0] = 4;
BMenuTxt[3][1] = 114;
BMenu[1][3] = 3;
//int BMenuTxt[0].Hide();
//int BMenuTxt[1].Hide();
//int BMenuTxt[2].Hide();
//int BMenuTxt[3].Hide();

// Current charecter
//int BMenuTxt[4] = New StaticText("Shunketsu", myWindow, 40, 4, 117, 14);    // Charecter's name displayed in battle engine
BMenuTxt[4][0] = 45;
BMenuTxt[4][1] = 4;
// Subject selected
//int BMenuTxt[8] = New StaticText("Enemy", myWindow, 161, 4, 117, 14);  // Enemy's name displayed in battle engine
BMenuTxt[8][0] = 161;
BMenuTxt[8][1] = 4;
// Current Charecter's HP
//int BMenuTxt[5] = New StaticText("HP", myWindow, 40, 22, 36, 14);  // Charecter's HP displayed in battle engine
BMenuTxt[5][0] = 40;
BMenuTxt[5][1] = 22;
// HP of Subject
//int BMenuTxt[9] = New StaticText("HP", myWindow, 162, 22, 36, 14);
BMenuTxt[9][0] = 162;
BMenuTxt[9][1] = 22;
// CurrChar's EP
//int BMenuTxt[6] = New StaticText("EP", myWindow, 80, 22, 36, 14);
BMenuTxt[6][0] = 80;
BMenuTxt[6][1] = 22;
// EP of Subject
//int BMenuTxt[10] = New StaticText("EP", myWindow, 202, 22, 36, 14);
BMenuTxt[10][0] = 202;
BMenuTxt[10][1] = 22;
// CurrChar's MP
//int BMenuTxt[7] = New StaticText("MP", myWindow, 120, 22, 36, 14);
BMenuTxt[7][0] = 120;
BMenuTxt[7][1] = 22;
//int BMenuTxt[11] = New StaticText("MP", myWindow, 242, 22, 36, 14);
BMenuTxt[11][0] = 242;
BMenuTxt[11][1] = 22;
//int BMenuTxt[12] = New StaticText("Desc", myWindow, 5, 153, 151, 41);
BMenuTxt[12][0] = 5;
BMenuTxt[12][1] = 153;

//
// NOTE
/////////
//
// The following string position variables are commented out so that Java may compile without errors.  (hopefully)  Should finish these on final day.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Name of the shop
//int Shop[0] = New StaticText("Shop Name", myWindow, 38, 3, 159, 14);
//int Shop[0].SetColor(GetRGB(255, 255, 255));
//int Shop[0].SetBackColor(GetRGB(63,31,0));
//int Shop[0].Hide();
// The shopkeeper's greeting, perhaps announcing a discounted item
//int Shop[1] = New StaticText("Shop Name", myWindow, 200, 3, 115, 32);
//int Shop[1].SetColor(GetRGB(255, 255, 255));
//int Shop[1].SetBackColor(GetRGB(63,31,0));
//int Shop[1].Hide();
// Name of the item which the user has selected
//int Shop[2] = New StaticText("Shop Name", myWindow, 38, 42, 118, 14);
//int Shop[2].SetColor(GetRGB(255, 255, 255));
//int Shop[2].SetBackColor(GetRGB(63,31,0));
//int Shop[2].Hide();
// Value of the item selected
//int Shop[3] = New StaticText("Shop Name", myWindow, 63, 60, 93, 14);
//int Shop[3].SetColor(GetRGB(255, 255, 255));
//int Shop[3].SetBackColor(GetRGB(63,31,0));
//int Shop[3].Hide();
// Ammount of that item owned
//int Shop[4] = New StaticText("Shop Name", myWindow, 77, 78, 79, 14);
//int Shop[4].SetColor(GetRGB(255, 255, 255));
//int Shop[4].SetBackColor(GetRGB(63,31,0));
//int Shop[4].Hide();
// Description of item selected
//int Shop[5] = New StaticText("Shop Name", myWindow, 3, 95, 153, 14);
//int Shop[5].SetColor(GetRGB(255, 255, 255));
//int Shop[5].SetBackColor(GetRGB(63,31,0));
//int Shop[5].Hide();
// Ammount of item to purchase
//int Shop[6] = New StaticText("Shop Name", myWindow, 78, 159, 44, 14);
//int Shop[6].SetColor(GetRGB(255, 255, 255));
//int Shop[6].SetBackColor(GetRGB(63,31,0));
//int Shop[6].Hide();
// Ammount of Gold possesed by the party
//int Shop[7] = New StaticText("Shop Name", myWindow, 222, 144, 93, 14);
//int Shop[7].SetColor(GetRGB(255, 255, 255));
//int Shop[7].SetBackColor(GetRGB(63,31,0));
//int Shop[7].Hide();
// Gold being transferred in transaction
//int Shop[8] = New StaticText("Shop Name", myWindow, 222, 161, 93, 14);
//int Shop[8].SetColor(GetRGB(255, 255, 255));
//int Shop[8].SetBackColor(GetRGB(63,31,0));
//int Shop[8].Hide();
// Gold party will posses after transaction is made
//int Shop[9] = New StaticText("Shop Name", myWindow, 223, 181, 92, 14);
//int Shop[9].SetColor(GetRGB(255, 255, 255));
//int Shop[9].SetBackColor(GetRGB(63,31,0));
//int Shop[9].Hide();
// First line in items list
//int Shop[10] = New StaticText("ln 1", myWindow, 162, 54, 153, 14);
//int Shop[10].SetColor(GetRGB(255, 255, 255));
//int Shop[10].SetBackColor(GetRGB(63,31,0));
//int Shop[10].OnClick = textClick;
//int Shop[10].Hide();
// Second line in items list
//int Shop[11] = New StaticText("ln 2", myWindow, 162, 68, 153, 14);
//int Shop[11].SetColor(GetRGB(255, 255, 255));
//int Shop[11].SetBackColor(GetRGB(63,31,0));
//int Shop[11].OnClick = textClick;
//int Shop[11].Hide();
// Third line in items list
//int Shop[12] = New StaticText("ln 3", myWindow, 162, 82, 153, 14);
//int Shop[12].SetColor(GetRGB(255, 255, 255));
//int Shop[12].SetBackColor(GetRGB(63,31,0));
//int Shop[12].OnClick = textClick;
//int Shop[12].Hide();
// Fourth line in items list
//int Shop[13] = New StaticText("ln 4", myWindow, 162, 96, 153, 14);
//int Shop[13].SetColor(GetRGB(255, 255, 255));
//int Shop[13].SetBackColor(GetRGB(63,31,0));
//int Shop[13].OnClick = textClick;
//int Shop[13].Hide();
// Fifth line in items list
//int Shop[14] = New StaticText("ln 5", myWindow, 162, 110, 153, 14);
//int Shop[14].SetColor(GetRGB(255, 255, 255));
//int Shop[14].SetBackColor(GetRGB(63,31,0));
//int Shop[14].OnClick = textClick;
//int Shop[14].Hide();

//int pauseTxt[0] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[0].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[0].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[0].Hide();
//int pauseTxt[1] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[1].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[1].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[1].Hide();
//int pauseTxt[2] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[2].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[2].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[2].Hide();
//int pauseTxt[3] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[3].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[3].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[3].Hide();
//int pauseTxt[4] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[4].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[4].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[4].Hide();
//int pauseTxt[5] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[5].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[5].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[5].Hide();
//int pauseTxt[6] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[6].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[6].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[6].Hide();
//int pauseTxt[7] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[7].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[7].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[7].Hide();
//int pauseTxt[8] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[8].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[8].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[8].Hide();
//int pauseTxt[9] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[9].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[9].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[9].Hide();
//int pauseTxt[10] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[10].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[10].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[10].Hide();
//int pauseTxt[11] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[11].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[11].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[11].Hide();
//int pauseTxt[12] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[12].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[12].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[12].Hide();
//int pauseTxt[13] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[13].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[13].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[13].Hide();
//int pauseTxt[14] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[14].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[14].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[14].Hide();
//int pauseTxt[15] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[15].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[15].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[15].Hide();
//int pauseTxt[16] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[16].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[16].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[16].Hide();
//int pauseTxt[17] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[17].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[17].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[17].Hide();
//int pauseTxt[18] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[18].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[18].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[18].Hide();
//int pauseTxt[19] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[19].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[19].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[19].Hide();
//int pauseTxt[20] = New StaticText("ln", myWindow, 162, 110, 153, 14);
//int pauseTxt[20].SetColor(GetRGB(255, 255, 255));
//int pauseTxt[20].SetBackColor(GetRGB(63,31,0));
//int pauseTxt[20].Hide();
//pauseTxt[0].OnClick = textClick;
//pauseTxt[1].OnClick = textClick;
//pauseTxt[2].OnClick = textClick;
//pauseTxt[3].OnClick = textClick;
//pauseTxt[4].OnClick = textClick;
//pauseTxt[5].OnClick = textClick;
//for (int ln = 0; ln < 6; ln++)
//{
//  pauseTxt[ln].OnClick = textClick;
//}

//int ExpGain[0,1] = New StaticText("Charecter 1 Name", myWindow, 38, 3, 120, 14);
//int ExpGain[0,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,1].Hide();
//int ExpGain[0,2] = New StaticText("Ex until next level", myWindow, 50, 21, 45, 14);
//int ExpGain[0,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,2].Hide();
//int ExpGain[0,3] = New StaticText("Mx until next level", myWindow, 113, 21, 45, 14);
//int ExpGain[0,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,3].Hide();
//int ExpGain[0,4] = New StaticText("LvlUp ln 1", myWindow, 161, 5, 154, 14);
//int ExpGain[0,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,4].Hide();
//int ExpGain[0,5] = New StaticText("LvlUp ln 2", myWindow, 161, 19, 154, 14);
//int ExpGain[0,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[0,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[0,5].Hide();
//int ExpGain[1,1] = New StaticText("Charecter 2 Name", myWindow, 38, 42, 120, 14);
//int ExpGain[1,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,1].Hide();
//int ExpGain[1,2] = New StaticText("Ex until next level", myWindow, 50, 60, 45, 14);
//int ExpGain[1,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,2].Hide();
//int ExpGain[1,3] = New StaticText("Mx until next level", myWindow, 113, 60, 45, 14);
//int ExpGain[1,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,3].Hide();
//int ExpGain[1,4] = New StaticText("LvlUp ln 1", myWindow, 161, 44, 154, 14);
//int ExpGain[1,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,4].Hide();
//int ExpGain[1,5] = New StaticText("LvlUp ln 2", myWindow, 161, 58, 154, 14);
//int ExpGain[1,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[1,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[1,5].Hide();
//int ExpGain[2,1] = New StaticText("Charecter 3", myWindow, 38, 81, 120, 14);
//int ExpGain[2,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,1].Hide();
//int ExpGain[2,2] = New StaticText("Ex until next level", myWindow, 50, 99, 45, 14);
//int ExpGain[2,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,2].Hide();
//int ExpGain[2,3] = New StaticText("Mx until next level", myWindow, 113, 99, 45, 14);
//int ExpGain[2,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,3].Hide();
//int ExpGain[2,4] = New StaticText("LvlUp ln 1", myWindow, 161, 83, 154, 14);
//int ExpGain[2,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,4].Hide();
//int ExpGain[2,5] = New StaticText("LvlUp ln 2", myWindow, 161, 97, 154, 14);
//int ExpGain[2,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[2,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[2,5].Hide();
//int ExpGain[3,1] = New StaticText("Charecter 4", myWindow, 38, 120, 120, 14);
//int ExpGain[3,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,1].Hide();
//int ExpGain[3,2] = New StaticText("Ex until next level", myWindow, 50, 138, 45, 14);
//int ExpGain[3,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,2].Hide();
//int ExpGain[3,3] = New StaticText("Mx until next level", myWindow, 113, 138, 45, 14);
//int ExpGain[3,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,3].Hide();
//int ExpGain[3,4] = New StaticText("LvlUp ln 1", myWindow, 161, 122, 154, 14);
//int ExpGain[3,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,4].Hide();
//int ExpGain[3,5] = New StaticText("LvlUp ln 2", myWindow, 161, 136, 154, 14);
//int ExpGain[3,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[3,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[3,5].Hide();
//int ExpGain[4,1] = New StaticText("Charecter 5", myWindow, 38, 159, 120, 14);
//int ExpGain[4,1].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,1].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,1].Hide();
//int ExpGain[4,2] = New StaticText("Ex until next level", myWindow, 50, 177, 45, 14);
//int ExpGain[4,2].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,2].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,2].Hide();
//int ExpGain[4,3] = New StaticText("Mx until next level", myWindow, 113, 177, 45, 14);
//int ExpGain[4,3].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,3].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,3].Hide();
//int ExpGain[4,4] = New StaticText("LvlUp ln 1", myWindow, 161, 161, 154, 14);
//int ExpGain[4,4].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,4].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,4].Hide();
//int ExpGain[4,5] = New StaticText("LvlUp ln 2", myWindow, 161, 175, 154, 14);
//int ExpGain[4,5].SetColor(GetRGB(255, 255, 255));
//int ExpGain[4,5].SetBackColor(GetRGB(63,31,0));
//int ExpGain[4,5].Hide();

}

  public void paint(Graphics g) {
  
// Mode 1 is the mode for cut-scenes.
    if (Mode == 1) {
//    fakeIniFile = "D:\Program Files\Jamagic\Projects\Learning0002\cutscenEvent.dba";
    String fakeIniFile = "cutscenEvent.dba" + "--";
    String CsChar = getParameter(fakeIniFile + Progress + "--" + Timers);
    if (getParameter(fakeIniFile + Progress + "--" + Timers) != "null") {
    if (CsChar == "charb-1") {
      imgCsChar = getImage(getCodeBase(), "charb-1.gif");
    }
    if (CsChar == "charb-2") {
      imgCsChar = getImage(getCodeBase(), "charb-2.gif");
    }
    if (CsChar == "charb-3") {
      imgCsChar = getImage(getCodeBase(), "charb-3.gif");
    }
    if (CsChar == "charb-4") {
      imgCsChar = getImage(getCodeBase(), "charb-4.gif");
    }
    if (CsChar == "charb-5") {
      imgCsChar = getImage(getCodeBase(), "charb-5.gif");
    }
    if (CsChar == "charb-6") {
      imgCsChar = getImage(getCodeBase(), "charb-6.gif");
    }
      g.drawImage(imgCsChar, 3, 147, this);
    }
//    fakeIniFile = "D:\Program Files\Jamagic\Projects\Learning0002\cutscenEvent.dbe");
    fakeIniFile = "cutscenEvent.dbe--";
//    g.SetFont( , , 10);
//    g.SetColor(getColor(Color.white));
    g.drawString(getParameter(fakeIniFile + Progress + "--" + Timers), 55, 147);
//    StatusText.SetColor(GetRGB(255, 255, 255));
//    StatusText.SetSize(260, 48);
      if (Progress == 1) {
        if (Timers == 14) {
          Gold = 500;
        }
        if (Timers == 15) {
          Progress = 4;
          Mode = 4;
          Timers = 0;
        }
      }
      if (Progress == 4) {
        Timers = 0;
        Mode = 4;
      }
      if (Progress == 5) {
        if (Timers == 8) {
          Progress = 6;
          Mode = 4;
          Timers = 0;
        }
      }
      if (Progress == 6) {
        Timers = 0;
        Mode = 4;
      }
      if (Progress == 7) {
        if (Timers == 6) {
          Progress = 9;
          Mode = 4;
          Timers = 0;
        }
      }
      if (Progress == 9) {
        Timers = 0;
        Mode = 4;
      }
      if (Progress == 8) {
        if (Timers == 11) {
          Progress = 42;
        }
      }
      if (Progress == 42) {
        Timers = 0;
        Progress = 43;
      }
      if (Progress == 11) {
        if (Timers == 11) {
          Progress = 42;
        }
      }
      if (Progress == 43) {
        if (Timers == 6) {
//      End;
        }
      }
    }
  
  // Pause Menu
  if (Mode == 12)  {
    for (int ln = 0; ln < 6; ln++) {
      if (ln == pauseInt[8]) {
//        pauseTxt[ln].SetBackColor(GetRGB(128,64,0));
    } else {
//      pauseTxt[ln].SetBackColor(GetRGB(63,31,0));
    }
    }
    switch (Timers) {
      // Main Screen
      case 0:
      imgBg = getImage(getCodeBase(), "sPauseMenu.gif");
    g.drawImage(imgBg, 0, 0, this);
    break;
      // Map
      case 1:
//      imgBg.Set(0, 0, "----");
    break;
      // Charecters Menu
      case 2:
//    fakeIniFile = "D:\Program Files\Jamagic\Projects\Learning0002\names.sor");
    fakeIniFile = "names.sor--";
      imgBg = getImage(getCodeBase(), "sCharMenu.gif");
    g.drawImage(imgBg, 0, 0, this);
//    pauseTxt[0]
    tempVar = pauseInt[0] + 1;
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + tempVar), 163, 18);
//    pauseTxt[0].SetPosition(163, 18);
//    pauseTxt[0].SetSize(152, 14);
//    pauseTxt[1]
    tempVar = pauseInt[1] + 1;
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + tempVar), 163, 32);
//    pauseTxt[1].SetPosition(163, 32);
//    pauseTxt[1].SetSize(152, 14);
//    pauseTxt[2]
    tempVar = pauseInt[2] + 1;
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + tempVar), 163, 46);
//    pauseTxt[2].SetPosition(163, 46);
//    pauseTxt[2].SetSize(152, 14);
//    pauseTxt[3]
    tempVar = pauseInt[3] + 1;
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + tempVar), 163, 60);
//    pauseTxt[3].SetPosition(163, 60);
//    pauseTxt[3].SetSize(152, 14);
//    pauseTxt[4]
    tempVar = pauseInt[4] + 1;
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + tempVar), 163, 74);
//    pauseTxt[4].SetPosition(163, 74);
//    pauseTxt[4].SetSize(152, 14);
//    pauseTxt[6]
// Unknown line commented out:
//    tempVar = pauseTxt[pauseInt[8]];
    g.drawString("" + tempVar, 3, 3);
//    pauseTxt[6].SetPosition(3, 3);
//    pauseTxt[6].SetSize(155, 14);
//    pauseTxt[7]
//    g.drawString("");
//    pauseTxt[7].SetPosition(55, 21);
//    pauseTxt[7].SetSize(103, 14);
//    pauseTxt[8]
//    g.drawString("");
//    pauseTxt[8].SetPosition(55, 38);
//    pauseTxt[8].SetSize(103, 14);
//    pauseTxt[9]
//    g.drawString("");
//    pauseTxt[9].SetPosition(55, 55);
//    pauseTxt[9].SetSize(103, 14);
//    pauseTxt[10]
    tempVar = pauseInt[pauseInt[8]] + 1;
    g.drawString(getParameter(fakeIniFile + "charDesc" + "--" + tempVar), 3, 73);
//    pauseTxt[10].SetPosition(3, 73);
//    pauseTxt[10].SetSize(155, 112);
//    pauseTxt[5].Hide();
    break;
      // Charecters Screen
      case 3:
      imgBg = getImage(getCodeBase(), "sCharScreen.gif");
    g.drawImage(imgBg, 0, 0, this);
    fakeIniFile = "names.sor--";
    String pauseTemp = "weapon";
    if (pauseInt[7] == 0) {
      pauseTemp = "weapon";
    }
    if (pauseInt[7] == 1) {
      pauseTemp = "armor";
    }
    if (pauseInt[7] == 2) {
      pauseTemp = "shield";
    }
    if (pauseInt[7] == 3) {
      pauseTemp = "smove";
    }
    if (pauseInt[7] == 4) {
      pauseTemp = "magic";
    }
    if (pauseInt[7] != 0 && pauseInt[7] != 1 && pauseInt[7] != 2 && pauseInt[7] != 3 && pauseInt[7] != 4) {
      pauseTemp = "weapon";
      pauseInt[7] = 0;
    }
//    pauseTxt[0]
    tempVar = pauseInt[0] + 1;
    g.drawString(getParameter(fakeIniFile + pauseTemp + pauseInt[6] + "--" + tempVar), 164, 92);
//    pauseTxt[0].SetPosition(164, 92);
//    pauseTxt[0].SetSize(151, 14);
//    pauseTxt[1]
    tempVar = pauseInt[1] + 1;
    g.drawString(getParameter(fakeIniFile + pauseTemp + pauseInt[6] + "--" + tempVar), 164, 106);
//    pauseTxt[1].SetPosition(164, 106);
//    pauseTxt[1].SetSize(151, 14);
//    pauseTxt[2]
    tempVar = pauseInt[2] + 1;
    g.drawString(getParameter(fakeIniFile + pauseTemp + pauseInt[6] + "--" + tempVar), 164, 120);
//    pauseTxt[2].SetPosition(164, 120);
//    pauseTxt[2].SetSize(151, 14);
//    pauseTxt[3]
    tempVar = pauseInt[3] + 1;
    g.drawString(getParameter(fakeIniFile + pauseTemp + pauseInt[6] + "--" + tempVar), 164, 134);
//    pauseTxt[3].SetPosition(164, 134);
//    pauseTxt[3].SetSize(151, 14);
//    pauseTxt[4]
    tempVar = pauseInt[4] + 1;
    g.drawString(getParameter(fakeIniFile + pauseTemp + pauseInt[6] + "--" + tempVar), 164, 148);
//    pauseTxt[4].SetPosition(164, 148);
//    pauseTxt[4].SetSize(151, 14);
//    pauseTxt[6]
    tempVar = pauseInt[8] + 1;
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + tempVar), 55, 3);
//    pauseTxt[6].SetPosition(55, 3);
//    pauseTxt[6].SetSize(260, 14);
//    pauseTxt[7]
    tempVar = CharInfo[pauseInt[6] + 1][4][1];
    g.drawString("" + tempVar, 71, 20);
//    pauseTxt[7].SetPosition(71, 20);
//    pauseTxt[7].SetSize(46, 14);
//    pauseTxt[8]
    tempVar = CharInfo[pauseInt[6] + 1][4][4];
    int tempVarA = CharInfo[pauseInt[6] + 1][4][3];
    g.drawString("" + tempVar + "/" + tempVarA, 72, 37);
//    pauseTxt[8].SetPosition(72, 37);
//    pauseTxt[8].SetSize(45, 14);
//    pauseTxt[9]
    tempVar = CharInfo[pauseInt[6] + 1][4][7];
    tempVarA = CharInfo[pauseInt[6] + 1][4][5];
    g.drawString("" + tempVar + "/" + tempVarA, 136, 20);
//    pauseTxt[9].SetPosition(136, 20);
//    pauseTxt[9].SetSize(47, 14);
//    pauseTxt[10]
    g.drawString("", 121, 37);
//    pauseTxt[10].SetPosition(121, 37);
//    pauseTxt[10].SetSize(62, 14);
//    pauseTxt[11]
    tempVar = CharInfo[pauseInt[6] + 1][4][10];
    g.drawString("" + tempVar, 204, 20);
//    pauseTxt[11].SetPosition(204, 20);
//    pauseTxt[11].SetSize(45, 14);
//    pauseTxt[12]
    tempVar = CharInfo[pauseInt[6] + 1][4][9];
    g.drawString("" + tempVar, 203, 37);
//    pauseTxt[12].SetPosition(203, 37);
//    pauseTxt[12].SetSize(46, 14);
//    pauseTxt[13]
    tempVar = CharInfo[pauseInt[6] + 1][4][12];
    g.drawString("" + tempVar, 269, 20);
//    pauseTxt[13].SetPosition(269, 20);
//    pauseTxt[13].SetSize(46, 14);
//    pauseTxt[14]
    tempVar = CharInfo[pauseInt[6] + 1][4][11];
    g.drawString("" + tempVar, 272, 37);
//    pauseTxt[14].SetPosition(272, 37);
//    pauseTxt[14].SetSize(43, 14);
//    pauseTxt[15].SetPosition(3, 78);
//    pauseTxt[15].SetSize(156, 14);
    if (pauseInt[7] == 0) {
//      pauseTxt[15]
      tempVar = pauseInt[6] + 1;
      tempVarA = pauseInt[pauseInt[8]] + 1;
      g.drawString(getParameter(fakeIniFile + "weapon" + tempVar + "--" + tempVarA), 3, 78);
//      pauseTxt[16]
//      g.drawString(WeaponInfo[pauseInt[6] + 1][pauseInt[pauseInt[8]] + 1][2]tempVar);
//      pauseTxt[0].SetPosition(20, 95);
//      pauseTxt[0].SetSize(59, 14);
//      pauseTxt[0]
      tempVar = pauseInt[0] + 1;
      tempVarA = pauseInt[6];
      g.drawString(getParameter(fakeIniFile + pauseTemp + tempVarA + "--" + tempVar), 20, 95);
//      pauseTxt[0].SetPosition(164, 92);
//      pauseTxt[0].SetSize(151, 14);
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0].SetPosition(164, 92);
//      pauseTxt[0].SetSize(151, 14);
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0].SetPosition(164, 92);
//      pauseTxt[0].SetSize(151, 14);
    }
    if (pauseInt[7] == 1) {
//      pauseTxt[15]g.drawString(parseParam(0, fakeIniFile + "armor" + pauseInt[6] + 1), pauseInt[pauseInt[8]] + 1)));
//      pauseTxt[16]g.drawString(ArmorInfo[pauseInt[6] + 1,pauseInt[pauseInt[8]] + 1,2]));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
    }
    if (pauseInt[7] == 2) {
//      pauseTxt[15]g.drawString(parseParam(0, fakeIniFile + "shield" + pauseInt[6] + 1), pauseInt[pauseInt[8]] + 1)));
//      pauseTxt[16]g.drawString(ShieldInfo[pauseInt[6] + 1,pauseInt[pauseInt[8]] + 1,2]));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
    }
    if (pauseInt[7] == 3) {
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
    }
    if (pauseInt[7] == 4) {
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//      pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
    }
//    pauseTxt[0]g.drawString(parseParam(0, fakeIniFile + pauseTemp + pauseInt[6]), pauseInt[0] + 1)));
//    pauseTxt[0].SetPosition(164, 92);
//    pauseTxt[0].SetSize(151, 14);
//    pauseTxt[5].Hide();
    break;
      // Items Menu
      case 4:
//      imgBg.Set(0, 0, "----");
    break;
      // Items Screen
      case 5:
//      imgBg.Set(0, 0, "----");
    break;
      // Journal
      case 6:
//      imgBg.Set(0, 0, "----");
    break;
      // Discoveries
      case 7:
//      imgBg.Set(0, 0, "----");
    break;
      // Mini-Games
      case 8:
//      imgBg.Set(0, 0, "----");
    break;
      // Options
      case 9:
//      imgBg.Set(0, 0, "----");
    break;
      // Save
      case 10:
//      imgBg.Set(0, 0, "----");
    break;
      // Load
      case 11:
//      imgBg.Set(0, 0, "----");
    break;
    }
  }

// Map Exploration
    if (Mode == 4) {
    if (Location == 6 && MapX == 40 && MapY == 11) {
      Location = 9;
    MapX = 18;
    MapY = 0;
    }
    if (Location == 9 && MapX == 18 && MapY == 0 - 1) {
      Location = 6;
    MapX = 39;
    MapY = 11;
    }
    switch (Location) {
      case 6:
    imgBg = getImage(getCodeBase(), "mL-6.gif");
    break;
    case 7:
    imgBg = getImage(getCodeBase(), "mL-7.gif");
    break;
    case 9:
    imgBg = getImage(getCodeBase(), "mL-9.gif");
    break;
    }
    imgMapChar = getImage(getCodeBase(), "mP-1.gif");
    g.drawImage(imgMapChar, 152, 92, this);
    g.drawImage(imgBg, 152 - (MapX * 16), 92 - (MapY * 16), this);
    if (Location == 6 && MapX == 26 && MapY == 20 && Progress == 4) {
      Timers = 0;
    Progress = 5;
    Mode = 1;
    repaint();
    }
    }
// Battle Menu
    if (Mode == 2) {
    CharInfo[2][0][1] = 0;
    CharInfo[3][0][1] = 0;
    CharInfo[4][0][1] = 0;
    CharInfo[5][0][1] = 0;
    if (CharInfo[CurrChar][4][6] > CharInfo[CurrChar][4][5]) {
      CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][5];
    }
    imgBg = getImage(getCodeBase(), "sBmenu.gif");
    g.drawImage(imgBg, 0, 0, this);
//    fakeIniFile = "D:\Program Files\Jamagic\Projects\Learning0002\charMovEvent.sor");
    fakeIniFile = "charMovEvent.sor--";
    // Catch any invalid variables before they are used
    if (BMenu[0][0] < 1) {
      BMenu[0][0] = 4;
    }
    if (BMenu[0][0] > 4) {
      BMenu[0][0] = 1;
    }
    if (BMenu[0][1] < 1) {
      BMenu[1][3] = BMenu[1][2];
    BMenu[1][2] = BMenu[1][1];
    BMenu[1][1] = BMenu[1][0];
    BMenu[1][0] = BMenu[1][0] - 1;
    BMenu[0][1] = 1;
    }
    if (BMenu[0][1] > 4 || BMenu[1][0] < 0) {
      BMenu[1][0] = BMenu[1][1];
    BMenu[1][1] = BMenu[1][2];
    BMenu[1][2] = BMenu[1][3];
    BMenu[1][3] = BMenu[1][3] + 1;
    BMenu[0][1] = 4;
    }
    if (BMenu[0][0] == 1) {
      tempVar = BMenu[1][BMenu[0][1] - 1];
      if (CharInfo[CurrChar][3][BMenu[1][BMenu[0][1] - 1]] > 0 || parseParam(0, fakeIniFile + "attack" + CurrChar + "--" + "EP" + tempVar) > CharInfo[CurrChar][4][6]) {
        BMenu[0][1] = 1;
      }
    }
    if (CharInfo[CurrChar][4][2] > CharInfo[CurrChar][4][1]) {
      CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][1];
    }
    // Load the strings into the list
    for (int ln = 0; ln < 4 && BMenu[0][0] == 1; ln++) {
//      BMenuTxt[ln]
    tempVar = BMenu[1][ln];
    g.drawString(getParameter(fakeIniFile + "attack" + CurrChar + "--" + "BMenu" + tempVar), BMenuTxt[ln][0], BMenuTxt[ln][1]);
//    BMenuTxt[12]
    tempVar = BMenu[1][BMenu[0][1] - 1];
    g.drawString(getParameter(fakeIniFile + "attack" + CurrChar + "--" + "Desc" + tempVar), BMenuTxt[12][0], BMenuTxt[12][1]);
    }
    for (int ln = 0; ln < 4 && BMenu[0][0] == 2; ln++) {
//      BMenuTxt[ln]
    tempVar = BMenu[1][ln];
    g.drawString(getParameter(fakeIniFile + "magic" + CurrChar + "--" + "BMenu" + tempVar), BMenuTxt[ln][0], BMenuTxt[ln][1]);
//    BMenuTxt[12]
    tempVar = BMenu[1][BMenu[0][1] - 1];
    g.drawString(getParameter(fakeIniFile + "magic" + CurrChar + "--" + "Desc" + tempVar), BMenuTxt[12][0], BMenuTxt[12][1]);
    }
    for (int ln = 0; ln < 4 && BMenu[0][0] == 3; ln++) {
//      BMenuTxt[ln]
    tempVar = BMenu[1][ln];
    tempVarA = Item[BMenu[1][ln]];
    g.drawString(getParameter(fakeIniFile + "item" + "--" + "BMenu" + tempVar) + " (" + tempVarA + ")", BMenuTxt[ln][0], BMenuTxt[ln][1]);
//    BMenuTxt[12]
    tempVar = BMenu[1][BMenu[0][1] - 1];
    g.drawString(getParameter(fakeIniFile + "item" + "--" + "Desc" + tempVar), BMenuTxt[12][0], BMenuTxt[12][1]);
    }
    for (int ln = 0; ln < 4 && BMenu[0][0] == 4; ln++) {
//      BMenuTxt[ln]
    tempVar = BMenu[1][ln];
    g.drawString(getParameter(fakeIniFile + "strat" + CurrChar + "--" + "BMenu" + tempVar), BMenuTxt[ln][0], BMenuTxt[ln][1]);
//    BMenuTxt[12]
    tempVar = BMenu[1][BMenu[0][1] - 1];
    g.drawString(getParameter(fakeIniFile + "strat" + CurrChar + "--" + "Desc" + tempVar), BMenuTxt[12][0], BMenuTxt[12][1]);
    }
    // Highlight the selected list item
    for (int ln = 0; ln < 4; ln++) {
      if (BMenu[0][1] == ln + 1) {
//      BMenuTxt[ln].SetBackColor(GetRGB(128,64,0));
    } else {
//      BMenuTxt[ln].SetBackColor(GetRGB(63,31,0));
    }
    }
    // Darken unavailable items
    for (int ln = 0; ln < 4; ln++) {
      if (BMenu[0][0] == 1) {
        tempVar = BMenu[1][ln];
        if (CharInfo[CurrChar][3][BMenu[1][ln]] > 0 || parseParam(0, fakeIniFile + "attack" + CurrChar + "--" + "EP" + tempVar) > CharInfo[CurrChar][4][6]) {
//          BMenuTxt[ln].SetColor(GetRGB(159,79,15));
      }
      } else {
//      BMenuTxt[ln].SetColor(GetRGB(255,255,255));
    }
    }
//    BMenuTxt[0].Show();
//    BMenuTxt[1].Show();
//    BMenuTxt[2].Show();
//    BMenuTxt[3].Show();
//    BMenuTxt[12].Show();
    switch (Enemy[0][0]) {
      case 2:
    imgBattleC = getImage(getCodeBase(), "sEnemy1.gif");
      g.drawImage(imgBattleC, 283, 145, this);
//    BMenuTxt[8]
    g.drawString("Tribal Villager", BMenuTxt[8][0], BMenuTxt[8][1]);
    break;
    case 4:
    imgBattleC = getImage(getCodeBase(), "sEnemy1.gif");
      g.drawImage(imgBattleC, 283, 145, this);
//    BMenuTxt[8]
    g.drawString("Cave Bat", BMenuTxt[8][0], BMenuTxt[8][1]);
    break;
    case 28:
    imgBattleC = getImage(getCodeBase(), "sEnemy1.gif");
      g.drawImage(imgBattleC, 283, 145, this);
//    BMenuTxt[8]
    g.drawString("forest Owl", BMenuTxt[8][0], BMenuTxt[8][1]);
    break;
    case 29:
    imgBattleC = getImage(getCodeBase(), "sEnemy1.gif");
      g.drawImage(imgBattleC, 283, 145, this);
//    BMenuTxt[8]
    g.drawString("Anabanese Moose", BMenuTxt[8][0], BMenuTxt[8][1]);
    break;
    case 30:
    imgBattleC = getImage(getCodeBase(), "sEnemy1.gif");
      g.drawImage(imgBattleC, 283, 145, this);
//    BMenuTxt[8]
    g.drawString("Wild Dog", BMenuTxt[8][0], BMenuTxt[8][1]);
    break;
    }
//    fakeIniFile = "D:\Program Files\Jamagic\Projects\Learning0002\names.sor");
    fakeIniFile = "names.sor--";
//    BMenuTxt[4]
    g.drawString(getParameter(fakeIniFile + "chars" + "--" + CurrChar), BMenuTxt[4][0], BMenuTxt[4][1]);
//    BMenuTxt[8]
    tempVar = Enemy[0][0];
    g.drawString(getParameter(fakeIniFile + "enemies" + "--" + tempVar), BMenuTxt[8][0], BMenuTxt[8][1]);
//    BMenuTxt[5]
    g.drawString("" + CharInfo[CurrChar][4][2], BMenuTxt[5][0], BMenuTxt[5][1]);
//    BMenuTxt[9]
    g.drawString("" + Enemy[0][1], BMenuTxt[9][0], BMenuTxt[9][1]);
//    BMenuTxt[6]
    g.drawString("" + CharInfo[CurrChar][4][6], BMenuTxt[6][0], BMenuTxt[6][1]);
//    BMenuTxt[10]
    g.drawString("" + Enemy[0][6], BMenuTxt[10][0], BMenuTxt[10][1]);
//    BMenuTxt[7]
    g.drawString("" + CharInfo[CurrChar][4][4], BMenuTxt[7][0], BMenuTxt[7][1]);
//    BMenuTxt[11]
    g.drawString("" + Enemy[0][11], BMenuTxt[11][0], BMenuTxt[11][1]);
    }
// Battle Run
    if (Mode == 3) {
    CurrEnemy = 1;
    CurrChar = 1;
    g.drawImage(imgBattleA, 0, 142, this);
    imgBattleB = getImage(getCodeBase(), "chars-1.gif");
    g.drawImage(imgBattleB, 3, 145, this);
    if (Enemy[0][0] == 2) {
      imgBattleC = getImage(getCodeBase(), "sEnemy1");
      g.drawImage(imgBattleC, 283, 145, this);
//    Battle[3]
    g.drawString("Tribal Villager", Battle[3][0], Battle[3][1]);
    }
    if (Enemy[0][0] == 4) {
      imgBattleC = getImage(getCodeBase(), "sEnemy1");
      g.drawImage(imgBattleC, 283, 145, this);
//    Battle[3]
    g.drawString("Cave Bat", Battle[3][0], Battle[3][1]);
    }
    if (Enemy[0][0] == 28) {
      imgBattleC = getImage(getCodeBase(), "sEnemy1");
      g.drawImage(imgBattleC, 283, 145, this);
//    Battle[3]
    g.drawString("forest Owl", Battle[3][0], Battle[3][1]);
    }
    if (Enemy[0][0] == 29) {
      imgBattleC = getImage(getCodeBase(), "sEnemy1");
      g.drawImage(imgBattleC, 283, 145, this);
//    Battle[3]
    g.drawString("Anabanese Moose", Battle[3][0], Battle[3][1]);
    }
    if (Enemy[0][0] == 30) {
      imgBattleC = getImage(getCodeBase(), "sEnemy1");
      g.drawImage(imgBattleC, 283, 145, this);
//    Battle[3]
    g.drawString("Wild Dog", Battle[3][0], Battle[3][1]);
    }
    imgBattleC = getImage(getCodeBase(), "sEnemy1");
    g.drawImage(imgBattleC, 283, 145, this);
    imgBg = getImage(getCodeBase(), "mL-6.gif");
    g.drawImage(imgBg, 0, 0, this);
//    Battle[0]
    g.drawString("Shunketsu", Battle[0][0], Battle[0][1]);
//    Battle[1]
    g.drawString(CharInfo[1][4][2] + "/" + CharInfo[1][4][1], Battle[1][0], Battle[1][1]);
//    Battle[2]
    g.drawString(CharInfo[1][4][6] + "/" + CharInfo[1][4][5], Battle[2][0], Battle[2][1]);
//    Battle[4]
    g.drawString(Enemy[0][1] + "/" + Enemy[0][2], Battle[4][0], Battle[4][1]);
//    Battle[5]
    g.drawString(Enemy[0][6] + "/" + Enemy[0][7], Battle[5][0], Battle[5][1]);
//    StatusText.SetPosition(4, 182);
//    StatusText.SetSize(311, 12);
    g.drawString(strStatusText, 4, 182);
//    BattleDispAttack.Set("attack-" + BattleAttack));
//    BattleDispAttack.Show();
    }
// Shop
  if (Mode == 6) {
    fakeIniFile = CurrShop + ".sop--";
//    Shop[ShopDat[5] + 10].SetBackColor(GetRGB(128,64,0));
//    Shop[0]
    g.drawString(getParameter(fakeIniFile + "strings" + "--" + "shopName"), Shop[0][0], Shop[0][1]);
    if (ShopDat[6] == 0) {
      for (int ln = 0; ln < 5; ln++) {
        if (parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemCost" + ShopDat[ln]) > Gold) {
//          Shop[ln + 10].SetColor(GetRGB(159,79,15));
        } else {
//        Shop[ln + 10].SetColor(GetRGB(255,255,255));
      }
    }
    }
    g.drawString(getParameter(fakeIniFile + "strings" + "--" + "shopSale" + Progress), 200, 3);
    g.drawString(getParameter(fakeIniFile + "items" + Progress + "--" + "itemName" + ShopDat[ShopDat[5]]), 38, 42);
    tempVar = parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemCost" + ShopDat[ShopDat[5]]);
    g.drawString("" + tempVar, 63, 60);
// Following line was commented out, not sure if it was commented out due to conversion progress or for smoother program operation.
    g.drawString("" + Item[parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemId" + ShopDat[ShopDat[5]])], 77, 78);
    g.drawString(getParameter(fakeIniFile + "items" + Progress + "--" + "itemDesc" + ShopDat[ShopDat[5]]), 3, 95);
    g.drawString("" + ShopDat[7], 78, 159);
    g.drawString("" + Gold, 222, 144);
    tempVar = ShopDat[7] * parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemCost" + ShopDat[ShopDat[5]]);
    g.drawString("" + tempVar, 222, 161);
    tempVar = Gold - (ShopDat[7] * parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemCost" + ShopDat[ShopDat[5]]));
    g.drawString("" + tempVar, 223, 181);
    imgBg = getImage(getCodeBase(), "sShop.gif");
    g.drawImage(imgBg, 0, 0, this);
  }
// Gain Experience
  if (Mode == 11) {
    imgBg = getImage(getCodeBase(), "sExpGain.gif");
    g.drawImage(imgBg, 0, 0, this);
    fakeIniFile = "names.sor--";
    g.drawString("Shunketsu", 38, 3);
  }
// Loading
    if (Mode == 0) {
    imgBg = getImage(getCodeBase(), "sLoading.gif");
    g.drawImage(imgBg, 0, 0, this);
    }
  }


// Modes:
//
// 1 == Cut-Scenes
// 2 == Battle Menu
// 3 == Battle Run
// 4 == Map Exploration
// 5 == Question
// 6 == Shop
// 7 == Inn
// 8 == Boat Navigation (Post-Alpha)
// 9 == Naval Battle Menu (Post-Alpha)
// 10 == Naval Battle Run (Post-Alpha)
// 11 == Gain Experience
// 12 == Pause Menu

    public int parseParam(int defaultvalue, String param) {
		String value = getParameter(param);
		int result=defaultvalue;
		try {
			if (value != null)
				result = Integer.parseInt(value);
		} catch (Exception e) {}
		return result;
	}
    public String parseParam(String defaultstring, String param) {
      String value = getParameter(param);
      String result = defaultstring;
      if (value != null)
        result = value;
      return result;
    }
//  public void DoError(code, text, path, x, y) {
//    myMessageBox.OkBox("ERR" + code) + " - " + Program.GetErrorMessage(code) + " -- occoured on line " + y), "An error has occoured.");
//  End;
//  }

// NOTE
//
// this method will be combined into mouseClick
//  public void textClick(ob) {
//    for (int ln = 0; ln < 6 && Mode == 12 && Timers == 2; ln++) {
//    if (ob == pauseTxt[ln]) {
//      pauseInt[8] = ln;
//    }
//  }
//    for (int ln = 0; ln < 5 && Mode == 6; ln++)  {
//    if (ob == Shop[ln + 10]) {
//      ShopDat[5] = ln;
//    }
//  }
//  fakeIniFile = "charMovEvent.sor";
//    for (int ln = 0; ln < 4 && Mode == 2; ln++)  {
//    BMenu[0][4] = 0;
//    if (BMenu[0][0] == 1) {
//      if (ob == BMenuTxt[ln] && CharInfo[CurrChar][3][BMenu[1][ln]] <= 0 && parseParam(0, fakeIniFile + "attack" + CurrChar + "--" + "EP" + BMenu[1][ln]) <= CharInfo[CurrChar][4][6]) {
//        BMenu[0][1] = ln + 1;
//      }
//    } else {
//      if (ob == BMenuTxt[ln])  {
//      BMenu[0][1] = ln + 1;
//    }
//    }
//  }
//  repaint();
//  Return TRUE;
//  }

  public void mouseClick(Event e, int mouseX, int mouseY) {
  if (mouseX < 2 && mouseY < 2) {
    Mode = 4;
    battling = 0;
  }
  if (Mode == 12)  {
    if (Timers == 0) {
      if (mouseX > 2 && mouseY > 2 && mouseX < 102 && mouseY < 19) {
      Timers = 1;
      pauseInt[8] = 0;
      pauseInt[0] = 0;
      pauseInt[1] = 1;
      pauseInt[2] = 2;
      pauseInt[3] = 3;
      pauseInt[4] = 4;
      pauseInt[5] = 5;
    }
      if (mouseX > 2 && mouseY > 20 && mouseX < 102 && mouseY < 37) {
      Timers = 2;
    }
      if (mouseX > 2 && mouseY > 38 && mouseX < 102 && mouseY < 55) {
      Timers = 3;
    }
      if (mouseX > 2 && mouseY > 56 && mouseX < 102 && mouseY < 73) {
      Timers = 4;
    }
      if (mouseX > 2 && mouseY > 74 && mouseX < 102 && mouseY < 91) {
      Timers = 5;
    }
      if (mouseX > 2 && mouseY > 92 && mouseX < 102 && mouseY < 109) {
      Timers = 6;
    }
      if (mouseX > 2 && mouseY > 110 && mouseX < 102 && mouseY < 127)  {
      Timers = 7;
    }
      if (mouseX > 2 && mouseY > 128 && mouseX < 102 && mouseY < 145)  {
      Timers = 8;
    }
      if (mouseX > 2 && mouseY > 146 && mouseX < 102 && mouseY < 163)  {
      Timers = 9;
    }
      if (mouseX > 2 && mouseY > 164 && mouseX < 102 && mouseY < 181)  {
      Timers = 10;
    }
      if (mouseX > 161 && mouseY > 180 && mouseX < 239 && mouseY < 197) {
      Timers = 11;
    }
      if (mouseX > 239 && mouseY > 180 && mouseX < 317 && mouseY < 197) {
      Timers = 12;
    }
    }
    if (Timers == 1) {
    }
    if (Timers == 2) {
      // << Back
      if (mouseX > 161 && mouseY > 170 && mouseX < 239 && mouseY < 187) {
      Timers = 0;
    }
    // Details
      if (mouseX > 239 && mouseY > 170 && mouseX < 317 && mouseY < 187) {
      Timers = 3;
      pauseInt[6] = pauseInt[8];
      pauseInt[8] = 0;
      pauseInt[0] = 0;
      pauseInt[1] = 1;
      pauseInt[2] = 2;
      pauseInt[3] = 3;
      pauseInt[4] = 4;
      pauseInt[5] = 5;
    }
    }
    if (Timers == 3) {
      if (mouseX > 162 && mouseY > 180 && mouseX < 239 && mouseY < 197 ) {
      Timers = 2;
      pauseInt[8] = pauseInt[6];
      pauseInt[0] = 0;
      pauseInt[1] = 1;
      pauseInt[2] = 2;
      pauseInt[3] = 3;
      pauseInt[4] = 4;
      pauseInt[5] = 5;
    }
    }
    repaint();
  }
  if (Mode == 6) {
    fakeIniFile = CurrShop + ".sop";
    // Purchase Button
    if (mouseX > 37 && mouseY > 20 && mouseX < 91 && mouseY < 37) {
      ShopDat[6] = 0;
    }
    // Sell Button
    if (mouseX > 91 && mouseY > 20 && mouseX < 145 && mouseY < 37) {
      ShopDat[6] = 1;
    }
    // Exit Button
    if (mouseX > 145 && mouseY > 20 && mouseX < 199 && mouseY < 37) {
      Mode = 4;
    }
    // ScrollUp Button
    if (mouseX > 161 && mouseY > 41 && mouseX < 317 && mouseY < 53) {
      for (int ln = 0; ln < 5; ln++) {
      ShopDat[ln] = ShopDat[ln] - 1;
    }
    }
    // ScrollDown Button
    if (mouseX > 161 && mouseY > 127 && mouseX < 317 && mouseY < 139) {
      for (int ln = 0; ln < 5; ln++) {
      ShopDat[ln] = ShopDat[ln] + 1;
    }
    }
    // QuanityUp Button
    if (mouseX > 124 && mouseY > 158 && mouseX < 141 && mouseY < 175) {
      ShopDat[7] = ShopDat[7] + 1;
    }
    // QuanityDown Button
    if (mouseX > 141 && mouseY > 158 && mouseX < 158 && mouseY < 175) {
      ShopDat[7] = ShopDat[7] - 1;
    }
    // Purchase/Sell Button
    if (mouseX > 37 && mouseY > 177 && mouseX < 158 && mouseY < 194) {
      if (ShopDat[6] == 0) {
      if (Gold >= ShopDat[7] * parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemCost" + ShopDat[ShopDat[5]])) {
          tempVar = parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemId" + ShopDat[ShopDat[5]]);
        Item[tempVar] = Item[tempVar] + ShopDat[7];
        Gold = Gold - (ShopDat[7] * parseParam(0, fakeIniFile + "items" + Progress + "--" + "itemCost" + ShopDat[ShopDat[5]]));
      }
    } else {
      Item[ShopDat[ShopDat[5]]] = Item[ShopDat[ShopDat[5]]] - ShopDat[7];
      Gold = Gold + (ShopDat[7] * parseParam(0, fakeIniFile + "sellItem" + Progress + "--" + "itemCost" + ShopDat[ShopDat[5]]));
    }
    }
    repaint();
  }
  if (Mode == 1) {
    Timers = Timers + 1;
    repaint();
  }
  if (Mode == 2) {
    // Attacks List
    if (mouseX > 3 && mouseY > 39 && mouseX < 41 && mouseY < 56) {
      BMenu[0][4] = 0;
      BMenu[0][0] = 1;
    BMenu[0][1] = 1;
    BMenu[1][0] = 0;
    BMenu[1][1] = 1;
    BMenu[1][2] = 2;
    BMenu[1][3] = 3;
    }
    // Magic List
    if (mouseX > 42 && mouseY > 39 && mouseX < 80 && mouseY < 56) {
      BMenu[0][4] = 0;
      BMenu[0][0] = 2;
    BMenu[0][1] = 1;
    BMenu[1][0] = 0;
    BMenu[1][1] = 1;
    BMenu[1][2] = 2;
    BMenu[1][3] = 3;
    }
    // Items List
    if (mouseX > 81 && mouseY > 39 && mouseX < 119 && mouseY < 56) {
      BMenu[0][4] = 0;
      BMenu[0][0] = 3;
    BMenu[0][1] = 1;
    BMenu[1][0] = 0;
    BMenu[1][1] = 1;
    BMenu[1][2] = 2;
    BMenu[1][3] = 3;
    }
    // Strategy List
    if (mouseX > 120 && mouseY > 39 && mouseX < 158 && mouseY < 56) {
      BMenu[0][4] = 0;
      BMenu[0][0] = 4;
    BMenu[0][1] = 1;
    BMenu[1][0] = 0;
    BMenu[1][1] = 1;
    BMenu[1][2] = 2;
    BMenu[1][3] = 3;
    }
    if (mouseX > 161 && mouseY > 39 && mouseX < 238 && mouseY < 56) {
      BMenu[0][2] = 1;
    BMenu[0][4] = 1;
    }
    if (mouseX > 239 && mouseY > 39 && mouseX < 316 && mouseY < 56) {
      BMenu[0][2] = 2;
    BMenu[0][4] = 1;
    }
    if (mouseX > 237 && mouseY > 179 && mouseX < 276 && mouseY < 196) {
      BMenu[0][4] = 1;
      if (CurrChar == 5) {
      if (CharInfo[4][0][1] == 1) {
        CurrChar = 4;
      } else {
        if (CharInfo[3][0][1] == 1) {
        CurrChar = 3;
      } else {
        if (CharInfo[2][0][1] == 1) {
          CurrChar = 2;
        } else {
          if (CharInfo[1][0][1] == 1) {
          CurrChar = 1;
        }
        }
      }
      }
    }
      if (CurrChar == 4) {
        if (CharInfo[3][0][1] == 1) {
        CurrChar = 3;
      } else {
        if (CharInfo[2][0][1] == 1) {
          CurrChar = 2;
        } else {
          if (CharInfo[1][0][1] == 1) {
          CurrChar = 1;
        }
        }
      }
    }
      if (CurrChar == 3) {
      if (CharInfo[2][0][1] == 1) {
        CurrChar = 2;
      } else {
        if (CharInfo[1][0][1] == 1)  {
        CurrChar = 1;
      }
      }
    }
      if (CurrChar == 2) {
      if (CharInfo[1][0][1] == 1) {
        CurrChar = 1;
      }
    }
    }
    BMenuSubjectSelection = 1;
    if (mouseX > 277 && mouseY > 179 && mouseX < 316 && mouseY < 196) {
      Attacks[CurrChar][0] = BMenu[1][BMenu[0][1]];
      Attacks[CurrChar][1] = BMenu[0][0];
      Attacks[CurrChar][2] = BMenu[2][BMenu[0][3]];
    BMenu[0][4] = 0;
      for (int VeryTempVar = 1; CurrChar < 100; VeryTempVar++) {
      CurrChar = CurrChar + 1;
      if (CurrChar > 5) {
        Timers = 0;
        Mode = 3;
      keyDown();
        break;
      }
      if (CharInfo[CurrChar][0][1] == 1) {
        break;
      }
      }
    }
    repaint();
  }
  if (Mode == 3) {
    keyDown();
  }
  if (Mode == 11)  {
    keyDown();
  }
  }

  public void charAttack() {
    CurrEnemy = 0;
  // Strategy
  if (Attacks[CurrChar][1] == 4) {
    // Run
    if (Attacks[CurrChar][0] == 1) {
      fakeIniFile = "names.sor";
        if (randVal.nextInt() * (CharInfo[CurrChar][4][12] * Attacks[CurrChar][3]) > (Enemy[CurrEnemy][5]) - (CharInfo[CurrChar][4][12] * Attacks[CurrChar][3])) {
          Mode = 4;
        } else {
          strStatusText = "Unable to escape from battlEvent.";
        }
    Timers = Timers + 2;
    repaint();
      }
    // Defend
    if (Attacks[CurrChar][0] == 2) {
      Attacks[CurrChar][5] = 3;
    strStatusText = "Charecters moves into a defensive Position.";
    Timers = Timers + 2;
    repaint();
    }
    // Energize
    if (Attacks[CurrChar][0] == 3) {
      CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + CharInfo[CurrChar][4][7];
    strStatusText = "Charecter Energizes. " + CharInfo[CurrChar][4][7] + " EP gained.";
    Timers = Timers + 2;
    repaint();
    }
  }
  // Magic
  if (Attacks[CurrChar][1] == 2) {
    // Quicksand
    if (Attacks[CurrChar][0] == 2) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] - 2;
        EnemyLose = (100 - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]);
        strStatusText = "Magic Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Avalanche (Multiple Enemies)
    if (Attacks[CurrChar][0] == 3) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] - 5;
        EnemyLose = (100 - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]);
        strStatusText = "Magic Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Earthquake (Multiple Enemies)
    if (Attacks[CurrChar][0] == 4) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] - 10;
        EnemyLose = (500 - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]);
        strStatusText = "Magic Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Raise the Dead
    if (Attacks[CurrChar][0] == 5) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] - 15;
        EnemyLose = (1000 - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]);
        strStatusText = "Magic Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
  }
  // Items
  if (Attacks[CurrChar][1] == 3) {
    //Health Crystal
    if (Attacks[CurrChar][0] == 1) {
      strStatusText = "Charecter uses Holy Crystal. 100 HP Gained.";
    CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][2] + 100;
    Item[0] = Item[0] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 2) {
      strStatusText = "Charecter uses Holy Water. 500 HP Gained.";
    CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][2] + 500;
    Item[1] = Item[1] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 3) {
      strStatusText = "Charecter uses Holy Dust. 1000 HP Gained.";
    CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][2] + 1000;
    Item[2] = Item[2] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 4) {
      strStatusText = "Charecter uses Magic Crystal. 1 MP Gained.";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] + 1;
    Item[3] = Item[3] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 5) {
      strStatusText = "Charecter uses Magic Water. 5 MP Gained.";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] + 5;
    Item[4] = Item[4] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 6) {
      strStatusText = "Charecter uses Magic Dust. 15 MP Gained.";
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] + 15;
    Item[5] = Item[5] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 7) {
      strStatusText = "Charecter uses Energy Crystal. 5 EP Gained.";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + 5;
    Item[6] = Item[6] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 8) {
      strStatusText = "Charecter uses Energy Water. 10 EP Gained.";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + 10;
    Item[7] = Item[7] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 9) {
      strStatusText = "Charecter uses Energy Dust. 15 EP Gained.";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + 15;
    Item[8] = Item[8] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 10) {
      strStatusText = "Charecter uses Tokubetsu Crystal.";
    CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][2] + 100;
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] + 1;
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + 5;
    Item[9] = Item[9] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 11) {
      strStatusText = "Charecter uses Tokubetsu Water.";
    CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][2] + 500;
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] + 5;
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + 10;
    Item[10] = Item[10] - 1;
    Timers = 3;
    repaint();
    }
    if (Attacks[CurrChar][0] == 12) {
      strStatusText = "Charecter uses Tokubetsu Dust.";
    CharInfo[CurrChar][4][2] = CharInfo[CurrChar][4][2] + 1000;
    CharInfo[CurrChar][4][4] = CharInfo[CurrChar][4][4] + 15;
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] + 15;
    Item[11] = Item[11] - 1;
    Timers = 3;
    repaint();
    }
  }
    // Normal/Special Attacks
  if (Attacks[CurrChar][1] == 1) {
    // Normal Attack
    if (Attacks[CurrChar][0] == 1) {
      fakeIniFile = "names.sor";
    // Depending on the Enemy's Agility, and the charecter's Speed, we need to determine if the the enemy blocks the attack.
        if (randVal.nextInt() * (CharInfo[CurrChar][4][12] * Attacks[CurrChar][3]) > Enemy[CurrEnemy][5] - (CharInfo[CurrChar][4][12] * Attacks[CurrChar][3])) {
          EnemyLose = randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]);
          strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
          Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
        } else {
          strStatusText = "Enemy blocked attack.";
        }
    // Detect Counter-Attack
        if (randVal.nextInt() * (Enemy[0][9]) > (CharInfo[1][4][11] * (Attacks[1][4] + WeaponInfo[1][1][3] + ShieldInfo[1][1][3] + ArmorInfo[1][1][3])) - Enemy[0][9]) {
      Timers = Timers + 1;
    } else {
          Timers = 3;
    }
    repaint();
      }    
    // Legendary Attack
    if (Attacks[CurrChar][0] == 2 && CurrChar == 1) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] - 3;
        EnemyLose = randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]);
        strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Spiritual Attack
    if (Attacks[CurrChar][0] == 3 && CurrChar == 1) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] - 7;
        EnemyLose = (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7] + 1.25) - Enemy[CurrEnemy][4]);
        strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Naitote
    if (Attacks[CurrChar][0] == 4 && CurrChar == 1) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] - 10;
        EnemyLose = (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7] + 1.75) - Enemy[CurrEnemy][4]);
        strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Dust Storm
    if (Attacks[CurrChar][0] == 5 && CurrChar == 1) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] - 15;
        EnemyLose = (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7] + 2) - Enemy[CurrEnemy][4]);
        strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Rains of Peril
    if (Attacks[CurrChar][0] == 2 && CurrChar == 2) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] - 3;
        EnemyLose = (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7] + 2) - Enemy[CurrEnemy][4]);
        strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
    // Blade of Fire
    if (Attacks[CurrChar][0] == 2 && CurrChar == 5) {
      fakeIniFile = "names.sor";
    CharInfo[CurrChar][4][6] = CharInfo[CurrChar][4][6] - 7;
        EnemyLose = (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7]) - Enemy[CurrEnemy][4]) + randVal.nextInt() * (CharInfo[CurrChar][4][10] * (WeaponInfo[CurrChar][1][2] + ShieldInfo[CurrChar][1][2] + Attacks[CurrChar][7] + 2) - Enemy[CurrEnemy][4]);
        strStatusText = "Attack Successful. Enemy lost " + EnemyLose + " HP";
        Enemy[CurrEnemy][1] = Enemy[CurrEnemy][1] - EnemyLose;
    Timers = Timers + 2;
    repaint();
      }
  }
  }
  
  public void loadBattle()
  {
  // Set up enemies for battle
  LocationEnemies = parseParam(0, fakeIniFile + "enemies" + "--" + "ttlenemies");
  Enemy[0][0] = parseParam(0, fakeIniFile + "enemies" + "--" + "enemy" + randVal.nextInt() * (LocationEnemies));
  // Prepare Enenmy 1
  fakeIniFile = Enemy[0][0] + ".nmy";
  Enemy[0][10] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyGold")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemyGoldBoost");
  Enemy[0][3] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyAPmax") - parseParam(0, fakeIniFile + "stats" + "--" + "EnemyAPmin")) + parseParam(0, fakeIniFile + "stats" + "EnemyAPmin");
  Enemy[0][2] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyTHPmax") - parseParam(0, fakeIniFile + "stats" + "--" + "EnemyTHPmin")) + parseParam(0, fakeIniFile + "stats" + "EnemyTHPmin");
  Enemy[0][12] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyTMPmax") - parseParam(0, fakeIniFile + "stats" + "--" + "EnemyTMPmin")) + parseParam(0, fakeIniFile + "stats" + "EnemyTMPmin");
  Enemy[0][1] = Enemy[0][2] - randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyHP"));
  Enemy[0][11] = Enemy[0][12] - randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyMP"));
  Enemy[0][4] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyDPmax") - parseParam(0, fakeIniFile + "stats", "EnemyDPmin")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemyDPmin");
  Enemy[0][5] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyAGmax") - parseParam(0, fakeIniFile + "stats", "EnemyAGmin")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemyAGmin");
  Enemy[0][9] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemySPmax") - parseParam(0, fakeIniFile + "stats", "EnemySPmin")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemySPmin");
  Enemy[0][6] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyEPmax") - parseParam(0, fakeIniFile + "stats", "EnemyEPmin")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemyEPmin");
  Enemy[0][8] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyEPupMax") - parseParam(0, fakeIniFile + "stats", "EnemyEPupMin")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemyEPupMin");
  Enemy[0][7] = randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyTEPmax") - parseParam(0, fakeIniFile + "stats", "EnemyTEPmin")) + parseParam(0, fakeIniFile + "stats" + "--" + "EnemyTEPmin");
  Enemy[0][13] = parseParam(0, fakeIniFile + "stats" + "--" + "EnemyItems");
  int tempVar = randVal.nextInt() * (Enemy[0][13]);
  Enemy[0][14] = parseParam(0, fakeIniFile + "stats" + "--" + "EnemyItemID" + tempVar);
  tempVar = Enemy[0][14];
  tempStr = tempVar;
  Enemy[0][15] = 1 + randVal.nextInt() * (parseParam(0, fakeIniFile + "stats" + "--" + "EnemyItemQU" + tempStr));
  Enemy[0][16] = Integer.parseInt(parseParam(0, fakeIniFile + "stats" + "--" + "EnemyEX"));
  // Begin Battle
  BMenu[0][1] = 1;
  BMenu[1][0] = 0;
  BMenu[1][1] = 1;
  BMenu[1][2] = 2;
  BMenu[1][3] = 3;
  Timers = 0;
  CharInfo[1][4][6] = CharInfo[1][4][7];
//  CharInfo[2,4,6] = CharInfo[2,4,7];
//  CharInfo[3,4,6] = CharInfo[3,4,7];
//  CharInfo[4,4,6] = CharInfo[4,4,7];
//  CharInfo[5,4,6] = CharInfo[5,4,7];
  CurrChar = 1;
  Mode = 2;
  repaint();
  }

  public boolean keyDown(Event e, int key) {
    // Cut Scenes
    if (Mode == 1) {
    if (key != Event.DOWN && key != Event.UP && key != Event.LEFT && key != Event.RIGHT) {
        Timers = Timers + 1;
        repaint();
    }
    }
  // Battle Menu
  if (Mode == 2) {
    if (BMenu[0][4] == 0) {
      switch (key) {
      case Event.DOWN:
      BMenu[0][1] = BMenu[0][1] + 1;
      break;
      case Event.UP:
      BMenu[0][1] = BMenu[0][1] - 1;
      break;
      case Event.LEFT:
      BMenu[0][0] = BMenu[0][0] - 1;
      break;
      case Event.RIGHT:
      BMenu[0][0] = BMenu[0][0] + 1;
      break;
      case Event.Return:
      BMenu[0][4] = 1;
      break;
    }
    } else {
      switch (key) {
      case Event.DOWN:
      BMenu[0][3] = BMenu[0][3] + 1;
      break;
      case Event.UP:
      BMenu[0][3] = BMenu[0][3] + 1;
      break;
      case Event.LEFT:
      BMenu[0][2] = BMenu[0][2] - 1;
      break;
      case Event.RIGHT:
      BMenu[0][2] = BMenu[0][2] + 1;
      break;
      case Event.Return:
        Attacks[CurrChar][0] = BMenu[1][BMenu[0][1]];
        Attacks[CurrChar][1] = BMenu[0][0];
        Attacks[CurrChar][2] = BMenu[2][BMenu[0][3]];
      BMenu[0][4] = 0;
        for (int VeryTempVar = 1; CurrChar < 100; VeryTempVar++) {
        CurrChar = CurrChar + 1;
        if (CurrChar > 5) {
          Timers = 0;
          Mode = 3;
          fakeIniFile = "names.sor--";
        keyDown();
          break;
        }
        if (CharInfo[CurrChar][0][1] == 1) {
          break;
      }
      }
      break;
//      case Event.END: // HI
//      BMenu[0][4] = 0;
//      break;
      default:
      tempVar = 0;
      }
    }
    repaint();
  }
    // Map Exploration
    if (Mode == 4) {
    // X + (Y * L)
    if (e.controlDown()) {
      Mode = 12;
    Timers = 0;
    }
    switch (Location) {
      case 6:
      myBinary = new FileInputStream("L6.map");
      myBinary.read(binaryMap, 0, 1200);
    break;
    case 7:
    myBinary = new FileInputStream("L7.map");
	myBinary.read(binaryMap, 0, 1200);
    break;
    case 9:
    myBinary = new FileInputStream("L9.map");
	myBinary.read(binaryMap, 0, 1280);
    break;
    }
    NavMap = binaryMap[MapX + (MapY * 40)];
    fakeIniFile = Location + ".wld--";
      if (key == Event.RIGHT) {
        if (NavMap == 2 || NavMap == 5 || NavMap == 8 || NavMap == 9 || NavMap == 17 || NavMap == 18 || NavMap == 19 || NavMap == 21) {
          MapX = MapX + 1;
      // Detect if a battle occours
      if (randVal.nextInt() * (parseParam(0, fakeIniFile + "enemies" + "--" + "battlefreq")) < 10 && battling == 1) {
        loadBattle();
      }
        }
    }
      if (key == Event.LEFT) {
        if (NavMap == 4 || NavMap == 7 || NavMap == 9 || NavMap == 16 || NavMap == 17 || NavMap == 19 || NavMap == 20 || NavMap == 21) {
          MapX = MapX - 1;
      // Detect if a battle occours
      if (randVal.nextInt() * (parseParam(0, fakeIniFile + "enemies" + "--" + "battlefreq")) < 10 && battling == 1) {
        loadBattle();
      }
        }
      }
      if (key == Event.UP) {
        if (NavMap == 1 || NavMap == 5 || NavMap == 6 || NavMap == 7 || NavMap == 17 || NavMap == 18 || NavMap == 20 || NavMap == 21) {
          MapY = MapY - 1;
      // Detect if a battle occours
      if (randVal.nextInt() * (parseParam(0, fakeIniFile + "enemies" + "--" + "battlefreq")) < 10 && battling == 1) {
        loadBattle();
      }
        }
      }
      if (key == Event.DOWN) {
        if (NavMap == 3 || NavMap == 6 || NavMap == 8 || NavMap == 16 || NavMap == 18 || NavMap == 19 || NavMap == 20 || NavMap == 21) {
          MapY = MapY + 1;
      // Detect if a battle occours
      if (randVal.nextInt() * (parseParam(0, fakeIniFile + "enemies" + "--" + "battlefreq")) < 10 && battling == 1) {
        loadBattle();
      }
        }
      }
    repaint();
    }
    // Batle Run
    if (Mode == 3) {
    Attacks[1][4] = 1;
      if (Timers == 0) {
    fakeIniFile = "names.sor";
    strStatusText = parseParam(0, fakeIniFile + "chars" + "--" + CurrChar) + " attacks enemy.";
    Timers = 1;
    repaint();
    }
    if (Timers == 1) {
      charAttack();
    }
      // Detect if enemy Counter-Attacks
    
      if (Timers == 2) {
        HeroLose = randVal.nextInt() * (Enemy[0][3] - (WeaponInfo[1][1][1] + Attacks[1][5] + ShieldInfo[1][1][1] + ArmorInfo[1][1][1]) * CharInfo[1][4][9]);
        strStatusText = "Counter Attack! " + parseParam(0, fakeIniFile + "chars" + "--" + CurrChar) + " lost " + HeroLose + " HP";
        CharInfo[1][4][2] = CharInfo[1][4][2] - HeroLose;
        Timers = Timers + 1;
        repaint();
      }
      // Enemy's attack
    Attacks[0][0] = 1;
    if (Timers == 3) {
      if (Attacks[0][0] == 1)  {
      strStatusText = "Enemy attacks " + parseParam(0, fakeIniFile + "chars" + "--" + CurrChar);
      Timers = Timers + 1;
    }
    }
      if (Timers == 4) {
        if (randVal.nextInt() * (Enemy[0][9]) > (CharInfo[1][4][11] * (Attacks[1][4] + WeaponInfo[1][1][3] + ShieldInfo[1][1][3] + ArmorInfo[1][1][3])) - Enemy[0][9]) {
          HeroLose = randVal.nextInt() * (Enemy[0][3] - (WeaponInfo[1][1][1] + Attacks[1][5] + ShieldInfo[1][1][1] + ArmorInfo[1][1][1]) * CharInfo[1][4][9]);
          strStatusText = "Attack! " + parseParam(0, fakeIniFile + "chars" + "--" + CurrChar) + " lost " + HeroLose + " HP";
          CharInfo[1][4][2] = CharInfo[1][4][2] - HeroLose;
        } else {
          strStatusText = parseParam(0, fakeIniFile + "chars" + "--" + CurrChar) + " blocked the enemy's attack!";
        }
    // Detect Counter-Attack
        if (randVal.nextInt() * (CharInfo[1][4][12] * Attacks[1][3]) > Enemy[0][5] - (CharInfo[1][4][12] * Attacks[1][3])) {
      Timers = Timers + 1;
    } else {
      Timers = 6;
    }
    repaint();
      }
      // Detect if charecter Counter-Attacks
      if (Timers == 5) {
        EnemyLose = randVal.nextInt() * (CharInfo[1][4][10] * (WeaponInfo[1][1][2] + ShieldInfo[1][1][2] + Attacks[1][7]) - Enemy[0][4]);
        strStatusText = "Counter Attack! Enemy lost " + EnemyLose + " HP";
        Enemy[0][1] = Enemy[0][1] - EnemyLose;
        Timers = Timers + 1;
        repaint();
    }
      // Detect what to do next.
      if (Timers == 6) {
      // if the charecters are all dead, the game should end.
//        if (CharInfo[1][4][2] < 1) {
//          ButtonID = myMessageBox.OkBox("Game Over", "The Stone of Reikai");
//      End;
//        }
    // if all enemies are dead, the battle should end, and should progress to earning items from the battlEvent.
        if (Enemy[0][1] < 1) {
          strStatusText = "Battle Won!";
      Timers = 0;
      Mode = 11;
        }
    // if an enemy is still alive, continue by opening up the attack screen.
        if (Enemy[0][1] > 1) {
      BMenu[0][1] = 1;
      BMenu[1][0] = 0;
      BMenu[1][1] = 1;
      BMenu[1][2] = 2;
      BMenu[1][3] = 3;
          Mode = 2;
      if (CharInfo[1][4][6] >= 0) {
        CharInfo[1][4][6] = CharInfo[1][4][6] + CharInfo[1][4][7];
      }
        }
        repaint();
      }
    }
  if (Mode == 11)  {
    if (Timers == 0) {
      // Temporary Gold and Item gain for testing purposes.
    if (Enemy[0][14] != 0) {
      Item[Enemy[0][14] - 1] = Item[Enemy[0][14] - 1] + Enemy[0][15];
    }
    Gold = Gold + Enemy[0][10];
    // Temporary code ends
      ExpGainAC = "" + CharInfo[1][4][8];
    ExpGainAD = "Mx";
    Timers = Timers + 1;
    repaint();
    }
    if (Timers == 1) {
      if (CharInfo[1][4][8] - Enemy[0][16] < 1) {
      CharInfo[1][4][0] = CharInfo[1][4][0] + 1;
        fakeIniFile = "charlvls.sor--";
      CharInfo[1][4][8] = parseParam(0, CharInfo[1][4][0] + "--" + "HeroNextEX");
      ExpGainAC = "" + CharInfo[1][4][8];
      ExpGainAE = "Level Up!";
      Timers = Timers + 1;
      repaint();
    } else {
      CharInfo[1][4][8] = CharInfo[1][4][8] - Enemy[0][16];
      ExpGainAC = "" + CharInfo[1][4][8];
      Timers = 6;
      repaint();
    }
    }
    if (Timers == 2) {
      fakeIniFile = "charlvls.sor--";
    CharInfo[1][4][1] = CharInfo[1][4][1] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroHP");
    ExpGainAE = "THP +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroHP");
    CharInfo[1][4][3] = CharInfo[1][4][3] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroMP");
    ExpGainAF = "TMP +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroMP");
    Timers = Timers + 1;
    repaint();
    }
    if (Timers == 3) {
      fakeIniFile = "charlvls.sor--";
    CharInfo[1][4][5] = CharInfo[1][4][5] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroEP");
    ExpGainAE = "TEP +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroEP");
    CharInfo[1][4][7] = CharInfo[1][4][7] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroEPup");
    ExpGainAF = "EPup +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroEPup");
    Timers = Timers + 1;
    repaint();
    }
    if (Timers == 4) {
      fakeIniFile = "charlvls.sor--";
    CharInfo[1][4][10] = CharInfo[1][4][10] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroAP");
    ExpGainAE = "AP +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroAP");
    CharInfo[1][4][9] = CharInfo[1][4][9] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroDP");
    ExpGainAF = "DP +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroDP");
    Timers = Timers + 1;
    repaint();
    }
    if (Timers == 5) {
      fakeIniFile = "charlvls.sor--";
    CharInfo[1][4][11] = CharInfo[1][4][11] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroAG");
    ExpGainAE = "AG +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroAG");
    CharInfo[1][4][12] = CharInfo[1][4][12] + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroSP");
    ExpGainAF = "SP +" + parseParam(0, fakeIniFile + CharInfo[1][4][0] + "--" + "HeroSP");
    Timers = Timers + 1;
    repaint();
    }
    if (Timers == 6) {
      Timers = 0;
    Mode = 4;
    repaint();
    }
  }
  }
}

    Source: geocities.com/tsgames