This is the room code that makes the monster appear in the room and follow the character and when the character and player collide it transports the player to the battle room:
[code]
function room_RepExec()
{
//If goblin character = the alive view and is colliding with player, Display battle message and move player to room 301, the battle room.
if ((goblin.View==88)&&((player.IsCollidingWithChar(goblin) == 1))){
Display("Hostile intent is evident, You prepare for battle.");
player.ChangeRoom(301);
goblin.FollowCharacter(null);
}
}
//Random chance of the monster appearing when the player enters the room.
function room_AfterFadeIn()
{
int ran=Random(7777);
if (ran==777) goblin.ChangeRoom(21, 279, 121);
}
//Makes the living goblin character follow the character.
function room_FirstLoad()
{
goblin.FollowCharacter(player, 0, 0);
}
//Resets the goblin after he has been killed and the player leaves the room and changes him back to his living view with his beginning amount of life.
function room_Leave()
{
goblin.ChangeView(88);
monsterz=35;
goblin.FollowCharacter(player, 0, 0);
}
[/code]
This is the battle room code where the battle takes place, then the player is transported back to the previous room he was in afterwards:
[code]
function room_AfterFadeIn()
{
//Turns on the monster/player lifebar "monsterui", places the character in the correct position for the battle.
monsterui.Visible=true;
player.PlaceOnWalkableArea();
//changes the object which acts as the characters sword and hand to the correct one
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
//makes the goblin character stop following so when the battle is over the goblin corpse wont follow you lol.
goblin.FollowCharacter(null);
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
}
function room_RepExec()
//Depending on which character the player chooses this changes him and the sword/hand object to the correct battle view.
{
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);
}
//animates the sword/hand object
if (IsKeyPressed(eKeyUpArrow) == 1)
{
object[0].Animate(0, 3, eOnce, eBlock);
object[0].Animate(1, 3, eOnce, eBlock);
//Causes the monster random damage.
int dmg = Random(5);
monsterz -= dmg + 1;
//Animates the monster object.
object[1].SetView(56);
object[1].Animate(0, 25, eOnce, eBlock);
//Random damage the monster causes
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;
}
//if the monster is dead bring the player back to the room he was in before and placeonwalkable.
else if (monsterz<=0) {
int p=player.PreviousRoom;
player.ChangeRoom(p, 160, 120);
goblin.ChangeRoom(p, 160, 120);
player.PlaceOnWalkableArea();
///Still trying to figure out the best way to decrease the amount of experience gained and stats gained as the player levels
if (level == 1) {
level++;
expierance += 15;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
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 );
if (level > 2)
{
level++;
expierance += 12;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
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 );
if (level > 3) {
level++;
expierance += 10;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
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 );
///gives the player a random amount of gold after the battle.
int win=Random(2);
if (monsterz <= 0){
if (win==0) goldshow += 20;
else if (win==1) goldshow += 10;
else goldshow += 5;
}
}
}
}
}
}
///secondary check to make sure the player changes to the correct view for the battle scenedepending on which character he chose.
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);
}
}
///Displays defeat message, changes the player back to his correct non-battle view, sends a message to the server that the players speed has changed and sets the character to walking speed and view.
function room_Leave()
{
Display("You have triumphed over your enemy!");
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);
}
///removes the healthbars.
monsterui.Visible=false;
///changes the goblin to the dead corpse view.
goblin.ChangeView(89);
}
[/code]
Goblin following character until it collides and starts battle:

Inside the battle room:

It's really messy and some beta testing might be necissary to fully understand it, any help would be greatly appreciated.
If you have any requests on syntax,grammar or explanations please let me know!
But be specific, Remember I am feeble minded

I need to figure out a better way to tally the expeirance and level ups also probley need some type of adjustment as to how much strength,stamina,health,gold etc.... is added....
It needs ALOT of work

PS. I will clean up, organize and format the code as I find time to do so.
I'm not asking anyone to help me with all the problems at once, just give me small little tips here and there, my mind is not advanced enough to handle more than small tidbits at a time.
Thanks,
-Jared