User Tools

Site Tools


coding:basicweapon

A Basic Weapon

 
 1 #include <mudlib.h>
 2 inherit WEAPON;
 3 
 4 
 5 void reset(int arg){
 6   ::reset(arg);
 7   if (arg) return;
 8 
 9   set_name("prototype");
10   set_short("A prototype weapon");
11   set_long("It's hard to tell what it is.");
12 
13   set_type("Hand to Hand");
14   set_weight(1);
15   set_class(10);
16 }

Just like the other examples, let's roll through this line-by-line, but I'll ignore things which were explained in the room examples, like what reset() is for.

 2 inherit WEAPON;

This is one of those shortcuts from “mudlib.h”. WEAPON points to “/obj/player/weapon.c” which is the base object containing everything which makes a weapon a weapon.

 9   set_name("prototype");

All items should have a name. It's what allows us to 'get prototype' or 'drop prototype' or 'wield prototype'. This should be a single short word.

10   set_short("A prototype weapon");

This is the “name” of the weapon as seen on the ground or while in inventory.

11   set_long("It's hard to tell what it is.");

This is the description seen when you examine or look at the weapon.

13   set_type("Hand to Hand");

This sets what type of weapon it is. Under the hood, this determines what skill is used for the weapon's effectiveness, what type (slash/blunt/pierce) damage it does, and a few other things. The capitalization is important and must match the corresponding skill name.

14   set_weight(1);

Everything carryable (by a player) should have a weight. As far as I know, weight only matters for determining if you can carry it.

15   set_class(10);

This sets the “weapon class” of the weapon. This is a mysterious number that determines how “good” the weapon is in all sorts of ways. 10 is pretty bad. 50 is pretty good. 100 is obscene.

coding/basicweapon.txt · Last modified: 2018/10/17 21:06 by luther