Re: [Circle] Check for Player

From: Daniel Koepke (dkoepke@california.com)
Date: 11/28/96


On Thu, 28 Nov 1996 linebacker@microlink.net wrote:

> I have a simple sacrifice command that simply extracts the object or corpse
> from the room. My problem is that if a player tries to sacrifice a mob,
> the game crashes. How would I perform a check to see that the argument
> (*buf) is a mobile (or player)?
> 
> I check to see if the arg is an object by if (obj = get_obj_in_list_vis(blah..
> 
> How would I do this for a player or mob?

If you want to sacrafice mobiles (why?!), you can do:

  struct char_data *mob = NULL;

  /* if we find an object do a sacrafice on it */ 
  if (obj = get_obj_in_list_vis(ch, arg, world[ch->in_room].contents)) {
    if (GET_OBJ_TYPE(obj) != ITEM_CONTAINER || !GET_OBJ_VAL(obj, 3)) {
      send_to_char("You can only sacrafice corpses.\r\n", ch);
      return;
    }

    act("$n sacrafices $p to $s god.", TRUE, ch, 0, 0, TO_ROOM);
    act("You sacrafice $p to your god.", FALSE, ch, 0, 0, TO_CHAR);
    obj_from_room(obj);
    extract_obj(obj);
    // give a little reward
    GET_GOLD(ch) += (GET_OBJ_WEIGHT(obj) / 8);
  } else if (mob = get_char_room_vis(ch, arg)) {
    raw_kill(mob);
    return;
  } else if (mob && !IS_NPC(mob)) {
    send_to_char("You can't sacrafice a player.\r\n", ch);
    return;
  } else {
    send_to_char("Sacrafice who or what?\r\n", ch);
    return;
  }
}


--
Daniel Koepke
dkoepke@california.com
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