log/
/***************************************************************************
 *  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.                                               *
 *                                                                         *
 *  Dystopia Mud improvements copyright (C) 2000, 2001 by Brian Graversen  *
 *                                                                         *
 *  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.                                                  *
 ***************************************************************************/

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

/*
 * The following special functions are available for mobiles.
 */
DECLARE_SPEC_FUN( spec_priest		);
DECLARE_SPEC_FUN( spec_ninja		);


/***************************************************
 * This is a prototype of a special program, feel  *
 * free to copy and edit this to suit your needs   *
 ***************************************************

bool spec_prototype(CHAR_DATA *ch, char *argument)
{
  if (!str_cmp(argument, "update"))
  {
    if (ch->fighting) return FALSE;

    // This part should contain movement, spell-casting, etc,
    // this part is called once every 4 seconds, and is not
    // related to combat...
  }
  else if (!str_cmp(argument, "midround"))
  {
    if (!ch->fighting) return FALSE;

    // This part is the combat oriented part of the code,
    // and is called once every combat round. It should
    // contain special moves/powers the mob uses in combat.
  }

  return FALSE;
}

****************************************************/

bool spec_ninja(CHAR_DATA *ch, char *argument)
{
  if (!str_cmp(argument, "update"))
  {
    if (ch->fighting) return FALSE;

    /* if not hidden, hide */
    if (ch->position == POS_STANDING && !IS_AFFECTED(ch, AFF_HIDE))
      do_hide(ch, "");
    else return FALSE;
  }
  else if (!str_cmp(argument, "midround"))
  {
    CHAR_DATA *victim;

    if ((victim = ch->fighting) == NULL)
      return FALSE;

    if (number_range(1,3) == 2)
      one_hit(ch, victim, gsn_backstab, 0);
  }

  return FALSE;
}

bool spec_priest(CHAR_DATA *ch, char *argument)
{
  if (!str_cmp(argument, "update"))
  {
    CHAR_DATA *vch;
    CHAR_DATA *gch;
    bool found = FALSE;
    int sn;

    for (vch = ch->in_room->people; vch && !found; vch = vch->next_in_room)
    {
      if (vch == ch) continue;
      if (number_range(1,2) == 1) continue;
      found = TRUE;
      gch = vch;
    }

    if (!found) return FALSE;

    switch(number_range(1,3))
    {
      case 1:
        sn = skill_lookup("heal");
        break;
      case 2:
        sn = skill_lookup("bless");
        break;
      case 3:
        sn = skill_lookup("darkblessing");
        break;
    }
    if (sn < 1) return FALSE;

    act("$n mumbles a few arcane words.", ch, NULL, NULL, TO_ROOM);
    (*skill_table[sn].spell_fun) (sn, ch->level, ch, gch);

    return TRUE;
  }
  else if (!str_cmp(argument, "midround"))
  {
    /* the priest does not fight */
    return FALSE;
  }

  return FALSE;
}

/*
 * Special Functions Table.     OLC
 */
const   struct  spec_type       spec_table      [ ] =
{
    /*
     * Special function commands.
     */
    { "spec_priest",                spec_priest         },
    { "spec_ninja",                 spec_ninja          },

    /*
     * End of list.
     */
    { "",                       0       }
};


/*****************************************************************************
 Name:          spec_lookup
 Purpose:       Given a name, return the appropriate spec fun.
 Called by:     do_mset(act_wiz.c) load_specials,reset_area(db.c)
 ****************************************************************************/
SPEC_FUN *spec_lookup( const char *name )       /* OLC */
{   
    int cmd;

    for ( cmd = 0; *spec_table[cmd].spec_name; cmd++ )  /* OLC 1.1b */
        if ( !str_cmp( name, spec_table[cmd].spec_name ) )
            return spec_table[cmd].spec_fun;
 
    return 0;
}

/*****************************************************************************
 Name:          spec_string
 Purpose:       Given a function, return the appropriate name.
 Called by:     <???>
 ****************************************************************************/
char *spec_string( SPEC_FUN *fun )      /* OLC */
{
    int cmd;

    for ( cmd = 0; *spec_table[cmd].spec_fun; cmd++ )   /* OLC 1.1b */
        if ( fun == spec_table[cmd].spec_fun )
            return spec_table[cmd].spec_name;
    
    return 0;
}