/* An example spell book made by Nick */

inherit "/std/spells";  /* To inherit the standard spell function. */
#include <macros.h>

#define SPELL_DIR "/d/Wiz/simon/" /* To be used later. */

string spell_verb; /* This string will hold the verb the caster of a spell */
		   /* used. */

/*
 * Here follow the standard create routine of spells.
 * Here you can add spells to the object 
 */
void
create_spells()
{

    ustaw_nazwe(({"ksiega","ksiegi","ksiedze","ksiege","ksiega","ksiedze"}),
		({"ksiegi","ksiag","ksiega","ksiegi","ksiegami","ksiegach"}),
		PL_ZENSKI);
    ustaw_shorty(({"ksiega czarow","ksiegi czarow","ksiedze czarow",
		  "ksiege czarow","ksiega czarow","ksiedze czarow"}),
		({"ksiegi czarow","ksiag czarow","ksiega czarow",
		"ksiegi czarow","ksiegami czarow","ksiegach czarow"}),
		PL_ZENSKI);
    dodaj_przym("zielony","zieleni");
    set_long("Wyglada bardzo interesujaco moze bys ja przeczytal.\n");

    /* Now we add the spells. */
    /*         verb           function              name  */

    add_spell("promien", "cast_spell",     "magiczny promien");
}

/*
 * Add any more commands here?
 */
void
init()
{
    ::init(); /* Always good to do. */
    add_action("read", "przeczytaj");
}

/*
 * Player tries to read something
 */
int
read(string str)
{
    notify_fail("Przeczytaj co? Moze ksiege?\n");
    if (str!="ksiege")
	return 0;

    write(break_string("Zaczynasz czytac starodawne runy w ksiedze. " +
        "Rozpoznajesz jedna formule czru:\n", 70) +
        "promien   - Magiczny promien raniacy twych przeciwnikow.\n");
    return 1;
}

/*
 * This function is called when the spell is actually cast. This is the
 * second argument in add_spell(). See create_spell() above
 */
int
cast_spell(string str)
{
    string spell_file;

    seteuid(getuid(this_object())); /* We might have to load a file. */
    spell_file = SPELL_DIR + spell_verb;

    /* This will call the <function name> in th <spell_file> with the
       argument str. The actual spell code is there. */
    return call_other(spell_file, spell_verb, str);
}

/*
 * Does this spell take much time to cast? 
 */
int
query_spell_time(string str)
{
    spell_verb = str;

    if (str == "promien")
	return 3; /* Energy_blast takes a little more concentration */

    return 0; /* Concentration will be during 2 (default value) + 0 */
	      /* heart beats this way. */
}

/*
 * Do we want a special message to be printed or is the default message fine
 * with us?
 */
int
query_spell_mess(string str)
{
    if (str == "promien")
    {
	write("Wypowiadasz glosno i wyraznie starodawna formule.\n");
	say(QCTNAME(this_player()) + " wypowiada glosno nie zrozumiale tobie slowa.\n");
        return 1;
    }
    return 0;
}

/*
 * Description:	This is called upon given spell command.
 *		It should print fail messages if appropriate
 * Returns:	1 if the spell fails.
 */
int
start_spell_fail(string verb, string arg)
{
    string str;
    string spell_file;

    spell_verb = verb;

    seteuid(getuid(this_object())); /* We might have to load a file. */
    spell_file = SPELL_DIR + verb;

    /* This will call the <function name> in th <spell_file> with the
       argument str. The actual spell code is there. */
    str = call_other(spell_file, spell_verb + "_start_fail", verb, arg);
    if (stringp(str))
    {
    write(str);
	return 1;
    }
    return 0;
}

	
