weapon

std
OBJECT
	weapon

LAST UPDATE
	Thragor, 21 Jan 1997, 17:30:00 MET

SYNOPSIS
	inherit "std/weapon";

	#include <properties.h>
	#include <combat.h>

DESCRIPTION
	This is the general class for all conventional weapons.
	It is a descendant of /std/thing with the combat functionality
	added.

	To be useful for combat, the weapon must be wielded. Dropping
	or destructing the weapon also unwields it.

	/std/weapon implements the following additional properties:

	- P_WC		: the class of this weapon
	- P_WEAPON_TYPE : the type of this weapon - must be one of
			  the WT_xxx from /sys/combat.h
	- P_DAM_TYPE	: the type of damage this weapon does - must be
			  one of the DT_xxx from /sys/combat.h.

	- P_WP_PER_QP	: This value allows you to reduce the quality of your
			  weapon.
			  Weapon quality ranges from 0-100%. A weapon's
			  percentage of quality will be reduced as follows:
			  From each hit done by the weapon, a certain amount
			  can be absorbed by the target's armour. If the amount
			  of damage absorbed is more than twice the number
			  defined in P_WP_PER_QP, the amount of absorbed damage
			  is divided by P_WP_PER_QP. The result is subtracted
			  from the overall percentage of quality of the weapon.

			  Example: P_WP_PER_QP is set to 5. A hit to
	                    the enemy's armour does 30 points of
	                    damage, but 20 of that is absorbed by the
	                    armour. 20 divided by 5 is 4, so the
	                    weapon degrades in quality by 4%.

	The following weapon types are defined:

	  WT_SWORD, WT_AXE, WT_CLUB, WT_SPEAR, WT_KNIFE, WT_STAFF,
	  WT_WHIP, WT_INFANTRY, WT_CHAIN, WT_RAPIER, WT_HAMMER

	whereas each of the types describes a whole class.

	Weapons can do following damages:

	- DT_SLASH    (e.g. swords)
	- DT_BLUDGEON (e.g. clubs)
	- DT_PIERCE   (e.g. spears)

	There are more damages defined, but they are magic-only.

	The weapon may be configured (besides the normal /std/thing-calls)
	with:

	SetWeaponType (string weapon_type)
	  Sets the type to <weapon_type>. This also adds an corresponding
	  id.

	SetWC (int wc)
	  Sets the weapon class to <wc>.

	SetDamType (int damage_type)
	  Sets the damage type to <damage_type>.

	int SetStandard (string weapon_type, int wc, int size)
	  Configures the weapon as a standard weapon of given <weapon_type>
	  and class <wc>.
	  If no size is set, PSIZE_GENERIC is taken. The size is needed to
	  calculate the weight. PSIZE_GENERIC means same weight as
	  PSIZE_NORMAL, so old weapons should work properly.
	  It sets description, weight, value, WT, WC, DT, and hands.
	  If <weapon_type> is illegal, 0 is returned, else 1.
	  If you need to use SetStandard() with SetProperties() you
	  may give an array as first argument, which looks like this:
	    ({ weapon_type [, wc [, size] ] }).
	  E. g. you may call:
	    weapon->SetStandard(({WT_SWORD,10,PSIZE_SMALL}));

	Following funs are also of interest:

	int QueryDamageType ()
	  Returns the set damage type of this weapon.
	  It is called by the wielding living for every hit.

	int QueryDamage (object enemy)
	  This is called when the wielding living tries to damage
	  <enemy> with this weapon. The result is the amount of
	  hitpoints to reduce.
	  If set, hitobject->WeaponHit() is called and returned,
	  else CalcDamage().

	int CalcDamage (object enemy)
	  Return the damage this weapon gives on hitting <enemy>.
	  It is calculated by some magic formula.

	Following functions exist for compatibility only:

	SetWeaponHands (int hands)
	  Sets the no. of needed hands to <hands>.

	SetHitObj (ob)
	  Sets the hitobject to <ob>.
	  If the weapon hits an enemy, and a hitobject is specified,
	  hitobject->WeaponHit(enemy)  is called and the result is the
	  damage to be done. Also hitobject->WeaponHitType() is called
	  to obtain the weapon's damage type. If that yields 0, the
	  weapons Builtin property P_DAMTYPE is used (QueryDamType()).

	SetWieldObj (ob)
	  Sets the wieldobject to <ob>.
	  If the weapon is wielded, and a wieldobject specified,
	  wieldobject->CheckWield (wielder) is done. If it returns 0,
	  the weapon is not wielded.

	SetUnwieldObj (ob)
	  Sets the unwieldobject to <ob>.
	  If the weapon is unwielded, and an unwieldobject specified,
	  unwieldobject->CheckUnwield (wielder) is done. If it returns 0,
	  the weapon is not unwielded.

INHERITANCE TREE
	weapon
	  |-weapon/combat
	  |   `-std/equipment
	  `-thing
	      |-thing/cleaning
	      |-thing/moving
	      |-thing/properties
	      `-thing/description


SEE ALSO
	equipment(S), armour(C), wc(C), living(C), thing(S), properties(C)