Re: Newbie EQ... Class/Race affected:)

From: Admin of The Keep (dkoepke@california.com)
Date: 10/21/96


On Mon, 21 Oct 1996, Marie J. Myers wrote:

> Anyone have any code that would make it so when a new player logged on
> it would give them Eq accordin to there Class/Race???
> Its not that hard to code I guess... but I would apprecite it a lot :)

  Here's one way to do it.  I've written the equip-newbie code several
  times to the list in this form (where it actually will equip_char,
  put the eq in a bag, load multiples, etc.) but not with the ability
  to make the eq class/race selective.  Each time I've written it in
  my mailer, as with this time, and since this is always a popular
  requset for code, I think I'll make a patch for it.

  The below uses bitvectors to make your class/race selective.  You can't
  just put: CLASS_WARRIOR, to make something for just warriors.  You have
  to put "BIT(CLASS_WARRIOR)."  The reason for this is so you can "or" on
  other classes.  An example list follows the code.

    #define BIT(x)	(1 << (x))
    #define RACE_SET	(eq[j][3] != -1 && IS_SET(eq[j][3], race))
    #define CLASS_SET   (eq[j][4] != -1 && IS_SET(eq[j][4], cls))
    #define VALID_VNUM  (real_number(eq[j][0]) >= 0)
    #define CHECK_BAG   (!bag && bag[j][2] == BAG)

    void give_eq(struct char_data * ch) {
      int race = BIT(GET_RACE(ch)), cls = BIT(GET_CLASS(ch)), j, rnum;
      struct obj_data * bag = NULL, * obj;
      const int INVENTORY = -1, BAG = -2;
      int bag_vnum = <vnum of bag>;

      int eq[][5] = {
        { <vnum>, <quantity>, <where>, <raceBV>, <classBV> },
        { -1, -1, -1, -1, -1 }
      };

      if ((rnum = real_object(bag_vnum)) >= 0)
        bag = read_object(rnum, REAL);

      for (j = 0; eq[j][0] != -1; j++) {
        if (!VALID_VNUM || CHECK_BAG || !RACE_SET || !CLASS_SET)
          continue;
        obj = read_object(rnum, REAL);
        if (eq[j][1] > 1 && eq[j][2] <= INVENTORY) {
          for (k = 0; k < eq[j][1]; k++) {
            if (eq[j][2] == BAG) obj_to_obj(obj, bag);
            else		       obj_to_char(obj, ch);
          }
        }
        if (eq[j][2] == BAG) 		obj_to_obj(obj, bag);
        else if (eq[j][2] == INVENTORY) obj_to_char(obj, ch);
        else				equip_char(ch, obj, eq[j][2]);
      }
    }

  For instance, the 'eq' list might look like:

    { 10, 1, WEAR_WIELD, BIT(RACE_HUMAN), BIT(CLASS_WARRIOR) },
    { 11, 1, WEAR_WIELD, BIT(RACE_DWARF) | BIT(RACE_DREUGAR), -1 },
    { -1, -1, -1, -1, -1 }

  If -1 for either race or class indicates that it should load no matter
  what the race or class is.  This permits you to make general eq without
  the hassle, and it also allows you to give all Dwarves an axe, or all
  clerics a cross.  The list must end with -1 for vnum (as shown above),
  otherwise you'll get a crash.

  The quantity loading thing is especially nice if you want to load four
  things (eg., four rations); I often put one in the inventory and three
  in the bag so the person has quick access to one if they need it before
  they figure out how to 'get ration [from] bag'; this would work like
  this:

    { 15, 1, INVENTORY, -1, -1 }, // 1 of #15 in INV for any class/race
    { 15, 3, BAG, -1, -1 }, // 3 of #15 in BAG for any class/race

  Sorry for the C++ style comments, but I've been converting my MUD from
  scratch (known as "Project TUME" to some, and now "Darkstar++" to me)
  to C++ and it's grown to be a bad habbit.  While I'm thinking about it,
  anyone ever convert CircleMUD to C++?  It seems realitively easy to do
  save for a possible obfusicated error with how signals are set (It
  looks like, to me, that gnu c++ would report a problem with how you
  pass functions to 'my_signal' as it did with my code and regular old
  'signal' -- which I finally figured out after fooling about for some
  time).  Although it probably wouldn't be all that advantageous anyways,
  unless someone wrote some good, sturdy classes.


  <*=-+Daniel+-=*>
  "Forgive me father, for I am sin."


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



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