Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candle on Fri 31/12/2004 03:20:46

Title: Bird in room and **Squawk Squawk Squawk** [SOLVED]
Post by: Candle on Fri 31/12/2004 03:20:46
I just want him to say **Squawk  Squawk  Squawk **  random times with out blocking . whats the easy way to do this ?
Title: Re: Bird in room and **Squawk Squawk Squawk **
Post by: Gilbert on Fri 31/12/2004 03:33:00
You may try using DisplaySpeechBackground() and some scripting. Like for example:

Define necessary variables on top of the room's script:
int overid, squawk;

Then in repeatedly execute of that room:

if (squawk==0) {  //If bird is not talking
  if (Random(10)==0) { //so it'll be 1/10 chance, increase that 10 if you want it to speak less frequently and decrease if you ant the opposite
    squawk=1;
    overid=DisplaySpeechBackground(BIRD, "**Squawk  Squawk  Squawk **");
  } else if (IsOverlayValid (overid)==0) squawk=0;
Title: Re: Bird in room and **Squawk Squawk Squawk **
Post by: Candle on Fri 31/12/2004 03:42:14
Thank you , I'll give it a try .
Title: Re: Bird in room and **Squawk Squawk Squawk **
Post by: Barbarian on Fri 31/12/2004 03:43:26
Okay, this is just one possible example of how you might do something like that:

For the room you want to add the random "Squawking", and at the "Player enters screen (before fadein)" part, add a "Run Script" command, and in the script have a command such as: SetTimer(1,Random(200+400));

Then in that room's Repeatedly Execute part, add another script with commands such as:
if (IsTimerExpired(1)==1){ Ã, 

PlaySound(4);

SetTimer(1,Random(200+400));
}


Whereas Sound number 4 is your "Squawk" sound effect (or whatever number it is for your game). And you can change the Timer's (200+400) part to either lower number to have the Squawk sound play more frequently or increse the number higher to slow down the frequency. If you wanted actual text message to appear rather than an sound-effect, you could easily replace or add a DisplaySpeech command in where the "PlaySound(4);" part of the script was.

*Edit, I notice Gilbot was adding a reply at the same time I was entering my reply, but I'll still post my message as another option for you to consider.
Title: Re: Bird in room and **Squawk Squawk Squawk **
Post by: Candle on Fri 31/12/2004 03:53:22
Thanks Barbarian , I got yours to work were the other one only  ran the one time and that was it . I messed with the time but didn't seem to help .but yours works fine .
Thanks .
Title: Re: Bird in room and **Squawk Squawk [SOLVED]
Post by: Gilbert on Fri 31/12/2004 04:05:42
BTW Barbarian, I suppose your line was intended to be:

SetTimer(1,200+Random(400));

which may work better, right? ;)
Title: Re: Bird in room and **Squawk Squawk [SOLVED]
Post by: Candle on Fri 31/12/2004 04:06:40
Quote from: Gilbot V7000a on Fri 31/12/2004 04:05:42
BTW Barbarian, I suppose your line was intended to be:

SetTimer(1,200+Random(400));

which may work better, right? ;)

Seems to work fine now ?