/* Cat spec from Ansalonmud.com - DSL
If you want to give credit, cool 
Include this in the bools in special.c

No warrantees etc, this is provided 'as is'
*/

/* In the defines add */
DECLARE_SPEC_FUN( spec_alleycat         );

/* In const struct  spec_type spec_table add */
    { "spec_alleycat",         spec_alleycat         },


bool spec_alleycat( 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("mouse", victim->name)
       && !is_name("bird", victim->name)
       && !is_name("swallow", victim->name)
       && !is_name("sparrow", victim->name))
      continue;

	if ( IS_AWAKE(victim) && number_range( 0, ch->level ) <= ch->level / 2 )
	{
	    act( "$n arches $s back and yowls at you!", ch, NULL, victim, TO_VICT );
	    act( "$n arches $s back at $N and yowls!", ch, NULL, victim, TO_NOTVICT );
	    return TRUE;
	}
	else
	{
        //Unnecessary unless you have changed hide/vis messages, comment out if wanted.
        if (!IS_AFFECTED(ch,AFF_HIDE))
           SET_BIT(ch->affected_by,AFF_HIDE);
        if (ch->level >= victim->level || victim->level - ch->level < 5)
        {
          //If you've made do_bite() as a combat action; 
          //uncomment the next line
          //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;

    /* IS_KENDER(ch) etc are defined in merc.h such as:
    #define IS_KENDER(ch)     (ch->race == race_lookup("kender"))
    
    You'll want to make these for any race you want the
    cats to be MORE friendly to */

    // 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;
    }
    /* IS_MINOTAUR(ch) etc are defined in merc.h such as:
    #define IS_MINOTAUR(ch)     (ch->race == race_lookup("minotaur"))
    
    You'll want to make these for any race you want the
    cats to ignore or even 'fear' if you add that. */
    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("mouse", victim->name)
	     || is_name("bird", victim->name)
	     || is_name("swallow", victim->name)
	     || is_name("sparrow", victim->name)
	     || is_name("dog", victim->name)
	     || !IS_HUMANOID(victim))
      continue;

    switch (number_range (1, 12)) // Positive Reaction Switch
    {
    default:
    case 1:
    case 2:
    case 3:
      {
        act( "$n quietly meows at you.", ch, NULL, victim, TO_VICT );
        act( "$n quietly meows at $N.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;
    case 4:
    case 5:
      {
        act( "$n purrs at you and rubs against your leg.", ch, NULL, victim, TO_VICT );
        act( "$n purrs at $N and rubs against $S leg.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;
    case 6:
      {
        act( "$n meows at you loudly.", ch, NULL, victim, TO_VICT );
        act( "$n meows at $N loudly.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;
    case 7:
    case 8:
      {
        act( "$n looks at you and begins cleaning $mself.", ch, NULL, victim, TO_VICT );
        act( "$n looks at $N and begins cleaning $mself.", ch, NULL, victim, TO_NOTVICT );
        return TRUE;
      }
      break;    
    case 9:
    case 10:
        if (victim->position >= POS_STANDING)
        {
          act( "$n walks around your legs and purrs.", ch, NULL, victim, TO_VICT );
          act( "$n walks around $N's legs and purrs.", ch, NULL, victim, TO_NOTVICT );
        }
        else
        {
          act( "$n crawls up onto your lap for a moment and rubs against you.", ch, NULL, victim, TO_VICT );
          act( "$n crawls up onto $N's lap and rubs against $M for a moment.", ch, NULL, victim, TO_NOTVICT );
        }
      return TRUE;
      break;
    case 11:
    case 12:
        if (victim->position >= POS_STANDING)
        {
           act ("$n yawns and stretches, then curls up.", ch, NULL, NULL, TO_ROOM);
           do_function (ch, &do_sleep, "");
           return TRUE;
        }
      break;    
    }// End Random Positive Reaction Switch

    }// End FRIEND section
    return FALSE;
}