/
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 "potion_attrs.h"

int     x1, x2, y1, y2;

void    set_boundaries( int *min, int *max )
{
    x1 = min[ 0 ];
    x2 = max[ 0 ];
    y1 = min[ 1 ];
    y2 = max[ 1 ];
}

int    *query_coordinate()
/*
 * this is for setting up potions ... say a wizard wants to put a healing
 * potion on her monster, she would put the line
 * set_ps_coord_quantity("/std/effects/cure_wounds"->query_coordinate(), 1000)
 * on it ... this one is the dumb standard one which just averages them
 * to get the midpoint
 */
{
    return({ (x1 + x2) / 2, ( y1 + y2 ) / 2 });
}

mixed * query_attrs( int *coord )
/*
 * return attrs@coord.  attrs is an array with elements as defined in
 *  include/potion_attrs.h ... definitely to be masked
 */
{
    return({ 0, 100, ({ }), ({ }), ({ }), ({ }) });
}

int     query_pass_through( int *coord )
/*
 * how much of any 'masked' effects will be passed through?
 * returns percentage 
 */
{
    return 100;
}

/* 
   backdrop(int *coord)
   * if this returns true if this effect is just a 'backdrop' 
   * if it _is_ then unless it is the first effect to be found, it 
   * will _not_ be called at all.  This is so that an area can have
   * a poison defined over it as a backdrop, then wherever useful potions
   * are placed on it the backdrop potion is not used, tho any given
   * healing/whatever potion will probably pass all or most through
 */

/*
   void action_drunk(object ob, int *coord, int quantity)
   * this is called when a player drinks a potion @ relevant coordinate
 */

/*
   void action_touch(object ob, int *coord, int quantity)
   * this is called when an object is splashed with a potion of this effect
 */

/*
   void action_smell(object ob, int *coord, int quantity)
   * this is called when a player smells the potion.  The quantity is
   * a measure of the concentration of the potion ... basically
   * the potions ps_quantity * 100 / volume
 */

/*
   void action_create(object ob, int *coord, int quantity)
   * this is called when a potion is assigned the coordinate appropriate.
   * This is intended for those effects that are spontaneous upon creation ...
   * eg.  Exploding spontaneously
   *      Turning into a sludge monster
   *      Such concentrated acid that it dissolves the container its in
   *      etc
   * 'ob' is the container with the liquid in it.
 */

void    install_effect()
/*
 * install potion in potion space handler dbase
 */
{
    (void)POTION_SPACE_HANDLER->remove_effect( file_name( this_object() ) );
    (void)POTION_SPACE_HANDLER->add_effect( file_name( this_object() ), x1, x2, y1, y2 );
}

int     sqrt( int p )
{
    int     i;

    for( i = 1; i < 500; i++ )
	if( i * i > p )
	    return i - 1;
}

int     distance_within_region( int *coord )
{
    int     dx, dy;

    if( x1 < 0 )
    {
	if( x2 > 0 )
	    dx = (coord[ 0 ] < 0) ? -coord[ 0 ] : coord[ 0 ];
	else
	    dx = (x2 - coord[ 0 ]);
    }
    else
	dx = coord[ 0 ] - x1;

    if( y1 < 0 )
    {
	if( y2 > 0 )
	    dy = (coord[ 1 ] < 0) ? -coord[ 1 ] : coord[ 1 ];
	else
	    dy = (y2 - coord[ 1 ]);
    }
    else
	dy = coord[ 1 ] - y1;

    return sqrt( dx * dx + dy * dy );
}

int     distance_from_origin( int *coord )
{
    return sqrt( coord[ 0 ] * coord[ 0 ] + coord[ 1 ] * coord[ 1 ] );
}