(SOLVED)Bug in my code

Started by Construed, Wed 23/10/2013 01:38:33

Previous topic - Next topic

Construed

Code: ags


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.
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Scavenger

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.

Khris

Two other things:

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


This ChangeRoom's chance of happening is 1 in 7777 or 0,0128%:
Code: ags
  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)?

Construed

Thanks savage, fixed er right up!

Code: ags

      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

  goldshow += 0;

Lol indeed!

Thanks guys!

-J

I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

SMF spam blocked by CleanTalk