Scripting repeatedly_execute() function for non-eblock char.walk()

Started by , Tue 30/01/2007 21:05:37

Previous topic - Next topic

Cu

First of all, I hope this post is in the proper place, forum registration was very scary.

I have created a room with a 'First Time Player Enters Screen' process that walks another character about it in a sort of cut scene that is entirely reliant on eBlock(). The problem is, I would like that character afterward (once play resumes/eBlock is finished) to continue work in the space station by walking to a different x,y in the room every 8 seconds except without pausing the command processor so that the player can continue to explore the room.

This seemed like it would be very simple at first, but I posted this in advanced tech because the simplest solution I could think of, after fumbling with the interaction editor, was to script the following:

// in room script. goal: every game cycle, 1 is added to the int FATHERMOVE (room var). When this reaches 640 (640 cycles = 8 seconds) the character 'FATHER' is walked to a new location. Upon reaching that x/y, the int FATHERMOVE is reset to 645, where he will move to a new location at 1280, etc, ultimately it will be reset to 0 so that he will walk in rounds about the room.//

int FATHERMOVE;

function repeatedly_execute() {
  if (FATHERMOVE == 5) {   // then time for him to go to the computer thingy
    Character.Walk(FATHER,229,151,eNoBlock); //don't pause c.p.
    FATHERMOVE = 10; // Reset the int 'timer' to 10, to wait 8 sec till' 640
  }
  else {
    FATHERMOVE += 1 // add one to my little integer 'timer'
  }
}

// After this I would like to have more repeatedly_execute() conditionals (just like the above one) to repeatedly check the FATHERMOVE int. and upon 640 walk him to his graph printer, reset to 645, upon 1280 walk him to his sink, reset to 0 so his journey begins again. Only the other conditionals would not add 1 to the integer (because the above conditional handles that).//

For some reason, this does not work. The character simply stops after the opening 'cutscene' and refuses to go on his scheduled meanderings.

SO, I apologize if that is a confusing trainwreck. This is all just my best attempt to have this 'FATHER' character walk to a new location in the room every 8 seconds without pausing the command processor. I know that I could simply make him walk without eBlock in an unending loop of waypoints, but I want him to stay in each place for 8 seconds or so without pausing the command processor. If there is an easier way to go about achieving this goal, any advice would be a huge help.

Thanks again! 8 )

Please don't slap me with a moist trout, to the best of my knowledge this is where this post belongs!

joelcbarker@yahoo.com





Khris

Welcome to the forums, and yes, this is the proper place.

Code: ags
int status;

// old, wrong: function repeatedly_execute() {

function room_x {
Ã,  // room's repeatedly_execute
Ã,  int x;
Ã,  int y;
Ã,  if (IsTimerExpired(1) && cFather.Moving==false) {Ã,  // cFather finished walking or pausing
Ã,  Ã,  status++;
Ã,  Ã,  if (status==11) status=1;Ã,  // 5 waypoints
Ã,  Ã,  if ((status/2)*2!=status) {Ã,  // odd number, walk
Ã,  Ã,  Ã,  if (status==1) { x=229; y=151; }Ã,  // set waypoints here
Ã,  Ã,  Ã,  if (status==3) { x=260; y=178; }
Ã,  Ã,  Ã,  if (status==5) { ... }
Ã,  Ã,  Ã,  cFather.Walk(x,y);Ã,  // eNoBlock is the default setting
Ã,  Ã,  }
Ã,  Ã,  else {Ã,  // even number, pause for 8 seconds
Ã,  Ã,  Ã,  SetTimer(1, 8*GetGameSpeed());
Ã,  Ã,  }
Ã,  }
}


In the room's player enters (after fadein), call SetTimer(1, 4*GetGameSpeed(); to start the sequence.

EDIT: changed function's name

Cu

Hey thanks! That was fast! I'm probably not supposed post thank-yous but here it is anyway. Take it easy

Khris

There's no problem with saying thank you ;)
Did it work? I didn't test it.

SMF spam blocked by CleanTalk