New weapon types
From Wormhole Sci-Fi MUD Homepage
An article by Artoo, explaining how to add new kinds of attack to the game engine.
BY default, Wormhole has about twenty attack types; those used to define weapons and the skill that the owner should practice, some non-weapon based ones like bite or sting, and some 'special' ones for damage by explosions, falling down, and so on. Now, suppose we want to add a new kind of weapon to the game... and perhaps a new skill as well. Maybe we want to be able to represent a 'garrote' attack? Nice! Here's how...
Most of the definitions (#define) for things are in the header (.h) files. For example, TYPE_CRUSH is defined in spells.h as number 410. (Yes, I know it's called 'spells' but it actually details every different way to do damage, including skills and weapons.) Code snippet follows:
... #define TYPE_START 400 #define TYPE_HIT 400 #define TYPE_BLUDGEON 401 #define TYPE_PIERCE 402 #define TYPE_SLASH 403 #define TYPE_BLAST 404 #define TYPE_WHIP 405 ...
Of course, you'd just add a line for your new kind of attack.
Now, in fight.c you will find a case for each of these attacks. This is where the player's proficiency with a particular weapon type is taken into account. For example:
case 10:
w_type = TYPE_CRUSH;
if (number (1, 110) < GET_SKILL (ch, SKILL_BLUDGEON))
skillbonus = 2;
break;
Also in fight.c, just above these cases, note the line that says something like:
if ((attacktype >= TYPE_HIT) && (attacktype <= TYPE_SNIPE)
Since TYPE_SNIPE will no longer be the highest numbered attack type, you should adjust this line to say '<= TYPE_GARROTE)' or whatever.
Note that in the 'crush' example given above SKILL_BLUDGEON already exists. You can find it in skillconst.c. If you are adding a new skill, 'garrote' then it needs entries in skillconst.c (see adding skills) and in spells.h. Search for all instances of one of the existing attack types; it'll show you where your new one should have an entry.
In constants.c, add an extra line under "const char *attacktypes". Also add an extra line under "const int sharp". (Just give it a zero, for now.)
Now, we also need to set the messages for this new form of attack; the things that the attacker, the victim and any bystanders are shown, when the attack takes place. The numbered entry used in the messages file must match the #define entry you made in spells.h
Finally, your new weapon type should also be made available for use in olc, since this will provide you with the quickest means of testing it. To make your new weapon type 'olc friendly', increase the value given for NUM_ATTACK_TYPES in olc.h
Note that because you have been changing header files, a 'make clean' will be needed before you recompile, or the changes won't take effect properly. Then, it's time for a deep breath, and a reboot. Do all this on a developer port of Wormhole first, and make backups of all the files before you change them. Duh.
