Coding Class: Dagger

From LSWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:35, 8 May 2008 (edit)
Matts (Talk | contribs)

← Previous diff
Revision as of 22:36, 8 May 2008 (edit)
Matts (Talk | contribs)
(Important Header Files)
Next diff →
Line 1: Line 1:
- // Include our base header file+// Include our base header file
#include <item.h> #include <item.h>
// Inherit our base object for what we're creating // Inherit our base object for what we're creating
Line 21: Line 21:
==== Important Header Files ==== ==== Important Header Files ====
-/lib/craft.h - Craft_Good+* /lib/craft.h - Craft_Good
-/lib/item.h+* /lib/item.h
-/lib/materials.h - Material_Iron+* /lib/materials.h - Material_Iron
-/lib/weapons.h - Weapon_Type_Dagger+* /lib/weapons.h - Weapon_Type_Dagger
-/lib/descriptors/description.h - Description_Type_Generic+* /lib/descriptors/description.h - Description_Type_Generic
-/lib/descriptors/element.h - Element_Type, Element_Proportion+* /lib/descriptors/element.h - Element_Type, Element_Proportion
==== Important Source Files ==== ==== Important Source Files ====

Revision as of 22:36, 8 May 2008

// Include our base header file

#include <item.h>
// Inherit our base object for what we're creating
inherit "/std/item";
// configure() is where we define what the object -is-, and indirectly what it does.
void configure() {
    // Call the configure() function from the file we inherited above.  This really only calls one other function but it's necessary so that everything we're about to do works.
    ::configure();
    // Call set_weapon_type() in the weapon extension and set it to Weapon_Type_Dagger (since we're making a dagger!)
    weapon()->set_weapon_type(Weapon_Type_Dagger);
    // Set the craft of the item.
    set_craft(Craft_Good);
    // Setup a general default description.
    add_description(Description_Type_Generic);
    // Setup the materials and forms and parts that we want our dagger to be made of.
    add_proportion(([
        Element_Type       : Material_Iron,
        Element_Proportion : 1.0,
    ]));
}

Important Header Files

  • /lib/craft.h - Craft_Good
  • /lib/item.h
  • /lib/materials.h - Material_Iron
  • /lib/weapons.h - Weapon_Type_Dagger
  • /lib/descriptors/description.h - Description_Type_Generic
  • /lib/descriptors/element.h - Element_Type, Element_Proportion

Important Source Files

/obj/extensions/weapon.c /std/item.c

Code Discussion

Personal tools