Coding Class: Dagger IV

From LSWiki

(Difference between revisions)
Jump to: navigation, search

Current revision

#include <item.h>
inherit "/std/item";
void configure() {
   ::configure();
   set_unique(True);
   alter_identity(([
       Identity_Name       : "Heartpiercer",
       Identity_Flags      : Identity_Flag_Proper,
   ]), Identity_Alter_Add);
   set_identify_skills(([
       Skill_History       : 57,
       Skill_Legend_Lore   : 38,
       Skill_Theology      : 20,
   ]));
   weapon()->set_weapon_type(Weapon_Type_Dagger);
   set_craft(Craft_Good);
   add_description(([
       Description_Type    : Description_Type_Simple,
       Description_Content : ({
           ({ 'v', 0 }), ({ "are", 0 }), ({ 'a', Description(Description_Type_Craftsmanship_Adjective) }), 
           Description(Description_Type_Weapon_Type_Name), "with",
           ({ 'a', Description(Description_Type_Element_Name, ({ "sharp", "blade" }), ([ Element_Part : Part_Bulk ])) }),
           "and", ({ 'a', Description(Description_Type_Element_Name, ({ 0, "hilt" }), ([ Element_Part : Part_Base ])) }),
           "wrapped in", Description(Description_Type_Element_Name, 0, ([ Element_Part : Part_Wrap ])), 'b',
           ({ 'r', 0, "blade" }), "bears", 
           Description(Description_Type_Element_Name, ({ "elegant", 0 }), ([ Element_Part: Part_Inlay ])), 'b',
           Description(Description_Type_Object_Known, ({
               ({ 'v', 0 }), ({ "are", 0 }), 0, "-- once known as", ({ 't', "favored weapon" }),
               "of",  ({ 't', "legendary Lowlander danaan assassin Othdandel,"  }), "who famously used", ({ 'p', 0 }),
               "to assassinate Saint Clorcus,", ({ 't', "fifth Archistator of Cianna" }), "in A.A. 851", 'b',
               ({ 'v', 0 }), Description(Description_Type_Weapon_Type_Name), ({ "were", 0 }), "later captured from",
               "Othdandel by members of", ({ 't', "Julinian Company" }), "--", ({ 'a', "mercenary band" }), "hired by",
               ({ 's', "Saint Clorcus", "successor" }), 'b', "since", ({ 's', "Saint Clorcus", "canonization as a martyr-saint" }), 
               "in A.A. 989,", 0, ({ "have", 0 }), "become", ({ 'a', "object of veneration" }), "for",
               ({ 't', "Pantarchic Church" }), ", which considers", ({ 'v', 0 }), ({ 'a', "first-class relic" }),
               "as", ({ 'p', 0 }), ({ "are", 0 }), "said to bear traces of", ({ 's', "Saint Clorcus", "blood" }), 'b',
           })),
       }),
   ]));
   set_readable(({ "writing" }), Skill_Anglic, "Heartpiercer");
   add_proportion(([
       Element_Type        : Material_Steel,
       Element_Proportion  : 1.0,
   ]));
   add_proportion(([
       Element_Type        : Material_Oak,
       Element_Proportion  : 0.4,
       Element_Part        : Part_Base,
       Element_Flags       : Element_Flag_Secondary,
   ]));
   add_proportion(([
       Element_Type        : Material_Leather,
       Element_Proportion  : 0.4,
       Element_Part        : Part_Wrap,
       Element_Form        : Form_Strips,
       Element_Color       : "black",
       Element_Flags       : Element_Flag_Secondary,
   ]));
   add_proportion(([
       Element_Type        : Material_Silver,
       Element_Proportion  : 0.1,
       Element_Part        : Part_Inlay,
       Element_Form        : Form_Writing,
   ]));
   add_proportion(([
       Element_Type        : Material_Kedusham,
       Element_Proportion  : 0.02,
       Element_Part        : Part_Infusion,
   ]));
}


Important Header Files

  • /lib/descriptors/description.h
    • Description_*
  • /lib/descriptors/identity.h
    • Identity_*

Important Source Files

  • /std/item.c
  • /def/descriptor/description.c
  • /def/descriptor/identity.c
  • /txt/doc/build/timeline ('man timeline')
  • /txt/doc/build/consonance ('man consonance')

Code Comments

In the last class, we put the word "Heartpiercer" on the dagger, which suggests that this could be a unique item. Now, we expand on that idea, using set_unique(True) to do so. The set_unique() function will stop clones of this object from being instantiated if set to True, which has most immediately noticeable effect of stopping the 'clone' command from working with the object. One should generally use reload -t <object file> to bring a unique object to oneself. Unique objects typically can't be replicated or kept (and if kept will be dropped upon disincarnation), and may be treated differently by processes and functions which query their unique status.

This reveals a fundamental difference between unique objects and non-unique ones; the file for a unique object is loaded into memory and the resultant object is moved into an environment where the it interacts directly with the world of Lost Souls, whereas the base file for a non-unique object is loaded into memory and the object it represents is used as a template for copies to be made. The non-unique base objects that exist without an environment still exist and can technically be moved into an environment (though this should not be done), so it can be useful to think of them as real objects existing in a non-physical space (and needing to exist there for fundamental reasons), while their copies are moved into and exist in physical environments. This touches a bit on the concept of 'consonance' -- the idea that everything in the MUD or its codebase isn't a model or simulation of reality, but a distinct reality in and of itself. Read 'man consonance' early on in your dev career to try and understand this concept, but be forewarned: Here is Where Things Get Weird.

Next, since we've made this item unique, let's give it a proper name. We can do this by altering the item's identity descriptor to add the name element and ensure it is treated as a proper name. The alter_identity() function takes a mapping for its first argument, which in our case contains the parts of an Identity descriptor which we want to add to the object's base identity -- in this case the name "Heartpiercer" set as the Identity_Name field and the fact that this is a proper name with Identity_Flag_Proper in the Identity_Flags field. We also use the Identity_Alter_Add argument to specify that we want this information to be added to the base identity for the item.

We've also added identify skills for this item using the set_identify_skills() function. This function takes a simple mapping of skills and the thresholds over which one would see this object natively as "Heartpiercer" instead of needing to identify it via separate means; without set_identify_skills(), this dagger would need to be identified using a lens of insight or other means. Some thought should always be given to the skills and thresholds used -- since this is the relic of a saint, the theology and legend lore skills seem fairly appropriate, and since it was involved in a historical episode (that may be semi-obscure to non-believers), we can also put in the history skill at a higher threshold.

We've also expanded the description, adding some lore for this item. Its descripiton now shows:

   This is a well-crafted dagger with a sharp steel blade and an oak hilt wrapped in black leather strips.  Its blade bears elegant pearlescent silver writing.  This is Heartpiercer -- once known as the favored weapon
of the legendary Lowlander danaan assassin Othdandel, who famously used it to assassinate Saint Clorcus, the fifth Archistator of Cianna in A.A. 851.  This dagger was later captured from Othdandel by members of the
Julinian Company -- a mercenary band hired by Saint Clorcus's successor.  Since Saint Clorcus's canonization as a martyr-saint in A.A. 989, Heartpiercer has become an object of veneration for the Pantarchic Church,
which considers this a first-class relic as it is said to bear traces of Saint Clorcus's blood.  It has a few thin wisps of pearlescent light within and around it.  It is in perfect condition.  It looks about three
tenths of a dimin wide and three and nine tenths dimins long.  It weighs very little.

This additional bit of description was generated using Description_Type_Object_Known as the type of an additional description descriptor, which keys the additional description to the viewer's knowledge of the item's knowledge subject. This can also be done using the add_known_description() function, which builds a Description descriptor of type Description_Type_Object_Known and adds it to the object.

In order to fit our bit of lore within the larger context of Lost Souls, we should consult 'man timeline', where events such as the establishment of the Cathedral of Cianna are detailed. If adding lore which affects or references an established project, it is also important to understand any lore documented in the project.

Finally, since this is a holy object, let's add a bit of kedusham. Note that adding kedusham will add its properties to the dagger, making it a holy, magickal object. Using the add_property() function to separately set these properties is thus unnecessary and the use of this function to do so is deprecated. Additionally, since kedusham is both stronger and lighter than steel, adding kedusham as an element improves the dagger in several ways, including raising its durability, lowering its weight, and improving its utility as a weapon -- similarly to adding properties, using functions such as set_weight() or set_max_durability() to set up items (as is often done in other LPC code bases) is largely unnecessary and deprecated.

Personal tools