Use enums for skills

This commit is contained in:
Pasi Kallinen
2017-10-07 17:10:46 +03:00
parent 9b82b72c6e
commit a4706b0928
+60 -52
View File
@@ -9,8 +9,9 @@
* in a separate file so it can be included in objects.c. * in a separate file so it can be included in objects.c.
*/ */
/* Code to denote that no skill is applicable */ enum p_skills {
#define P_NONE 0 /* Code to denote that no skill is applicable */
P_NONE = 0,
/* Weapon Skills -- Stephen White /* Weapon Skills -- Stephen White
* Order matters and are used in macros. * Order matters and are used in macros.
@@ -19,58 +20,63 @@
* Update weapon.c if you amend any skills. * Update weapon.c if you amend any skills.
* Also used for oc_subtyp. * Also used for oc_subtyp.
*/ */
#define P_DAGGER 1 P_DAGGER,
#define P_KNIFE 2 P_KNIFE,
#define P_AXE 3 P_AXE,
#define P_PICK_AXE 4 P_PICK_AXE,
#define P_SHORT_SWORD 5 P_SHORT_SWORD,
#define P_BROAD_SWORD 6 P_BROAD_SWORD,
#define P_LONG_SWORD 7 P_LONG_SWORD,
#define P_TWO_HANDED_SWORD 8 P_TWO_HANDED_SWORD,
#define P_SCIMITAR 9 P_SCIMITAR,
#define P_SABER 10 P_SABER,
#define P_CLUB 11 /* Heavy-shafted bludgeon */ P_CLUB, /* Heavy-shafted bludgeon */
#define P_MACE 12 P_MACE,
#define P_MORNING_STAR 13 /* Spiked bludgeon */ P_MORNING_STAR, /* Spiked bludgeon */
#define P_FLAIL 14 /* Two pieces hinged or chained together */ P_FLAIL, /* Two pieces hinged or chained together */
#define P_HAMMER 15 /* Heavy head on the end */ P_HAMMER, /* Heavy head on the end */
#define P_QUARTERSTAFF 16 /* Long-shafted bludgeon */ P_QUARTERSTAFF, /* Long-shafted bludgeon */
#define P_POLEARMS 17 P_POLEARMS,
#define P_SPEAR 18 /* includes javelin */ P_SPEAR, /* includes javelin */
#define P_TRIDENT 19 P_TRIDENT,
#define P_LANCE 20 P_LANCE,
#define P_BOW 21 P_BOW,
#define P_SLING 22 P_SLING,
#define P_CROSSBOW 23 P_CROSSBOW,
#define P_DART 24 P_DART,
#define P_SHURIKEN 25 P_SHURIKEN,
#define P_BOOMERANG 26 P_BOOMERANG,
#define P_WHIP 27 P_WHIP,
#define P_UNICORN_HORN 28 /* last weapon */ P_UNICORN_HORN, /* last weapon */
/* Spell Skills added by Larry Stewart-Zerba */
P_ATTACK_SPELL,
P_HEALING_SPELL,
P_DIVINATION_SPELL,
P_ENCHANTMENT_SPELL,
P_CLERIC_SPELL,
P_ESCAPE_SPELL,
P_MATTER_SPELL,
/* Other types of combat */
P_BARE_HANDED_COMBAT, /* actually weaponless; gloves are ok */
P_TWO_WEAPON_COMBAT,
P_RIDING, /* How well you control your steed */
P_NUM_SKILLS
};
#define P_MARTIAL_ARTS P_BARE_HANDED_COMBAT /* Role distinguishes */
#define P_FIRST_WEAPON P_DAGGER #define P_FIRST_WEAPON P_DAGGER
#define P_LAST_WEAPON P_UNICORN_HORN #define P_LAST_WEAPON P_UNICORN_HORN
/* Spell Skills added by Larry Stewart-Zerba */
#define P_ATTACK_SPELL 29
#define P_HEALING_SPELL 30
#define P_DIVINATION_SPELL 31
#define P_ENCHANTMENT_SPELL 32
#define P_CLERIC_SPELL 33
#define P_ESCAPE_SPELL 34
#define P_MATTER_SPELL 35
#define P_FIRST_SPELL P_ATTACK_SPELL #define P_FIRST_SPELL P_ATTACK_SPELL
#define P_LAST_SPELL P_MATTER_SPELL #define P_LAST_SPELL P_MATTER_SPELL
/* Other types of combat */
#define P_BARE_HANDED_COMBAT 36 /* actually weaponless; gloves are ok */
#define P_MARTIAL_ARTS P_BARE_HANDED_COMBAT /* Role distinguishes */
#define P_TWO_WEAPON_COMBAT 37 /* Finally implemented */
#define P_RIDING 38 /* How well you control your steed */
#define P_LAST_H_TO_H P_RIDING #define P_LAST_H_TO_H P_RIDING
#define P_FIRST_H_TO_H P_BARE_HANDED_COMBAT #define P_FIRST_H_TO_H P_BARE_HANDED_COMBAT
#define P_NUM_SKILLS (P_LAST_H_TO_H + 1)
/* These roles qualify for a martial arts bonus */ /* These roles qualify for a martial arts bonus */
#define martial_bonus() (Role_if(PM_SAMURAI) || Role_if(PM_MONK)) #define martial_bonus() (Role_if(PM_SAMURAI) || Role_if(PM_MONK))
@@ -81,13 +87,15 @@
* with the current skill-1. To work out for the UNSKILLED case, * with the current skill-1. To work out for the UNSKILLED case,
* a value of 0 needed. * a value of 0 needed.
*/ */
#define P_ISRESTRICTED 0 enum skill_levels {
#define P_UNSKILLED 1 P_ISRESTRICTED = 0,
#define P_BASIC 2 P_UNSKILLED,
#define P_SKILLED 3 P_BASIC,
#define P_EXPERT 4 P_SKILLED,
#define P_MASTER 5 /* Unarmed combat/martial arts only */ P_EXPERT,
#define P_GRAND_MASTER 6 /* Unarmed combat/martial arts only */ P_MASTER, /* Unarmed combat/martial arts only */
P_GRAND_MASTER /* Unarmed combat/martial arts only */
};
#define practice_needed_to_advance(level) ((level) * (level) *20) #define practice_needed_to_advance(level) ((level) * (level) *20)