Manual:Zone Manual/The NPC Section/NPC macros

From DikuMUD Wiki
Jump to navigation Jump to search

NPC macros

The attack and armour macro

The natural attack and armour fields allow you to set the NPC to do damage like a certain type of weapons and to defend like a certain type of armour respectively. Lets say you had a metal cougar it would have an attack type of claw and an armour type of plate while a normal dog would have an armour type of leather and an attack type of bite. The 'NATURAL_DEF' macro is what allows you to set these fields. This macro is defined in wmacros.h and looks like this.

	#define NATURAL_DEF(weapon_category, armour_category) \
	   armour armour_category \
	   attack weapon_category

The word natural can sometimes be a little confusing since you can set any of the weapons types you like on the NPC. It doesn't exactly make sense to have a dog that attacks as if it uses a long sword but if you wish it you can do it. The following is a short list of just the natural weapon types but you can find a full list in (Link to app-d) or in the values.h of your mud just in case you have added some weapon types.

	#define WPN_FIST         34
	#define WPN_KICK         35
	#define WPN_BITE         36
	#define WPN_STING        37
	#define WPN_CLAW         38
	#define WPN_CRUSH        39

Again you don't have to use leather for dogs as we have already mentioned with our metal cat idea you could make a cloth dragon if you really want but its up to you to keep some sanity on your VME. The following is the list of armour types that can be set. You will see that the list is exactly the same as the list you will find later when making armour.

	#define ARM_CLOTHES  0  /*Same as a Human in jeans and a T-shirt*/
	#define ARM_LEATHER  1  /* A soft flexible leather base armour   */
	#define ARM_HLEATHER 2  /* A hard un flexible leather base armour */
	#define ARM_CHAIN    3  /* A flexible armour composed of interlocking rings */
	#define ARM_PLATE    4  /* An un flexible plate armour. */

Now that you have the defines to work with we will return to our metal cat and normal dog. The definitions for them would look something like this.

	//Metal Cat
	NATURAL_DEF(WPN_CLAW, ARM_PLATE)

	//normal dog
	NATURAL_DEF(WPN_BITE, ARM_LEATHER)

You should know that the weight of the monster determines the maximum amount of damage it can give when using a natural attack. The weight is categorized as follows:

Weight size chart
LBS Size
0 - 5 Tiny
6 - 40 Small
41 - 160 Medium
161 - 500 Large
500 and up Huge

By default monsters are medium. So make sure you take this into account when you are creating your NPC.

The defense and offense bonus macro

There comes a time when you may want to make your NPC super naturally powerful. It is for those times that the offense and defense fields are available for you to set. Normally they default to 0 but you can set them from 0 to 5000. The higher you set the offense number the harder you will hit people you a re in combat with. The higher you set the defense the harder it will be for people to hit your NPC. The following macro allows you to set both the offense and defense.

	#define ATTACK_DEFENSE(attack, defense) \
	offensive attack \
	defensive defense

Using this macro is rather easy you just put the value you want for each and your all done

	//a really hard hitting hard to kill NPC
	ATTACK_DEFENSE( 1000, 1000)

The NPc abilities macro

All abilities are in the range [1..200]. Players usually have a maximum of 150, modified by magic... 200 is considered divine. When creating a monster you can not directly specify the size of the abilities, instead you specify a percentage distribution of points. The amount of points are then distributed by the computer according to the specified level. The 'MSET_ABILITY' macro is available for this purpose, and is defined as:

	#define MSET_ABILITY(str,dex,con,hpp,bra,cha,mag,div)   \
		ability[ABIL_STR]  str   \
	  ability[ABIL_DEX]  dex   \
	  ability[ABIL_CON]  con   \
	  ability[ABIL_HP]   hpp   \
	  ability[ABIL_BRA]  bra   \
	  ability[ABIL_MAG]  mag   \
	  ability[ABIL_DIV]  div   \
	  ability[ABIL_CHA]  cha

Note the sum of the ability values must be 100%. This is thus an example of an ability distribution: MSET_ABILITY(25,15,10,15,10,5,10,0) /* Sum is 100% */

The amount of points distributed depends directly upon the level of the monster and the percentage. If the percentage is too high and the level is also set High some ability points may be lost since a NPC gets all abilities over 255 cut off. For example a level 199 monster with an ability percentage a bit above 20% will make an ability above the 255 points maximum. In the current combat system in the VME 2.0 it is not necessary to spend points on both 'mag' and 'div' on the NPC since only one or the other is ever used depending on which is higher.

The NPc weapon and spell macros

NPCs know about weapons and spells but not at the same detailed level as the player. For NPCs the spell and weapon group are used. Thus the Axe hammer category defines all defence and all attack for all kinds of axes and hammers, whereas the player would have to train individually in each axe and hammer type. The same is true for spells. Thus if a monster has 25 points in the weapon sword category it will fight (and defend) with all sword-like weapons at skill 25. When you define weapon and spell skills (monsters have no skill skills) you also define these as percentages, and the program automatically distributes the points. Use the pre-defined macros:

	#define MSET_WEAPON(axe_ham, sword, club_mace, pole, unarmed, special)  \
	weapon[WPN_AXE_HAM]    axe_ham   \
	weapon[WPN_SWORD]      sword      \
	weapon[WPN_CLUB_MACE]  club_mace  \
	weapon[WPN_POLEARM]    pole \
	weapon[WPN_UNARMED]    unarmed    \
	weapon[WPN_SPECIAL]    special
MSET_WEAPON arguments
Argument Description
axe_ham any hammer or axe
sword any sword like weapon, including dagger and rapier, etc.
club_mace any club or mace like weapon, flails, morning star, etc.
polearm any spear or pole like weapon: spear, trident, sickle, scythe etc.
unarmed Is any bite, claw, sting or other natural attack.
special any very peculiar weapon, currently only whip.
	#define MSET_SPELL(div, pro, det, sum, cre, min, hea, col, cel, int, ext)  \
	spell[SPL_DIVINE]      div  \
	spell[SPL_PROTECTION]  pro  \
	spell[SPL_DETECTION]   det  \
	spell[SPL_SUMMONING]   sum  \
	spell[SPL_CREATION]    cre  \
	spell[SPL_MIND]        min  \
	spell[SPL_HEAT]        hea  \
	spell[SPL_COLD]        col  \
	spell[SPL_CELL]        cel  \
	spell[SPL_INTERNAL]    int  \
	spell[SPL_EXTERNAL]    ext
MSET_SPELL arguments
Argument Description
div Covers all divine sphere spell.
pro Covers all protection sphere spells.
det Covers all detection sphere spells.
sum Covers all summoning spells.
Cre Covers all creation spells.
min Covers all mind spells.
hea Covers all heat spells (fireball, etc.)
col Covers all cold spells (frostball, etc.)
cel Covers all cell (electricity) spells (lightning bolt, etc.)
int Covers all internal (poison) spells (toxicate, etc.)
ext Covers all external (acid) spells (acid ball etc).

If your not sure what your weapon or spell is categorized as you can look in the weapons.def or the spells.def for that you are using for your VME server.

The sum of all spell and weapon skills must be 100%. For example, the following would be a legal setting of weapons and spells.

	//  75%  Total,  Club/Mace  is primary
	      MSET_WEAPON(10,10,20,5,15,5)

	//  25%  Total,  Fire  is primary
	      MSET_SPELL(8,0,0,3,0,3,2,3,3,3,3)

Remember that the groups define both attack and defence. Thus if you make an Orc which has 0% in the flail group it can only use its dexterity to defend itself. Likewise with spell groups. For this reason the groups are both "resistance" as well as attack groups.

Using the composed.h

The file composed.h contains many standard monsters. It is a good idea to study these definitions, as they form the basis of many different monsters. Note that the definitions by no means are perfect, but we are hoping to make a more or less complete monster compendium. If you create certain (general) monsters, please design it as a macro so it can be incorporated in the file. The more monsters created by using these macros the easier it will be for your builders to create NPCs. If you think you have a really all inclusive Composed.h and want to share it with the rest of the VME servers running out there on the internet. Feel free to submit it to the VME staff and we will put it in the contribution directories on our release site.

For more information on how to use the composed.h when building your NPC see (Link to npcbasic).

Previous: The NPC Section
Next: Building your first NPC