summaryrefslogtreecommitdiffstats
path: root/stone_soup/crawl-ref/source/wpn-misc.cc
blob: 90b9cb0d373a1cce36c8abf8f0700c384c679f96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
 *********************************************************************
 *  File:       wpn-misc.cc                                          *
 *  Summary:    temporary home for weapon f(x) until struct'ed       *
 *  Written by: don brodale <dbrodale@bigfootinteractive.com>        *
 *                                                                   *
 *  Changelog(most recent first):                                    *
 *                                                                   *
 *  <00>     12jun2000     dlb     created after little thought      *
 *********************************************************************
 */

#include "AppHdr.h"
#include "wpn-misc.h"

#include "externs.h"

// all of this will be replaced by a struct and data handlers {dlb}:

/*
 **************************************************
 *                                                *
 *             BEGIN PUBLIC FUNCTIONS             *
 *                                                *
 **************************************************
*/

// FIXME: Remove these eventually

int damage_type(const item_def &item)
{
    return (damage_type(item.base_type, item.sub_type));
}

int damage_type(int wclass, int wtype)
{
    int type_damage = DVORP_CRUSHING;  // this is the default, btw {dlb}

    if (wclass == OBJ_WEAPONS)
    {
        switch (wtype)
        {
        case WPN_DAGGER:
        case WPN_DEMON_BLADE:
        case WPN_DOUBLE_SWORD:
        case WPN_GREAT_SWORD:
        case WPN_KATANA:
        case WPN_KNIFE:
        case WPN_LONG_SWORD:
        case WPN_QUICK_BLADE:
        case WPN_SABRE:
        case WPN_FALCHION:
        case WPN_SCIMITAR:
        case WPN_SCYTHE:
        case WPN_SHORT_SWORD:
        case WPN_TRIPLE_SWORD:
        case WPN_BLESSED_BLADE:
        case WPN_LAJATANG:
            type_damage = DVORP_SLICING;
            break;

        case WPN_DEMON_TRIDENT:
        case WPN_EVENINGSTAR:
        case WPN_GIANT_SPIKED_CLUB:
        case WPN_MORNINGSTAR:
        case WPN_SPEAR:
        case WPN_SPIKED_FLAIL:
        case WPN_TRIDENT:
            type_damage = DVORP_PIERCING;
            break;

        case WPN_WAR_AXE:
        case WPN_BATTLEAXE:
        case WPN_BROAD_AXE:
        case WPN_EXECUTIONERS_AXE:
        case WPN_GLAIVE:
        case WPN_HALBERD:
        case WPN_HAND_AXE:
        case WPN_LOCHABER_AXE:
            type_damage = DVORP_CHOPPING;
            break;
        }
    }

    return (type_damage);
}                               // end damage_type()

bool can_cut_meat(int wclass, int wtype)
{
    int type = damage_type( wclass, wtype );

    if (type == DVORP_CHOPPING || type == DVORP_SLICING)
        return (true);

    return (false);
}

int hands_reqd_for_weapon(int wclass, int wtype)
{
    int reqd_hands = HANDS_ONE;

    switch (wclass)
    {
    case OBJ_WEAPONS:
        switch (wtype)
        {
        case WPN_HALBERD:
        case WPN_SCYTHE:
        case WPN_GLAIVE:
        case WPN_QUARTERSTAFF:
        case WPN_LAJATANG:
        case WPN_BATTLEAXE:
        case WPN_EXECUTIONERS_AXE:
        case WPN_GREAT_SWORD:
        case WPN_TRIPLE_SWORD:
        case WPN_GREAT_MACE:
        case WPN_DIRE_FLAIL:
        case WPN_GIANT_CLUB:
        case WPN_GIANT_SPIKED_CLUB:
        case WPN_LOCHABER_AXE:
        case WPN_BOW:
        case WPN_LONGBOW:
        case WPN_CROSSBOW:
            reqd_hands = HANDS_TWO;
            break;

        case WPN_SPEAR:
        case WPN_TRIDENT:
        case WPN_DEMON_TRIDENT:
        case WPN_WAR_AXE:
        case WPN_BROAD_AXE:
        case WPN_KATANA:
        case WPN_DOUBLE_SWORD:
        case WPN_HAND_CROSSBOW:
        case WPN_BLOWGUN:
        case WPN_SLING:
            reqd_hands = HANDS_HALF;
            break;
        }
        break;

    case OBJ_STAVES:
        reqd_hands = HANDS_TWO;
        break;
    }

    return (reqd_hands);
}                               // end hands_reqd_for_weapon()

bool is_demonic(unsigned char weapon_subtype)
{
    switch (weapon_subtype)
    {
    case WPN_DEMON_BLADE:
    case WPN_DEMON_WHIP:
    case WPN_DEMON_TRIDENT:
        return true;

    default:
        return false;
    }
}                               // end is_demonic()

bool launches_things( unsigned char weapon_subtype )
{
    switch (weapon_subtype)
    {
    case WPN_SLING:
    case WPN_BOW:
    case WPN_LONGBOW:
    case WPN_CROSSBOW:
    case WPN_HAND_CROSSBOW:
    case WPN_BLOWGUN:
        return (true);

    default:
        return (false);
    }
}                               // end launches_things()

unsigned char launched_by(unsigned char weapon_subtype)
{
    switch (weapon_subtype)
    {
    case WPN_BLOWGUN:
        return MI_NEEDLE;
    case WPN_SLING:
        return MI_STONE;
    case WPN_BOW:
    case WPN_LONGBOW:
        return MI_ARROW;
    case WPN_CROSSBOW:
        return MI_BOLT;
    case WPN_HAND_CROSSBOW:
        return MI_DART;
    default:
        return MI_NONE;     // lame debugging code :P {dlb}
    }
}                               // end launched_by()