-=[ Notes on /inherit/base/base_obj.c ]=- This base object is the parent object that is inherited by all of the generic objects, such as armour, weapon, room, container, living. In turn, living is inherited by monster, and player. And wizard inherits player. Why have these inheriting a base object? This can be answered in three ways. Firstly, the base object contains the code the was basically repeated in armour, weapon, room, etc. This saves function space and frees up memory. Secondly, all objects will have a complement of functions which are the same for all objects. Thirdly, a global change to a functions usage can easily be done by changing its implementation in one object. The disadvantage to this is an error in the base object will show up in all objects, so care has to be made when maintaining. Complete failure can result in the mudlib to breakdown. Failsafes have been built into the login to quickly rectify these situations. -=[ Process_str(str) & process_msg(str) ]=- Process_str() can parse a string and call functions that return strings. This can be useful for dynamically changing quantities. It has a format of "@@function:objectname|arg1|arg2|..|argn@@". However, its downfall is that you have to know the ditional parsing to allow the following format, "@@function:$this_player()$|arg1|..|argn@@". It will also accept, this_object(), environment(), previous_object(), environment(this_player()). All functions in the base object that do 'writes', parse the string through process_msg(). Thus a very simple watch could be made, void reset(status arg) { if(arg) return; set_name("watch"); set_short("Watch"); set_long("The time is @@query_time:$environment(this_player())$@@\n"); } -=[ Functions In Base Object ]=- string query_object_type(); returns the object type when this is inherited by the configurable objects. /inherit/armour returns "Armour", /inherit/weapon returns "Weapon", /inherit/room2 returns "Room", etc. -=- string query_create_room(); this returns the filename for the outer most environment which this_object was moved. -=- varargs string query_name(status arg); string set_name(string s); returns the capitalised name of an object. If it is living it will return the name appropriate to flags set in the monster/player. This can be invisible name, disguised name. If query_name is called with an arg of 1 then it returns the lower_case name (Its real_name). -=- string query_id(); string set_id(string s); returns the real_name of an object. -=- string query_alias_name(); string query_alias(); string set_alias_name(string s); string set_alias(string s); returns an object alias_name. This is an alternative id for the object. In living objects this is equivalent to 'disguise' name. -=- string query_alt_name(); string set_alt_name(string s); returns an objects alternative name. This is an alternative id for the object. In living objects this is equivalent to the 'invis_name'. -=- string query_short(); string set_short(string s); returns the short string which is seen when this object is not in the inventory of a living object. -=- string query_alt_short(); string set_alt_short(string arg); returns the alternative short string. This is seen by someone when this object is in the inventory of a living object. -=- string query_inv_short(); string set_inv_short(string arg); returns the inventory short string. This is seen by the living object when they look in their own inventory. -=- string query_long(); string set_long(string s); returns the long string of an object. -=- string query_alt_long(); string set_alt_long(string arg); returns the alternative long string. This is seen by the living object when they look at an object in their inventory. -=- string query_extra_long(); string set_extra_long(string s); returns the extra_long string. The extra_long is a string seen in the long of an object when this object is in its inventory. -=- string query_alt_extra_long(); string set_alt_extra_long(string arg); returns the alternative extra long. This is a string seen below the long of a living object when this is in its inventory. -=- string query_info(); string set_info(string s); returns the info string. The info string is what is seen by identify, divination spells. -=- string query_extra_info(); string query_examine(); returns the extra info string. Normally when you 'look at <item>' and 'examine <item>' are the same. However, if you set extra info, the 'examine' will yield extra_info. -=- string query_read(); string set_read(string s); returns the read string of the object. -=- string query_listen(); string set_listen(string s); returns the list string of the object. -=- string query_smell(); string set_smell(string s); returns the smell string of the object. -=- int query_weight(); int set_weight(int i); returns the weight of the object. Of note is living objects can only carry a weight of 10 + strength + racial carry bonus + magical bonus. -=- int query_value(); int set_value(int i); returns the value of the object. -=- int query_real_light(); returns the light value seen by this object. -=- int query_light_value(); returns the light value of this object. Note: this is only accurate if adj_light() is used. -=- status query_enchanted(); status set_enchanted(status s); returns true is this object is treated as enchanted. Eg high weapon class weapons. Usually these destruct when sold. -=- status query_modified(); status set_modified(status s); returns modified flag. If you modify an existing object. Eg. change its weapon class. Then you should set the modified flag to 1. -=- status query_quest_item(); status set_quest_item(status s); returns whether this is a quest item. If the item is specific for a quest, you should set this flag to 1. -=- status query_sell_destruct(); status set_sell_destruct(status s); returns true if destructs this object when selling to shop. -=- mixed query(string fun, mixed arg1, mixed arg2); A general query function. Eg. query("name",1) will return query_name(1). -=- mixed set(string fun, mixed arg1, mixed arg2); A general set function. Eg. set("name","bob") will call set_name("bob"); -=- int adj_light(int i); Adjusts the light value of this object by i. -=- status id(string str); returns true (1) if the string str is an id of this object. -=- string short(status wiz); returns a string. This is the string seen when in brief mode when looking in rooms, or is seen when a show_inventory() is called. See query_short(), query_alt_short(), query_inv_short(). -=- void long(status wiz); This writes the appropriate long string to the player. It is seen by the player when they 'look' or 'look at <item>' -=- void extra_long(status wiz); This writes the extra_info string to a player when they do an examine. If there is no extra_info string, then it writes the long(). -=- varargs status show_inventory(object ob); This writes the inventory of ob. If ob is 0 then, it writes the inventory of this object. -=- void info(); This writes the info string to the player. See query_info(), set_info(). -=- status read_msg(string str); writes the read message to the player. See query_read(), set_read(). -=- status listen(string str); writes the listen message to the player. See query_listen(), set_listen(). -=- status smell(string str); writes the smell message to the player. See query_smell(), set_smell(). Example: Using alt_short, alt_long /* a load stone */ inherit "inherit/treasure"; void reset(status arg) { if(arg) return; set_name("stone"); /* id of item */ set_alt_name("external"); /* id used by recalc_carry() for carry bonus */ set_short("Stone"); /* short seen when this is in a room */ /* short seen by those looking at player, note process_msg() */ set_alt_short("@@query_name:$environment()$@@'s Grey Stone"); /* short seen by player when doing an inventory */ set_inv_short("A Load Stone"); /* long seen when stone in room */ set_long("A small grey stone.\n"); /* long seen by player when they 'look at stone in their inventory */ set_alt_long("The stone seems quit weightless, but seems to burden you.\n"); /* seen above the players carry list when the player does an inventory */ set_alt_extra_long("You feel burdened.\n"); /* item given a value of 10 coins */ set_value(10); /* signal shop to destruct this when sold */ set_sell_destruct(1); /* flag that this is magical */ set_enchanted(1); /* give some more information if an identify is used */ set_info("The stone seems to be cursed.\n"+ "It gives the holder of the stone a weight problem.\n"); } /* fn called by recalc_carry() to return carry bonus */ int query_carry_bonus() { return -4; } /* flag that this cannot be dropped, destructs automatically on quit */ status drop() { return 1; } /* init is called each time an object is moved into its environment, or this object is moved */ init() { ::init(); if(environment() != this_player()) return; this_player()->recalc_carry(); }