Non blocking idle sequence

Started by Andrea1992, Fri 05/03/2021 11:26:22

Previous topic - Next topic

Andrea1992

Hellou guys,

Is there any simple way to create an idle and non blocking sequence?

Something similar to the BgSpeech module but instead of only speech I want to queue a number of different actions.

For example, i have a dog in a room. Its actions would be:

Code: ags

function perroIdle()
{
walk to (randomX, randomY)
wait random couple of seconds 
walk to (randomX, randomY)
animate a specific view
say something
.
.
.
more random actions
}


I want this function to repeat but if the main character interacts with the dog it should pause, then continues.

I need to do this for a lot of characters in my game and so far I have used a ridiculous amount of timers to control, literally, each action and it's not yet a smooth idle sequence, have had a lot of issues.

So, any advice would be very much appreciated.

Matti

#1
Do the actions have to happen in a specific order? It would be easier to randomize them, because then you could do something like this in the rep_exec:

Code: ags

if (cDog.Animating == false && cDog.Moving == false)
{
  int r = Random(5);
  if (r == 1) cDog.Walk(x,y);
  if (r == 2) cDog.Animate(..)
  if (r == 3) cDog.Say("...");
  ...
}

Crimson Wizard

Matti, it's "Random", not "random", this caused another person to make a mistake earlier in another forum thread.

https://adventuregamestudio.github.io/ags-manual/Globalfunctions_General.html#random

Matti

Ah, sorry, corrected! I'm not sure why I keep repeating that mistake.

SMF spam blocked by CleanTalk