/* -------------------------------------------
 * Phase Skill for ROM24, 1.00 - 3/28/98
 * -------------------------------------------
 * The phase skill is a defensive skill similar
 * to dodge that allows the player to shift
 * out of phase to avoid incoming attacks.
 *
 * As with all else, please email me if you use
 * this code so I know my time is not going
 * to waste. :)
 *
 * Brian Babey (aka Varen)
 * [bribe@erols.com]
 * ------------------------------------------- */


/* -----------------------------------------------
 * In const.c, insert this into the skill table */

    {
        "phase",                { 10, 15, 40, 53 },     { 1, 3, 6, 0},
        spell_null,             TAR_IGNORE,             POS_FIGHTING,
        &gsn_phase,             SLOT( 0),       0,      0,
        "",                     "!Phase!",   ""
    },


/* ----------------------------------------------
 * In merc.h, under Game Parameters, increment
 * the variable MAX_SKILL by 1. */


/* ----------------------------------------------
 * In merc.h, under the new gsns section, insert
 * this line */

extern sh_int  gsn_phase;


/* ----------------------------------------------
 * In db.c, under new gsns, insert this line: */

sh_int                  gsn_phase;


/* ----------------------------------------------
 * In fight.c, in the local function declarations,
 * insert this line. */

bool    check_phase     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );


/* ---------------------------------------------
 * In fight.c, insert this function wherever
 * it belongs alphabetically (or wherever you'd
 * like it to be - it really doesn't matter) */

bool check_phase( CHAR_DATA *ch, CHAR_DATA *victim )
{
    int chance;

    if ( !IS_AWAKE(victim) )
	return FALSE;

    chance = get_skill(victim,gsn_phase) / 2;

    if (!can_see(victim,ch))
	chance /= 2;

    if ( number_percent( ) >= chance + victim->level - ch->level )
        return FALSE;

    act( "Your body phases to avoid $n's attack.", ch, NULL, victim, TO_VICT    );
    act( "$N's body phases to avoid your attack.", ch, NULL, victim, TO_CHAR    );
    check_improve(victim,gsn_phase,TRUE,6);
    return TRUE;
}

/* -------------------------------------------
 * In fight.c, inside BOTH damage and damage_old
 * functions, in the section where it checks
 * for parry/dodge, insert this line underneath
 * shield block */

        if ( check_phase( ch, victim) )
            return FALSE;
