core.c

demise/src/core.c · 42.5 KB

From the archive dodbackup-final.tar.gz

Download the archive   « Back to the archive contents

/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/

/***************************************************************************
 *  God Wars Mud improvements copyright (C) 1994, 1995, 1996 by Richard    *
 *  Woolcock.  This mud is NOT to be copied in whole or in part, or to be  *
 *  run without the permission of Richard Woolcock.  Nobody else has       *
 *  permission to authorise the use of this code.                          *
 ***************************************************************************/

#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

char *
PERS2 (CHAR_DATA * ch, CHAR_DATA * looker)
{
  static char buf[200];

  if (IS_IMMORTAL (ch) && !can_see (looker, ch))
    {
      strcpy (buf, "A Divine Entity");
    }
//  if (IS_XXX (ch, XXX_SE))
//      strcpy (buf, "A Secret Enforcer");
  else if (!can_see (looker, ch) && !IS_IMMORTAL (looker)
	   && !IS_IMMORTAL (ch))
    {
      strcpy (buf, "someone");
    }
  else if (IS_NPC (ch))
    {
      strcpy (buf, ch->short_descr);
    }
  else if (IS_AFFECTED (ch, AFF_POLYMORPH) && !IS_ELF (ch))
    {
      sprintf (buf, "(%s) %s", ch->name, ch->morph);
    }
  else if (IS_AFFECTED (ch, AFF_POLYMORPH) && IS_ELF (ch)
	   && !IS_SET (ch->polyaff, POLY_ELFFORM))
    {
      sprintf (buf, "%s", ch->morph);
    }
  else if (IS_AFFECTED (ch, AFF_POLYMORPH) && IS_ELF (ch)
	   && IS_SET (ch->polyaff, POLY_ELFFORM))
    {
      sprintf (buf, "(%s) %s", ch->name, ch->morph);
    }

  else				/* They are an unpolymorphed player */
    {
      strcpy (buf, ch->name);
    }
  return (&buf[0]);
}

char *
PERS3 (CHAR_DATA * ch, CHAR_DATA * looker)
{
  static char buf[200];

  if (IS_IMMORTAL (ch) && !can_see (looker, ch))
    {
      strcpy (buf, "A Divine Entity");
    }
  else if (IS_XXX (ch, XXX_SE))
    strcpy (buf, "A Secret Enforcer");

  else if (!can_see (looker, ch) && !IS_IMMORTAL (looker)
	   && !IS_IMMORTAL (ch))
    {
      strcpy (buf, "someone");
    }
  else if (IS_NPC (ch))
    {
      strcpy (buf, ch->short_descr);
    }
  else				/* They are a player */
    {
      strcpy (buf, ch->name);
    }
  return (&buf[0]);
}

char *
PERS4 (CHAR_DATA * ch, CHAR_DATA * looker)
{
  static char buf[200];

  if (IS_NPC (ch))
    {
      strcpy (buf, ch->short_descr);
    }
  else				/* They are a player */
    {
      strcpy (buf, ch->name);
    }
  return (&buf[0]);
}

bool
is_undying (CHAR_DATA * ch)
{
  if (IS_NPC (ch))
    return FALSE;
  if (IS_HERO (ch))
    return TRUE;
  if (IS_SOUL (ch))
    return TRUE;

  return FALSE;
}

/*
 * Start fights.
 */
void
set_fighting (CHAR_DATA * ch, CHAR_DATA * victim)
{
  if (ch->fighting != NULL)
    {
      bug ("Set_fighting: already fighting", 0);
      return;
    }

  if (ch->next_fight != NULL || ch->prev_fight != NULL)
    {
      bug ("Set_fighting: new fight code", 0);
      return;
    }
  if (IS_SET (ch->in_room->added_flags, ROOM2_CMIST))
    REMOVE_BIT (ch->in_room->added_flags, ROOM2_CMIST);
  if (IS_XBITS (ch, X_NINJA_HIDE))
    REMOVE_BIT (ch->xbits, X_NINJA_HIDE);
  if (IS_XXX (ch, XXX_CAMOUFLAGE))
    REMOVE_BIT (ch->xxxbits, XXX_CAMOUFLAGE);

  if (!IS_NPC (ch))
    {
      if (IS_DRACWEAP (ch, DRAC_INVIS))
	REMOVE_BIT (ch->pcdata->cpowers[DRAC_WEAPONRY], DRAC_INVIS);
    }

  if (IS_AFFECTED (ch, AFF_SLEEP))
    affect_strip (ch, gsn_sleep);

  if (IS_XBITS (ch, X_SLEEP))
    {
      REMOVE_BIT (ch->xbits, X_SLEEP);
      do_wake (ch, "");
    }
  if (ch->sleeptimer > 0)
    {
      ch->sleeptimer = 0;
    }

  if (IS_XBITS (victim, X_SLEEP))
    {
      REMOVE_BIT (victim->xbits, X_SLEEP);
      do_wake (victim, "");
    }

  if (victim->sleeptimer > 0)
    {
      victim->sleeptimer = 0;
    }

  if (ch->safetimer > 0)
    {
      ch->safetimer = 0;
    }

  if (!IS_COR (ch, COR_HYBRID) && IS_COR (victim, COR_HYBRID))
    {
      SET_BIT (ch->nymbits, NYM_NOTSAFE);
    }

  if (!IS_NPC (ch) && IS_VAMPIRE (ch))
    {
      if (IS_WILLPOWER (ch, RES_CELERITY) && ch->pcdata->celerity < 1)
	do_celerity (ch, "");
    }

  if (IS_VAMPIRE (victim) && !IS_NPC (victim))
    {
      if (IS_WILLPOWER (victim, RES_CELERITY) && victim->pcdata->celerity < 1)
	do_celerity (victim, "");
    }

  ch->fighting = victim;
  ch->position = POS_FIGHTING;
  ch->damcap[DAM_CHANGE] = 1;


  if (first_fight == NULL)
    first_fight = ch;

  if (last_fight != NULL)
    {
      last_fight->next_fight = ch;
      ch->prev_fight = last_fight;
    }
  last_fight = ch;
  if (!IS_NPC (ch) && !IS_NPC (victim))
    ch->fight_timer = 0;
  if (ch->agitated > 0)
    ch->agitated = 0;

  if (!IS_NPC (victim) && !IS_NPC (ch))
    victim->fight_timer = 0;
  if (victim->agitated > 0)
    victim->agitated = 0;
  set_autostance (ch);
  set_autostance (victim);
  update_retaliation (victim, ch);
  return;
}



/*
 * Stop fights.
 */
void
stop_fighting (CHAR_DATA * ch, bool fBoth)
{
  CHAR_DATA *fch;
  CHAR_DATA *fch_next;

  for (fch = first_fight; fch != NULL; fch = fch_next)
    {
      fch_next = fch->next_fight;

      if (fch == ch || (fBoth && fch->fighting == ch))
	{
	  if (!IS_NPC (fch) && !IS_NPC (fch->fighting) && !IS_ELF (fch))
	    fch->fight_timer = 30;
	  if (!IS_NPC (fch) && !IS_NPC (fch->fighting) && IS_ELF (fch)
	      && fch->pcdata->wisdoms[ELF_ARCHERY] < 2)
	    fch->fight_timer = 30;
	  fch->fighting = NULL;
	  if (!IS_NPC (fch))
	    {
	      fch->agitated += 2;
	      fch->position = POS_AGITATED;
	    }
	  else
	    {
	      fch->position = POS_STANDING;
	    }
	  if (fch->prev_fight != NULL && fch->next_fight != NULL)
	    {
	      fch->prev_fight->next_fight = fch->next_fight;
	      fch->next_fight->prev_fight = fch->prev_fight;
	    }
	  else if (fch->prev_fight != NULL)
	    {
	      fch->prev_fight->next_fight = NULL;
	      last_fight = fch->prev_fight;
	    }
	  else if (fch->next_fight != NULL)
	    {
	      fch->next_fight->prev_fight = NULL;
	      first_fight = fch->next_fight;
	    }
	  else
	    {
	      first_fight = NULL;
	      last_fight = NULL;
	    }

	  fch->prev_fight = NULL;
	  fch->next_fight = NULL;

	  update_pos (fch);
	}
    }

  return;
}

bool
regenerate_part (OBJ_DATA * obj)
{
  CHAR_DATA *ch;
  CHAR_DATA *victim;
  int teeth = 0;

  if (obj->in_obj != NULL)
    return FALSE;

  if (strlen (obj->questmaker) < 2)
    return FALSE;

  if (obj->in_room != NULL && (victim = obj->in_room->people) != NULL)
    {
      if ((ch = get_char_room (victim, obj->questmaker)) == NULL)
	return FALSE;
    }
  else if ((victim = obj->carried_by) != NULL && victim->in_room != NULL)
    {
      if ((ch = get_char_room (victim, obj->questmaker)) == NULL)
	return FALSE;
    }
  else
    return FALSE;

  if ((victim = obj->carried_by) != NULL && victim != ch &&
      victim->in_room != NULL)
    {
      act ("$p leaps out of your hands.", victim, obj, NULL, TO_CHAR);
      act ("$p leaps out of $n's hands.", victim, obj, NULL, TO_ROOM);
      obj_from_char (obj);
      obj_to_room (obj, victim->in_room);
      return FALSE;
    }
/*
    if ( obj->in_room != NULL && ch->in_room == obj->in_room )
    {
	act("$p leaps into your hands.",ch,obj,NULL,TO_CHAR);
	act("$p leaps into $n's hands.",ch,obj,NULL,TO_ROOM);
	obj_from_room( obj );
	obj_to_char( obj, ch );
	return FALSE;
    }
*/
  if (obj->in_room != NULL && (victim = obj->in_room->people) != NULL &&
      ch->in_room != obj->in_room && number_range (1, 3) != 1)
    {
      if (number_range (1, 4) == 1)
	{
	  act ("$p twitches on the floor.", victim, obj, NULL, TO_CHAR);
	  act ("$p twitches on the floor.", victim, obj, NULL, TO_ROOM);
	}
      return FALSE;
    }

  if (IS_HEAD (ch, LOST_TOOTH_1))
    teeth += 1;
  if (IS_HEAD (ch, LOST_TOOTH_2))
    teeth += 2;
  if (IS_HEAD (ch, LOST_TOOTH_4))
    teeth += 4;
  if (IS_HEAD (ch, LOST_TOOTH_8))
    teeth += 8;
  if (IS_HEAD (ch, LOST_TOOTH_16))
    teeth += 16;

  if (obj->pIndexData->vnum == OBJ_VNUM_SLICED_ARM)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && !IS_ARM_R (ch, LOST_ARM))
	return FALSE;
      if (IS_ARM_L (ch, LOST_ARM))
	{
	  if (IS_BLEEDING (ch, BLEEDING_ARM_L))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_ARM);
	}
      else if (IS_ARM_R (ch, LOST_ARM))
	{
	  if (IS_BLEEDING (ch, BLEEDING_ARM_R))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_ARM);
	}
      act ("$p shoots towards your shoulder.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's shoulder.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto the stump of your shoulder.", ch, obj,
	   NULL, TO_CHAR);
      act ("$p presses itself onto the stump of $n's shoulder.", ch, obj,
	   NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SLICED_LEG)
    {
      if (!IS_LEG_L (ch, LOST_LEG) && !IS_LEG_R (ch, LOST_LEG))
	return FALSE;
      if (IS_LEG_L (ch, LOST_LEG))
	{
	  if (IS_BLEEDING (ch, BLEEDING_LEG_L))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_LEG_L], LOST_LEG);
	}
      else if (IS_LEG_R (ch, LOST_LEG))
	{
	  if (IS_BLEEDING (ch, BLEEDING_LEG_R))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_LEG_R], LOST_LEG);
	}
      act ("$p shoots towards your hip.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's hip.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto the stump of your hip.", ch, obj, NULL,
	   TO_CHAR);
      act ("$p presses itself onto the stump of $n's hip.", ch, obj, NULL,
	   TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SQUIDGY_EYEBALL)
    {
      if (!IS_HEAD (ch, LOST_EYE_L) && !IS_HEAD (ch, LOST_EYE_R))
	return FALSE;
      if (IS_HEAD (ch, LOST_EYE_L))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_EYE_L);
      else if (IS_HEAD (ch, LOST_EYE_R))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_EYE_R);
      act ("$p shoots towards your face.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's face.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself into your empty eye socket.", ch, obj, NULL,
	   TO_CHAR);
      act ("$p presses itself into $n's empty eye socket.", ch, obj, NULL,
	   TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SLICED_EAR)
    {
      if (!IS_HEAD (ch, LOST_EAR_L) && !IS_HEAD (ch, LOST_EAR_R))
	return FALSE;
      if (IS_HEAD (ch, LOST_EAR_L))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_EAR_L);
      else if (IS_HEAD (ch, LOST_EAR_R))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_EAR_R);
      act ("$p shoots towards your head.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's head.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto the side of your head.", ch, obj, NULL,
	   TO_CHAR);
      act ("$p presses itself onto the side of $n's head.", ch, obj, NULL,
	   TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SLICED_NOSE)
    {
      if (!IS_HEAD (ch, LOST_NOSE))
	return FALSE;
      REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_NOSE);
      act ("$p shoots towards your face.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's face.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto the front of your face.", ch, obj, NULL,
	   TO_CHAR);
      act ("$p presses itself onto the front of $n's face.", ch, obj, NULL,
	   TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_HAND)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && IS_ARM_L (ch, LOST_HAND))
	{
	  if (IS_BLEEDING (ch, BLEEDING_HAND_L))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_HAND);
	}
      else if (!IS_ARM_R (ch, LOST_ARM) && IS_ARM_R (ch, LOST_HAND))
	{
	  if (IS_BLEEDING (ch, BLEEDING_HAND_R))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_HAND);
	}
      else
	return FALSE;
      act ("$p shoots towards your wrist.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's wrist.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto the stump of your wrist.", ch, obj, NULL,
	   TO_CHAR);
      act ("$p presses itself onto the stump of $n's wrist.", ch, obj, NULL,
	   TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_FOOT)
    {
      if (!IS_LEG_L (ch, LOST_LEG) && IS_LEG_L (ch, LOST_FOOT))
	{
	  if (IS_BLEEDING (ch, BLEEDING_LEG_L))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_LEG_L], LOST_FOOT);
	}
      else if (!IS_LEG_R (ch, LOST_LEG) && IS_LEG_R (ch, LOST_FOOT))
	{
	  if (IS_BLEEDING (ch, BLEEDING_LEG_R))
	    return FALSE;
	  REMOVE_BIT (ch->loc_hp[LOC_LEG_R], LOST_FOOT);
	}
      else
	return FALSE;
      act ("$p shoots towards your ankle.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's ankle.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto the stump of your ankle.", ch, obj, NULL,
	   TO_CHAR);
      act ("$p presses itself onto the stump of $n's ankle.", ch, obj, NULL,
	   TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_THUMB)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && !IS_ARM_L (ch, LOST_HAND)
	  && IS_ARM_L (ch, LOST_THUMB))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_THUMB);
      else if (!IS_ARM_R (ch, LOST_ARM) && !IS_ARM_R (ch, LOST_HAND)
	       && IS_ARM_R (ch, LOST_THUMB))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_THUMB);
      else
	return FALSE;
      act ("$p shoots towards your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's hand.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p presses itself onto $n's hand.", ch, obj, NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_INDEX)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && !IS_ARM_L (ch, LOST_HAND)
	  && IS_ARM_L (ch, LOST_FINGER_I))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_FINGER_I);
      else if (!IS_ARM_R (ch, LOST_ARM) && !IS_ARM_R (ch, LOST_HAND)
	       && IS_ARM_R (ch, LOST_FINGER_I))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_FINGER_I);
      else
	return FALSE;
      act ("$p shoots towards your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's hand.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p presses itself onto $n's hand.", ch, obj, NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_MIDDLE)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && !IS_ARM_L (ch, LOST_HAND)
	  && IS_ARM_L (ch, LOST_FINGER_M))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_FINGER_M);
      else if (!IS_ARM_R (ch, LOST_ARM) && !IS_ARM_R (ch, LOST_HAND)
	       && IS_ARM_R (ch, LOST_FINGER_M))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_FINGER_M);
      else
	return FALSE;
      act ("$p shoots towards your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's hand.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p presses itself onto $n's hand.", ch, obj, NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_RING)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && !IS_ARM_L (ch, LOST_HAND)
	  && IS_ARM_L (ch, LOST_FINGER_R))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_FINGER_R);
      else if (!IS_ARM_R (ch, LOST_ARM) && !IS_ARM_R (ch, LOST_HAND)
	       && IS_ARM_R (ch, LOST_FINGER_R))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_FINGER_R);
      else
	return FALSE;
      act ("$p shoots towards your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's hand.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p presses itself onto $n's hand.", ch, obj, NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (obj->pIndexData->vnum == OBJ_VNUM_SEVERED_LITTLE)
    {
      if (!IS_ARM_L (ch, LOST_ARM) && !IS_ARM_L (ch, LOST_HAND)
	  && IS_ARM_L (ch, LOST_FINGER_L))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_L], LOST_FINGER_L);
      else if (!IS_ARM_R (ch, LOST_ARM) && !IS_ARM_R (ch, LOST_HAND)
	       && IS_ARM_R (ch, LOST_FINGER_L))
	REMOVE_BIT (ch->loc_hp[LOC_ARM_R], LOST_FINGER_L);
      else
	return FALSE;
      act ("$p shoots towards your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's hand.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself onto your hand.", ch, obj, NULL, TO_CHAR);
      act ("$p presses itself onto $n's hand.", ch, obj, NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  else if (teeth > 0)
    {
      if (IS_HEAD (ch, LOST_TOOTH_1))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_1);
      if (IS_HEAD (ch, LOST_TOOTH_2))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_2);
      if (IS_HEAD (ch, LOST_TOOTH_4))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_4);
      if (IS_HEAD (ch, LOST_TOOTH_8))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_8);
      if (IS_HEAD (ch, LOST_TOOTH_16))
	REMOVE_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_16);
      teeth -= 1;
      if (teeth >= 16)
	{
	  teeth -= 16;
	  SET_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_16);
	}
      if (teeth >= 8)
	{
	  teeth -= 8;
	  SET_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_8);
	}
      if (teeth >= 4)
	{
	  teeth -= 4;
	  SET_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_4);
	}
      if (teeth >= 2)
	{
	  teeth -= 2;
	  SET_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_2);
	}
      if (teeth >= 1)
	{
	  teeth -= 1;
	  SET_BIT (ch->loc_hp[LOC_HEAD], LOST_TOOTH_1);
	}
      act ("$p shoots towards your face.", ch, obj, NULL, TO_CHAR);
      act ("$p shoots towards $n's face.", ch, obj, NULL, TO_ROOM);
      act ("$p presses itself into your mouth.", ch, obj, NULL, TO_CHAR);
      act ("$p presses itself into $n's mouth.", ch, obj, NULL, TO_ROOM);
      extract_obj (obj);
      return TRUE;
    }
  return FALSE;
}

/*
 * The primary output interface for formatted output.
 */
void
act (const char *format, CHAR_DATA * ch, const void *arg1, const void *arg2,
     int type)
{
  static char *const he_she[] = { "it", "he", "she" };
  static char *const him_her[] = { "it", "him", "her" };
  static char *const his_her[] = { "its", "his", "her" };

  char bugbuf[MSL];
  char buf[MSL];
  char fname[MIL];
  CHAR_DATA *to;
/* Next 1 line
*/
  CHAR_DATA *to_old;

  CHAR_DATA *vch = (CHAR_DATA *) arg2;
/* Next 2 lines
*/
  CHAR_DATA *familiar = NULL;
  CHAR_DATA *wizard = NULL;

  OBJ_DATA *obj1 = (OBJ_DATA *) arg1;
  OBJ_DATA *obj2 = (OBJ_DATA *) arg2;
  const char *str;
  const char *i;
  char *point;
  int bugcount = 0;
/* Next 1 line
*/
  bool is_fam;

  bool is_ok;
  /*
   * Discard null and zero-length messages.
   */
  if (format == NULL || format[0] == '\0')
    return;

  if ((ch == NULL) || (ch->position == POS_DEAD))
    return;

  to = ch->in_room->people;
  if (type == TO_VICT)
    {
      if (IS_NPC (vch))
	return;

      if (vch == NULL || vch->in_room == NULL || vch->position == POS_DEAD)
	{
	  sprintf (bugbuf, "%s Act: null vch with TO_VICT: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}
      to = vch->in_room->people;
    }

  for (; to != NULL; to = to->next_in_room)
    {
/* Next 2 lines
*/
      is_fam = FALSE;
      to_old = to;
      if (ch->in_room == NULL && type == TO_ROOM)
	{
	  sprintf (bugbuf, "%s Act: null room with TO_ROOM: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}
      if (to == NULL && type == TO_ROOM)
	{
	  sprintf (bugbuf, "%s Act: null to with TO_ROOM: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}

      if (ch == NULL && type == TO_ROOM)
	{
	  sprintf (bugbuf, "%s Act: null ch with TO_ROOM: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}
      if (type == TO_CHAR && to != ch)
	continue;
      if (type == TO_VICT && (to != vch || to == ch))
	continue;
      if (type == TO_ROOM && to == ch && bugcount < 1)
	{
	  bugcount++;
	  continue;
	}
      if (type == TO_ROOM && to == ch && bugcount >= 1)
	{
	  sprintf (bugbuf, "%s Act: freeze bug with TO_ROOM: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}
      if (type == TO_NOTVICT && (to == ch || to == vch))
	continue;
/* Next if statement
*/
      if (to->desc == NULL && IS_NPC (to) && (wizard = to->wizard) != NULL)
	{
	  if (!IS_NPC (wizard)
	      && ((familiar = wizard->pcdata->familiar) != NULL)
	      && familiar == to)
	    {
	      if (to->in_room == ch->in_room &&
		  wizard->in_room != to->in_room)
		{
		  to = wizard;
		  SET_BIT (to->extra, EXTRA_CAN_SEE);
		  is_fam = TRUE;
		}
	    }
	}

      if (to->desc == NULL || !IS_AWAKE (to))
	{
/* Next if statement
*/
	  if (is_fam)
	    {
	      REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	      to = to_old;
	    }

	  continue;
	}

      if (ch->in_room->vnum == ROOM_VNUM_IN_OBJECT)
	{
	  is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_room != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_room != NULL &&
	      ch->in_room == to->in_room)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_obj != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_obj != NULL &&
	      ch->pcdata->chobj->in_obj == to->pcdata->chobj->in_obj)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!is_ok)
	    {
/* Next if statement
*/
	      if (is_fam)
		{
		  REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
		  to = to_old;
		}

	      continue;
	    }
	}

      point = buf;
      str = format;
      while (*str != '\0')
	{
	  if (*str != '$')
	    {
	      *point++ = *str++;
	      continue;
	    }
	  ++str;

	  if (arg2 == NULL && *str >= 'A' && *str <= 'Z')
	    {
	      bug ("Act: missing arg2 for code %d.", *str);
	      i = " <@@@> ";
	    }
	  else
	    {
	      switch (*str)
		{
		default:
		  {
		    char bugbuf[MIL];
		    sprintf (bugbuf, "%s Act: bad code %d", ch->name, *str);
		    bug (bugbuf, 0);
		  }
		  i = " <@@@> ";
		  break;
		  /* Thx alex for 't' idea */
		case 't':
		  i = (char *) arg1;
		  break;
		case 'T':
		  i = (char *) arg2;
		  break;
		case 'n':
		  i = PERS2 (ch, to);
		  break;
		case 'N':
		  i = PERS2 (vch, to);
		  break;
		case 'e':
		  i = he_she[URANGE (0, ch->sex, 2)];
		  break;
		case 'E':
		  i = he_she[URANGE (0, vch->sex, 2)];
		  break;
		case 'm':
		  i = him_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'M':
		  i = him_her[URANGE (0, vch->sex, 2)];
		  break;
		case 's':
		  i = his_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'S':
		  i = his_her[URANGE (0, vch->sex, 2)];
		  break;

		case 'p':
		  i = can_see_obj (to, obj1)
		    ? ((obj1->chobj != NULL && obj1->chobj == to)
		       ? "you" : obj1->short_descr) : "something";
		  break;

		case 'P':
		  i = can_see_obj (to, obj2)
		    ? ((obj2->chobj != NULL && obj2->chobj == to)
		       ? "you" : obj2->short_descr) : "something";
		  break;

		case 'd':
		  if (arg2 == NULL || ((char *) arg2)[0] == '\0')
		    {
		      i = "door";
		    }
		  else
		    {
		      one_argument ((char *) arg2, fname);
		      i = fname;
		    }
		  break;
		}
	    }

	  ++str;
	  while ((*point = *i) != '\0')
	    ++point, ++i;
	}

      *point++ = '\n';
      *point++ = '\r';
/* Next if statement
*/
      if (is_fam)
	{
	  if (to->in_room != ch->in_room &&
	      familiar != NULL && familiar->in_room == ch->in_room)
	    send_to_char ("[ ", to);
	  else
	    {
	      REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	      to = to_old;
	      continue;
	    }
	}

      buf[0] = UPPER (buf[0]);
      write_to_buffer (to->desc, buf, point - buf);
/* Next if statement
*/
      if (is_fam)
	{
	  REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	  to = to_old;
	}

    }
  return;
}

void
global_act (const char *format, CHAR_DATA * ch, const void *arg1,
	    const void *arg2)
{
  static char *const he_she[] = { "it", "he", "she" };
  static char *const him_her[] = { "it", "him", "her" };
  static char *const his_her[] = { "its", "his", "her" };

  char bugbuf[MSL];
  char buf[MSL];
  char fname[MIL];
  CHAR_DATA *to;
  CHAR_DATA *to_next;
/* Next 1 line
*/
  CHAR_DATA *to_old;

  CHAR_DATA *vch = (CHAR_DATA *) arg2;
/* Next 2 lines
*/
  CHAR_DATA *familiar = NULL;
  CHAR_DATA *wizard = NULL;

  OBJ_DATA *obj1 = (OBJ_DATA *) arg1;
  OBJ_DATA *obj2 = (OBJ_DATA *) arg2;
  const char *str;
  const char *i;
  char *point;
/* Next 1 line
*/
  bool is_fam;

  bool is_ok;
  /*
   * Discard null and zero-length messages.
   */
  if (format == NULL || format[0] == '\0')
    return;

  if ((ch == NULL) || (ch->position == POS_DEAD))
    return;

  to = ch->in_room->people;
  for (to = char_list; to != NULL; to = to_next)
    {
      to_next = to->next;
/* Next 2 lines
*/
      is_fam = FALSE;
      to_old = to;

      if (IS_NPC (to))
	continue;

/* Next if statement
*/
      if (to->desc == NULL && IS_NPC (to) && (wizard = to->wizard) != NULL)
	{
	  if (!IS_NPC (wizard)
	      && ((familiar = wizard->pcdata->familiar) != NULL)
	      && familiar == to)
	    {
	      if (to->in_room == ch->in_room &&
		  wizard->in_room != to->in_room)
		{
		  to = wizard;
		  SET_BIT (to->extra, EXTRA_CAN_SEE);
		  is_fam = TRUE;
		}
	    }
	}

      if (to->desc == NULL || !IS_AWAKE (to))
	{
/* Next if statement
*/
	  if (is_fam)
	    {
	      REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	      to = to_old;
	    }

	  continue;
	}

      if (ch->in_room->vnum == ROOM_VNUM_IN_OBJECT)
	{
	  is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_room != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_room != NULL &&
	      ch->in_room == to->in_room)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_obj != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_obj != NULL &&
	      ch->pcdata->chobj->in_obj == to->pcdata->chobj->in_obj)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!is_ok)
	    {
/* Next if statement
*/
	      if (is_fam)
		{
		  REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
		  to = to_old;
		}

	      continue;
	    }
	}

      point = buf;
      str = format;
      while (*str != '\0')
	{
	  if (*str != '$')
	    {
	      *point++ = *str++;
	      continue;
	    }
	  ++str;

	  if (arg2 == NULL && *str >= 'A' && *str <= 'Z')
	    {
	      bug ("Act: missing arg2 for code %d.", *str);
	      i = " <@@@> ";
	    }
	  else
	    {
	      switch (*str)
		{
		default:
		  {
		    char bugbuf[MIL];
		    sprintf (bugbuf, "%s Act: bad code %d", ch->name, *str);
		    bug (bugbuf, 0);
		  }
		  i = " <@@@> ";
		  break;
		  /* Thx alex for 't' idea */
		case 't':
		  i = (char *) arg1;
		  break;
		case 'T':
		  i = (char *) arg2;
		  break;
		case 'n':
		  i = PERS2 (ch, to);
		  break;
		case 'N':
		  i = PERS2 (vch, to);
		  break;
		case 'e':
		  i = he_she[URANGE (0, ch->sex, 2)];
		  break;
		case 'E':
		  i = he_she[URANGE (0, vch->sex, 2)];
		  break;
		case 'm':
		  i = him_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'M':
		  i = him_her[URANGE (0, vch->sex, 2)];
		  break;
		case 's':
		  i = his_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'S':
		  i = his_her[URANGE (0, vch->sex, 2)];
		  break;

		case 'p':
		  i = can_see_obj (to, obj1)
		    ? ((obj1->chobj != NULL && obj1->chobj == to)
		       ? "you" : obj1->short_descr) : "something";
		  break;

		case 'P':
		  i = can_see_obj (to, obj2)
		    ? ((obj2->chobj != NULL && obj2->chobj == to)
		       ? "you" : obj2->short_descr) : "something";
		  break;

		case 'd':
		  if (arg2 == NULL || ((char *) arg2)[0] == '\0')
		    {
		      i = "door";
		    }
		  else
		    {
		      one_argument ((char *) arg2, fname);
		      i = fname;
		    }
		  break;
		}
	    }

	  ++str;
	  while ((*point = *i) != '\0')
	    ++point, ++i;
	}

      *point++ = '\n';
      *point++ = '\r';
/* Next if statement
*/
      if (is_fam)
	{
	  if (to->in_room != ch->in_room &&
	      familiar != NULL && familiar->in_room == ch->in_room)
	    send_to_char ("[ ", to);
	  else
	    {
	      REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	      to = to_old;
	      continue;
	    }
	}

      buf[0] = UPPER (buf[0]);
      write_to_buffer (to->desc, buf, point - buf);
/* Next if statement
*/
      if (is_fam)
	{
	  REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	  to = to_old;
	}

    }
  return;
}

void
act3 (const char *format, CHAR_DATA * ch, const void *arg1, const void *arg2,
      int type)
{
  static char *const he_she[] = { "it", "he", "she" };
  static char *const him_her[] = { "it", "him", "her" };
  static char *const his_her[] = { "its", "his", "her" };

  char bugbuf[MSL];
  char buf[MSL];
  char fname[MIL];
  CHAR_DATA *to;
/* Next 1 line
*/
  CHAR_DATA *to_old;

  CHAR_DATA *vch = (CHAR_DATA *) arg2;
/* Next 2 lines
*/
  CHAR_DATA *familiar = NULL;
  CHAR_DATA *wizard = NULL;

  OBJ_DATA *obj1 = (OBJ_DATA *) arg1;
  OBJ_DATA *obj2 = (OBJ_DATA *) arg2;
  const char *str;
  const char *i;
  char *point;
/* Next 1 line
*/
  bool is_fam;

  bool is_ok;
  /*
   * Discard null and zero-length messages.
   */
  if (format == NULL || format[0] == '\0')
    return;

  if ((ch == NULL) || (ch->position == POS_DEAD))
    return;

  to = ch->in_room->people;
  if (type == TO_VICT)
    {
      if (IS_NPC (vch))
	return;

      if (vch == NULL || vch->in_room == NULL || vch->position == POS_DEAD)
	{
	  sprintf (bugbuf, "%s Act3: null vch with TO_VICT: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}
      to = vch->in_room->people;
    }

  for (; to != NULL; to = to->next_in_room)
    {
/* Next 2 lines
*/
      is_fam = FALSE;
      to_old = to;

      if (type == TO_CHAR && to != ch)
	continue;
      if (type == TO_VICT && (to != vch || to == ch))
	continue;
      if (type == TO_ROOM && to == ch)
	continue;
      if (type == TO_NOTVICT && (to == ch || to == vch))
	continue;
/* Next if statement
*/
      if (to->desc == NULL && IS_NPC (to) && (wizard = to->wizard) != NULL)
	{
	  if (!IS_NPC (wizard)
	      && ((familiar = wizard->pcdata->familiar) != NULL)
	      && familiar == to)
	    {
	      if (to->in_room == ch->in_room &&
		  wizard->in_room != to->in_room)
		{
		  to = wizard;
		  SET_BIT (to->extra, EXTRA_CAN_SEE);
		  is_fam = TRUE;
		}
	    }
	}

      if (to->desc == NULL || !IS_AWAKE (to))
	{
/* Next if statement
*/
	  if (is_fam)
	    {
	      REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	      to = to_old;
	    }

	  continue;
	}

      if (ch->in_room->vnum == ROOM_VNUM_IN_OBJECT)
	{
	  is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_room != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_room != NULL &&
	      ch->in_room == to->in_room)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_obj != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_obj != NULL &&
	      ch->pcdata->chobj->in_obj == to->pcdata->chobj->in_obj)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!is_ok)
	    {
/* Next if statement
*/
	      if (is_fam)
		{
		  REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
		  to = to_old;
		}

	      continue;
	    }
	}

      point = buf;
      str = format;
      while (*str != '\0')
	{
	  if (*str != '$')
	    {
	      *point++ = *str++;
	      continue;
	    }
	  ++str;

	  if (arg2 == NULL && *str >= 'A' && *str <= 'Z')
	    {
	      bug ("Act: missing arg2 for code %d.", *str);
	      i = " <@@@> ";
	    }
	  else
	    {
	      switch (*str)
		{
		default:
		  {
		    char bugbuf[MIL];
		    sprintf (bugbuf, "%s Act: bad code %d", ch->name, *str);
		    bug (bugbuf, 0);
		  }
		  i = " <@@@> ";
		  break;
		  /* Thx alex for 't' idea */
		case 't':
		  i = (char *) arg1;
		  break;
		case 'T':
		  i = (char *) arg2;
		  break;
		case 'n':
		  i = PERS3 (ch, to);
		  break;
		case 'N':
		  i = PERS3 (vch, to);
		  break;
		case 'e':
		  i = he_she[URANGE (0, ch->sex, 2)];
		  break;
		case 'E':
		  i = he_she[URANGE (0, vch->sex, 2)];
		  break;
		case 'm':
		  i = him_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'M':
		  i = him_her[URANGE (0, vch->sex, 2)];
		  break;
		case 's':
		  i = his_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'S':
		  i = his_her[URANGE (0, vch->sex, 2)];
		  break;

		case 'p':
		  i = can_see_obj (to, obj1)
		    ? ((obj1->chobj != NULL && obj1->chobj == to)
		       ? "you" : obj1->short_descr) : "something";
		  break;

		case 'P':
		  i = can_see_obj (to, obj2)
		    ? ((obj2->chobj != NULL && obj2->chobj == to)
		       ? "you" : obj2->short_descr) : "something";
		  break;

		case 'd':
		  if (arg2 == NULL || ((char *) arg2)[0] == '\0')
		    {
		      i = "door";
		    }
		  else
		    {
		      one_argument ((char *) arg2, fname);
		      i = fname;
		    }
		  break;
		}
	    }

	  ++str;
	  while ((*point = *i) != '\0')
	    ++point, ++i;
	}

      *point++ = '\n';
      *point++ = '\r';
/* Next if statement
*/
      if (is_fam)
	{
	  if (to->in_room != ch->in_room &&
	      familiar != NULL && familiar->in_room == ch->in_room)
	    send_to_char ("[ ", to);
	  else
	    {
	      REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	      to = to_old;
	      continue;
	    }
	}

      buf[0] = UPPER (buf[0]);
      write_to_buffer (to->desc, buf, point - buf);
/* Next if statement
*/
      if (is_fam)
	{
	  REMOVE_BIT (to->extra, EXTRA_CAN_SEE);
	  to = to_old;
	}

    }
  return;
}

void
act2 (const char *format, CHAR_DATA * ch, const void *arg1, const void *arg2,
      int type)
{
  static char *const he_she[] = { "it", "he", "she" };
  static char *const him_her[] = { "it", "him", "her" };
  static char *const his_her[] = { "its", "his", "her" };

  char bugbuf[MSL];
  char buf[MSL];
  CHAR_DATA *to;
/*
    CHAR_DATA *to_old;
*/
  CHAR_DATA *vch = (CHAR_DATA *) arg2;
/*
    CHAR_DATA *familiar = NULL;
    CHAR_DATA *wizard = NULL;
*/
  OBJ_DATA *obj1 = (OBJ_DATA *) arg1;
  OBJ_DATA *obj2 = (OBJ_DATA *) arg2;
  const char *str;
  const char *i;
  char *point;
/*
    bool is_fam;
*/
  bool is_ok;
  /*
   * Discard null and zero-length messages.
   */
  if (format == NULL || format[0] == '\0')
    return;

  if ((ch == NULL) || (ch->position == POS_DEAD))
    return;

  to = ch->in_room->people;
  if (type == TO_VICT)
    {
      if (IS_NPC (vch))
	return;

      if (vch == NULL || vch->in_room == NULL || vch->position == POS_DEAD)
	{
	  sprintf (bugbuf, "%s Act2: null vch with TO_VICT: %s.", ch->name,
		   format);
	  bug (bugbuf, 0);
	  return;
	}
      to = vch->in_room->people;
    }

  for (; to != NULL; to = to->next_in_room)
    {
/*
	is_fam = FALSE;
	to_old = to;
*/
      if (type == TO_CHAR && to != ch)
	continue;
      if (type == TO_VICT && (to != vch || to == ch))
	continue;
      if (type == TO_ROOM && to == ch)
	continue;
      if (type == TO_NOTVICT && (to == ch || to == vch))
	continue;
/*
	if ( to->desc == NULL && IS_NPC(to) && (wizard = to->wizard) != NULL )
	{
	    if (!IS_NPC(wizard) && ((familiar=wizard->pcdata->familiar) != NULL)
		&& familiar == to)
	    {
		if (to->in_room == ch->in_room && 
		    wizard->in_room != to->in_room)
		{
		    to = wizard;
		    is_fam = TRUE;
		}
	    }
	}
*/
      if (to->desc == NULL || !IS_AWAKE (to))
	{
/*
	    if (is_fam) to = to_old;
*/
	  continue;
	}

      if (ch->in_room->vnum == ROOM_VNUM_IN_OBJECT)
	{
	  is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_room != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_room != NULL &&
	      ch->in_room == to->in_room)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_obj != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_obj != NULL &&
	      ch->pcdata->chobj->in_obj == to->pcdata->chobj->in_obj)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!is_ok)
	    {
/*
		if (is_fam) to = to_old;
*/
	      continue;
	    }
	}

      point = buf;
      str = format;
      while (*str != '\0')
	{
	  if (*str != '$')
	    {
	      *point++ = *str++;
	      continue;
	    }
	  ++str;

	  if (arg2 == NULL && *str >= 'A' && *str <= 'Z')
	    {
/*
		bug( "Act: missing arg2 for code %d.", *str );
*/
	      i = " <@@@> ";
	    }
	  else
	    {
	      switch (*str)
		{
		default:
		  i = " ";
		  break;
		case 'n':
		  if (ch != NULL)
		    i = PERS3 (ch, to);
		  else
		    i = " ";
		  break;
		case 'N':
		  if (vch != NULL)
		    i = PERS3 (vch, to);
		  else
		    i = " ";
		  break;
		case 'e':
		  if (ch != NULL)
		    i = he_she[URANGE (0, ch->sex, 2)];
		  else
		    i = " ";
		  break;
		case 'E':
		  if (vch != NULL)
		    i = he_she[URANGE (0, vch->sex, 2)];
		  else
		    i = " ";
		  break;
		case 'm':
		  if (ch != NULL)
		    i = him_her[URANGE (0, ch->sex, 2)];
		  else
		    i = " ";
		  break;
		case 'M':
		  if (vch != NULL)
		    i = him_her[URANGE (0, vch->sex, 2)];
		  else
		    i = " ";
		  break;
		case 's':
		  if (ch != NULL)
		    i = his_her[URANGE (0, ch->sex, 2)];
		  else
		    i = " ";
		  break;
		case 'S':
		  if (vch != NULL)
		    i = his_her[URANGE (0, vch->sex, 2)];
		  else
		    i = " ";
		  break;
		case 'p':
		  if (obj1 != NULL)
		    {
		      i = can_see_obj (to, obj1)
			? ((obj1->chobj != NULL && obj1->chobj == to)
			   ? "you" : obj1->short_descr) : "something";
		    }
		  else
		    i = " ";
		  break;

		case 'P':
		  if (obj2 != NULL)
		    {
		      i = can_see_obj (to, obj2)
			? ((obj2->chobj != NULL && obj2->chobj == to)
			   ? "you" : obj2->short_descr) : "something";
		    }
		  else
		    i = " ";
		  break;
		}
	    }

	  ++str;
	  while ((*point = *i) != '\0')
	    ++point, ++i;
	}

      *point++ = '\n';
      *point++ = '\r';
/*
	if (is_fam)
	{
	    if (to->in_room != ch->in_room && familiar != NULL &&
		familiar->in_room == ch->in_room)
		send_to_char("[ ", to);
	    else
	    {
		to = to_old;
		continue;
	    }
	}
*/
      buf[0] = UPPER (buf[0]);
      write_to_buffer (to->desc, buf, point - buf);
/*
	if (is_fam) to = to_old;
*/
    }
  return;
}



void
kavitem (const char *format, CHAR_DATA * ch, const void *arg1,
	 const void *arg2, int type)
{
  static char *const he_she[] = { "it", "he", "she" };
  static char *const him_her[] = { "it", "him", "her" };
  static char *const his_her[] = { "its", "his", "her" };

  char buf[MSL];
  char bugbuf[MSL];
  char kav[MIL];
  CHAR_DATA *to;
  CHAR_DATA *vch = (CHAR_DATA *) arg2;
  OBJ_DATA *obj1 = (OBJ_DATA *) arg1;
  const char *str;
  const char *i;
  char *point;
  bool is_ok;
  int bugcount = 0;
  /*
   * Discard null and zero-length messages.
   */
  if (format == NULL || format[0] == '\0')
    return;

  if ((ch == NULL) || (ch->position == POS_DEAD))
    return;

  to = ch->in_room->people;
  if (type == TO_VICT)
    {
      if (IS_NPC (vch))
	return;

      if (vch == NULL || vch->in_room == NULL || vch->position == POS_DEAD)
	{
	  sprintf (bugbuf, "%s Kavitem: null vch with TO_VICT.", ch->name);
	  bug (bugbuf, 0);
	  return;
	}
      to = vch->in_room->people;
    }

  for (; to != NULL; to = to->next_in_room)
    {
      if (to->desc == NULL || !IS_AWAKE (to) && bugcount < 1)
	{
	  bugcount++;
	  continue;
	}
      if (to->desc == NULL || !IS_AWAKE (to) && bugcount >= 1)
	{
	  sprintf (bugbuf, "%s Kavitem: freeze bug, returning.", ch->name);
	  bug (bugbuf, 0);
	  return;
	}

      if (ch->in_room->vnum == ROOM_VNUM_IN_OBJECT)
	{
	  is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_room != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_room != NULL &&
	      ch->in_room == to->in_room)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!IS_NPC (ch) && ch->pcdata->chobj != NULL &&
	      ch->pcdata->chobj->in_obj != NULL &&
	      !IS_NPC (to) && to->pcdata->chobj != NULL &&
	      to->pcdata->chobj->in_obj != NULL &&
	      ch->pcdata->chobj->in_obj == to->pcdata->chobj->in_obj)
	    is_ok = TRUE;
	  else
	    is_ok = FALSE;

	  if (!is_ok)
	    continue;
	}
      if (type == TO_CHAR && to != ch)
	continue;
      if (type == TO_VICT && (to != vch || to == ch))
	continue;
//      if (type == TO_ROOM && to == ch)
//      continue;
      bugcount = 0;
      if (type == TO_ROOM && to == ch && bugcount < 1)
	{
	  bugcount++;
	  continue;
	}
      if (type == TO_ROOM && to == ch && bugcount >= 1)
	{
	  sprintf (bugbuf, "%s kavitem: freeze bug with TO_ROOM: %s.",
		   ch->name, format);
	  bug (bugbuf, 0);
	  return;
	}

      if (type == TO_NOTVICT && (to == ch || to == vch))
	continue;

      point = buf;
      str = format;
      while (*str != '\0')
	{
	  if (*str != '$')
	    {
	      *point++ = *str++;
	      continue;
	    }
	  ++str;

	  if (arg2 == NULL && *str >= 'A' && *str <= 'Z')
	    i = "";
	  else
	    {
	      switch (*str)
		{
		default:
		  i = "";
		  break;
		case 'n':
		  i = PERS3 (ch, to);
		  break;
		case 'e':
		  i = he_she[URANGE (0, ch->sex, 2)];
		  break;
		case 'm':
		  i = him_her[URANGE (0, ch->sex, 2)];
		  break;
		case 's':
		  i = his_her[URANGE (0, ch->sex, 2)];
		  break;
		case 'p':
		  i = can_see_obj (to, obj1)
		    ? ((obj1->chobj != NULL && obj1->chobj == to)
		       ? "you" : obj1->short_descr) : "something";
		  break;

		case 'o':
		  if (obj1 != NULL)
		    sprintf (kav, "%s's", obj1->short_descr);
		  i = can_see_obj (to, obj1)
		    ? ((obj1->chobj != NULL && obj1->chobj == to)
		       ? "your" : kav) : "something's";
		  break;

		}
	    }

	  ++str;
	  while ((*point = *i) != '\0')
	    ++point, ++i;
	}

      *point++ = '\n';
      *point++ = '\r';
      buf[0] = UPPER (buf[0]);
      if (to->desc && (to->desc->connected == CON_PLAYING))
	write_to_buffer (to->desc, buf, point - buf);
    }

  return;
}

Site Stats

Snippets: 1791
Codebases: 571