Re: Newplayer load items

From: Glover, Rick I. (RIGLOVER@PHJW.com)
Date: 05/08/00


-----Original Message-----
From: Alex Mann [mailto:alex4501@HOTMAIL.COM]
Sent: Monday, May 08, 2000 2:31 AM
To: CIRCLE@post.queensu.ca
Subject: [CIRCLE] Newplayer load items


Hi
I have been looking through the code, trying to find the clode which creates
the character, to try and add newbie items to thier inventory when they
login for the first time. Has anyone done this or seen the apprpriate code
anywhere.

Cheers
Alex Mann
(naryan.2mud.com port 4445)

-----Reply-----

There are obviously several different approaches to this from the responses
that have come up.  I went ahead and created a command to give newbie
equipment to a player.  That way, if an admin takes pity on a mortal that
lost his newbie gear or didn't receive it due to the newbie objects being
messed up, an admin can always grant the newbie some new gear.  I created
"do_newbie", in act.wizard.c and put the appropriate entries in
interpreter.c along with a procedure called "give_starting_eq()" in class.c.
ACMD(do_newbie) calls give_starting_eq() after the appropriate checks are
made and give_starting_eq is called in nanny() in interpreter.c right after
do_start() is called.  Below is a snippet of my give_starting_eq(), which
shows several different possibilities that you can do with this function.
There is a lot of extra code in here for making it crash-safe and
informative, which I like.

void give_starting_eq(struct char_data * ch)
{
  int counter;
  struct obj_data *obj, *cont = NULL;

  /*
   * Load cloth pants.
   */
  if ((obj = read_object(2, VIRTUAL))) {
    equip_char(ch, obj, WEAR_LEG);
    if (!obj->worn_by) {
      obj_to_char(obj, ch);
      mudlog("SYSERR: failed to wear newbie leg gear.", NRM, LVL_GOD,
FALSE);
    }
  } else
    mudlog("`cRSYSERR`c0: newbie pants missing.  vnum 2.", NRM, LVL_GOD,
FALSE);

  /*
   * Load cloth shirt/blouse.
   */
  if ((obj = read_object(GET_SEX(ch) == SEX_FEMALE ? 4 : 3, VIRTUAL))) {
    equip_char(ch, obj, WEAR_BODY);
    if (!obj->worn_by) {
      obj_to_char(obj, ch);
      mudlog("`cRSYSERR`c0: failed to wear newbie shirt/blouse.", NRM,
LVL_GOD, FALSE);
    }
  } else
    mudlog("`cRSYSERR`c0: newbie shirt/blouse missing.  vnum 3/4.", NRM,
LVL_GOD, FALSE);

  /*
   * Load cloth purse.
   */
  if ((cont = read_object(5, VIRTUAL)))
    obj_to_char(cont, ch);
  else
    mudlog("`cRSYSERR`c0: newbie purse missing.  vnum 5.", NRM, LVL_GOD,
FALSE);

  /*
   * Load cloth bag and load it with a wineskin and 7 rations.
   */
  if ((cont = read_object(6, VIRTUAL)))
    obj_to_char(cont, ch);
  else
    mudlog("`cRSYSERR`c0: newbie bag missing.  vnum 6.", NRM, LVL_GOD,
FALSE);

  if (cont && (obj = read_object(10, VIRTUAL)))
    obj_to_obj(obj, cont);
  else if ((obj = read_object(10, VIRTUAL)))
    obj_to_char(obj, ch);
  else
    mudlog("`cRSYSERR`c0: newbie wineskin missing.  vnum 10.", NRM, LVL_GOD,
FALSE);

  for (counter = 0; counter < 7; counter++) {
    if (cont && (obj = read_object(9, VIRTUAL)))
      obj_to_obj(obj, cont);
    else if ((obj = read_object(9, VIRTUAL)))
      obj_to_char(obj, ch);
    else {
      mudlog("`cRSYSERR`c0: newbie ration missing.  vnum 9.", NRM, LVL_GOD,
FALSE);
      break;
    }
  }

  /*
   * Load spellbook if it's a mage.
   */
  if (GET_CLASS(ch) == CLASS_MAGE)
    if ((obj = read_object(8, VIRTUAL)))
      obj_to_char(obj, ch);
}

Enjoy,
Rick


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



This archive was generated by hypermail 2b30 : 04/10/01 PDT