Dark Age Games
Home Dark Age EX Dark Age 2 Message Board Fan Art FAQ Kelzar Mage DALpedia MS Forum
Board Index Dark Age General Bug Report Website Off Topic Register User Edit User User List Search

Real Time Battle System
Posted by: William
13:00:42 09-18-2005

Check this, been coding it for a few weeks now. Should I change SetImageTransparent to SetImage, because right now its a little bit laggy:

This battle system has:
-Pixel or Tile Movement
-3 sword attacks
-1 arrow attack
- 1-4 enemies
And its hopefully completly bug free :P

//-----------------------------\\
//Made by: William           \\
//For: Toolkitzones Members   \\
//Date: 2005.09.25           \\
//Info: Real Time Battle System\\
//Website: www.Bevrias.com \\
//-----------------------------\\

//Recomended: Read the INFORMATION parts and go through the code, even if you dont think on changing anything.

//Varibles to use for special things
//HealingPotions!=HealingPotions!+1  -Put that in chests in the game.
RealTimeBattle!=0 //0 - Real Time Battle System (recommended), 1 - Turn Based battle System (not very good)
//Character Varibles
PixelMovement!=0 // 0 - Tile Movement (recommended), 1 - Pixel Movement (as good as it can be)
PlayerMinimumDmg!=2
PlayerMinimumArrowDmg!=2
CharStartX!=5
CharStartY!=5
CharSizeX!=32 //Not implemented (you need to cover old char with GrassTile$)
CharSizeY!=32 //Not implemented (you need to cover old char with GrassTile$)
CharNorth$ = "CharNorth.bmp"
CharSouth$ = "CharSouth.bmp"
CharWest$  = "CharWest.bmp"
CharEast$  = "CharEast.bmp"
CharR!=255
CharG!=255
CharB!=255
//Fighting With Sword Varibles
AttackOne!=10       //(Z) -Hits the enemy almost all the time but with less power
AttackOneRange!=20  //(Z) -Misses the enemy 1 on 10
AttackTwo!=5        //(X) -Misses the enemy sometimes, but have more power
AttackTwoRange!=6   //(X) -Misses the enemy 1 on 6
AttackThree!=0      //(C) -Great chance of missing but with full power
AttackThreeRange!=3 //(C) -Misses the enemy 1 on 3
//Using Bow/Arrows Varibles (different character direction can have different ragnes)
ArrowRangeWest!=4        //(V) -Length on tiles to shot west with a arrow
ArrowRangeEast!=4        //(V) -Length on tiles to shot east with a arrow
ArrowRangeNorth!=4       //(V) -Length on tiles to shot north with a arrow
ArrowRangeSouth!=4       //(V) -Length on tiles to shot south with a arrow
ArrowAgility!=5          //Misses the enemy 1 on 5
ArrowDecreaseDmg!=5      //Removes 5 FP because the arrow can attack enemies far away, so theres now a small weakness with it
ArrowWest$  = "ArrowWest.bmp"
ArrowEast$  = "ArrowEast.bmp"
ArrowNorth$ = "ArrowNorth.bmp"
ArrowSouth$ = "ArrowSouth.bmp"
//Board Varibles
BattleBoardMapName$ = "BattleMap.brd"
XStart!=0
YStart!=0
XEnd!=13
YEnd!=9
GrassTile$ = "Grass.bmp"
//EnemyOptions Varibles
EnemySpeedTime!=2 //Not recommended to have it above 50 due to speed is going to slow
EnemyAmount!=2 //Max 4 Enemies as Default (recommended to have max 3 due to speed), more will not work if you dont modify the code.
EnemyR!=255
EnemyG!=255
EnemyB!=255
//Clear Enemy Varibles
For(clear!=1; clear! <= EnemyAmount!; clear!=clear!+1)
{
EnemyName[clear!]$=""
EnemyGraphic[clear!]$= ""
EnemyStrength[clear!]!=0
EnemyMinimumDmg[clear!]!=0
EnemyDefence[clear!]!=0
EnemyHealth[clear!]!=0
EnemyStartX[clear!]!=0
EnemyStartY[clear!]!=0
EnemySizeX[clear!]!=0
EnemySizeY[clear!]!=0
EnemyExp[clear!]!=0
EnemyGold[clear!]!=0
}
//Enemy 1 Stat Varibles
EnemyName[1]$="Goblin" //Not implemented
EnemyGraphic[1]$= "Enemy1.bmp"
EnemyStrength[1]!=5
EnemyMinimumDmg[1]!=1
EnemyDefence[1]!=3
EnemyHealth[1]!=15
EnemyExp[1]!=10
EnemyGold[1]!=10
EnemyStartX[1]!=4
EnemyStartY[1]!=2
EnemySizeX[1]!=32
EnemySizeY[1]!=32
//Enemy 2 Stat Varibles
EnemyName[2]$="Skeleton" //Not implemented
EnemyGraphic[2]$= "Enemy1.bmp"
EnemyStrength[2]!=5
EnemyMinimumDmg[2]!=1
EnemyDefence[2]!=3
EnemyHealth[2]!=15
EnemyExp[2]!=10
EnemyGold[2]!=10
EnemyStartX[2]!=2
EnemyStartY[2]!=2
EnemySizeX[2]!=32
EnemySizeY[2]!=32
//Enemy 3 Stat Varibles
EnemyName[3]$="Maze" //Not implemented
EnemyGraphic[3]$= "Enemy1.bmp"
EnemyStrength[3]!=5
EnemyMinimumDmg[3]!=1
EnemyDefence[3]!=3
EnemyHealth[3]!=15
EnemyExp[3]!=10
EnemyGold[3]!=10
EnemyStartX[3]!=5
EnemyStartY[3]!=7
EnemySizeX[3]!=32
EnemySizeY[3]!=32
//Enemy 4 Stat Varibles
EnemyName[4]$="Ghost" //Not implemented
EnemyGraphic[4]$= "Enemy1.bmp"
EnemyStrength[4]!=5
EnemyMinimumDmg[4]!=1
EnemyDefence[4]!=3
EnemyHealth[4]!=15
EnemyExp[4]!=10
EnemyGold[4]!=10
EnemyStartX[4]!=8
EnemyStartY[4]!=4
EnemySizeX[4]!=32
EnemySizeY[4]!=32
//Start Methods, Varibles and Commands
SaveScreen() //Command
ViewBRD(BattleBoardMapName$) //Command
CharDirection$="SOUTH" //Varible
EmemyTurn!=0 //Varible
HealingVital!=10 //How much HP you should gain from one HealingPotion
//Equations:


//All Equations (should be left untouched if you want the battle system to work)
//*************INFORMATION*****************************************\\
//I multiply by 32 because thats the size of the tiles. 32 pixels. \\
//*****************************************************************\\

CharPositionX!=CharStartX! * 32
CharPositionY!=CharStartY! * 32
XStart!=XStart! * 32
YStart!=YStart! * 32
XEnd!=XEnd! * 32
YEnd!=YEnd! * 32
EnemyPositionX[1]!=EnemyStartX[1]! * 32
EnemyPositionY[1]!=EnemyStartY[1]! * 32
EnemyPositionX[2]!=EnemyStartX[2]! * 32
EnemyPositionY[2]!=EnemyStartY[2]! * 32
EnemyPositionX[3]!=EnemyStartX[3]! * 32
EnemyPositionY[3]!=EnemyStartY[3]! * 32
EnemyPositionX[4]!=EnemyStartX[4]! * 32
EnemyPositionY[4]!=EnemyStartY[4]! * 32
//Equations End

Done!=0
While(Done!==0)
{
//*************INFORMATION*****************************************\\
//CharDirection is a varible for the direction the character is    \\
//facing. Here it makes sure that it shows the right direction for \\
//the character.                                                   \\
//*****************************************************************\\
If(CharDirection$="SOUTH")
{
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If End
If(CharDirection$="NORTH")
{
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If End
If(CharDirection$="WEST")
{
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If End
If(CharDirection$="EAST")
{
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If End

//*************INFORMATION*****************************************\\
//This for loops puts all the enemy graphics on the map.           \\
//*****************************************************************\\
For (slots! = 1; Slots! <= EnemyAmount!; Slots!++)
{
If(EnemyHealth[slots!]! > 0)
{
SetImageTransparent(EnemyGraphic[slots!]$, EnemyPositionX[slots!]!, EnemyPositionY[slots!]!, EnemySizeX[slots!]!, EnemySizeY[slots!]!, EnemyR!, EnemyG!, EnemyB!)
}//If EnemyHealth End
}//For Loop End

//*************INFORMATION*****************************************\\
//This is the part that decides how fast the enemies should move.  \\
//On the top of the code, on the varibles, there is a varible      \\
//called EnemySpeed, the default speed is between 5-15.            \\
//*****************************************************************\\

EnemySpeed! = EnemySpeed! + 1
If (EnemySpeedTime! == EnemySpeed!)
{
EnemySpeed! = 0
CheckAttackOrMovement()
}

//*************INFORMATION*****************************************\\
//This part checks what button the player pressed.                 \\
//*****************************************************************\\

If (RealTimeBattle! < 1){Get(ButtonPress$)}
If (RealTimeBattle! > 0)
{
Wait(ButtonPress$)
}
If (ButtonPress$ == "UP"){ShowCharGraphic(1)}
If (ButtonPress$ == "DOWN"){ShowCharGraphic(2)}
If (RealTimeBattle! < 1)
{
If (ButtonPress$ == "RIGHT"){ShowCharGraphic(3)}
If (ButtonPress$ == "LEFT"){ShowCharGraphic(4)}
}
If (RealTimeBattle! > 0)
{
If (ButtonPress$ == "RIGHT"){ShowCharGraphic(4)}
If (ButtonPress$ == "LEFT"){ShowCharGraphic(3)}
}
If (ButtonPress$ == "A"){Potion()}
If (ButtonPress$ == "Z"){Attack(1)}
If (ButtonPress$ == "X"){Attack(2)}
If (ButtonPress$ == "C"){Attack(3)}
If (ButtonPress$ == "V"){ArrowAttack()}
}//While Loop End





Method CheckAttackOrMovement()
{
//*************INFORMATION*****************************************\\
//This code checks if all enemies is dead, if so, give the rewards.\\
//*****************************************************************\\
Dead!=0
for(check!=1; check! <= EnemyAmount!; check!++)
{
If(EnemyHealth[check!]! < 1)
{
clear!=check!
EnemyName[clear!]$=""
EnemyGraphic[clear!]$=""
EnemyStrength[clear!]!=0
EnemyMinimumDmg[clear!]!=0
EnemyDefence[clear!]!=0
EnemyHealth[clear!]!=0
SetImage(GrassTile$, EnemyPositionX[clear!]!, EnemyPositionY[clear!]!, EnemySizeX[clear!]!, EnemySizeY[clear!]!)
EnemyStartX[clear!]!=0
EnemyStartY[clear!]!=0
EnemySizeX[clear!]!=0
EnemySizeY[clear!]!=0
EnemyPositionX[clear!]!=1000
EnemyPositionY[clear!]!=1000
Dead!=Dead!+1
}
If(Dead!=EnemyAmount!)
{
//Gain When All Enemies is Dead
EnemyExp!=EnemyExp[1]!+EnemyExp[2]!
EnemyExp!=EnemyExp!+EnemyExp[3]!
EnemyExp!=EnemyExp!+EnemyExp[4]!

EnemyGold!=EnemyGold[1]!+EnemyGold[2]!
EnemyGold!=EnemyGold!+EnemyGold[3]!
EnemyGold!=EnemyGold!+EnemyGold[4]!
GiveGP(EnemyGold!)
GiveExp(playerhandle[0]$, EnemyExp!)
MWin("You gained: <EnemyGold!> Gold and <EnemyExp!> Experience.")
Wait()
Done!=1
RestoreScreen()
End
Done!=1
Run("Empty.prg") //Just to make sure the program ends
}//If Dead = EnemyAmount End
}//For Loop End

//*************INFORMATION*****************************************\\
//This part decides which enemy is gonna move or attack.           \\
//*****************************************************************\\

EnemyTurn!=EnemyTurn!+1
If(EnemyTurn! > EnemyAmount!){EnemyTurn! = 1}
slot!=EnemyTurn!
If (EnemyHealth[slot!]! > 0)
{
//*************INFORMATION*****************************************\\
//This checks if the enemy is 32 pixels from the character, if so  \\
//the enemy will attack, if not, the enemy will move closer to the \\
//character.                                                       \\
//*****************************************************************\\
CharSouth!=CharPositionY[slot!]! + 32
CharNorth!=CharPositionY[slot!]! - 32
CharEast! =CharPositionX[slot!]! + 32
CharWest! =CharPositionX[slot!]! - 32
Movement!=0
If (EnemyPositionY[slot!]! == CharSouth!){EnemyDamage(slot!) Movement=1}
If (EnemyPositionY[slot!]! == CharNorth!){EnemyDamage(slot!) Movement=1}
If (EnemyPositionX[slot!]! == CharEast!){EnemyDamage(slot!) Movement=1}
If (EnemyPositionX[slot!]! == CharWest!){EnemyDamage(slot!) Movement=1}
If (Movement! == 0)
{
If (EnemyPositionY[slot!]! > CharPositionY!){Move!=1} //North
If (EnemyPositionY[slot!]! < CharPositionY!){Move!=2} //South
If (EnemyPositionX[slot!]! > CharPositionX!){Move!=3} //West
If (EnemyPositionX[slot!]! < CharPositionX!){Move!=4} //East
//Clear old enemy tile
SetImage(GrassTile$, EnemyPositionX[slot!]!, EnemyPositionY[slot!]!, EnemySizeX[slot!]!, EnemySizeY[slot!]!)
If (Move!==1){EnemyPositionY[slot!]!=EnemyPositionY[slot!]!-32} //North
If (Move!==2){EnemyPositionY[slot!]!=EnemyPositionY[slot!]!+32} //South
If (Move!==3){EnemyPositionX[slot!]!=EnemyPositionX[slot!]!-32} //West
If (Move!==4){EnemyPositionX[slot!]!=EnemyPositionX[slot!]!+32} //East

If (EnemyPositionX[slot!]!==CharPositionX!)//Checks if enemy is on same X coord as character
{
If (EnemyPositionY[slot!]!==CharPositionY!)//Checks if enemy is on same Y coord as character
{
//Checks what direction the enemy moved in so we can move the same way back
if (move!==1){EnemyPositionY[slot!]!=EnemyPositionY[slot!]!+32}
if (move!==2){EnemyPositionY[slot!]!=EnemyPositionY[slot!]!-32}
if (move!==3){EnemyPositionX[slot!]!=EnemyPositionX[slot!]!+32}
if (move!==4){EnemyPositionX[slot!]!=EnemyPositionX[slot!]!-32}
}//If Y End
}//If X End

//*************INFORMATION*****************************************\\
//We dont want the enemy to walk into another enemy, so this code  \\
//checks to see if a enemy is on another, if so move it.           \\
//*****************************************************************\\

For (slots!=0; Slots! <= EnemyAmount!; Slots!++)
{
If(EnemyHealth[slots!]! > 0)
{
if(slot!=slots!)
{
}
Else
{
if (EnemyPositionX[slots!]! == EnemyPositionX[slot!]!)
{
if (EnemyPositionY[slots!]! == EnemyPositionY[slot!]!)
{
if (move!==1)
{
EnemyPositionY[slot!]!=EnemyPositionY[slot!]! + 32
}
if (move!==2)
{
EnemyPositionY[slot!]!=EnemyPositionY[slot!]! - 32
}
if (move!==3)
{
EnemyPositionX[slot!]!=EnemyPositionX[slot!]! + 32
}
if (move!==4)
{
EnemyPositionX[slot!]!=EnemyPositionX[slot!]! - 32
}
}//If Y End
}//If X End
}//Else End
}//If Enemy Health > 0 End
}//For Loop End
}//If Movement == 0 End
}//If EnemyHealth > 0 End
}//Method CheckAttackOrMovement End





Method ShowCharGraphic(number!)
{
//*************INFORMATION*****************************************\\
//This is the movement method for the character. It checks what    \\
//direction he is moving at, number!=1 is North, number!=2 is South\\
//, number!=3 is West and number!=4 is East. It also have a if     \\
//command that checks if the character should be moved by pixels or\\
//whole tiles.                                                     \\
//*****************************************************************\\

SetImage(GrassTile$, CharPositionX!, CharPositionY!, 32, 32)
if (number! == 1)//North
{
OldY!=CharPositionY!
OldYPlus!=CharPositionY!-32
CharDirection$="NORTH"
If(PixelMovement!<1)
{
CharPositionY!=CharPositionY! - 32
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If PixelMovement < 1 End
If(PixelMovement!>0)
{
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! - 4
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
}//If PixelMovement = 1 End
CheckCharOutOfRange(1)
CheckCharOnSameCoordAsEnemy()
}
if (number! == 2)//South
{
OldY!=CharPositionY!
OldYPlus!=CharPositionY!+32
CharDirection$="SOUTH"
If(PixelMovement!<1)
{
CharPositionY!=CharPositionY! + 32
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If PixelMovement < 1 End
If(PixelMovement!>0)
{
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
CharPositionY!=CharPositionY! + 4
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, CharPositionX!, OldY!, 32, 32)
SetImage(GrassTile$, CharPositionX!, OldYPlus!, 32, 32)
}//If PixelMovement = 1 End
CheckCharOutOfRange(2)
CheckCharOnSameCoordAsEnemy()
}
if (number! == 3)//West
{
OldX!=CharPositionX!
OldXPlus!=CharPositionX!-32
CharDirection$="WEST"
If(PixelMovement!<1)
{
CharPositionX!=CharPositionX! - 32
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If PixelMovement < 1 End
If(PixelMovement!>0)
{
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(ChaWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! - 4
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
}//If PixelMovement = 1 End
CheckCharOutOfRange(3)
CheckCharOnSameCoordAsEnemy()
}
if (number! == 4)//East
{
OldX!=CharPositionX!
OldXPlus!=CharPositionX!+32
CharDirection$="EAST"
If(PixelMovement!<1)
{
CharPositionX!=CharPositionX! + 32
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//If PixelMovement < 1 End
If(PixelMovement!>0)
{
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(ChaEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
CharPositionX!=CharPositionX! + 4
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
SetImage(GrassTile$, OldX!, CharPositionY!, 32, 32)
SetImage(GrassTile$, OldXPlus!, CharPositionY!, 32, 32)
}//If PixelMovement = 1 End
CheckCharOutOfRange(4)
CheckCharOnSameCoordAsEnemy()
}
}//Method ShowCharGraphic End





Method CheckCharOutOfRange(num!)
{
//*************INFORMATION*****************************************\\
//The map need borders, so this is the part that checks if the     \\
//character is trying to run out of the map, if so move him back.  \\
//*****************************************************************\\

if (num! == 1)//North
{
if (CharPositionY! < YStart!)
{
CharPositionY!=CharPositionY!+32
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}
}

if (num! == 2)//South
{
if (CharPositionY! > YEnd!)
{
CharPositionY!=CharPositionY!-32
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}
}

if (num! == 3)//West
{
if (CharPositionX! < XStart!)
{
CharPositionX!=CharPositionX!+32
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}
}

if (num! == 4)//East
{
if (CharPositionX! > XEnd!)
{
CharPositionX!=CharPositionX!-32
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}
}
}//Method CheckCharOutOfRange End





Method CheckCharOnSameCoordAsEnemy()
{
//*************INFORMATION*****************************************\\
//What this does is that it checks if the character walked into    \\
//a enemy, if so move him back to the direction he came from.      \\
//*****************************************************************\\

For (slots!=0; slots! <= EnemyAmount!; slots!++)
{
If(EnemyHealth[slots!]! > 0 )
{
if (EnemyPositionX[slots!]! == CharPositionX!)
{
if (EnemyPositionY[slots!]! == CharPositionY!)
{
SetImage(GrassTile$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!)
if (CharDirection$="NORTH")
{
CharPositionY!=CharPositionY!+32
SetImageTransparent(CharNorth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//Old North, walking to South
if (CharDirection$="SOUTH")
{
CharPositionY!=CharPositionY!-32
SetImageTransparent(CharSouth$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//Old South, walking to North
if (CharDirection$="WEST")
{
CharPositionX!=CharPositionX!+32
SetImageTransparent(CharWest$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//Old West, walking to East
if (CharDirection$="EAST")
{
CharPositionX!=CharPositionX!-32
SetImageTransparent(CharEast$, CharPositionX!, CharPositionY!, CharSizeX!, CharSizeY!, CharR!, CharG!, CharB!)
}//Old East, walking to West
}//If Y End
}//If X End
}//If EnemyHealth > 0 End
}//For Loop End
}//Method CheckCharOnSameCoordAsEnemy End





Method EnemyDamage(slot!)
{
//*************INFORMATION*****************************************\\
//All this does is it removes the HP from the character, that the  \\
//enemy did in damage. After that it checks if the character is    \\
//dead, if so, run the Game Over Program, and end the game.        \\
//*****************************************************************\\
GetStats()
EnemyDmg!=EnemyStrength[slot!]!
EnemyDmg!=EnemyDmg!-PlayerDP!
if(EnemyDmg!<EnemyMinimumDmg[slot!]!)
{
EnemyDmg!=EnemyMinimumDmg[slot!]!
}
PlayerHP!=PlayerHP!-EnemyDmg!
//GiveHP(playerhandle[0]$, -PlayerHP!)
If (PlayerHP! < 1)
{
Mwin("You died!")
Wait
done!=1
Over()
End()
Quit()
}
}//Method EnemyDamage End





Method GetStats()
{
//*************INFORMATION*****************************************\\
//This simply saves the stats into a varible, which is used for    \\
//defending and attacking only.                                    \\
//*****************************************************************\\
GetHP(playerhandle[0]$,PlayerHP!)
//GetMaxHP(playerhandle[0]$,tempmaxhp!)
getfp(playerhandle[0]$,PlayerFP!)
//getlevel(playerhandle[0]$,onelevel!)
GetDP(playerhandle[0]$,PlayerDP!)
//GetLevel(playerhandle[0]$,level!)
//GetMaxSMP(playerhandle[0]$,smpMax!)
//GetSMP(playerhandle[0]$,smp!)  
}





Method Attack(Styles!)
{
//*************INFORMATION*****************************************\\
//This part mostly checks what direcion the character if facing,   \\
//and after that, it check if a enemy is standing a tile before    \\
//that direction, so if he is facing South, the enemy will only    \\
//lose HP if he stands one step down from the character.           \\
//*****************************************************************\\
//The commands below saves the positions around the character.     \\
//*****************************************************************\\
Style!=Styles!
PlayerXWest!=CharPositionX!-32
PlayerXEast!=CharPositionX!+32
PlayerYNorth!=CharPositionY!-32
PlayerYSouth!=CharPositionY!+32

If(CharDirection$ == "WEST")
{
For(pos!=1; pos! <= EnemyAmount!; pos!=pos!+1)
{
If(PlayerXWest! == EnemyPositionX[pos!]!)
{
If(CharPositionY! == EnemyPositionY[pos!]!)
{
CharacterDamage(Style!,pos!)
}// If PlayerPositionY == EnemyPositionY[pos] End
}//If PlayerXWest == EnemyPositionX[pos] End
}//For Loop End
}//If CharDirection == "WEST" End

If(CharDirection$ == "EAST")
{
For(pos!=1; pos! <= EnemyAmount!; pos!=pos!+1)
{
If(PlayerXEast! == EnemyPositionX[pos!]!)
{
If(CharPositionY! == EnemyPositionY[pos!]!)
{
CharacterDamage(Style!,pos!)
}// If PlayerPositionY == EnemyPositionY[pos] End
}//If PlayerXEast == EnemyPositionX[pos] End
}//For Loop End
}//If CharDirection == "EAST" End

If(CharDirection$ == "NORTH")
{
For(pos!=1; pos! <= EnemyAmount!; pos!=pos!+1)
{
If(CharPositionX! == EnemyPositionX[pos!]!)
{
If(PlayerYNorth! == EnemyPositionY[pos!]!)
{
CharacterDamage(Style!,pos!)
}// If PlayerYNorth == EnemyPositionY[pos] End
}//If PlayerPositionX == EnemyPositionX[pos] End
}//For Loop End
}//If CharDirection == "NORTH" End

If(CharDirection$ == "SOUTH")
{
For(pos!=1; pos! <= EnemyAmount!; pos!=pos!+1)
{
If(CharPositionX! == EnemyPositionX[pos!]!)
{
If(PlayerYSouth! == EnemyPositionY[pos!]!)
{
CharacterDamage(Style!,pos!)
}// If PlayerYSouth == EnemyPositionY[pos] End
}//If PlayerPositionX == EnemyPositionX[pos] End
}//For Loop End
}//If CharDirection == "SOUTH" End

}//Method Attack End





Method CharacterDamage(Style!,pos!)
{
//*************INFORMATION*****************************************\\
//This is the follow up of the method above that checks if the     \\
//player can attack. And it checks what button is pressed too,     \\
//because button Z is saved as Style!=1, X is Style!=2 and C is    \\
//Style=3. Style!=4 is for the arrow attack.                       \\
//*****************************************************************\\
GetStats()
If(Style! == 1)
{
Random(AttackOneRange!,Random!)
If(Random!=1){PlayerFP!=PlayerFP!-AttackOne!}
PlayerFP!=PlayerFP!-EnemyDefence[pos!]!
If(PlayerFP! < PlayerMinimumDmg!){PlayerFP!=PlayerMinimumDmg!} //If End
EnemyHealth[pos!]!=EnemyHealth[pos!]!-PlayerFP!
}//If Style == 1 End

If(Style! == 2)
{
Random(AttackTwoRange!,Random!)
If(Random!=1){PlayerFP!=PlayerFP!-AttackTwo!}
PlayerFP!=PlayerFP!-EnemyDefence[pos!]!
If(PlayerFP! < PlayerMinimumDmg!){PlayerFP!=PlayerMinimumDmg!} //If End
EnemyHealth[pos!]!=EnemyHealth[pos!]!-PlayerFP!
}//If Style == 2 End

If(Style! == 3)
{
Random(AttackThreeRange!,Random!)
If(Random!=1){PlayerFP!=PlayerFP!-AttackThree!}
PlayerFP!=PlayerFP!-EnemyDefence[pos!]!
If(PlayerFP! < PlayerMinimumDmg!){PlayerFP!=PlayerMinimumDmg!} //If End
EnemyHealth[pos!]!=EnemyHealth[pos!]!-PlayerFP!
}//If Style == 3 End

If(Style! == 4)
{
Random(ArrowAgility!,Random!)
If(Random!=1){PlayerFP!=PlayerFP!-ArrowDecreaseDmg!}
PlayerFP!=PlayerFP!-EnemyDefence[pos!]!
If(PlayerFP! < PlayerMinimumArrowDmg!){PlayerFP!=PlayerMinimumArrowDmg!} //If End
EnemyHealth[pos!]!=EnemyHealth[pos!]!-PlayerFP!
}//If Style == 3 End
}//Method CharacterDamage End





Method Potion()
{
//*************INFORMATION*****************************************\\
//This part runs if the player pressed the potion button, it       \\
//restores Health to the player.                                   \\
//*****************************************************************\\
If(HealingPotions! > 0)
{
HealingPotion!=HealingPotion!-1
GiveHP(PlayerHandle[0]$, HealingVital!)
}//If Healing Potion End
}//Method Potion End





Method ArrowAttack()
{
//*************INFORMATION*****************************************\\
//This is the arrow attack, its almost the same as the             \\
//Method Attack(Style!), but this is a little bit more advanced.   \\
//It will also check if the arrow hits a enemy, if so the arrow    \\
//dissapears, if not the arrow continues until it reached its range\\
//set in the begining of this bs.                                  \\
//*****************************************************************\\
If(CharDirection$ == "WEST")
{
ArrowLocation!=CharPositionX!
For(ArrowPos!=1; ArrowPos! <= ArrowRangeWest!; ArrowPos!=ArrowPos!+1)
{
SetImageTransparent(GrassTile$, ArrowLocation!, CharPositionY!, 32, 32, CharR!, CharG!, CharB!)
ArrowLocation!=ArrowLocation!-32
SetImageTransparent(ArrowWest$, ArrowLocation!, CharPositionY!, 32, 32, CharR!, CharG!, CharB!)
For(EnemyNum!=1; EnemyNum! <= EnemyAmount!; EnemyNum!=EnemyNum!+1)
{
If(ArrowLocation! == EnemyPositionX[EnemyNum!]!)
{
If(CharPositionY! == EnemyPositionY[EnemyNum!]!)
{
ArrowPos!=ArrowRangeWest!+5 //just to stop the For Loop
CharacterDamage(4,EnemyNum!)
}//If CharPositionY End
}//If Arrow Location End
}//For Loop End
}//For Loop End
SetImageTransparent(GrassTile$, ArrowLocation!, CharPositionY!, 32, 32, CharR!, CharG!, CharB!)
}//If CharDirection == "WEST" End

If(CharDirection$ == "EAST")
{
ArrowLocation!=CharPositionX!
For(ArrowPos!=1; ArrowPos! <= ArrowRangeEast!; ArrowPos!=ArrowPos!+1)
{
SetImageTransparent(GrassTile$, ArrowLocation!, CharPositionY!, 32, 32, CharR!, CharG!, CharB!)
ArrowLocation!=ArrowLocation!+32
SetImageTransparent(ArrowEast$, ArrowLocation!, CharPositionY!, 32, 32, CharR!, CharG!, CharB!)
For(EnemyNum!=1; EnemyNum! <= EnemyAmount!; EnemyNum!=EnemyNum!+1)
{
If(ArrowLocation! == EnemyPositionX[EnemyNum!]!)
{
If(CharPositionY! == EnemyPositionY[EnemyNum!]!)
{
ArrowPos!=ArrowRangeEast!+5 //just to stop the For Loop
CharacterDamage(4,EnemyNum!)
}//If CharPositionY End
}//If Arrow Location End
}//For Loop End
}//For Loop End
SetImageTransparent(GrassTile$, ArrowLocation!, CharPositionY!, 32, 32, CharR!, CharG!, CharB!)
}//If CharDirection == "EAST" End

If(CharDirection$ == "NORTH")
{
ArrowLocation!=CharPositionY!
For(ArrowPos!=1; ArrowPos! <= ArrowRangeNorth!; ArrowPos!=ArrowPos!+1)
{
SetImageTransparent(GrassTile$, CharPositionX!, ArrowLocation!, 32, 32, CharR!, CharG!, CharB!)
ArrowLocation!=ArrowLocation!-32
SetImageTransparent(ArrowNorth$, CharPositionX!, ArrowLocation!, 32, 32, CharR!, CharG!, CharB!)
For(EnemyNum!=1; EnemyNum! <= EnemyAmount!; EnemyNum!=EnemyNum!+1)
{
If(CharPositionX! == EnemyPositionX[EnemyNum!]!)
{
If(ArrowLocation! == EnemyPositionY[EnemyNum!]!)
{
ArrowPos!=ArrowRangeNorth!+5 //just to stop the For Loop
CharacterDamage(4,EnemyNum!)
}//If Arrow Location End
}//If CharPositionY End
}//For Loop End
}//For Loop End
SetImageTransparent(GrassTile$, CharPositionX!, ArrowLocation!, 32, 32, CharR!, CharG!, CharB!)
}//If CharDirection == "NORTH" End

If(CharDirection$ == "SOUTH")
{
ArrowLocation!=CharPositionY!
For(ArrowPos!=1; ArrowPos! <= ArrowRangeSouth!; ArrowPos!=ArrowPos!+1)
{
SetImageTransparent(GrassTile$, CharPositionX!, ArrowLocation!, 32, 32, CharR!, CharG!, CharB!)
ArrowLocation!=ArrowLocation!+32
SetImageTransparent(ArrowSouth$, CharPositionX!, ArrowLocation!, 32, 32, CharR!, CharG!, CharB!)
For(EnemyNum!=1; EnemyNum! <= EnemyAmount!; EnemyNum!=EnemyNum!+1)
{
If(CharPositionX! == EnemyPositionX[EnemyNum!]!)
{
If(ArrowLocation! == EnemyPositionY[EnemyNum!]!)
{
ArrowPos!=ArrowRangeSouth!+5 //just to stop the For Loop
CharacterDamage(4,EnemyNum!)
}//If Arrow Location End
}//If CharPositionY End
}//For Loop End
}//For Loop End
SetImageTransparent(GrassTile$, CharPositionX!, ArrowLocation!, 32, 32, CharR!, CharG!, CharB!)
}//If CharDirection == "SOUTH" End
}//Method ArrowAttack End

_______________
Fan of DA. Keep it going.

Working on other things now. Trying to get my life to pieces.
That was a long time ago I wrote this:
Project: Marovia
Finished: 32%
Edit Post