/* Obiek sluzacy do uciszania niewygodnych osob ......
 *
 * Napisane przez Alfena
 *
 */

#include <stdproperties.h>
inherit "/std/paralyze";

/* Some commands may always be issued. */
#define ALLOWED ({ "?", "zakoncz", "pomoc", "reply" })


void
create_paraliz()
{
  set_standard_paralyze("paraliz");
  set_stop_verb("robaczek");
}


public nomask void
create_paralyze()
{
  create_paraliz();
}


/*
 * Function name: stop
 * Description  : Here all commands the player gives comes.
 * Argument     : string str - The command line argument.
 * Returns      : int 1/0    - success/failure.
 */
int
stop(string str)
{
    /* Only paralyze our environment */
    if (environment() != this_player())
    {
	return 0;
    }

    /* Some commands may always be issued. */
    if (member_array(query_verb(), ALLOWED) != -1)
    {
	return 0;
    }

    /* If there is a verb stopping the paralyze, check it. */
    if (stringp(stop_verb) &&
	(query_verb() == stop_verb))
    {
	/* If a stop_fun is defined it MUST return 1 in order not stop the
	 * paralyze.
	 */
	if (objectp(stop_object) &&
	    call_other(stop_object, stop_fun, str))
	{
	    return 1;
	}

	set_alarm(0.3, 0.0, remove_object);

	if (stringp(stop_message))
	{
	    this_player()->catch_msg(stop_message);
	}

	return 1;
    }

    /* We allow VBFC, so here we may use catch_msg(). */
    if (stringp(fail_message))
    {
	this_player()->catch_msg(fail_message);
    }

    /* Only paralyze mortals. */
    if ((this_player()->query_real_name())!="alfen")
    {
	return 1;
    }
    else
    {
      write("No coz na tworcy sie nie da uzyc tego obiektu.... \n");
      if (objectp(stop_object) &&
	    call_other(stop_object, stop_fun, str))
	{
	    return 1;
	}

	set_alarm(0.3, 0.0, remove_object);

	if (stringp(stop_message))
	{
	    this_player()->catch_msg(stop_message);
	}

	return 1;
    }
    return 0;
}


void
enter_env(object dest, object old)
{
  if (dest&&living(dest))
  {
    dest->add_prop(LIVE_S_EXTRA_SHORT,
      " oplecin"+dest->koncowka("y","a")+" ognistymi kregami");
    dest->add_prop(LIVE_I_STUNNED, 40);
  }
  ::enter_env(dest, old);
}


int
remove_object()
{
  object ob = environment(this_object());
  if (ob && living (ob) )
  {
    ob->remove_prop(LIVE_S_EXTRA_SHORT);
    ob->remove_prop(LIVE_I_STUNNED);
  } 
  return ::remove_object();
}
