! phototalk.inf by Adam Cadre

! This file contains those portions of the Photopia source code dealing
! with its menu conversation system.  Its principles differ little from
! my binary-flag module, flags.h.

! The basic idea is that each NPC is given a number.  Available quips are
! set thusly: SetQuip([NPC's #],[quip #],[1=on 0=off]); and you can see
! whether a quip is on using QuipOn([NPC's #],[quip #]);.

Array qflag -> 6;   ! This number should be greater than the number of
                   ! speeches in the game divided by eight.

Array quips -> 4 1 10 7 2 3 4 3 5 1 1 1;   ! This is the how many speeches
                                          ! each character has, sorted by
                                          ! that character's number.

Global selected; ! the chosen dialogue option

[ Initialise;
  SetQuip(0,0,1); SetQuip(0,1,1); SetQuip(0,2,1); SetQuip(1,0,1);
  SetQuip(2,0,1); SetQuip(2,1,1); SetQuip(2,6,1); SetQuip(3,3,1);
  SetQuip(4,0,1); SetQuip(4,1,1); SetQuip(5,1,1); SetQuip(5,2,1);
  SetQuip(6,0,1); SetQuip(6,2,1); SetQuip(6,3,1); SetQuip(7,0,1);
  SetQuip(7,1,1); SetQuip(7,2,1); SetQuip(8,0,1); SetQuip(8,1,1);
  SetQuip(8,2,1); SetQuip(8,3,1); SetQuip(8,4,1); SetQuip(9,0,1);
  SetQuip(10,0,1); SetQuip(11,0,1);
];

[ TalkSub x y z ok;

! Talking to yourself. [Each PC was given number 999.]

 if (noun.number == 999) "Talking to yourself is a sign of impending mental
    collapse.";

! If it can't talk, you can't talk to it.

 if (noun hasnt animate) {
    if (location has white) "[You can only speak to living creatures.]";
    "You can only speak to living creatures.";
 }

! Count up all the lines by previous characters.

 if (noun provides number) {
    for (x=0: x<noun.number: x++) {
       y = y + quips->x;
    }
 }

! Check to make sure you have something to say.

 for (x=y: x<y+quips->noun.number: x++) {
    if (QuipOn(noun.number,x-y)) { ok++; }
 }

! Okay, let's put something on the screen.

 if (ok > 0) {
    print "Please select one:^^";

! List the lines you have to choose from.

    for (x=y: x<y+quips->noun.number: x++) {
       if (QuipOn(noun.number,x-y)) {
          z++;
          print "(", z, ") ";
          SayQ(noun.number,x-y);
       }
    }

! Get the choice and respond to it.

    new_line; GetDial(z);
    if (selected ~= 0) {
       ok = 0; new_line;
       for (x=y: x<y+quips->noun.number: x++) {
          if (QuipOn(noun.number,x-y)) {
             ok++;
             if (ok == selected) { Respond(noun.number,x-y); }
          }
       }
    }
    rtrue;
 }
 "You can't think of anything in particular to say.";
];

[ GetDial max n;
 do {
    print "Select an option or 0 to say nothing >> ";
    read buffer parse DrawStatusLine;
    n = TryNumber(1);
 } until ((n >= 0) && (n <= max));
 if (n == 0) { print "^You decide not to say anything after all.^"; }
 selected = n;
];

[ SetQuip char line onoff x y z n;
 for (x=0: x<char: x++) {
    n = n + quips->x; }
 n = n + line;
 y = n / 8;
 z = n % 8;
 z = Power(2,z);
 if (onoff == 1) {
    qflag->y = qflag->y | z; }
 if (onoff == 0) {
    qflag->y = qflag->y & ~z; }
];

[ QuipOn char line x y z n;
 for (x=0: x<char: x++) {
    n = n + quips->x; }
 n = n + line;
 y = n / 8;
 z = n % 8;
 z = Power(2,z);
 if (qflag->y & z == z) { return(1); }
 return(0);
];

[ Power a b c sum;
 sum = a;
 if (b == 0) { return(1); }
 if (b == 1) { return(a); }
 for (c=0: c<b-1: c++) {
    sum = sum * a;
 }
 return(sum);
];

[ SayQ char line;
 switch (char) {
    0: switch (line) {
          0: print ">ASK ROB ABOUT BLOOD ALCOHOL LEVEL^";
          1: print ">ASK ROB ABOUT THOSE CHICKS^";
          2: print ">ROB, PLEASE PULL THE FUCK OVER^";
          3: print ">ROB, PULL OVER AND LET ME OUT^";
       }
    1: switch (line) {
          0: print ">GABRIEL, PERFORM CPR^";
       }
    2: switch (line) {
          0: print ">TELL ALLEY ABOUT INVERSE SQUARE LAW^";
          1: print ">TELL ALLEY ABOUT CRYSTALLINE SPHERES^";
          2: print ">TELL ALLEY ABOUT SOLAR RADIATION^";
          3: print ">TELL ALLEY ABOUT GALLIUM PRODUCTION^";
          4: print ">TELL ALLEY ABOUT PLANETARY ACCRETION^";
          5: print ">TELL ALLEY ABOUT DINOSAUR EXTINCTION^";
          6: print ">ALLEY, COME INSIDE^";
          7: print ">TELL ALLEY ABOUT ASTRONAUT SELECTION^";
          8: print ">TELL ALLEY ABOUT SPACE CAMP^";
          9: print ">ALLEY, COME INSIDE AND I MEAN IT THIS TIME^";
       }
    3: switch (line) {
          0: print ">ASK ALLEY FOR AN ORANGE^";
          1: print ">ALLEY, GIVE ME YOUR ORANGE^";
          2: print ">TELL ALLEY ABOUT THE SEYCHELLES^";
          3: print ">ALLEY, PLEASE COME DOWN FOR A SECOND^";
          4: print ">TELL ALLEY ABOUT OUR LACK OF ANIMOSITY^";
          5: print ">ASK ALLEY ABOUT POSSIBLE PARAMOURS^";
          6: print ">ASK ALLEY TO THE DANCE ON FRIDAY^";
       }
    4: switch (line) {
          0: print ">ASK JOYCE FOR A BALLOON^";
          1: print ">ASK JOYCE IF ALLEY LIKES ME^";
       }
    5: switch (line) {
          0: print ">ASK SHERRILL ABOUT CANADA^";
          1: print ">ASK SHERRILL FOR A BALLOON^";
          2: print ">ASK SHERRILL IF ALLEY LIKES ME^";
       }
    6: switch (line) {
          0: print ">ASK ALLEY ABOUT HOW I SOUND LIKE HER DAD^";
          1: print ">ASK ALLEY ABOUT INORDINATE GLEE^";
          2: print ">TELL ALLEY ABOUT WENDY'S UNDYING ADORATION^";
          3: print ">ASK ALLEY IF SHE CAN BABYSIT ON THURSDAY^";
       }
    7: switch (line) {
          0: print ">ASK SALESMAN ABOUT QUEEN^";
          1: print ">ASK SALESMAN FOR SOME RAIN^";
          2: print ">ASK SALESMAN ABOUT WOLF^";
       }
    8: switch (line) {
          0: print ">ASK ALLEY ABOUT HER HOMEWORK^";
          1: print ">ASK ALLEY FOR A GLASS OF WATER^";
          2: print ">ASK ALLEY WHERE SHE GETS HER IDEAS^";
          3: print ">ASK ALLEY ABOUT HOW I GET HOME^";
          4: print ">ASK ALLEY ABOUT THE QUEEN^";
       }
    9: switch (line) {
          0: print ">TELL ALLEY THANKS FOR BABYSITTING^";
       }
    10: switch (line) {
          0: print ">ASK SAM ABOUT PHOTOPIA^";
       }
    11: switch (line) {
          0: print ">ASK ALLEY FOR A HINT^";
       }
 }
];

[ Respond char line;
 switch (char) {
    0: switch (line) {
          0: SetQuip(0,0,0); "~Lower than yours, bud,~ Rob says.";
          1: SetQuip(0,1,0); "~Yeah, we should [...] they changed clothes?~";
          2: SetQuip(0,2,0); SetQuip(0,3,1);
             "~Only reason I'd [...] dude,~ Rob says.";
          3: noguilt = 1;   ! note that there's no need to worry about the
                            ! character's quip settings if that character
                            ! will never appear again -- and also note that
                            ! you can have more in these blocks than just
                            ! strings
             print "Rob shakes his [...] in the distance...^";
             Pause(); Red();
       }
    1: switch (line) {
          0: SetQuip(1,0,0);
             print "~Please, I can't [...] does OVER it.~^"; Pause(); Blue();
       }
    2: switch (line) {
          0: SetQuip(2,0,0); SetQuip(2,1,0); SetQuip(2,2,1);
             "Mary thinks it's [...] or just light?~";
          1: SetQuip(2,1,0); "~Well,~ you say, [...] work?~ Alley asks.";
          2: SetQuip(2,2,0); SetQuip(2,3,1);
             "~Well,~ you say, [...] gallium come from?~";
         3: SetQuip(2,3,0); SetQuip(2,4,1);
                  "~Good question,~ you [...] out of space?~";
         4: SetQuip(2,4,0); SetQuip(2,5,1);
                  "~Maybe indirectly,~ you [...] something like that.~";
         5: print "~That's right,~ you [...] sad about that.^";
                  Pause(); Cyan();
         6: SetQuip(2,0,0); SetQuip(2,1,0); SetQuip(2,2,0); SetQuip(2,3,0);
                  SetQuip(2,4,0); SetQuip(2,5,0); SetQuip(2,6,0); SetQuip(2,7,1);
            SetQuip(2,9,1); "~Okay, kiddo, time [...] gets to go?~";
         7: SetQuip(2,7,0); SetQuip(2,8,1);
            "~Well, it used [...] the best way?~";
         8: print "~That's the best [...] sad about that.^";
            Pause(); Cyan();
         9: print "~Okay, no more [...] sad about that.^";
            Pause(); Cyan();
       }
    3: switch (line) {
          0: SetQuip(3,0,0); move apple to jon;
             "Alley digs around [...] it to you.";
          1: SetQuip(3,1,0); move orange to jon;
             print "Alley gives you [...] the WORLD, huh?~^";
             Pause(); @erase_window -1; ChangePlayer(mrmac);
             print "^^"; <<Look>>;
          2: SetQuip(3,2,0); SetQuip(5,0,1);
             "~Hey, that's pretty [...] That was RAD.";
          3: give alley12 general; SetQuip(3,0,1); SetQuip(3,3,0);
             SetQuip(3,4,1); SetQuip(3,5,1); SetQuip(3,6,1);
             move orange to alley12;
             "~Sure, I'm just [...] one?~ she asks.";
          4: SetQuip(3,4,0); "~So, uh, we [...] ~Sure,~ she says.";
          5: SetQuip(3,5,0); "~So, um, are [...] Alley says cheerfully.";
          6: print "You take a [...] like a lifetime.^";
             Pause(); @erase_window -1; ChangePlayer(mrmac);
             print "^^"; <<Look>>;
       }
    4: switch (line) {
          0: SetQuip(4,0,0); SetQuip(5,1,0);   ! Note that I'm turning off
                                               ! quips for a different NPC
                                               ! here, to prevent redundant
                                               ! responses
             "~No way,~ Joyce says. ~We need these.~";
          1: SetQuip(4,1,0); SetQuip(5,2,0);
             "~Does she LIKE [...] guess it is.~";
       }
    5: switch (line) {
          0: SetQuip(5,0,0);
             "~You're just jealous [...] week,~ Sherrill says.";
          1: SetQuip(4,0,0); SetQuip(5,1,0);
             "~No way,~ Sherrill says. ~We need these.~";
          2: SetQuip(4,1,0); SetQuip(5,2,0);
             "~Does she LIKE [...] guess it is.~";
       }
    6: switch (line) {
          0: SetQuip(6,0,0); SetQuip(6,1,1);
             "~Hmm?~ Alley says. [...] it!'~ She smiles.";
          1: SetQuip(6,1,0); "~Well,~ Alley says, [...] of Venus envy.'~";
          2: SetQuip(6,2,0); "~You know, Wendy's [...] down to her.~";
          3: SetQuip(6,3,0); "~I hate to [...] than me anyhow.~";
       }
    7: switch (line) {
          0: SetQuip(7,0,0); "~No one's ever [...] people to stone.~";
          1: SetQuip(7,1,0); <<Buy rain>>;
          2: SetQuip(7,2,0); "~Can't be from [...] nothing to eat.~";
       }
    8: switch (line) {
          0: SetQuip(8,0,0); "~Oh, it's just [...] angles and stuff.~";
          1: SetQuip(8,1,0); move wglass to wendyreal;
             "~Sure thing,~ Alley [...] it,~ she says.";
          2: SetQuip(8,2,0);
             print "Alley puts down [...] starts like this...~^";
             Pause(); BoxPurple();
          3: SetQuip(8,3,0); "~You'll find out [...] choose to do.~";
          4: SetQuip(8,4,0);
             print "~The Queen?~ Alley [...] starts like this...~^";
             Pause(); Purple();
       }
    9: switch (line) {
          0: SetQuip(9,0,0); "~Sure, no problem,~ Alley says. ~I enjoy it.~";
       }
    10: switch (line) {
          0: SetQuip(10,0,0);
          "~Isn't it great?~ [...] completely lucked out!~";
        }
    11: switch (line) {
          0: Hint();
        }
 }
];

Verb 'talk' 'speak'
  * 'to' creature -> Talk
  * 'to' noun   -> Talk;