OSDN Git Service

fix #39767
[jnethack/source.git] / include / skills.h
1 /* NetHack 3.6  skills.h        $NHDT-Date: 1547255911 2019/01/12 01:18:31 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.15 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
3 /*-Copyright (c) Pasi Kallinen, 2017. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 #ifndef SKILLS_H
7 #define SKILLS_H
8
9 /* Much of this code was taken from you.h.  It is now
10  * in a separate file so it can be included in objects.c.
11  */
12
13 enum p_skills {
14     /* Code to denote that no skill is applicable */
15     P_NONE = 0,
16
17 /* Weapon Skills -- Stephen White
18  * Order matters and are used in macros.
19  * Positive values denote hand-to-hand weapons or launchers.
20  * Negative values denote ammunition or missiles.
21  * Update weapon.c if you amend any skills.
22  * Also used for oc_subtyp.
23  */
24     P_DAGGER             =  1,
25     P_KNIFE              =  2,
26     P_AXE                =  3,
27     P_PICK_AXE           =  4,
28     P_SHORT_SWORD        =  5,
29     P_BROAD_SWORD        =  6,
30     P_LONG_SWORD         =  7,
31     P_TWO_HANDED_SWORD   =  8,
32     P_SCIMITAR           =  9,
33     P_SABER              = 10,
34     P_CLUB               = 11, /* Heavy-shafted bludgeon */
35     P_MACE               = 12,
36     P_MORNING_STAR       = 13, /* Spiked bludgeon */
37     P_FLAIL              = 14, /* Two pieces hinged or chained together */
38     P_HAMMER             = 15, /* Heavy head on the end */
39     P_QUARTERSTAFF       = 16, /* Long-shafted bludgeon */
40     P_POLEARMS           = 17, /* attack two or three steps away */
41     P_SPEAR              = 18, /* includes javelin */
42     P_TRIDENT            = 19,
43     P_LANCE              = 20,
44     P_BOW                = 21, /* launchers */
45     P_SLING              = 22,
46     P_CROSSBOW           = 23,
47     P_DART               = 24, /* hand-thrown missiles */
48     P_SHURIKEN           = 25,
49     P_BOOMERANG          = 26,
50     P_WHIP               = 27, /* flexible, one-handed */
51     P_UNICORN_HORN       = 28, /* last weapon, two-handed */
52
53     /* Spell Skills added by Larry Stewart-Zerba */
54     P_ATTACK_SPELL       = 29,
55     P_HEALING_SPELL      = 30,
56     P_DIVINATION_SPELL   = 31,
57     P_ENCHANTMENT_SPELL  = 32,
58     P_CLERIC_SPELL       = 33,
59     P_ESCAPE_SPELL       = 34,
60     P_MATTER_SPELL       = 35,
61
62     /* Other types of combat */
63     P_BARE_HANDED_COMBAT = 36, /* actually weaponless; gloves are ok */
64     P_TWO_WEAPON_COMBAT  = 37, /* pair of weapons, one in each hand */
65     P_RIDING             = 38, /* How well you control your steed */
66
67     P_NUM_SKILLS         = 39
68 };
69
70 #define P_MARTIAL_ARTS P_BARE_HANDED_COMBAT /* Role distinguishes */
71
72 #define P_FIRST_WEAPON P_DAGGER
73 #define P_LAST_WEAPON P_UNICORN_HORN
74
75 #define P_FIRST_SPELL P_ATTACK_SPELL
76 #define P_LAST_SPELL P_MATTER_SPELL
77
78 #define P_LAST_H_TO_H P_RIDING
79 #define P_FIRST_H_TO_H P_BARE_HANDED_COMBAT
80
81 /* These roles qualify for a martial arts bonus */
82 #define martial_bonus() (Role_if(PM_SAMURAI) || Role_if(PM_MONK))
83
84 /*
85  * These are the standard weapon skill levels.  It is important that
86  * the lowest "valid" skill be be 1.  The code calculates the
87  * previous amount to practice by calling  practice_needed_to_advance()
88  * with the current skill-1.  To work out for the UNSKILLED case,
89  * a value of 0 needed.
90  */
91 enum skill_levels {
92     P_ISRESTRICTED = 0, /* unskilled and can't be advanced */
93     P_UNSKILLED    = 1, /* unskilled so far but can be advanced */
94     /* Skill levels Basic/Advanced/Expert had long been used by
95        Heroes of Might and Magic (tm) and its sequels... */
96     P_BASIC        = 2,
97     P_SKILLED      = 3,
98     P_EXPERT       = 4,
99     /* when the skill system was adopted into nethack, levels beyond expert
100        were unnamed and just used numbers.  Devteam coined them Master and
101        Grand Master.  Sometime after that, Heroes of Might and Magic IV (tm)
102        was released and had two more levels which use these same names. */
103     P_MASTER       = 5, /* Unarmed combat/martial arts only */
104     P_GRAND_MASTER = 6  /* ditto */
105 };
106
107 #define practice_needed_to_advance(level) ((level) * (level) *20)
108
109 /* The hero's skill in various weapons. */
110 struct skills {
111     xchar skill;
112     xchar max_skill;
113     unsigned short advance;
114 };
115
116 #define P_SKILL(type) (u.weapon_skills[type].skill)
117 #define P_MAX_SKILL(type) (u.weapon_skills[type].max_skill)
118 #define P_ADVANCE(type) (u.weapon_skills[type].advance)
119 #define P_RESTRICTED(type) (u.weapon_skills[type].skill == P_ISRESTRICTED)
120
121 #define P_SKILL_LIMIT 60 /* Max number of skill advancements */
122
123 /* Initial skill matrix structure; used in u_init.c and weapon.c */
124 struct def_skill {
125     xchar skill;
126     xchar skmax;
127 };
128
129 #endif /* SKILLS_H */