Re: [NEWBIE] new player equipment

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 05/30/98


On Sat, 30 May 1998, Jesse Scott wrote:

->I was wondering what the best way to set up newbie eq is, I've looked
->around on the web and searched the source extensively, but I don't want
->to have to hard code in what they get, esp since vnums could change,
->should I set up a file that lists it and write something to equip them
->from the file or what?  thanks for the help

Oi!  _The_ question is back!  I remember this stuff from well over a
year ago -- really vintage Mailer Code(tm), that (too bad code doesn't
ferment, eh?)

Okay, so this has a little different spin on it: you don't want hard
coded vnums (ehh, I can't see why you'd change the vnums of the newbie
equipment, though; just stick it all in the 0-99 range -- shouldn't
ever be a reason to move it).  Okay, the basic code is (has always
been :),

  int b_mage = (1 << CLASS_MAGIC_USER);
  int b_cleric = (1 << CLASS_CLERIC);
  int b_thief = (1 << CLASS_THIEF);
  int b_warrior = (1 << CLASS_WARRIOR);
  int b_class = (1 << GET_CLASS(ch));
  int inv = -1, cont = -2;

  int bag_vnum = 20;
  struct obj_data * bag;

  /* THIS IS JUST AN EXAMPLE LIST */
  int eq_list[][4] = {
    /* class(es)        , vnum, amt, to */
    { 0                 ,   21,   1, inv }, /* newbie guide book */
    { b_warrior         ,   22,   1, WEAR_WIELD }, /* sword */
    { b_cleric | b_mage ,   24,   1, WEAR_WIELD }, /* staff */
    { 0                 ,   12,   4, cont }, /* bread (in bag) */
    { -1, -1, -1, -1 } /* ALWAYS LAST */
  };

  int i, j;

  bag = read_object(bag_vnum, VIRTUAL);
  obj_to_char(bag, ch);

  for (i = 0; eq_list[i][1] >= 0; i++)
    if (!eq_list[i][0] || IS_SET(eq_list[i][0], b_class)) {
      for (j = 0; j < eq_list[i][2]; j++) {
        struct obj_data * tmp = read_object(eq_list[i][1], VIRTUAL);
        if (!tmp) break;
        if (eq_list[i][3] == cont && bag)
          obj_to_obj(tmp, bag);
        else if (eq_list[i][3] >= 0 && !EQ(ch, eq_list[i][3]))
          equip_char(ch, tmp, eq_list[i][3]);
        else
          obj_to_char(tmp, ch);
      }
    }

If you want to move this list into a file, use a function like this,

  /* ewww, structure */
  struct eq_list_data {
    int class_bitv;
    obj_vnum vnum;
    int amt;
    int to;
  };

  /* global variable */
  struct eq_list_data * eq_list = NULL;

  void load_newbie_eq(void)
  {
    FILE * fp;
    char line[256], flags[128];
    int t[3], count = 0, i = 0;

    if (!(fp = fopen(NEWBIE_EQ, "r"))) {
      perror(NEWBIE_EQ);
      exit(1);
    }

    while (get_line(fp, line) && *line != '$')
      count++;

    rewind(fp);
    CREATE(eq_list, struct eq_list_data, count);

    while (get_line(fp, line) && *line != '$') {
      if (sscanf(line, " %s %d %d %d ", flags, t, t+1, t+2) != 4) {
        fprintf(stderr, "SYSERR: Reading newbie eq list.\n");
        exit(1);
      }
      eq_list[i].class_bitv = asciiflag_conv(flags);
      eq_list[i].vnum = t[0];
      eq_list[i].amt = t[1];
      eq_list[i].to = t[2];
      i++;
    }

    fclose(fp);
  }

I'll leave the conversion of the actual code to give the newbie the
objects to use the eq_list_data eq_list[] dynamic array as an exercise
for the reader (it's rather simple).

Wow, that's the most Mailer Code(tm) I've posted in a _long_ time...

-dak : I got a haircut today... :)


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST