Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mats Berglinn on Sat 01/10/2005 18:00:32

Title: Randomly idle-veiws
Post by: Mats Berglinn on Sat 01/10/2005 18:00:32
Is it possible to have a idle veiw for the main character that is randomly selected between three or more veiws, like in DOTT? If yes, then how?
Title: Re: Randomly idle-veiws
Post by: RickJ on Sat 01/10/2005 22:06:30
I think you could do something like the following:

#define IDLE_VIEW   7
#define IDLE_DELAY  10

int IdleTmr=IDLE_DELAY;

repeatedly_execute() {
   IdleTmr--;
   if (IdleTmr<) {
      Character.SetIdleView(FIRST_VIEW+Random(5));
      IdleTmr = IDLE_DELAY;
   }
}
Title: Re: Randomly idle-veiws
Post by: Mats Berglinn on Sun 02/10/2005 07:09:22
I think that's for the 2.7 version but what about 2.62 version?
Title: Re: Randomly idle-veiws
Post by: RickJ on Sun 02/10/2005 08:20:46
CharacterSetIdleView();
Title: Re: Randomly idle-veiws
Post by: Mats Berglinn on Sun 02/10/2005 09:27:10
You mean "SetCharacterIdle". You're not telling me the full code for the 2.62 Version, only the SetCharacterIdle bit. Please, tell me the whole code.
Title: Re: Randomly idle-veiws
Post by: RickJ on Sun 02/10/2005 19:26:25
Sorry Mats for the confusion.  I thought that would have been enough.  Anyway here is the entire code snippet for AGS 2.62.   It assumes that there IDLE_NUMBER_OF_VIEWS idle views consecutively numbered with the first one being given by the constant IDLE_VIEW.  The constant IDLE_DELAY determines how often the selection is changed.    You can set these constants to whatever numbers that give the best results in your opinion.   


#define IDLE_NUMBER_OF_VIEWS   5
#define IDLE_VIEW   7
#define IDLE_DELAY  10

int IdleTmr=IDLE_DELAY;

repeatedly_execute() {
   IdleTmr--;
   if (IdleTmr<) {
      CharacterSetIdle(EGO,FIRST_VIEW+Random(IDLE_NUMBER_OF_VIEWS));
      IdleTmr = IDLE_DELAY;
   }
}
Title: Re: Randomly idle-veiws
Post by: Kweepa on Thu 06/10/2005 04:33:04
You need to be careful with Random().
If you call Random(5), it returns one of 6 possible values 0..5.
So, in that code you should use Random(IDLE_NUMBER_OF_VIEWS-1).