A group of NPC changing room

Started by nightmarer, Mon 26/10/2020 18:17:27

Previous topic - Next topic

nightmarer

Hello all.

I want to make 4 different NPC to leave next room, so the main character can see them, and follow them.
In AfterFadeIn I make this happen, but hte thing is that if I  make this thing it doesn't work.


    1)When the FadeIn finishes Ithey have already left to next room, as they are not blocked.
Code: ags
   Cultist1.Walk(Cultist1.x, 244, eNoBlock);
   Cultist2.Walk(Cultist2.x, 244, eNoBlock);
   Cultist3.Walk(Cultist3.x, 244, eNoBlock);
   Cultist4.Walk(Cultist4.x, 244, eNoBlock);
   
   Cultist1.ChangeRoom(10, 99, 210, eDirectionUpRight);
   Cultist2.ChangeRoom(10, 300, 209, eDirectionUp);
   Cultist3.ChangeRoom(10, 269, 205, eDirectionUpLeft);
   Cultist4.ChangeRoom(10, 444, 209, eDirectionUp);


2) If I block them, then make the move first NPC, then second... and then they leave.
Code: ags
   Cultist1.Walk(Cultist1.x, 244, eBlock);
   Cultist2.Walk(Cultist2.x, 244, eBlock);
   Cultist3.Walk(Cultist3.x, 244, eBlock);
   Cultist4.Walk(Cultist4.x, 244, eBlock);
   
   Cultist1.ChangeRoom(10, 99, 210, eDirectionUpRight);
   Cultist2.ChangeRoom(10, 300, 209, eDirectionUp);
   Cultist3.ChangeRoom(10, 269, 205, eDirectionUpLeft);
   Cultist4.ChangeRoom(10, 444, 209, eDirectionUp);


How can I make them leave at the same time?

Snarky

Make them all non-blocking except the last one.

nightmarer

Well, they at the same time, but it works better than before.

Khris

They disappear at the same time, I assume? Try this:

Code: ags
bool leaving = false;

function room_AfterFadein() {
  leaving = true;
  Cultist1.Walk(Cultist1.x, 244, eNoBlock);
  Cultist2.Walk(Cultist2.x, 244, eNoBlock);
  Cultist3.Walk(Cultist3.x, 244, eNoBlock);
  Cultist4.Walk(Cultist4.x, 244, eBlock);
}

function repeatedly_execute_always() {
  if (leaving) {
    if (Cultist1.Room == player.Room && !Cultist1.Moving) Cultist1.ChangeRoom(10, 99, 210, eDirectionUpRight);
    if (Cultist2.Room == player.Room && !Cultist2.Moving) Cultist2.ChangeRoom(10, 300, 209, eDirectionUp);
    if (Cultist3.Room == player.Room && !Cultist3.Moving) Cultist3.ChangeRoom(10, 269, 205, eDirectionUpLeft);
    if (Cultist4.Room == player.Room && !Cultist4.Moving) Cultist4.ChangeRoom(10, 444, 209, eDirectionUp);
  }
}

nightmarer


SMF spam blocked by CleanTalk