[go: up one dir, main page]

Menu

[897c37]: / mlib / std / itemer.lpc  Maximize  Restore  History

Download this file

68 lines (57 with data), 1.3 kB

/* 
 *  ITEMER
 * 
 *  Find an item and outfit the given object with it.
 *  If not available create it?
 *
 *	The itemer probably should have some way of knowing to
 *	use the /std/weaponer or /std/armorer when no item
 *	is available for sale and it is a weapon/armor that we are after!
 *
 *  Dredd
 */

#include "Servers.h"

create_item(str)
{
    if (WEAPONER->weapon_exists(str))
    {
        return WEAPONER->make(str);
    }
    else if (ARMOURER->armour_exists(str))
    {
        return ARMOURER->make("any", str);
    }
    else if (GEMMER->gem_exists(str))
    {
        return GEMMER->make(random(10)+1, str);
    }
    return 0;
}

make(str)
{
    string who;
    array items;

	who = query_su_name(caller());
	if (!who) who = "#treasury";
	items =	SHOP_SERVER->get_cheapest(str, who, 3000);
	if (items) return items[0];
}

outfit(whom, str, a)
{
    string who, com;
    array items;

	who = query_su_name(caller());
	if (!who) who = "#treasury";
	if (a) str = str + " " + a;

	items =	SHOP_SERVER->get_cheapest(str, who);
	if (!items) 
    {
        items = create_item(str);
        if (!items) return 0;
    }

	transfer(items[0], whom);
	if (items[0]->armour_class()) com = "wear ";
	else if (items[0]->weapon_class()) com = "wield ";

	if (com) command(com  + str, whom);

	return items[0];
}