/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
#define MIN_LVL 1
#define AMBUSH_COST 50
#define STEALTH "other.covert.stealth"
#define HIDDEN_BONUS 50
#define TEACH_LEVEL 40
#define LEARN_LEVEL 10


/*
 * inherit "/std/weapon_logic";
 */

int     ambush( string str )
{
    int     skill, mul, i;
    object  weap, ambusher, *obs;
    string  sname, mess;

    ambusher = this_player();

/*  Looks pretty finished to me...
   if (!ambusher->query_creator()) {
   notify_fail("Ambush not finished.\n");
   return 0;
   }
 */
    if( !str )
    {
	notify_fail( "Usage: ambush <person>\n" );
	return 0;
    }
    skill = (int)ambusher->query_skill_bonus( STEALTH );
    if( ambusher->query_hide_shadow() )
	skill += HIDDEN_BONUS;

    if( skill < MIN_LVL )
    {
	write( "You are not stealthy enough even to try.\n" );
	return 1;
    }
    weap = (object)ambusher->query_weapon();
    if( !weap )
	weap = ambusher;
    skill += (int)weap->query_property( "ambush bonus" );
    sname = (string)weap->query_weap_skill();
    switch( sname )
    {
	case "fighting.combat.melee.sharp":
	    mess = "backstab";
	    break;
	case "fighting.combat.melee.blunt":
	    mess = "cosh";
	    break;
	case "fighting.combat.melee.unarmed":
	    mess = "Spock pinch";
	    break;
	default:
	    write( "You cannot ambush with that type of weapon.\n" );
	    return 1;
    }
    obs = find_match( str, environment( ambusher ) );
    if( !sizeof( obs ) )
    {
	write( "Ambush whom?\n" );
	return 1;
    }
    if( sizeof( (object *)ambusher->query_attacker_list() ) )
    {
	write( "You can't sneak up behind people in the heat of battle!\n" );
	return 1;
    }
    if( (int)ambusher->adjust_gp( AMBUSH_COST ) == -1 )
    {
	write( "You lack sufficient guild points to Ambush at the moment.\n" );
	return 1;
    }
    if( userp( obs[ 0 ] ) && userp( ambusher ) )
    {
	write( "You may not ambush " + obs[ 0 ]->query_name() + ".\n" );
	return 1;
    }
    write( "You " + mess + " " + obs[ 0 ]->query_name() + ".\n" );
    mess = pluralize( mess );
    say( ambusher->query_cap_name() + " " + mess + " " +
	 obs[ 0 ]->query_name() + ".\n", obs[ 0 ] );
    tell_object( obs[ 0 ], ambusher->query_cap_name() +
		 " " + mess + " you.\n" );
    obs[ 0 ]->attack_by( ambusher );
    ambusher->attack_by( obs[ 0 ] );
    ambusher->modify_skill( sname, skill );
    weap->weapon_attack( obs[ 0 ], ambusher );
    ambusher->modify_skill( sname, -skill );
    return 1;
}

string  help( string str )
{
    return "Syntax: ambush <person>\n\n" +
	"The ambush action gives a bonus to your first attack equal to your skill in " +
	STEALTH + ". This bonus can only be applied to melee weapons (or unarmed " +
	"combat) " +
	"To ambush you must not be in combat yourself (though your target may be). " +
	"Also, being hidden when you ambush gives a +" + HIDDEN_BONUS +
	"bonus to this action.\n" +
	"Example:\n" +
	"> wield club\n" +
	"> ambush thief\n" +
	"You cosh thief.\n\n" +
	"See also\n" +
	"  Hmmm?\n";
}

int     teach( object ob )
{
    if( this_player()->query_skill( STEALTH ) < TEACH_LEVEL )
	return -2;
    if( ob->query_skill( STEALTH ) < LEARN_LEVEL )
	return -1;
    ob->add_known_command( "ambush" );
    return 1;
}