/
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/
#include "language.h"
inherit "/std/object";

object *writing_on;
int     ink_amt, size;
object  ink_ob;

void    create()
{
    ::create();
    set_name( "quill" );
    set_long( "A nice long feathered quill.\n" );
    writing_on = ({ });
    set_weight( 10 );
    size = 10;
}

mixed * query_init_data()
{
    return ::query_init_data() +
	({ 
	      "name", 0, 0,
	      "long", 0, 0,
	      "short", 0, 0,
	      "plurals", 0, 0,
	      "adjectives", 0, 0,
	      "read_mess", 0, 0,
	      "main_plural", 0, 0,
	      "labels", 0, 0,
	      "alias", 0, 0,
	      "weight", 0, 0
	       });
}

void    init()
{
    ::init();
    this_player()->add_command( "dip", this_object(), "%D %p %I" );
    this_player()->add_command( "write", this_object(), "%p %I 'with' %D" );
    this_player()->add_command( "write", this_object(), "'with' %D %p %I" );
}

int     do_dip( object *obs )
{
    int     i;
    int *   coord;
    string *effects;

    for( i = 0; i < sizeof( obs ); i++ )
    {
	coord = (int *)obs[ i ]->query_ps_coord();
	if( (int)obs[ i ]->query_volume() && pointerp( coord ) )
	{
	    effects = (string *)"/obj/handlers/potion_space"->query_effect_at( coord );
	    if( sizeof( effects ) && effects[ 0 ]->query_ink() )
	    {
		this_player()->add_succeeded( obs[ i ] );
		ink_ob = obs[ i ];
		return 1;
	    }
	}
    }
    ink_ob = 0;
    return 0;
}

int     do_write( object *obs )
{
    int     i;
    string  lang;

    lang = (string)this_player()->query_current_language();
    if( !LANGUAGE_HAND->query_language_written( lang ) )
    {
	write( "You are not using a written language.\n" );
	return 0;
    }
    if( sizeof( writing_on ) )	/* Look!  We are already writing on it...  sheeze. */
	return 0;
    if( !ink_ob )
    {
	write( "You dont have any ink on " + short( 0 ) + "!\n" );

	return 0;
    }
    for( i = 0; i < sizeof( obs ); i++ )
	if( obs[ i ]->query_property( "writeable" ) )
	    writing_on += ({ obs[ i ] });
    if( !sizeof( writing_on ) )
	return 0;
    this_player()->add_succeeded( writing_on[ 0 ] );
    write( "Message to write on " + writing_on[ 0 ]->short() + "\n" );

    say( this_player()->query_cap_name() + " starts writing on " +
	 writing_on[ 0 ]->short() + ".\n" );

    this_player()->do_edit( 0, "finished_editing" );
    this_player()->supresse_add_command();	/* Supress the message printing. */
    return 1;
}

int     finished_editing( string str )
{
    string  lang;

    lang = (string)this_player()->query_current_language();
    if( !str || str == "" )
    {
	write( "Not writing anything on " + writing_on[ 0 ]->short() + ".\n" );
    }
    else
	if( !LANGUAGE_HAND->query_language_written( lang ) )
	{
	    write( "You seem to have changed to using a non written language.\n" );
	}
	else
	{
/* Ok... now do the writing itself... */
	    if( member_array( ink_ob, ( object * )environment()->find_inv_match() ) == -1 &&
		    member_array( ink_ob, ( object * )this_player()->find_inv_match() ) == -1 )
	    {
		write( "You have lost your ink.\n" );
		return 1;
	    }
	    ink_amt = strlen( str ) / 10;
/* I dont think we need this....
   str = replace(str, ({ "\n\n", "\n", "\n", " " }) );
 */
	    str = (string)writing_on[ 0 ]->add_read_mess( str,
							  ink_ob->query_liquid_name(), lang, size );
	    if( ink_ob->query_volume() < ink_amt )
	    {
		str = str[ 0..(int)ink_ob->query_volume() * 10 ];
		write( "Due to a shortage of ink you only write '" + str + "' on " +
		       writing_on[ 0 ]->short() + ".\n" );
	    }
	    else
		write( "You write '" + str + "' on " + writing_on[ 0 ]->short() + ".\n" );

	    ink_ob->remove_volume( strlen( str ) / 10 );
	    if( !strlen( str ) )
		write( "Your ink ran out and you could not write on " +
		       writing_on[ 0 ]->short() + ".\n" );

	    say( this_player()->query_cap_name() + " writes on " +
		 writing_on[ 0 ]->short() + " with " + short( 0 ) + ".\n" );
	}
    writing_on = writing_on[ 1..1000 ];
    if( sizeof( writing_on ) )
    {
	write( "Writing on " + writing_on[ 0 ]->short() + ".\n" );

	this_player()->do_edit( 0, "finished_editing" );
	return 1;
    }
    return 1;
}

void    heart_beat()
{
    ink_amt -= 2;
    if( ink_amt <= 0 )
    {
	ink_amt = 0;
	set_heart_beat( 0 );
    }
}