Coding Class: Dagger

From LSWiki

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

← Previous diff
Revision as of 22:45, 8 May 2008 (edit)
Matts (Talk | contribs)
(Code Discussion)
Next diff →
Line 1: Line 1:
- #include <item.h>+#include <item.h>
inherit "/std/item"; inherit "/std/item";
void configure() { void configure() {
Line 33: Line 33:
==== Code Discussion ==== ==== Code Discussion ====
-So the above code is the bare bones minimal effort it takes to create a code-current basic iron dagger. If you're an older coder you may notice several things missing that you are used to. Namely some type of set_id() or set_names(), set_weapon_class() and other such things. The reason we don't need them here is because we are using the power of [[definitions]] to our advantage. We tell the object that it's a dagger weapon made of iron and the game can figure out what to call it, how to color it, what weapon class, penetration, attack speed, weight and value it needs to have; among other things. You can get an idea of how this is possible by checking out the /def/* files listed above. Feel free to browse around while you're in there and get a feel of what's defined and what isn't.+So the above code is the bare bones minimal effort it takes to create a code-current basic iron dagger. If you're an older coder you may notice several things missing that you are used to. Namely some type of set_id() or set_names(), set_weapon_class() and other such things. The reason we don't need them here is because we are using the power of [[definitions]] to our advantage. We tell the object that it's a dagger weapon made of iron and the game can figure out what to call it, how to color it, what weapon class, penetration, attack speed, weight and value it needs to have; among other things.<br>
 +You can get an idea of how this is possible by checking out the /def/* files listed above. Feel free to browse around while you're in there and get a feel of what's defined and what isn't.<br><br>

Revision as of 22:45, 8 May 2008

  1. include <item.h>
inherit "/std/item";
void configure() {
    ::configure();
    weapon()->set_weapon_type(Weapon_Type_Dagger);
    set_craft(Craft_Good);
    add_description(Description_Type_Generic);
    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

  • /def/material/i/iron.c
  • /def/weapon_type/d/dagger.c
  • /obj/extensions/weapon.c
  • /std/item.c

Code Discussion

So the above code is the bare bones minimal effort it takes to create a code-current basic iron dagger. If you're an older coder you may notice several things missing that you are used to. Namely some type of set_id() or set_names(), set_weapon_class() and other such things. The reason we don't need them here is because we are using the power of definitions to our advantage. We tell the object that it's a dagger weapon made of iron and the game can figure out what to call it, how to color it, what weapon class, penetration, attack speed, weight and value it needs to have; among other things.
You can get an idea of how this is possible by checking out the /def/* files listed above. Feel free to browse around while you're in there and get a feel of what's defined and what isn't.

Personal tools