Randomly idle-veiws

Started by Mats Berglinn, Sat 01/10/2005 18:00:32

Previous topic - Next topic

Mats Berglinn

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?

RickJ

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;
   }
}

Mats Berglinn

I think that's for the 2.7 version but what about 2.62 version?

RickJ


Mats Berglinn

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.

RickJ

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;
   }
}

Kweepa

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).
Still waiting for Purity of the Surf II

SMF spam blocked by CleanTalk