Author Topic: Making objects cycle multiple times without using multiple flags  (Read 7236 times)

0 Members and 1 Guest are viewing this topic.

Offline Hysler

I'm a ways into making my AGI game and it's turning out to be amazing.  I've been trying to do something for a while now that I sort of skipped over because I couldn't figure out exactly how to do it though.  In many AGI games that I've played, a character will animate before he/she speaks to you.  For example, in Leisure Suit Larry 1 there are many instances such as talking to the drunk in Leftys bar, or talking to the convenience store clerk where they will move their mouths a few times before a message box pops up. 

Whenever I attempt this the message box will pop up first and then the object will animate.  I've done things like:

if (said("talk","man")) {                   if (said("talk","man")) {
  end.of.loop(o1,f50);              and     end.of.loop(o1,f50);
  print("blah,blah,blah");                  }
}                                                   if (f50) {
                                                       print("blah");
                                                       reset (f50);
                                                      }
The latter does what I want (sort of) because it goes through the animation first before displaying the message box.  But what I would like to do is have the object cycle multiple times and then display the message.

I understand there are a few ways to go about doing it like making multiple flags that use the end.of.loop command or making my view have more cels for the animation, but I'm sure there is a correct way to do it that I can't think of possibly with the use of variables or something.  Can anyone help? 

Thanks  :)



Offline lance.ewing

Re: Making objects cycle multiple times without using multiple flags
« Reply #1 on: August 28, 2011, 01:38:33 PM »
One suggestion that applies to AGI (but unfortunately not to SCI at the moment) is to look at the source code for the original Sierra games that you have seen this happen in. If you can remember the room in LSL1 where this happened then you can load that game up into one of the AGI editors such as WinAGI or AGI Studio and look over the source code for that room to see how they did it.

AGI has a 1-to-1 mapping from source code to compiled byte code, so tools like AGI Studio and WinAGI can do a pretty good job of reverse engineering the source code so that you can read it. I actually wrote the very first tool to do that kind of source code decompiling for AGI. It was a tool called SHOWLOG (Show Logic). I don't think many people used it at the time (around 1997) because it wasn't long after that that Peter Kelly released AGI Studio with the same feature. Peter and I were working together at the time to reverse engineer AGI and he used a lot of what I discovered with SHOWLOG to build the LOGIC support in to AGI Studio.

Offline klownstein

Re: Making objects cycle multiple times without using multiple flags
« Reply #2 on: August 28, 2011, 08:15:41 PM »
One option that I have used is to use a variable as a counter.  Set the variable to 0 (v200=0) at the start of your logic.  Then, each time the view loops, have it add 1 to the variable (v200++).  You can have logic that cuts in at any number of cycles.  The good thing about this is that the variable will reset to 0 every time the player enters the room and you can reuse the same variable in the next room assuming you set it back to 0 in that room.  Your code may look something like this:

(AT THE BEGINNING OF YOUR LOGIC, ONLY LOADED ONCE)
v200=0;
...

(LATER IN THE MAIN BODY OF THE LOGIC)
...
if (said("talk","man")){
  set(f50)
}
if ((isset(f50)) && (v200!=5)) {
  end.of.loop(o1,f50);
  v200++
  reset (f50);
}
if(v200==2){
  print("blah, blah, blah");
}
if(v200==4){
  print("La di da da");
}


Hope that helps.

-klownstein

Offline lance.ewing

Re: Making objects cycle multiple times without using multiple flags
« Reply #3 on: August 29, 2011, 02:38:03 AM »
Not sure how much help this is but I recalled overnight that the first room (room 2) in my Ruby Cast game had something like what you described. The old man starts moving his mouth before the words pop up on the screen. Unfortunately I don't have the original source code with me any more but I opened up the game in AGI Studio and the code below appears to be what controls that part of the game:

Code: [Select]
if (v41 == 1) {
  set.loop(o1,1);
  set.cel(o1,0);
  start.cycling(o1);
  v41 = 2;
}
if (v41 == 2) {
  v42++;
  if (v42 > 10) {
    v42 = 0;
    v41 = 3;
    set.loop(o1,0);
    set.cel(o1,0);
  }
}
if (v41 == 3) {
  v41 = 4;
  reset(f15);
  v21 = 4;
  print.at("\"Ah, hgh, eh, hmpf, er ...\"",4,25,12);
  v21 = 8;
  print.at("\"Hah!! I almost forgot how to speak for a second there.\"",3,20,17);
  v21 = 8;
  print.at("\"Well, how you doing young son? Welcome to Adventure Park.\"",3,20,17);
  v21 = 8;
  print.at("\"Adventure Park? I thought this was a beach!!!\"",3,2,17);
}
if (v41 == 4) {
  set.loop(o1,2);
  set.cel(o1,0);
  start.cycling(o1);
  v41 = 5;
  v42 = 0;
}
if (v41 == 5) {
  v42++;
  if (v42 > 10) {
    v42 = 0;
    v41 = 6;
    set.loop(o1,0);
    set.cel(o1,0);
  }
}
if (v41 == 6) {
  v21 = 8;
  print.at("\"Good heavens no! It is far worse than that!\"",3,22,17);
  v21 = 20;
  print.at("\"You are now part of the game my friend. You can't leave until you "
           "collect the fourteen gold coins and place them in the ruby cast.\"",2,15,23);
  v21 = 26;
  print.at("\"Of course, you'll find it much harder now that the equipment "
           "isn't being maintained. Blow me down if the caretaker didn't just "
           "up and jump off that cliff into the void.\"",2,10,28);
  v21 = 8;
  print.at("\"Darndest thing I ever did see! (Stupid git)\"",3,21,17);
  v21 = 8;
  print.at("\"So where abouts is the ocean?\"",3,2,17);
  v21 = 20;
  print.at("\"There is no ocean here young man. We only have a lake, a river "
           "and a waterfall. This here is desert sand, not beach sand.\"",2,15,23);
  v21 = 16;
  print.at("\"By the way, I'm the gate keeper and I'm probably the only friend "
           "you've got in this world.\"",3,17,23);
  v21 = 8;
  print.at("\"Good luck on your quest.\"",3,22,17);
  observe.horizon(o0);
  accept.input();
  player.control();
  v41 = 0;
  reset(f48);
}

In the original source code I would have given the variables and flags more meaningful names. It looks like v41 is controlling what part of the sequence of movements it is up to. It looks like it uses different loops for different parts of the sequence. It starts with loop 1 and cycles through that and then when v42 (a second variable) is greater than 10 it stops cycling and switches to another loop. It then displays some of the dialog text between the two characters and after that it starts cycling through loop 2, sets v42 back to 0 and then increments v42 on each cycle, once again until it reaches 10, at which point it displays some more dialog text.

So it is using v42 to count how many game cycles the loop has cycled through and when it reaches a certain value then it stops the animation. I guess this is an alternative to end.of.loop. I suspect that the loops that it is cycling through are very short loops that simply open and close the mouth, so perhaps using end.of.loop felt a bit awkward to me to use for a short loop and I simply left it to cycle through the loop for ten cycles.
« Last Edit: August 29, 2011, 02:38:06 PM by lance.ewing »

Offline Hysler

Re: Making objects cycle multiple times without using multiple flags
« Reply #4 on: August 29, 2011, 07:14:16 PM »
Alright I just can't thank you guys enough!  I was racking my brain for a while trying to figure out how to do this and now I understand how to.  It's funny because while I was looking over the code for Leisure Suit Larry I saw what you (Lance) put down, but I didn't understand what the variables were for or what they were doing.  I'm so glad that I know how to do this now and it's making things a lot easier for me.  I severely thank you guys, I really appreciate you taking the time to answer me  :).


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.031 seconds with 22 queries.