Example #1
0
void quest_list(struct char_data *ch, struct char_data *qm, char argument[MAX_INPUT_LENGTH])
{
  qst_vnum vnum;
  qst_rnum rnum;

  if ((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING)
    send_to_char(ch, "That is not a valid quest!\r\n");
  else if ((rnum = real_quest(vnum)) == NOTHING)
    send_to_char(ch, "That is not a valid quest!\r\n");
  else if (QST_INFO(rnum)) {
    send_to_char(ch,"Complete Details on Quest %d \tc%s\tn:\r\n%s",
                      vnum,
         QST_DESC(rnum),
         QST_INFO(rnum));
    if (QST_PREV(rnum) != NOTHING)
      send_to_char(ch, "You have to have completed quest %s first.\r\n",
          QST_NAME(real_quest(QST_PREV(rnum))));
    if (QST_TIME(rnum) != -1)
      send_to_char(ch,
         "There is a time limit of %d turn%s to complete the quest.\r\n",
          QST_TIME(rnum),
          QST_TIME(rnum) == 1 ? "" : "s");
  } else
    send_to_char(ch, "There is no further information on that quest.\r\n");
}
Example #2
0
void quest_quit(struct char_data *ch)
{
  qst_rnum rnum;

  if (GET_QUEST(ch) == NOTHING)
    send_to_char(ch, "But you currently aren't on a quest!\r\n");
  else if ((rnum = real_quest(GET_QUEST(ch))) == NOTHING) {
    clear_quest(ch);
    send_to_char(ch, "You are now no longer part of the quest.\r\n");
    save_char(ch);
  } else {
    clear_quest(ch);
    if (QST_QUIT(rnum) && (str_cmp(QST_QUIT(rnum), "undefined") != 0))
      send_to_char(ch, "%s", QST_QUIT(rnum));
    else
      send_to_char(ch, "You are now no longer part of the quest.\r\n");
    if (QST_PENALTY(rnum)) {
      GET_QUESTPOINTS(ch) -= QST_PENALTY(rnum);
      send_to_char(ch,
        "You have lost %d quest points for your cowardice.\r\n",
        QST_PENALTY(rnum));
    }
    save_char(ch);
  }
}
Example #3
0
void quest_join(struct char_data *ch, struct char_data *qm, char argument[MAX_INPUT_LENGTH])
{
  qst_vnum vnum;
  qst_rnum rnum;
  char buf[MAX_INPUT_LENGTH];

  if (!*argument)
    snprintf(buf, sizeof(buf),
             "%s What quest did you wish to join?", GET_NAME(ch));
  else if (GET_QUEST(ch) != NOTHING)
    snprintf(buf, sizeof(buf),
             "%s But you are already part of a quest!", GET_NAME(ch));
  else if((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING)
    snprintf(buf, sizeof(buf),
             "%s I don't know of such a quest!", GET_NAME(ch));
  else if ((rnum = real_quest(vnum)) == NOTHING)
    snprintf(buf, sizeof(buf),
             "%s I don't know of such a quest!", GET_NAME(ch));
  else if (GET_LEVEL(ch) < QST_MINLEVEL(rnum))
    snprintf(buf, sizeof(buf),
             "%s You are not experienced enough for that quest!", GET_NAME(ch));
  else if (GET_LEVEL(ch) > QST_MAXLEVEL(rnum))
    snprintf(buf, sizeof(buf),
             "%s You are too experienced for that quest!", GET_NAME(ch));
  else if (is_complete(ch, vnum))
    snprintf(buf, sizeof(buf),
             "%s You have already completed that quest!", GET_NAME(ch));
  else if ((QST_PREV(rnum) != NOTHING) && !is_complete(ch, QST_PREV(rnum)))
    snprintf(buf, sizeof(buf),
             "%s That quest is not available to you yet!", GET_NAME(ch));
  else if ((QST_PREREQ(rnum) != NOTHING) &&
           (real_object(QST_PREREQ(rnum)) != NOTHING) &&
           (get_obj_in_list_num(real_object(QST_PREREQ(rnum)),
       ch->carrying) == NULL))
    snprintf(buf, sizeof(buf),
             "%s You need to have %s first!", GET_NAME(ch),
      obj_proto[real_object(QST_PREREQ(rnum))].short_description);
  else {
    act("You join the quest.",    TRUE, ch, NULL, NULL, TO_CHAR);
    act("$n has joined a quest.", TRUE, ch, NULL, NULL, TO_ROOM);
    snprintf(buf, sizeof(buf),
             "%s Listen carefully to the instructions.", GET_NAME(ch));
    do_tell(qm, buf, cmd_tell, 0);
    set_quest(ch, rnum);
    send_to_char(ch, "%s", QST_INFO(rnum));
    if (QST_TIME(rnum) != -1)
      snprintf(buf, sizeof(buf),
        "%s You have a time limit of %d turn%s to complete the quest.",
        GET_NAME(ch), QST_TIME(rnum), QST_TIME(rnum) == 1 ? "" : "s");
    else
      snprintf(buf, sizeof(buf),
        "%s You can take however long you want to complete the quest.",
 GET_NAME(ch));
  }
  do_tell(qm, buf, cmd_tell, 0);
  save_char(ch);
}
Example #4
0
int add_quest(struct aq_data *nqst)
{
  qst_rnum rnum;
  mob_rnum qmrnum;
  zone_rnum rznum = real_zone_by_thing(nqst->vnum);

  /* The quest already exists, just update it.  */
  if ((rnum = real_quest(nqst->vnum)) != NOWHERE) {
    copy_quest(&aquest_table[rnum], nqst, TRUE);
  } else {
    /* increase the number of quest table entries */
    total_quests++;
    RECREATE(aquest_table, struct aq_data, total_quests );
    /* Initialise top quest strings to null */
    QST_NAME(total_quests - 1) = NULL;
    QST_DESC(total_quests - 1) = NULL;
    QST_INFO(total_quests - 1) = NULL;
    QST_DONE(total_quests - 1) = NULL;
    QST_QUIT(total_quests - 1) = NULL;
    /* Now process enties from the top down to see where the new one goes */
    for (rnum = total_quests - 1; rnum > 0; rnum--) {
      if (nqst->vnum > QST_NUM(rnum - 1))
        break; //found the place
      aquest_table[rnum] = aquest_table[rnum - 1]; //shift quest up one
    }
    copy_quest(&aquest_table[rnum], nqst, FALSE);
  }
  qmrnum = real_mobile(QST_MASTER(rnum));
  /* Make sure we assign spec procs to the questmaster */
  if (qmrnum != NOBODY && mob_index[qmrnum].func &&
     mob_index[qmrnum].func != questmaster)
     QST_FUNC(rnum) = mob_index[qmrnum].func;
  if(qmrnum != NOBODY) 
    mob_index[qmrnum].func = questmaster;

  /* And make sure we save the updated quest information to disk */
  if (rznum != NOWHERE)
    add_to_save_list(zone_table[rznum].number, SL_QST);
  else
    mudlog(BRF, ADMLVL_BUILDER, TRUE,
           "SYSERR: GenOLC: Cannot determine quest zone.");

  return rnum;
}
Example #5
0
void quest_hist(struct char_data *ch)
{
  int i = 0, counter = 0;
  qst_rnum rnum = NOTHING;

  send_to_char(ch, "Quests that you have completed:\r\n"
    "Index Description                                          Questmaster\r\n"
    "----- ---------------------------------------------------- -----------\r\n");
  for (i = 0; i < GET_NUM_QUESTS(ch); i++) {
    if ((rnum = real_quest(ch->player_specials->saved.completed_quests[i])) != NOTHING)
      send_to_char(ch, "\tg%4d\tn) \tc%-52.52s\tn \ty%s\tn\r\n",
 ++counter, QST_DESC(rnum), (real_mobile(QST_MASTER(rnum)) == NOBODY) ? "Unknown" : GET_NAME(&mob_proto[(real_mobile(QST_MASTER(rnum)))]));
    else
      send_to_char(ch,
        "\tg%4d\tn) \tcUnknown Quest (it no longer exists)\tn\r\n", ++counter);
  }
  if (!counter)
    send_to_char(ch, "You haven't completed any quests yet.\r\n");
}
Example #6
0
void quest_progress(struct char_data *ch)
{
  qst_rnum rnum;

  if (GET_QUEST(ch) == NOTHING)
    send_to_char(ch, "But you currently aren't on a quest!\r\n");
  else if ((rnum = real_quest(GET_QUEST(ch))) == NOTHING) {
    clear_quest(ch);
    send_to_char(ch, "Your quest seems to no longer exist.\r\n");
  } else {
    send_to_char(ch, "You are on the following quest:\r\n%s\r\n%s",
        QST_DESC(rnum), QST_INFO(rnum));
    if (QST_QUANTITY(rnum) > 1)
      send_to_char(ch,
          "You still have to achieve %d out of %d goals for the quest.\r\n",
   GET_QUEST_COUNTER(ch), QST_QUANTITY(rnum));
    if (GET_QUEST_TIME(ch) > 0)
      send_to_char(ch,
          "You have %d turn%s remaining to complete the quest.\r\n",
   GET_QUEST_TIME(ch),
   GET_QUEST_TIME(ch) == 1 ? "" : "s");
  }
}
Example #7
0
void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
{
  qst_rnum rnum;
  mob_rnum qmrnum;
  char buf[MAX_STRING_LENGTH];
  char targetname[MAX_STRING_LENGTH];

  if (GET_ADMLEVEL(ch) < ADMLVL_IMMORT)
    send_to_char(ch, "Huh!?!\r\n");
  else if (!*argument)
    send_to_char(ch, "%s\r\n", quest_imm_usage);
  else if ((rnum = real_quest(atoi(argument))) == NOTHING )
    send_to_char(ch, "That quest does not exist.\r\n");
  else {
    sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf));
    switch (QST_TYPE(rnum)) {
      case AQ_OBJ_FIND:
      case AQ_OBJ_RETURN:
        snprintf(targetname, sizeof(targetname), "%s",
                 real_object(QST_TARGET(rnum)) == NOTHING ?
                 "An unknown object" :
    obj_proto[real_object(QST_TARGET(rnum))].short_description);
 break;
      case AQ_ROOM_FIND:
      case AQ_ROOM_CLEAR:
        snprintf(targetname, sizeof(targetname), "%s",
          real_room(QST_TARGET(rnum)) == NOWHERE ?
                 "An unknown room" :
    world[real_room(QST_TARGET(rnum))].name);
        break;
      case AQ_MOB_FIND:
      case AQ_MOB_KILL:
      case AQ_MOB_SAVE:
 snprintf(targetname, sizeof(targetname), "%s",
                 real_mobile(QST_TARGET(rnum)) == NOBODY ?
    "An unknown mobile" :
    GET_NAME(&mob_proto[real_mobile(QST_TARGET(rnum))]));
 break;
      default:
 snprintf(targetname, sizeof(targetname), "Unknown");
 break;
    }
    qmrnum = real_mobile(QST_MASTER(rnum));
    send_to_char(ch,
        "VNum  : [\ty%5d\tn], RNum: [\ty%5d\tn] -- Questmaster: [\ty%5d\tn] \ty%s\tn\r\n"
        "Name  : \ty%s\tn\r\n"
 "Desc  : \ty%s\tn\r\n"
 "Accept Message:\r\n\tc%s\tn"
 "Completion Message:\r\n\tc%s\tn"
 "Quit Message:\r\n\tc%s\tn"
 "Type  : \ty%s\tn\r\n"
        "Target: \ty%d\tn \ty%s\tn, Quantity: \ty%d\tn\r\n"
 "Value : \ty%d\tn, Penalty: \ty%d\tn, Min Level: \ty%2d\tn, Max Level: \ty%2d\tn\r\n"
 "Flags : \tc%s\tn\r\n",
     QST_NUM(rnum), rnum,
 QST_MASTER(rnum) == NOBODY ? -1 : QST_MASTER(rnum),
 (qmrnum == NOBODY) ? "(Invalid vnum)" : GET_NAME(&mob_proto[(qmrnum)]),
        QST_NAME(rnum), QST_DESC(rnum),
        QST_INFO(rnum), QST_DONE(rnum),
 (QST_QUIT(rnum) &&
  (str_cmp(QST_QUIT(rnum), "undefined") != 0)
          ? QST_QUIT(rnum) : "Nothing\r\n"),
     quest_types[QST_TYPE(rnum)],
 QST_TARGET(rnum) == NOBODY ? -1 : QST_TARGET(rnum),
 targetname,
 QST_QUANTITY(rnum),
     QST_POINTS(rnum), QST_PENALTY(rnum), QST_MINLEVEL(rnum),
 QST_MAXLEVEL(rnum), buf);
    if (QST_PREREQ(rnum) != NOTHING)
      send_to_char(ch, "Preq  : [\ty%5d\tn] \ty%s\tn\r\n",
        QST_PREREQ(rnum) == NOTHING ? -1 : QST_PREREQ(rnum),
        QST_PREREQ(rnum) == NOTHING ? "" :
   real_object(QST_PREREQ(rnum)) == NOTHING ? "an unknown object" :
       obj_proto[real_object(QST_PREREQ(rnum))].short_description);
    if (QST_TYPE(rnum) == AQ_OBJ_RETURN)
      send_to_char(ch, "Mob   : [\ty%5d\tn] \ty%s\tn\r\n",
        QST_RETURNMOB(rnum),
 real_mobile(QST_RETURNMOB(rnum)) == NOBODY ? "an unknown mob" :
           mob_proto[real_mobile(QST_RETURNMOB(rnum))].player.short_descr);
    if (QST_TIME(rnum) != -1)
      send_to_char(ch, "Limit : There is a time limit of %d turn%s to complete.\r\n",
   QST_TIME(rnum),
   QST_TIME(rnum) == 1 ? "" : "s");
    else
      send_to_char(ch, "Limit : There is no time limit on this quest.\r\n");
    send_to_char(ch, "Prior :");
    if (QST_PREV(rnum) == NOTHING)
      send_to_char(ch, " \tyNone.\tn\r\n");
    else
      send_to_char(ch, " [\ty%5d\tn] \tc%s\tn\r\n",
        QST_PREV(rnum), QST_DESC(real_quest(QST_PREV(rnum))));
    send_to_char(ch, "Next  :");
    if (QST_NEXT(rnum) == NOTHING)
      send_to_char(ch, " \tyNone.\tn\r\n");
    else
      send_to_char(ch, " [\ty%5d\tn] \tc%s\tn\r\n",
        QST_NEXT(rnum), QST_DESC(real_quest(QST_NEXT(rnum))));
  }
}
Example #8
0
void autoquest_trigger_check(struct char_data *ch, struct char_data *vict,
                struct obj_data *object, int type)
{
  struct char_data *i;
  qst_rnum rnum;
  int found = TRUE;

  if (IS_NPC(ch))
    return;
  if (GET_QUEST(ch) == NOTHING)  /* No current quest, skip this */
    return;
  if (GET_QUEST_TYPE(ch) != type)
    return;
  if ((rnum = real_quest(GET_QUEST(ch))) == NOTHING)
    return;
  switch (type) {
    case AQ_OBJ_FIND:
      if (QST_TARGET(rnum) == GET_OBJ_VNUM(object))
        generic_complete_quest(ch);
      break;
    case AQ_ROOM_FIND:
      if (QST_TARGET(rnum) == world[IN_ROOM(ch)].number)
        generic_complete_quest(ch);
      break;
    case AQ_MOB_FIND:
      for (i=world[IN_ROOM(ch)].people; i; i = i->next_in_room)
        if (IS_NPC(i))
          if (QST_TARGET(rnum) == GET_MOB_VNUM(i))
            generic_complete_quest(ch);
      break;
    case AQ_MOB_KILL:
      if (!IS_NPC(ch) && IS_NPC(vict) && (ch != vict))
          if (QST_TARGET(rnum) == GET_MOB_VNUM(vict))
            generic_complete_quest(ch);
      break;
    case AQ_MOB_SAVE:
       if (ch == vict)
        found = FALSE;
      for (i = world[IN_ROOM(ch)].people; i && found; i = i->next_in_room)
          if (i && IS_NPC(i) && !MOB_FLAGGED(i, MOB_NOTDEADYET))
            if ((GET_MOB_VNUM(i) != QST_TARGET(rnum)) &&
                !AFF_FLAGGED(i, AFF_CHARM))
              found = FALSE;
      if (found)
        generic_complete_quest(ch);
      break;
    case AQ_OBJ_RETURN:
      if (IS_NPC(vict) && (GET_MOB_VNUM(vict) == QST_RETURNMOB(rnum)))
        if (object && (GET_OBJ_VNUM(object) == QST_TARGET(rnum)))
          generic_complete_quest(ch);
      break;
    case AQ_ROOM_CLEAR:
      if (QST_TARGET(rnum) == world[IN_ROOM(ch)].number) {
        for (i = world[IN_ROOM(ch)].people; i && found; i = i->next_in_room)
          if (i && IS_NPC(i) && !MOB_FLAGGED(i, MOB_NOTDEADYET))
            found = FALSE;
        if (found)
   generic_complete_quest(ch);
      }
      break;
    default:
      log("SYSERR: Invalid quest type passed to autoquest_trigger_check");
      break;
  }
}
Example #9
0
void generic_complete_quest(struct char_data *ch)
{
  qst_rnum rnum;
  qst_vnum vnum = GET_QUEST(ch);
  struct obj_data *new_obj;
  int happy_qp, happy_gold, happy_exp;

  if (--GET_QUEST_COUNTER(ch) <= 0) {
    rnum = real_quest(vnum);
    if (IS_HAPPYHOUR && IS_HAPPYQP) {
      happy_qp = (int)(QST_POINTS(rnum) * (((float)(100+HAPPY_QP))/(float)100));
      happy_qp = MAX(happy_qp, 0);
      GET_QUESTPOINTS(ch) += happy_qp;
      send_to_char(ch,
          "%s\r\nYou have been awarded %d quest points for your service.\r\n",
          QST_DONE(rnum), happy_qp);
	} else {
      GET_QUESTPOINTS(ch) += QST_POINTS(rnum);
      send_to_char(ch,
          "%s\r\nYou have been awarded %d quest points for your service.\r\n",
          QST_DONE(rnum), QST_POINTS(rnum));
    }
    if (QST_GOLD(rnum)) {
      if ((IS_HAPPYHOUR) && (IS_HAPPYGOLD)) {
        happy_gold = (int)(QST_GOLD(rnum) * (((float)(100+HAPPY_GOLD))/(float)100));
        happy_gold = MAX(happy_gold, 0);
        increase_gold(ch, happy_gold);
        send_to_char(ch,
              "You have been awarded %d gold coins for your service.\r\n",
              happy_gold);
	  } else {
        increase_gold(ch, QST_GOLD(rnum));
        send_to_char(ch,
              "You have been awarded %d gold coins for your service.\r\n",
              QST_GOLD(rnum));
      }
    }
    if (QST_EXP(rnum)) {
      gain_exp(ch, QST_EXP(rnum));
      if ((IS_HAPPYHOUR) && (IS_HAPPYEXP)) {
        happy_exp = (int)(QST_EXP(rnum) * (((float)(100+HAPPY_EXP))/(float)100));
        happy_exp = MAX(happy_exp, 0);
        send_to_char(ch,
              "You have been awarded %d experience for your service.\r\n",
              happy_exp);
      } else {
        send_to_char(ch,
              "You have been awarded %d experience points for your service.\r\n",
              QST_EXP(rnum));
      }
    }
    if (QST_OBJ(rnum) && QST_OBJ(rnum) != NOTHING) {
      if (real_object(QST_OBJ(rnum)) != NOTHING) {
        if ((new_obj = read_object((QST_OBJ(rnum)),VIRTUAL)) != NULL) {
            obj_to_char(new_obj, ch);
            send_to_char(ch, "You have been presented with %s%s for your service.\r\n",
                GET_OBJ_SHORT(new_obj), CCNRM(ch, C_NRM));
        }
      }
    }
    if (!IS_SET(QST_FLAGS(rnum), AQ_REPEATABLE))
      add_completed_quest(ch, vnum);
    clear_quest(ch);
    if ((real_quest(QST_NEXT(rnum)) != NOTHING) &&
        (QST_NEXT(rnum) != vnum) &&
        !is_complete(ch, QST_NEXT(rnum))) {
      rnum = real_quest(QST_NEXT(rnum));
      set_quest(ch, rnum);
      send_to_char(ch,
          "The next stage of your quest awaits:\r\n%s",
          QST_INFO(rnum));
    }
  }
  save_char(ch);
}
Example #10
0
main() {
   int x, y, loop = 1, fact = 0;
   char instring[200], outstring[200], sub[200], vrb[200], rst[200], qwd[200];
   char osub[200], ovrb[200], orst[200];
   fam = 0;
   printf("Hello there.  My name is Eliza and I was written by Mohan Embar.\n");
   printf("Please type \"END\" to end this session.\n");
   printf("I'm here to help you if I can.  What seems to be the trouble?\n");
   while (loop) {
      printf("\n");
      gets(instring);
      printf("\n");
      parse(instring);
      if (numwords == 0) {
         switch (x = randnum(2)) {
            case 1 : printf("Don't you have anything to say?\n");
               break;
            case 2 : printf("Cat got your tongue?\n");
               break;
         }
         continue;
      }
      if (!strcmp(s[1],"END")) {
         printf("Goodbye.  Please come again.\n");
         break;
      }
      agree();
      if (bad_word())
         printf(b_word_resp());
      else if (naughty_word())
         printf(n_word_resp());
      else if (x = family()) {
         fam = x;
         printf(fam_resp());
         strcpy(fam_member,s[fam]);
      }
      else if (sword("ALIKE",1))
         printf(alike_resp());
      else if (sword("ALWAYS",1))
         printf(always_resp());
      else if (sword("BECAUSE",1))
         printf(because_resp());
      else if (sword("YES",1))
         printf(yes_resp());
      else if (sword("NO",1) || sword("NOT",1))
         printf(neg_resp());
      else if (x = i_am()) { /* If occurrence of I AM x.. */
         get_til_stop(x,outstring);    /* Get I AM x .. into outstring */
         printf(i_am_resp(),outstring); /* Print reponse for this */
      }
      else if (real_quest() ||
              (is_helper(s[1]) && is_sub_pronoun(s[2])) ||
              sub_and_helper()) {
         if (real_quest()) {
            strcpy(qwd,s[1]);
            strcpy(vrb,s[2]);
            strcpy(sub,s[3]);
            get_til_stop(4,rst);
         }
         else if (is_helper(s[1]) && is_sub_pronoun(s[2])) {
            strcpy(vrb,s[1]);
            strcpy(sub,s[2]);
            get_til_stop(3,rst);
            strcpy(qwd,"YES");
         }
         else if (sub_and_helper()) {
            x = find_helper();
            y = search_back_sub(x);
            strcpy(vrb,s[x]);
            get_til_stop(x+1,rst);
            getrange(y,x-1,sub);
            strcpy(qwd,"NO");
         }
         make_lower(qwd);
         if (strcmp(sub,"I")) make_lower(sub);
         make_lower(vrb);
         make_lower(rst);
         /* First do x verb y responses */

         /*
	 printf("\n*** %s\n",sub);
         */
	 
	 if (!strcmp(sub," I") || !strcmp(sub,"I")) {
            printf(you_resp());
         }
         else if (!strcmp(qwd,"no")) {
            /* Record this statement for later use. */
            fact = 1;
            strcpy(osub,sub); strcpy(ovrb,vrb); strcpy(orst,rst);
            if (is_be(vrb) && !strcmp(sub," you") && (y = sad_word())) {
               getrange(y,y,outstring);
               x = randnum(5)+6;
            }
            else if (is_be(vrb) && (y = sad_word())) {
               getrange(y,y,outstring);
               x = randnum(2)+11;
            }
            else if (is_be(vrb))
               x = randnum(6);
            else x = randnum(4);
            switch (x) {
               case 1 : printf("How do you feel about%s?\n",cnnv(sub));
                  break;
               case 2 : printf("Why %s%s%s?\n",vrb,sub,rst);
                  break;
               case 3 : for (y=1;sub[y]=sub[y--];y=y+2);
                  sub[0] = toupper(sub[0]);
                  printf("%s %s%s?\n",sub,vrb,rst);
                  break;
               case 4 : printf("Could you describe%s for me?\n",cnnv(sub));
                  break;
               case 5 : printf("What if%s were not%s?\n",sub,rst);
                  break;
               case 6 : printf("Would you be happy if%s were not%s?\n",sub,
                                rst);
                  break;
               case 7 : printf("I'm sorry to hear that you are%s.\n",outstring);
                  break;
               case 8 : printf("Do you think that coming here will help you not to be%s?\n",outstring);
                  break;
               case 9 : printf("Let's talk about why you feel%s.\n",outstring);
                  break;
               case 10 : printf("What happened that made you feel%s?\n",outstring);
                  break;
               case 11 : printf("What could be the reason for your feeling%s?\n",outstring);
                  break;
               case 12 : printf("What could cause%s to be%s?\n",cnnv(sub),outstring);
                  break;
               case 13 : printf("If%s came here, would it help%s not to be%s?\n",sub,cnnv(sub),outstring);
                  break;
            }
         }
         else if (!strcmp(sub,"you"))
            printf(you_know());
         else if (!strcmp(qwd,"yes")) {
            x = randnum(8);
            switch (x) {
               case 1 : printf("You want to know if %s %s%s.\n",sub,vrb,rst);
                  break;
               case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst);
                  break;
               case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst);
                  break;
               case 4 : printf("Why does %s concern you?\n",sub);
                  break;
               case 5 : printf("Why are you thinking of %s?\n",cnnv(sub));
                  break;
               case 6 : printf("Tell me more about %s.\n",cnnv(sub));
                  break;
               case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub));
                  break;
               case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub));
                  break;
               case 9 : printf("Why don't you ask %s?\n",cnnv(sub));
                  break;
            }
         }
         else {
            x = randnum(8);
            switch (x) {
               case 1 : printf("You want to know %s %s %s%s.\n",qwd,sub,vrb,rst);
                  break;
               case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst);
                  break;
               case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst);
                  break;
               case 4 : printf("Why does %s concern you?\n",sub);
                  break;
               case 5 : printf("Why are you thinking of %s?\n",cnnv(sub));
                  break;
               case 6 : printf("Tell me more about %s.\n",cnnv(sub));
                  break;
               case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub));
                  break;
               case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub));
                  break;
               case 9 : printf("Why don't you ask %s?\n",cnnv(sub));
                  break;
            }
         }
      }
      else if (is_command())
         printf(command_resp());
      else if (vague_quest())
         printf(question());
      else if ((s[numwords][0] == '?') && !real_quest())
         printf(question());
      else if (x = sad_word()) {
         getrange(x,x,outstring);
         for (y=1;outstring[y]=outstring[y--];y=y+2);
         outstring[0] = toupper(outstring[0]);
         printf("%s?\n",outstring);
      }
      else if (x = can_spit_out()) {
         if (x<=(numwords-2) && is_sub_pronoun(s[x])
                             && (matches("NEED",s[x+1]) ||
                                 matches("WANT",s[x+1]))) {
            get_til_stop(x+2,outstring);
            strcpy(sub,s[x]);
            if (strcmp(sub,"I")) make_lower(sub);
            if (strcmp(s[x],"I")) make_lower(s[x]);
            x = randnum(6);
            switch (x) {
               case 1 : printf("What would it mean to %s if %s got%s?\n",cnnv2(s[x]),sub,outstring);
                  break;
               case 2 : printf("Would %s really be happy if %s got%s?\n",sub,sub,outstring);
                  break;
               case 3 : printf("Why is getting%s so desirable?\n",outstring);
                  break;
               case 4 : printf("Okay.  Suppose %s got%s.  Then what?\n",sub,outstring);
                  break;
               case 5 : printf("Why is this important to %s?\n",cnnv2(sub));
                  break;
               case 6 : printf("What price would %s pay to achieve this?\n",sub);
                  break;
            }
         }
         else {
            get_til_stop(x,outstring);
            outstring[1]=toupper(outstring[1]);
            printf("%s.\n",outstring+1);
         }
      }
      else if (fam) {
         make_lower(fam_member);
         printf(family_resp(),fam_member);
         fam = 0;
      }
      else if (fact && (randnum(5)==3)) {
         printf(old_fact(),osub,ovrb,orst);
         fact = 0;
      }
      else {
         printf(go_on());
      }
   }
}
Example #11
0
int save_quests(zone_rnum zone_num)
{
  FILE *sf;
  char filename[128], oldname[128], quest_flags[MAX_STRING_LENGTH];
  char quest_desc[MAX_STRING_LENGTH], quest_info[MAX_STRING_LENGTH];
  char quest_done[MAX_STRING_LENGTH], quest_quit[MAX_STRING_LENGTH];
  char buf[MAX_STRING_LENGTH];
  int i, num_quests = 0;

#if CIRCLE_UNSIGNED_INDEX
  if (zone_num == NOWHERE || zone_num > top_of_zone_table) {
#else
  if (zone_num < 0 || zone_num > top_of_zone_table) {
#endif
    log("SYSERR: GenOLC: save_quests: Invalid zone number %d passed! (0-%d)",
         zone_num, top_of_zone_table);
    return FALSE;
  }

  log("GenOLC: save_quests: Saving quests in zone #%d (%d-%d).",
        zone_table[zone_num].number,
 genolc_zone_bottom(zone_num), zone_table[zone_num].top);

  snprintf(filename, sizeof(filename), "%s/%d.new",
 QST_PREFIX, zone_table[zone_num].number);
  if (!(sf = fopen(filename, "w"))) {
    perror("SYSERR: save_quests");
    return FALSE;
  }
  for (i = genolc_zone_bottom(zone_num); i <= zone_table[zone_num].top; i++) {
    qst_rnum rnum;
    if ((rnum = real_quest(i)) != NOTHING) {
      /* Copy the text strings and strip off trailing newlines. */
      strncpy(quest_desc, QST_DESC(rnum) ? QST_DESC(rnum) : "undefined",
              sizeof(quest_desc)-1 );
      strncpy(quest_info, QST_INFO(rnum) ? QST_INFO(rnum) : "undefined",
              sizeof(quest_info)-1 );
      strncpy(quest_done, QST_DONE(rnum) ? QST_DONE(rnum) : "undefined",
              sizeof(quest_done)-1 );
      strncpy(quest_quit, QST_QUIT(rnum) ? QST_QUIT(rnum) : "undefined",
              sizeof(quest_quit)-1 );
      strip_cr(quest_desc);
      strip_cr(quest_info);
      strip_cr(quest_done);
      strip_cr(quest_quit);
      /* Save the quest details to the file.  */
      sprintascii(quest_flags, QST_FLAGS(rnum));
      sprintf(buf,
        "#%d\n"
        "%s%c\n"
        "%s%c\n"
        "%s%c\n"
        "%s%c\n"
        "%s%c\n"
        "%d %d %s %d %d %d %d\n"
        "%d %d %d %d %d %d %d\n"
        "%d %d %d\n"
        "S\n",
        QST_NUM(rnum),
        QST_NAME(rnum) ? QST_NAME(rnum) : "Untitled", STRING_TERMINATOR,
        quest_desc, STRING_TERMINATOR,
        quest_info, STRING_TERMINATOR,
        quest_done, STRING_TERMINATOR,
        quest_quit, STRING_TERMINATOR,
        QST_TYPE(rnum),
        QST_MASTER(rnum) == NOBODY ? -1 : QST_MASTER(rnum),
        quest_flags,
        QST_TARGET(rnum) == NOTHING ? -1 : QST_TARGET(rnum),
        QST_PREV(rnum)   == NOTHING ? -1 : QST_PREV(rnum),
        QST_NEXT(rnum)   == NOTHING ? -1 : QST_NEXT(rnum),
        QST_PREREQ(rnum) == NOTHING ? -1 : QST_PREREQ(rnum),
        QST_POINTS(rnum), QST_PENALTY(rnum), QST_MINLEVEL(rnum),
        QST_MAXLEVEL(rnum), QST_TIME(rnum),
 QST_RETURNMOB(rnum) == NOBODY ? -1 : QST_RETURNMOB(rnum),
 QST_QUANTITY(rnum), QST_GOLD(rnum), QST_EXP(rnum), QST_OBJ(rnum)
      );
      
      fprintf(sf, convert_from_tabs(buf), 0);
      
      num_quests++;
    }
  }
  /* Write the final line and close it.  */
  fprintf(sf, "$~\n");
  fclose(sf);

  /* Old file we're replacing. */
  snprintf(oldname, sizeof(oldname), "%s/%d.qst",
           QST_PREFIX, zone_table[zone_num].number);
  remove(oldname);
  rename(filename, oldname);

  /* Do we need to update the index file? */
  if (num_quests > 0)
    create_world_index(zone_table[zone_num].number, "qst");

  if (in_save_list(zone_table[zone_num].number, SL_QST))
    remove_from_save_list(zone_table[zone_num].number, SL_QST);
  return TRUE;
}