// Guard Dogs, these will agro the 'wrong clan's in cities
// Also fun dog stuff, whine/wimper, bark etc
// Ziv/Dave/Skol on Ansalon.net

bool spec_gdog( CHAR_DATA *ch )
{
    CHAR_DATA *victim;
    CHAR_DATA *v_next;

    if ( ch->position != POS_STANDING )
      return FALSE;
	
    // Look for PREY
    for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
    {
	v_next = victim->next_in_room;

	if (is_safe (ch, victim) || (victim == ch))
	  continue;


	if ( !IS_NPC(victim)
	||   victim->level >= ch->level + 6
	||   number_bits( 4 ) != 0
	||   !can_see(ch,victim))
      continue;

    if (!is_name("rat", victim->name) 
       && !is_name("pig", victim->name)
       && !is_name("rabbit", victim->name)
       && !is_name("chicken", victim->name)
       && !is_name("rooster", victim->name)
       && !is_name("cat", victim->name))
      continue;

	if ( IS_AWAKE(victim) && number_range( 0, ch->level ) <= ch->level / 2 )
	{
	    act( "$n drops $s head low and growls at you!", ch, NULL, victim, TO_VICT );
	    act( "$n drops $s head and growls at $N!", ch, NULL, victim, TO_NOTVICT );
	    return TRUE;
	}
	else
	{
        if (!IS_AFFECTED(ch,AFF_HIDE))
           SET_BIT(ch->affected_by,AFF_HIDE);
        if (ch->level >= victim->level || victim->level - ch->level < 5)
        {
          do_function (ch, &do_bite, victim->name);
          multi_hit( ch, victim, TYPE_UNDEFINED );
	      return TRUE;
	    }
	    else
	      return FALSE;
	}
    }// End PREY section

    if (ch->hit < ch->max_hit)
      return FALSE; // Not friendly when hurt

    // Look for FRIENDS
    for ( victim = ch->in_room->people; victim != NULL; victim = v_next )
    {
	v_next = victim->next_in_room;

	if (!can_see (ch,victim) || (victim == ch))
	  continue;

    // Cats like little people better, not evils though
    if ((IS_KENDER(victim) || IS_AGHAR(victim) 
    || IS_NEIDAR(victim) || IS_HYLAR(victim) 
    || IS_GNOME(victim)))
    {
      if (number_bits (4) !=0)
      continue;
    }
    else if (IS_MINOTAUR(victim) || IS_GOBLIN(victim) 
    || IS_HOBGOBLIN(victim) || IS_OGRE(victim))
      continue;
    else if (number_bits (8) !=0)
      continue;

    if (is_name("rat", victim->name) 
       || is_name("pig", victim->name)
       || is_name("rabbit", victim->name)
       || is_name("chicken", victim->name)
       || is_name("rooster", victim->name)
       || is_name("cat", victim->name))
      continue;

    switch (number_range (1, 12)) // Positive Reaction Switch
    {
    default:
    case 1:
    case 2:
    case 3:
      {
        act( "$n quietly whines at you.", ch, NULL, victim, TO_VICT );
        act( "$n quietly whines at $N.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;
    case 4:
    case 5:
      {
        act( "$n pants and rubs against your leg.", ch, NULL, victim, TO_VICT );
        act( "$n pants and rubs against $N's leg.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;
    case 6:
      {
        act( "$n stares at you with puppy eyes.", ch, NULL, victim, TO_VICT );
        act( "$n stares at $N with big eyes.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;
    case 7:
    case 8:
      {
        act( "$n looks at you and begins scratching $mself.", ch, NULL, victim, TO_VICT );
        act( "$n looks at $N and begins to scratch.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;    
    case 9:
    case 10:
        if (victim->position >= POS_STANDING)
        {
          act( "$n walks between your legs wagging $s's tail.", ch, NULL, victim, TO_VICT );
          act( "$n walks between $N's legs wagging $s' tail.", ch, NULL, victim, TO_NOTVICT );
        }
        else
        {
          act( "$n crawls up to you and plops $S head in your lap.", ch, NULL, victim, TO_VICT );
          act( "$n crawls up to $N and plops $s head in $M's lap.", ch, NULL, victim, TO_NOTVICT );
        }
      return TRUE;
      break;
    case 11:
    case 12:
        if (victim->position >= POS_STANDING)
        {
            act ("$n stretches, then plops down.", ch, NULL, NULL, TO_ROOM);
	        if (IS_SET (ch->act, ACT_PET))
               return FALSE;
            else
            {
               do_function (ch, &do_sleep, "");
               return TRUE;
            }
        }
      break;    
    }// End Random Positive Reaction Switch

    }// End FRIEND section
    return FALSE;
}