An Expanding Bag

// Petrarch #include <std.h> inherit STORAGE; int mytake(string str); int myput(string str); int move_all(); void init() { ::init(); add_action("myput", "put"); add_action("mytake", "take"); add_action("mytake", "get"); } void create() { ::create(); set_name("bag"); set_id( ({ "bag" }) ); set_adjectives( ({ "bag"}) ); set_short("a small bag made from a blowfish"); set_long("This small bag is made of a Blowfish, it will expand to fit your needs."); set_mass(3); set_value(100+random(75)); set_material(({"organic"})); set_max_encumbrance(650+random(150)+random(100)); set_prevent_put("You cannot put this in there!"); } int move_all() { int i, j; object *things; i = sizeof(things = all_inventory(this_object())); if (i==0) return notify_fail("The bag is empty.\n"); for(j=0;j<i;j++) mytake(things[j]->query_name()+" from bag"); return 1; } int myput(string str) { int i; string obj; object ob; if(!str) return 0; if(i=sscanf(str, "%s in bag", obj) != 1) return notify_fail("Hummmm... try put [object] in bag.\n"); if(!(ob = present(obj, this_player()))) return notify_fail("You don't have that.\n"); if(ob->query_mass() + query_encumbrance() > query_max_encumbrance()) return notify_fail("It won't fit.\n"); if(ob->query_prevent_put()) return notify_fail(ob->query_prevent_put()); write("You put "+ob->query_name()+" in the bag."); say((string)this_player()->query_cap_name()+" puts "+ob->query_name()+" in the bag."); ob->move(this_object()); set_mass(3+(int)query_encumbrance()/10); this_player()->add_encumbrance(ob->query_mass()/10); return 1; } int mytake(string str) { int i; string obj; object ob; if(!str) return 0; if(i=sscanf(str, "%s from bag", obj) != 1) return notify_fail("Hummmm... try get [object] from bag.\n"); if(obj=="all") { move_all(); return 1; } if(!(ob = present(obj, this_object()))) return notify_fail("That is not in the bag.\n"); if(ob->query_mass()/9 + this_player()->query_encumbrance() > this_player()->query_max_encumbrance()) return notify_fail("You can't carry that much.\n"); write("You take "+ob->query_name()+" from the bag."); say((string)this_player()->query_cap_name()+" gets "+ob->query_name()+" from the bag."); ob->move(this_player()); set_mass(3+(int)query_encumbrance()/10); this_player()->add_encumbrance(-(ob->query_mass()/10)); return 1; }