/
lib/banish/
lib/d/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/doc/examples/
lib/doc/examples/armour/
lib/doc/examples/contain/
lib/doc/examples/food/
lib/doc/examples/magic/
lib/doc/examples/monster/
lib/doc/examples/room/
lib/doc/examples/weapons/
lib/function/
lib/include/
lib/include/fn_specs/
lib/include/skills/
lib/info/
lib/inherit/base/
lib/log/
lib/manuals/312/
lib/news/
lib/obj/party/
lib/objects/components/
lib/open/
lib/open/library/
lib/open/party/
lib/players/
lib/players/zilanthius/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/obj/
lib/room/city/shop/
lib/room/death/
lib/room/registry/
lib/secure/
lib/secure/UDP_CMD_DIR/
lib/skills/
lib/skills/fighter/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/players/
string tied_to;
object tied_to_ob;

id(str) {
    return str == "rope";
}

short() {
    if (tied_to)
        return "A rope tied to " + tied_to;
    return "A rope";
}

long() {
    write("You see nothing special about the rope.\n");
}

query_value() { return 15; }

get() {
    if (tied_to) {
        write("The rope is tied to " + tied_to + ".\n");
	return 0;
    }
    return 1;
}

query_weight() {
    return 1;
}

init() {
    add_action("tie", "tie");
    add_action("untie", "untie");
}

tie(str)
{
    string t1, t2;
    object ob;

    if (!str)
	return 0;
    if (tied_to) {
        write("It is already tied to " + tied_to + ".\n");
	return 1;
    }
    if (sscanf(str, "%s to %s", t1, t2) != 2)
        return 0;
    if (!id(t1))
	return 0;
    if (t2 == "me") {
        write("Why would you do that ?\n");
	return 1;
    }
    ob = present(t2, this_player());
    if (!ob)
	ob = present(t2, environment(this_player()));
    if (!ob) {
	if (call_other(environment(this_player()), "id", t2))
	    ob = environment(this_player());
    }
    if (!ob) {
	write("What ?\n");
	return 1;
    }
    if (!call_other(ob, "tie", t2)) {
        write("You can't tie the rope to " + t2 + ".\n");
	return 1;
    }
    /* Is he carrying the rope ? */
    if (environment() == this_player()) {
	move_object(this_object(), environment(this_player()));
	call_other(this_player(), "add_weight", - query_weight());
    }
    tied_to = t2;
    tied_to_ob = ob;
    write("Ok.\n");
    say(call_other(this_player(), "query_name") + " ties rope to " +
	t2 + ".\n");
    return 1;
}

untie(str) {
    if (!id(str))
        return 0;
    if (!tied_to) {
        write("It is not tied to anything.\n");
	return 1;
    }
    if (!call_other(tied_to_ob, "untie")) {
        write("You fail.\n");
	return 1;
    }
    write("Ok.\n");
    tied_to = 0;
    tied_to_ob = 0;
    return 1;
}