A
/ \ _ Play Now Nemesis on
| | | | _______ _ _ _______ _______ _ _______
| |\ | | | ____| | \ / | | ____| / ____| | | / ____|
/-------/-------------------------------------------------------------------,
O= Home <=XX| About News Pics Adventurers Wizards Download Connect >
\-------\-------------------------------------------------------------------'
| | \ | | |____ | | | | | |____ ___ \ \ | | ___ \ \
| | \_| |_______| |_| |_| |_______| |_______/ |_| |_______/
\ /
V
Documentation Area
Document Path: /doc/concepts/weapons
Weapons are items that can be carried around by players or monsters. Each
player can wield one weapon and will use that weapon to attack in combat.
Weapons have the following default properties:
Weapon class: a number in the range from 0 to 20. The higher the class the
better is the weapon. The weapon class will sink with the
usage of the weapon, but can be restored to the initial
weapon class again.
Weapon type: Either slashing, piercing or bludgeoning. This property is
only used to display different combat messages at the time.
Twohander: Is the weapon two-handed or one-handed.
Block value: The number that is added to the armour class of a armour
zone when block is used.
The proper way to create weapons is to use the convenience function set_class
to set the default values for a wide range of weapons. The different available
classes are listed in the file /include/weapon_tbl.h. It is possible to change
the default values of course.
If your weapon doesn't need to change the default values, you should create
the weapon using clone_object from inside your room or monster file:
object weapon;
weapon=clone_object("obj/weapon");
weapon->set_class("longsword");
move_object(weapon, this_object());
If your weapon differs from the defaults in one or more cases, you have to put
the weapon into a separate file:
inherit "obj/weapon";
reset(arg) {
::reset(arg);
if (arg) return;
set_class("longsword");
set_short("a fine longsword");
set_value(800);
}
Make sure that set_class is the first function you call, else it will delete
your previous settings.
If you need the defines for properties, such as P_NO_SELL (listed in
/include/properties.h and /include/weapon.h), you have to replace the
inherit "obj/weapon"; line with #include <weapon.h>.
Addendum 2016: There has never been and is NO property P_NO_SELL!
But there was and is a property P_DESTRUCT_WHEN_SOLD!
To get a complete list of functions you can call, look at the files
/obj/item.c and /obj/weapon.c. To get more information about properties
read 'man properties'.
Useful functions you can override are wield() and hit(), which are called
when the player wants to wield the weapon or when he hits an enemy respec-
tively. The proper way to do it is like this:
wield(str) {
if (this_player()->query_guild()!="fighters") {
write("You cannot wield this fine weapon.\n");
return 1;
}
return ::wield(str);
}
hit(ob) {
if (ob->query_race()=="troll") return random(10);
}
The return value of the hit function is added to the hits of the player.
Examples for various weapons are listed in /lib/weapon.
This page was generated in LPC
Imprint / Impressum