I've finally caught up to the point i was at before my game.agf crashed and am working upon the battle system again.
I'm looking for people who may have spare time to comment on how i can improve the battle systems stability and accuracy also ways in increment random damages, random exp etc...
Room script:
[code]
///Put in room that brings character to the fight room.
// room script file Room #21
//////////////////Room entrances/Exits
function hHotspot1_WalkOn()
{
player.ChangeRoom(20, 280, 126);
}
function hHotspot2_WalkOn()
{
player.ChangeRoom(22, 42, 126);
}
function hHotspot3_WalkOn()
{
player.ChangeRoom(25, 165, 170);
}
//////////////////////End Room entrances/Exits
//////////////////collision code between goblin and player
function room_RepExec()
{
if ((goblin.View==88)&&((player.IsCollidingWithChar(goblin) == 1))){
Display("Hostile intent is evident, You prepare for battle.");
player.ChangeRoom(301);
goblin.FollowCharacter(null);
}
}
////////////end collision
///////////////goblin random appearance
function room_AfterFadeIn(){
int ran=Random(7777);
if (ran==777) goblin.ChangeRoom(21, 279, 121);
}
///////////end random appearance
////////////goblin follow character
function room_FirstLoad()
{
goblin.FollowCharacter(player, 0, 0);
}
/////////////end follow character
[/code]
Fight room script Room # 301:
[code]
// room script file
function room_AfterFadeIn(){
///////monster/hero health
monsterui.Visible=true;
player.PlaceOnWalkableArea();
/////goblin attack
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
//////so goblin corpse wont follow character after fight
goblin.FollowCharacter(null);
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
}
function room_RepExec()
{
////////change player views to bigger views for in battle
if ((player.View==42)||(player.View==16)) {
player.ChangeView(85);
object[0].SetView(82);
}
else if ((player.View==17)||(player.View==59)) {
player.ChangeView(87);
object[0].SetView(84);
}
else if ((player.View==18)||(player.View==58)) {
player.ChangeView(86);
object[0].SetView(83);
}
if (IsKeyPressed(eKeyUpArrow) == 1){
//////////hero sword object
object[0].Animate(0, 3, eOnce, eBlock);
object[0].Animate(1, 3, eOnce, eBlock);
int dmg=Random(5);
if (dmg==0) monsterz-=1;
else if (dmg==1) monsterz-=2;
else if (dmg==2) monsterz-=3;
else if (dmg==3) monsterz-=4;
else if (dmg==4) monsterz-=5;
else if (dmg==5) monsterz-=6;
/////////////////goblin attack
object[1].SetView(56);
object[1].Animate(0, 25, eOnce, eBlock);
if (dmg==0) health-=0;
else if (dmg==1) health-=1;
else if (dmg==2) health-=2;
else if (dmg==3) health-=3;
else if (dmg==4) health-=4;
else if (dmg==5) health-=5;
}
///////bring to prev room if monster is dead
else if (monsterz<=0) {
int p=player.PreviousRoom;
player.ChangeRoom(p, 160, 120);
goblin.ChangeRoom(p, 160, 120);
player.PlaceOnWalkableArea();
////////////////////change the players views and speeds accordingly
if (player.View==85){
player.ChangeView(16);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
else if (player.View==86) {
player.ChangeView(18);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
else if (player.View==87) {
player.ChangeView(17);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
///////////////tally expierance
if ((expierance % 1) == 0) {
level++;
expierance += 15;
player_maxhealth += 5;
player_maxmana += 5;
player_maxstamina += 5;
strength += 1;
Display ("You have reached level %d And now have, %d strength, %d health, %d mana, %d stamina, %d gold",level, strength, player_maxhealth, player_maxmana,player_maxstamina, goldshow );
int win=Random(2);
monsterui.Visible=false;
goblin.ChangeView(89);
if (monsterz <= 0){
///////////////random amounts of gold added according to random
if (win==0) goldshow += 20;
else if (win==1) goldshow += 10;
else goldshow += 5;
}
}
}
}
////////////change player views and weapons according to class
function room_Load()
{
if ((player.View==42)||(player.View==16)) {
player.ChangeView(85);
object[0].SetView(82);
}
else if ((player.View==17)||(player.View==59)) {
player.ChangeView(87);
object[0].SetView(84);
}
else if ((player.View==18)||(player.View==58)) {
player.ChangeView(86);
object[0].SetView(83);
}
}
function room_Leave()
{
Display("You have triumphed over your enemy!");
}
[/code]
