Beispiel #1
0
int
v_take_pris(struct command *c)
{

  if (!check_char_here(c->who, c->a))
    return FALSE;

  take_prisoner(c->who, c->a);

  return TRUE;
}
int
d_capture_beasts(struct command *c)
{
  int type, piety, from = 0;
  int target = c->a;

  if (!has_holy_symbol(c->who)) {
    wout(c->who, "You must have a holy symbol to capture wild beasts.");
    return FALSE;
  };

  if (!has_holy_plant(c->who)) {
    wout(c->who, "Capturing wild beasts requires a holy plant.");
    return FALSE;
  };

  /*
   *  Target should be a character (oddly enough)
   *
   */
  if (kind(target) != T_char) {
    wout(c->who, "You cannot capture beasts from %s.",box_name(target));
    return FALSE;
  };

  /*
   *  In same location.
   *
   */
    
  if (!check_char_here(c->who, target)) {
    wout(c->who, "%s is not here.",box_name(c->a));
    return FALSE;
  };

  if (is_prisoner(target)) {
    wout(c->who, "Cannot capture beasts from prisoners.");
    return FALSE;
  };

  if (c->who == target) {
    wout(c->who, "Can't capture beasts from oneself.");
    return FALSE;
  };

  if (stack_leader(c->who) == stack_leader(target)) {
    wout(c->who, "Can't capture beasts from a member of the same stack.");
    return FALSE;
  };

  /*
   *  Now select a random beast from the target.  That can be either the
   *  target itself, or one of the beasts in the target's inventory.  In
   *  any case, the beast's statistics determine the piety cost of the
   *  spell.
   *
   *  Note that who the beast is "from" is also returned.
   *
   */
  type = get_random_beast(target, &from);

  if (!type || !item_animal(type)) {
    wout(c->who, "%s has no beasts that you can capture.", box_name(target));
    return FALSE;
  };

  piety = ((item_attack(type) + item_defense(type)) / 50.0) + 1.5;

  /*
   *  Perhaps he hasn't the piety.
   *
   */
  if (!has_piety(c->who, piety)) {
    wout(c->who, "You lack the piety to lure a beast from %s.",
	 box_name(target));
    return FALSE;
  };
  
  /*
   *  Lure the beast away.
   *
   */
  if (!move_item(from, c->who, type, 1)) {
    /*
     *  Possibly it is "from" himself who we are capturing.
     *
     */
    if (subkind(from) == sub_ni && item_animal(noble_item(from))) {
      wout(c->who, "You capture %s!",box_name(target));
      use_piety(c->who, piety);
      take_prisoner(c->who, from);
      /*
       *  Fri Mar 24 06:56:46 2000 -- Scott Turner
       *
       *  Take prisoner doesn't actually transfer the animal into your
       *  inventory, so we'll have to "create" one.
       *
       */
      gen_item(c->who, type, 1);
      return TRUE;
    };
    wout(c->who,"For some reason, you capture no beast.");
    return FALSE;
  };
  wout(c->who, "You capture a %s from %s!",box_name(type), box_name(target));
  use_piety(c->who, piety);
  return TRUE;
  
};