Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Construed on Wed 23/10/2013 01:38:33

Title: (SOLVED)Bug in my code
Post by: Construed on Wed 23/10/2013 01:38:33
Code (ags) Select


function room_AfterFadeIn()
{
 
if (goblin.View==88){
    goblin.FollowCharacter(player, 0, 0);
}

if (goblin.View==89){
     
     goblin.StopMoving();
     goblin.FollowCharacter(null);
}


aGoblin.Play();
player.PlaceOnWalkableArea();

  if (goblin.View==89) {
    Display("You have triumphed over your enemy!");
     int win=Random(2);
  if (win==0) {
  goldshow += 2;
  Display("You found 2 gold.");
}

  else if (win==1){
  goldshow += 1;
  Display("You found 1 gold.");
}

else {
   goldshow += 0;
   Display("Looks like that goblin lost at the latest poker game.");
}
    Display ("You now have, %d gold", goldshow );
  }

int ran=Random(7777);
if (ran==777) goblin.ChangeRoom(20, 279, 121);
}

function room_RepExec()
{
 
 
 


if ((goblin.View==88)&&((player.IsCollidingWithChar(goblin) == 1))){
    aBattlestart.Play();
    Display("Hostile intent is evident,  You prepare for battle.");
    player.ChangeRoom(302);
    goblin.FollowCharacter(null);
   }
}

function room_LeaveTop()
{
player.ChangeRoom(9, 163, 168);
aGoblin.Stop();
goblin.FollowCharacter(player, 0, 0);
goblin.ChangeRoom(302, 300, 300);
goblin.ChangeView(88);
monsterz=30;

}

This code is for a certain room where a goblin appears and fights you.
The problem is when the fight it over he changes to a new view which is what he's supposed to do, but every like 15 seconds he changed to the walking view for like 2 seconds even though he's supposed to be on the dead view.
Title: Re: Bug in my code
Post by: Scavenger on Wed 23/10/2013 01:48:53
Did you set an Idle view for the goblin? You may want to use SetIdleView to turn that off. It sounds like his walking animation was unwittingly set to that, if it's happening at 15 second intervals.
Title: Re: Bug in my code
Post by: Khris on Wed 23/10/2013 08:51:56
Two other things:

This line does absolutely nothing:
Code (ags) Select
  goldshow += 0;

This ChangeRoom's chance of happening is 1 in 7777 or 0,0128%:
Code (ags) Select
  int ran=Random(7777);
  if (ran==777) goblin.ChangeRoom(20, 279, 121);

Is this really what you want, in room after fadein (which is executed once, not continuously)?
Title: Re: Bug in my code
Post by: Construed on Tue 29/10/2013 11:08:19
Thanks savage, fixed er right up!

Code (ags) Select

      int ran=Random(7777);
      if (ran==777) goblin.ChangeRoom(20, 279, 121);

I'm not really sure khris, the goblin seems to enter the room every time and pretty quickly, maby too quickly :(

Code (ags) Select

  goldshow += 0;

Lol indeed!

Thanks guys!

-J