ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/skill_util.C
(Generate patch)

Comparing deliantra/server/server/skill_util.C (file contents):
Revision 1.21 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.47 by root, Sun May 13 19:56:57 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copryight (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copryight (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The author can be reached via e-mail to <crossfire@schmorp.de> 22 * The author can be reached via e-mail to <crossfire@schmorp.de>
22*/ 23 */
23 24
24/* Created July 95 to separate skill utilities from actual skills -b.t. */ 25/* Created July 95 to separate skill utilities from actual skills -b.t. */
25 26
26/* Reconfigured skills code to allow linking of skills to experience 27/* Reconfigured skills code to allow linking of skills to experience
27 * categories. This is done solely through the init_new_exp_system() fctn. 28 * categories. This is done solely through the init_new_exp_system() fctn.
39 40
40/* #define SKILL_UTIL_DEBUG */ 41/* #define SKILL_UTIL_DEBUG */
41 42
42#include <global.h> 43#include <global.h>
43#include <object.h> 44#include <object.h>
44#ifndef __CEXTRACT__
45# include <sproto.h> 45#include <sproto.h>
46#endif
47#include <living.h> /* for defs of STR,CON,DEX,etc. -b.t. */ 46#include <living.h> /* for defs of STR,CON,DEX,etc. -b.t. */
48#include <spells.h> 47#include <spells.h>
49 48
50/* Table of unarmed attack skills. Terminated by -1. This 49const uint8_t skill_flags[NUM_SKILLS] = {
51 * is also the list that we should try to use skills when 50 0, // SK_NONE
52 * automatically applying one for the player. 51# define def(uc, flags) flags,
53 */ 52# include "skillinc.h"
54static uint8 unarmed_skills[] = { 53# undef def
55 SK_KARATE,
56 SK_CLAWING,
57 SK_FLAME_TOUCH,
58 SK_SPARK_TOUCH,
59 SK_SHIVER,
60 SK_ACID_SPLASH,
61 SK_POISON_NAIL,
62 SK_PUNCHING,
63 (uint8)-1
64}; 54};
65 55
66static int attack_hth (object *pl, int dir, const char *string, object *skill); 56static int attack_hth (object *pl, int dir, const char *string, object *skill);
67static int attack_melee_weapon (object *op, int dir, const char *string, object *skill); 57static int attack_melee_weapon (object *op, int dir, const char *string, object *skill);
68 58
71 * subtypes. 61 * subtypes.
72 */ 62 */
73void 63void
74init_skills (void) 64init_skills (void)
75{ 65{
76 int i;
77 archetype *at;
78
79 for (at = first_archetype; at != NULL; at = at->next) 66 for (archetype *at = first_archetype; at; at = at->next)
80 if (at->clone.type == SKILL) 67 if (at->clone.type == SKILL)
81 { 68 {
82 if (skill_names[at->clone.subtype] != NULL) 69 if (skill_names[at->clone.subtype])
83 LOG (llevError, "init_skills: multiple skill using same subtype %d, %s, %s\n", 70 LOG (llevError, "init_skills: multiple skill using same subtype %d, %s, %s\n",
84 at->clone.subtype, &skill_names[at->clone.subtype], &at->clone.skill); 71 at->clone.subtype, &skill_names[at->clone.subtype], &at->clone.skill);
85 else 72 else
86 skill_names[at->clone.subtype] = at->clone.skill; 73 skill_names[at->clone.subtype] = at->clone.skill;
87 } 74 }
88 75
89 /* This isn't really an error if there is no skill subtype set, but 76 /* This isn't really an error if there is no skill subtype set, but
90 * checking for this may catch some user errors. 77 * checking for this may catch some user errors.
91 */ 78 */
92 for (i = 1; i < NUM_SKILLS; i++) 79 for (int i = 1; i < NUM_SKILLS; i++)
93 {
94 if (!skill_names[i]) 80 if (!skill_names[i])
95 LOG (llevError, "init_skills: skill subtype %d doesn't have a name?\n", i); 81 LOG (llevError, "init_skills: skill subtype %d doesn't have a name?\n", i);
96 }
97} 82}
98
99 83
100/* This function goes through the player inventory and sets 84/* This function goes through the player inventory and sets
101 * up the last_skills[] array in the player object. 85 * up the last_skills[] array in the player object.
102 * the last_skills[] is used to more quickly lookup skills - 86 * the last_skills[] is used to more quickly lookup skills -
103 * mostly used for sending exp. 87 * mostly used for sending exp.
104 */ 88 */
105void 89void
106link_player_skills (object *op) 90link_player_skills (object *op)
107{ 91{
108 object *tmp;
109
110 for (tmp = op->inv; tmp; tmp = tmp->below) 92 for (object *tmp = op->inv; tmp; tmp = tmp->below)
111 {
112 if (tmp->type == SKILL) 93 if (tmp->type == SKILL)
113 { 94 {
114 /* This is really a warning, hence no else below */ 95 /* This is really a warning, hence no else below */
115 if (op->contr->last_skill_ob[tmp->subtype] && op->contr->last_skill_ob[tmp->subtype] != tmp) 96 if (op->contr->last_skill_ob[tmp->subtype] && op->contr->last_skill_ob[tmp->subtype] != tmp)
116 {
117 LOG (llevError, "Multiple skills with the same subtype? %s, %s\n", 97 LOG (llevError, "Multiple skills with the same subtype? %s, %s\n",
118 &op->contr->last_skill_ob[tmp->subtype]->skill, &tmp->skill); 98 &op->contr->last_skill_ob[tmp->subtype]->skill, &tmp->skill);
119 } 99
120 if (tmp->subtype >= NUM_SKILLS) 100 if (tmp->subtype >= NUM_SKILLS)
121 {
122 LOG (llevError, "Invalid subtype number %d (range 0-%d)\n", tmp->subtype, NUM_SKILLS); 101 LOG (llevError, "Invalid subtype number %d (range 0-%d)\n", tmp->subtype, NUM_SKILLS);
123 }
124 else 102 else
125 { 103 {
126 op->contr->last_skill_ob[tmp->subtype] = tmp; 104 op->contr->last_skill_ob[tmp->subtype] = tmp;
127 op->contr->last_skill_exp[tmp->subtype] = -1; 105 op->contr->ns->last_skill_exp[tmp->subtype] = -1; //TODO: this should go
128 } 106 }
129 } 107 }
130 }
131} 108}
132 109
133/* This returns the skill pointer of the given name (the 110/* This returns the skill pointer of the given name (the
134 * one that accumlates exp, has the level, etc). 111 * one that accumlates exp, has the level, etc).
135 * 112 *
138 * tool, this code will equip it. 115 * tool, this code will equip it.
139 */ 116 */
140object * 117object *
141find_skill_by_name (object *who, const char *name) 118find_skill_by_name (object *who, const char *name)
142{ 119{
143 object *skill = NULL, *skill_tool = NULL, *tmp;
144
145 if (!name) 120 if (!name)
146 return NULL; 121 return 0;
122
123 object *skill = 0, *skill_tool = 0;
147 124
148 /* We make sure the length of the string in the object is greater 125 /* We make sure the length of the string in the object is greater
149 * in length than the passed string. Eg, if we have a skill called 126 * in length than the passed string. Eg, if we have a skill called
150 * 'hi', we don't want to match if the user passed 'high' 127 * 'hi', we don't want to match if the user passed 'high'
151 */ 128 */
152 for (tmp = who->inv; tmp != NULL; tmp = tmp->below) 129 for (object *tmp = who->inv; tmp; tmp = tmp->below)
153 { 130 {
154 if (tmp->type == SKILL && !strncasecmp (name, tmp->skill, strlen (name)) && (size_t) strlen (tmp->skill) >= strlen (name)) 131 if (tmp->type == SKILL && !strncasecmp (name, tmp->skill, strlen (name)) && strlen (tmp->skill) >= strlen (name))
155 skill = tmp; 132 skill = tmp;
156 133
157 /* Try to find appropriate skilltool. If the player has one already 134 /* Try to find appropriate skilltool. If the player has one already
158 * applied, we try to keep using that one. 135 * applied, we try to keep using that one.
159 */ 136 */
160 else if (tmp->type == SKILL_TOOL && !strncasecmp (name, tmp->skill, strlen (name)) && (size_t) strlen (tmp->skill) >= strlen (name)) 137 else if (tmp->type == SKILL_TOOL && !strncasecmp (name, tmp->skill, strlen (name)) && strlen (tmp->skill) >= strlen (name))
161 { 138 {
162 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 139 if (QUERY_FLAG (tmp, FLAG_APPLIED))
163 skill_tool = tmp; 140 skill_tool = tmp;
164 else if (!skill_tool || !QUERY_FLAG (skill_tool, FLAG_APPLIED)) 141 else if (!skill_tool || !QUERY_FLAG (skill_tool, FLAG_APPLIED))
165 skill_tool = tmp; 142 skill_tool = tmp;
166 } 143 }
167 } 144 }
145
168 /* If this is a skill that can be used without a tool, return it */ 146 /* If this is a skill that can be used without a tool, return it */
169 if (skill && QUERY_FLAG (skill, FLAG_CAN_USE_SKILL)) 147 if (skill && QUERY_FLAG (skill, FLAG_CAN_USE_SKILL))
170 return skill; 148 return skill;
171 149
172 /* Player has a tool to use the skill. IF not applied, apply it - 150 /* Player has a tool to use the skill. If not applied, apply it -
173 * if not successful, return null. If they do have the skill tool 151 * if not successful, return null. If they do have the skill tool
174 * but not the skill itself, give it to them. 152 * but not the skill itself, give it to them.
175 */ 153 */
176 if (skill_tool) 154 if (skill_tool)
177 { 155 {
178 if (!QUERY_FLAG (skill_tool, FLAG_APPLIED)) 156 if (!QUERY_FLAG (skill_tool, FLAG_APPLIED))
179 {
180 if (apply_special (who, skill_tool, 0)) 157 if (apply_special (who, skill_tool, 0))
181 return NULL; 158 return 0;
182 } 159
183 if (!skill) 160 if (!skill)
184 { 161 {
185 skill = give_skill_by_name (who, skill_tool->skill); 162 skill = give_skill_by_name (who, skill_tool->skill);
186 link_player_skills (who); 163 link_player_skills (who);
187 } 164 }
165
188 return skill; 166 return skill;
189 } 167 }
168
190 return NULL; 169 return 0;
191} 170}
192
193 171
194/* This returns the skill pointer of the given name (the 172/* This returns the skill pointer of the given name (the
195 * one that accumlates exp, has the level, etc). 173 * one that accumlates exp, has the level, etc).
196 * 174 *
197 * It is presumed that the player will be needing to actually 175 * It is presumed that the player will be needing to actually
203 * this replaces find_skill. 181 * this replaces find_skill.
204 */ 182 */
205object * 183object *
206find_skill_by_number (object *who, int skillno) 184find_skill_by_number (object *who, int skillno)
207{ 185{
186 if (!IN_RANGE_EXC (skillno, 1, NUM_SKILLS))
187 return 0;
188
208 object *skill = NULL, *skill_tool = NULL, *tmp; 189 object *skill = NULL, *skill_tool = NULL;
209 190
210 if (skillno < 1 || skillno >= NUM_SKILLS)
211 return NULL;
212
213 for (tmp = who->inv; tmp != NULL; tmp = tmp->below) 191 for (object *tmp = who->inv; tmp; tmp = tmp->below)
214 { 192 {
215 if (tmp->type == SKILL && tmp->subtype == skillno) 193 if (tmp->type == SKILL && tmp->subtype == skillno)
216 skill = tmp; 194 skill = tmp;
217 195
218 /* Try to find appropriate skilltool. If the player has one already 196 /* Try to find appropriate skilltool. If the player has one already
224 skill_tool = tmp; 202 skill_tool = tmp;
225 else if (!skill_tool || !QUERY_FLAG (skill_tool, FLAG_APPLIED)) 203 else if (!skill_tool || !QUERY_FLAG (skill_tool, FLAG_APPLIED))
226 skill_tool = tmp; 204 skill_tool = tmp;
227 } 205 }
228 } 206 }
207
229 /* If this is a skill that can be used without a tool, return it */ 208 /* If this is a skill that can be used without a tool, return it */
230 if (skill && QUERY_FLAG (skill, FLAG_CAN_USE_SKILL)) 209 if (skill && QUERY_FLAG (skill, FLAG_CAN_USE_SKILL))
231 return skill; 210 return skill;
232 211
233 /* Player has a tool to use the skill. IF not applied, apply it - 212 /* Player has a tool to use the skill. If not applied, apply it -
234 * if not successful, return null. If they do have the skill tool 213 * if not successful, return null. If they do have the skill tool
235 * but not the skill itself, give it to them. 214 * but not the skill itself, give it to them.
236 */ 215 */
237 if (skill_tool) 216 if (skill_tool)
238 { 217 {
239 if (!QUERY_FLAG (skill_tool, FLAG_APPLIED)) 218 if (!QUERY_FLAG (skill_tool, FLAG_APPLIED))
255} 234}
256 235
257/* This changes the objects skill to new_skill. 236/* This changes the objects skill to new_skill.
258 * note that this function doesn't always need to get used - 237 * note that this function doesn't always need to get used -
259 * you can now add skill exp to the player without the chosen_skill being 238 * you can now add skill exp to the player without the chosen_skill being
260 * set. This function is of most interest to players to update 239 * set. This function is of most interest to players to update
261 * the various range information. 240 * the various range information.
262 * if new_skill is null, this just unapplies the skill.
263 * flag has the current meaning:
264 * 0x1: If set, don't update the range pointer. This is useful when we
265 * need to ready a new skill, but don't want to clobber range.
266 * return 1 on success, 0 on error 241 * return 1 on success, 0 on error
267 */ 242 */
268
269int 243int
270change_skill (object *who, object *new_skill, int flag) 244change_skill (object *who, object *new_skill, int flag)
271{ 245{
272 int old_range;
273
274 if (who->type != PLAYER) 246 if (who->type != PLAYER)
275 return 0; 247 return 0;
276 248
277 old_range = who->contr->shoottype; 249#if 0
278 250 // optimise this supposedly common case
279 if (who->chosen_skill && who->chosen_skill == new_skill)
280 {
281 /* optimization for changing skill to current skill */
282 if (who->type == PLAYER && !(flag & 0x1))
283 who->contr->shoottype = range_skill;
284
285 return 1;
286 }
287
288 // move skill to front, so it will be preferred next time
289 new_skill->remove ();
290 who->insert (new_skill);
291
292 if (!new_skill || who->chosen_skill) 251 if (new_skill == who->chosen_skill)
293 if (who->chosen_skill) 252 return 1;
294 apply_special (who, who->chosen_skill, AP_UNAPPLY); 253#endif
295 254
296 /* Only goal in this case was to unapply a skill */
297 if (!new_skill) 255 if (!new_skill)
256 {
257 LOG (llevError | logBacktrace, "change_skill called on %s with NULL skill\n",
258 who->debug_desc ());
298 return 0; 259 return 0;
260 }
261
262 // the skill could be readied already because it is used by a weapon.
263 who->change_weapon (0);
264 new_skill->inv_splay ();
299 265
300 if (apply_special (who, new_skill, AP_APPLY)) 266 if (apply_special (who, new_skill, AP_APPLY))
301 return 0; 267 return 0;
302 268
303 if (flag & 0x1)
304 who->contr->shoottype = (rangetype)old_range;
305
306 return 1; 269 return 1;
307} 270}
308 271
309/* This function just clears the chosen_skill and range_skill values 272/* This function just clears the chosen_skill and range_skill values
310 * inthe player. 273 * in the player.
311 */ 274 */
312void 275void
313clear_skill (object *who) 276clear_skill (object *who)
314{ 277{
315 who->chosen_skill = NULL; 278 who->chosen_skill = 0;
316 CLEAR_FLAG (who, FLAG_READY_SKILL); 279 CLEAR_FLAG (who, FLAG_READY_SKILL);
280
317 if (who->type == PLAYER) 281 if (who->type == PLAYER)
318 { 282 if (who->contr->ranged_ob && who->contr->ranged_ob->type == SKILL)
319 who->contr->ranges[range_skill] = NULL; 283 who->contr->ranged_ob = 0;
320 if (who->contr->shoottype == range_skill)
321 who->contr->shoottype = range_none;
322 }
323} 284}
324 285
325/* do_skill() - Main skills use function-similar in scope to cast_spell(). 286/* do_skill() - Main skills use function-similar in scope to cast_spell().
326 * We handle all requests for skill use outside of some combat here. 287 * We handle all requests for skill use outside of some combat here.
327 * We require a separate routine outside of fire() so as to allow monsters 288 * We require a separate routine outside of fire() so as to allow monsters
330 * exp - no caller needed that info, but it also prevented the callers 291 * exp - no caller needed that info, but it also prevented the callers
331 * from know if a skill was actually used, as many skills don't 292 * from know if a skill was actually used, as many skills don't
332 * give any exp for their direct use (eg, throwing). 293 * give any exp for their direct use (eg, throwing).
333 * It returns 0 if no skill was used. 294 * It returns 0 if no skill was used.
334 */ 295 */
335
336int 296int
337do_skill (object *op, object *part, object *skill, int dir, const char *string) 297do_skill (object *op, object *part, object *skill, int dir, const char *string)
338{ 298{
339 int success = 0, exp = 0; 299 int success = 0, exp = 0;
340 int did_alc = 0; 300 int did_alc = 0;
341 object *tmp, *next;
342 301
343 if (!skill) 302 if (!skill)
344 return 0; 303 return 0;
345 304
346 /* The code below presumes that the skill points to the object that 305 /* The code below presumes that the skill points to the object that
348 * go and try to find the actual real skill pointer, and if the 307 * go and try to find the actual real skill pointer, and if the
349 * the player doesn't have a bucket for that, create one. 308 * the player doesn't have a bucket for that, create one.
350 */ 309 */
351 if (skill->type != SKILL && op->type == PLAYER) 310 if (skill->type != SKILL && op->type == PLAYER)
352 { 311 {
353 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 312 for (object *tmp = op->inv; tmp; tmp = tmp->below)
354 {
355 if (tmp->type == SKILL && tmp->skill == skill->skill) 313 if (tmp->type == SKILL && tmp->skill == skill->skill)
356 break; 314 {
315 skill = tmp;
316 goto found;
357 } 317 }
358 if (!tmp) 318
359 tmp = give_skill_by_name (op, skill->skill); 319 skill = give_skill_by_name (op, skill->skill);
360 skill = tmp; 320found: ;
361 } 321 }
362 322
363 // skill, by_whom, on_which_object, which direction, skill_argument 323 // skill, by_whom, on_which_object, which direction, skill_argument
364 if (INVOKE_OBJECT (USE_SKILL, skill, ARG_OBJECT (op), ARG_OBJECT (part), ARG_INT (dir), ARG_STRING (string))) 324 if (INVOKE_OBJECT (USE_SKILL, skill, ARG_OBJECT (op), ARG_OBJECT (part), ARG_INT (dir), ARG_STRING (string)))
365 return 0; 325 return 0;
366 326
367 switch (skill->subtype) 327 switch (skill->subtype)
368 { 328 {
369 case SK_LEVITATION: 329 case SK_LEVITATION:
370 /* Not 100% sure if this will work with new movement code - 330 /* Not 100% sure if this will work with new movement code -
371 * the levitation skill has move_type for flying, so when 331 * the levitation skill has move_type for flying, so when
372 * equipped, that should transfer to player, when not, 332 * equipped, that should transfer to player, when not,
373 * shouldn't. 333 * shouldn't.
374 */ 334 */
375 if (QUERY_FLAG (skill, FLAG_APPLIED)) 335 if (QUERY_FLAG (skill, FLAG_APPLIED))
376 { 336 {
377 CLEAR_FLAG (skill, FLAG_APPLIED); 337 CLEAR_FLAG (skill, FLAG_APPLIED);
378 new_draw_info (NDI_UNIQUE, 0, op, "You come to earth."); 338 new_draw_info (NDI_UNIQUE, 0, op, "You come to earth.");
379 } 339 }
380 else 340 else
381 { 341 {
382 SET_FLAG (skill, FLAG_APPLIED); 342 SET_FLAG (skill, FLAG_APPLIED);
383 new_draw_info (NDI_UNIQUE, 0, op, "You rise into the air!."); 343 new_draw_info (NDI_UNIQUE, 0, op, "You rise into the air!.");
384 } 344 }
385 fix_player (op); 345
346 op->update_stats ();
386 success = 1; 347 success = 1;
387 break; 348 break;
388 349
389 case SK_STEALING: 350 case SK_STEALING:
390 exp = success = steal (op, dir, skill); 351 exp = success = steal (op, dir, skill);
391 break; 352 break;
392 353
393 case SK_LOCKPICKING: 354 case SK_LOCKPICKING:
394 exp = success = pick_lock (op, dir, skill); 355 exp = success = pick_lock (op, dir, skill);
395 break; 356 break;
396 357
397 case SK_HIDING: 358 case SK_HIDING:
398 exp = success = hide (op, skill); 359 exp = success = hide (op, skill);
399 break; 360 break;
400 361
401 case SK_JUMPING: 362 case SK_JUMPING:
402 success = jump (op, dir, skill); 363 success = jump (op, dir, skill);
403 break; 364 break;
404 365
405 case SK_INSCRIPTION: 366 case SK_INSCRIPTION:
406 exp = success = write_on_item (op, string, skill); 367 exp = success = write_on_item (op, string, skill);
407 break; 368 break;
408 369
409 case SK_MEDITATION: 370 case SK_MEDITATION:
410 meditate (op, skill); 371 meditate (op, skill);
411 success = 1; 372 success = 1;
412 break; 373 break;
413 /* note that the following 'attack' skills gain exp through hit_player() */ 374 /* note that the following 'attack' skills gain exp through hit_player() */
414 375
415 case SK_KARATE: 376 case SK_KARATE:
416 (void) attack_hth (op, dir, "karate-chopped", skill); 377 attack_hth (op, dir, "karate-chopped", skill);
417 break; 378 break;
418 379
419 case SK_PUNCHING: 380 case SK_PUNCHING:
420 (void) attack_hth (op, dir, "punched", skill); 381 attack_hth (op, dir, "punched", skill);
421 break; 382 break;
422 383
423 case SK_FLAME_TOUCH: 384 case SK_FLAME_TOUCH:
424 (void) attack_hth (op, dir, "flamed", skill); 385 attack_hth (op, dir, "flamed", skill);
425 break; 386 break;
426 387
427 case SK_SPARK_TOUCH: 388 case SK_SPARK_TOUCH:
428 (void) attack_hth (op, dir, "zapped", skill); 389 attack_hth (op, dir, "zapped", skill);
429 break; 390 break;
430 391
431 case SK_SHIVER: 392 case SK_SHIVER:
432 (void) attack_hth (op, dir, "froze", skill); 393 attack_hth (op, dir, "froze", skill);
433 break; 394 break;
434 395
435 case SK_ACID_SPLASH: 396 case SK_ACID_SPLASH:
436 (void) attack_hth (op, dir, "dissolved", skill); 397 attack_hth (op, dir, "dissolved", skill);
437 break; 398 break;
438 399
439 case SK_POISON_NAIL: 400 case SK_POISON_NAIL:
440 (void) attack_hth (op, dir, "injected poison into", skill); 401 attack_hth (op, dir, "injected poison into", skill);
441 break; 402 break;
442 403
443 case SK_CLAWING: 404 case SK_CLAWING:
444 (void) attack_hth (op, dir, "clawed", skill); 405 attack_hth (op, dir, "clawed", skill);
445 break; 406 break;
446 407
447 case SK_ONE_HANDED_WEAPON: 408 case SK_ONE_HANDED_WEAPON:
448 case SK_TWO_HANDED_WEAPON: 409 case SK_TWO_HANDED_WEAPON:
449 (void) attack_melee_weapon (op, dir, NULL, skill); 410 attack_melee_weapon (op, dir, NULL, skill);
450 break; 411 break;
451 412
452 case SK_FIND_TRAPS: 413 case SK_FIND_TRAPS:
453 exp = success = find_traps (op, skill); 414 exp = success = find_traps (op, skill);
454 break; 415 break;
455 416
456 case SK_SINGING: 417 case SK_SINGING:
457 exp = success = singing (op, dir, skill); 418 exp = success = singing (op, dir, skill);
458 break; 419 break;
459 420
460 case SK_ORATORY: 421 case SK_ORATORY:
461 exp = success = use_oratory (op, dir, skill); 422 exp = success = use_oratory (op, dir, skill);
462 break; 423 break;
463 424
464 case SK_SMITHERY: 425 case SK_SMITHERY:
465 case SK_BOWYER: 426 case SK_BOWYER:
466 case SK_JEWELER: 427 case SK_JEWELER:
467 case SK_ALCHEMY: 428 case SK_ALCHEMY:
468 case SK_THAUMATURGY: 429 case SK_THAUMATURGY:
469 case SK_LITERACY: 430 case SK_LITERACY:
470 case SK_WOODSMAN: 431 case SK_WOODSMAN:
471 /* first, we try to find a cauldron, and do the alchemy thing. 432 /* first, we try to find a cauldron, and do the alchemy thing.
472 * failing that, we go and identify stuff. 433 * failing that, we go and identify stuff.
473 */ 434 */
474 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = next) 435 for (object *next, *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = next)
475 { 436 {
476 next = tmp->above; 437 next = tmp->above;
477 438
478 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 439 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
479 { 440 {
480 attempt_do_alchemy (op, tmp); 441 attempt_do_alchemy (op, tmp);
481 442
482 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 443 if (QUERY_FLAG (tmp, FLAG_APPLIED))
483 esrv_send_inventory (op, tmp); 444 esrv_send_inventory (op, tmp);
484 445
485 did_alc = 1; 446 did_alc = 1;
486 } 447 }
487 } 448 }
488 449
489 if (did_alc == 0) 450 if (did_alc == 0)
490 exp = success = skill_ident (op, skill);
491
492 break;
493
494 case SK_DET_MAGIC:
495 case SK_DET_CURSE:
496 exp = success = skill_ident (op, skill); 451 exp = success = skill_ident (op, skill);
452
497 break; 453 break;
498 454
455 case SK_DET_MAGIC:
456 case SK_DET_CURSE:
457 exp = success = skill_ident (op, skill);
458 break;
459
499 case SK_DISARM_TRAPS: 460 case SK_DISARM_TRAPS:
500 exp = success = remove_trap (op, dir, skill); 461 exp = success = remove_trap (op, dir, skill);
501 break; 462 break;
502 463
503 case SK_THROWING: 464 case SK_THROWING:
504 success = skill_throw (op, part, dir, string, skill); 465 success = skill_throw (op, part, dir, string, skill);
505 break; 466 break;
506 467
507 case SK_SET_TRAP: 468 case SK_SET_TRAP:
508 new_draw_info (NDI_UNIQUE, 0, op, "This skill is not currently implemented."); 469 new_draw_info (NDI_UNIQUE, 0, op, "This skill is not currently implemented.");
509 break; 470 break;
510 471
511 case SK_USE_MAGIC_ITEM: 472 case SK_USE_MAGIC_ITEM:
512 case SK_MISSILE_WEAPON: 473 case SK_MISSILE_WEAPON:
513 new_draw_info (NDI_UNIQUE, 0, op, "There is no special attack for this skill."); 474 new_draw_info (NDI_UNIQUE, 0, op, "There is no special attack for this skill.");
514 break; 475 break;
515 476
516 case SK_PRAYING: 477 case SK_PRAYING:
517 success = pray (op, skill); 478 success = pray (op, skill);
518 break; 479 break;
519 480
520 case SK_BARGAINING: 481 case SK_BARGAINING:
521 success = describe_shop (op); 482 success = describe_shop (op);
522 break; 483 break;
523 484
524 case SK_SORCERY: 485 case SK_SORCERY:
525 case SK_EVOCATION: 486 case SK_EVOCATION:
526 case SK_PYROMANCY: 487 case SK_PYROMANCY:
527 case SK_SUMMONING: 488 case SK_SUMMONING:
528 case SK_CLIMBING: 489 case SK_CLIMBING:
529 new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect."); 490 new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect.");
530 break; 491 break;
531 492
532 default: 493 default:
533 LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp); 494 LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp);
534 break; 495 break;
535 } 496 }
536 497
537 /* For players we now update the speed_left from using the skill. 498 /* For players we now update the speed_left from using the skill.
538 * Monsters have no skill use time because of the random nature in 499 * Monsters have no skill use time because of the random nature in
539 * which use_monster_skill is called already simulates this. 500 * which use_monster_skill is called already simulates this.
540 * If certain skills should take more/less time, that should be 501 * If certain skills should take more/less time, that should be
541 * in the code for the skill itself. 502 * in the code for the skill itself.
542 */ 503 */
543 504
544 if (op->type == PLAYER) 505 if (op->type == PLAYER)
545 op->speed_left -= 1.0; 506 op->speed_left -= 1.f;
546 507
547 /* this is a good place to add experience for successfull use of skills. 508 /* this is a good place to add experience for successfull use of skills.
548 * Note that add_exp() will figure out player/monster experience 509 * Note that add_exp() will figure out player/monster experience
549 * gain problems. 510 * gain problems.
550 */ 511 */
578 * op is the object that was 'defeated'. 539 * op is the object that was 'defeated'.
579 * skill is the skill used. If no skill is used, it should just 540 * skill is the skill used. If no skill is used, it should just
580 * point back to who. 541 * point back to who.
581 * 542 *
582 */ 543 */
583
584int 544int
585calc_skill_exp (object *who, object *op, object *skill) 545calc_skill_exp (object *who, object *op, object *skill)
586{ 546{
587 int op_exp = 0, op_lvl = 0; 547 int op_exp = 0, op_lvl = 0;
588 float base, value, lvl_mult = 0.0; 548 float base, value, lvl_mult = 0.0;
677 * This one actually teaches the player the skill as something 637 * This one actually teaches the player the skill as something
678 * they can equip. 638 * they can equip.
679 * Return 0 if the player knows the skill, 1 if the 639 * Return 0 if the player knows the skill, 1 if the
680 * player learns the skill, 2 otherwise. 640 * player learns the skill, 2 otherwise.
681 */ 641 */
682
683int 642int
684learn_skill (object *pl, object *scroll) 643learn_skill (object *pl, object *scroll)
685{ 644{
686 object *tmp; 645 object *tmp;
687 646
723 link_player_skills (pl); 682 link_player_skills (pl);
724 return 1; 683 return 1;
725} 684}
726 685
727/* Gives a percentage clipped to 0% -> 100% of a/b. */ 686/* Gives a percentage clipped to 0% -> 100% of a/b. */
728
729/* Probably belongs in some global utils-type file? */ 687/* Probably belongs in some global utils-type file? */
730static int 688static int
731clipped_percent (sint64 a, sint64 b) 689clipped_percent (sint64 a, sint64 b)
732{ 690{
733 int rv; 691 int rv;
806 } 764 }
807 765
808 clear_win_info (op); 766 clear_win_info (op);
809 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:"); 767 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:");
810 if (num_skills_found > 1) 768 if (num_skills_found > 1)
811 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) strcmp); 769 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp);
812 770
813 for (i = 0; i < num_skills_found; i++) 771 for (i = 0; i < num_skills_found; i++)
814 {
815 new_draw_info (NDI_UNIQUE, 0, op, skills[i]); 772 new_draw_info (NDI_UNIQUE, 0, op, skills[i]);
816 }
817 773
818 new_draw_info_format (NDI_UNIQUE, 0, op, "You can handle %d weapon improvements.", op->level / 5 + 5); 774 new_draw_info_format (NDI_UNIQUE, 0, op, "You can handle %d weapon improvements.", op->level / 5 + 5);
819 775
820 cp = determine_god (op); 776 cp = determine_god (op);
821 new_draw_info_format (NDI_UNIQUE, 0, op, "You worship %s.", cp ? cp : "no god at current time"); 777 new_draw_info_format (NDI_UNIQUE, 0, op, "You worship %s.", cp ? cp : "no god at current time");
828 * direction that the user is facing. Returns false if we are unable to 784 * direction that the user is facing. Returns false if we are unable to
829 * change to the requested skill, or were unable to use the skill properly. 785 * change to the requested skill, or were unable to use the skill properly.
830 * This is tricky because skills can have spaces. We basically roll 786 * This is tricky because skills can have spaces. We basically roll
831 * our own find_skill_by_name so we can try to do better string matching. 787 * our own find_skill_by_name so we can try to do better string matching.
832 */ 788 */
833
834int 789int
835use_skill (object *op, const char *string) 790use_skill (object *op, const char *string)
836{ 791{
837 object *skop; 792 object *skop;
838 size_t len; 793 size_t len;
886} 841}
887 842
888static bool 843static bool
889hth_skill_p (object *skill) 844hth_skill_p (object *skill)
890{ 845{
891 for (unsigned int i = 0; i < sizeof (unarmed_skills); ++i) 846 return (skill_flags [skill->subtype] & (SF_COMBAT | SF_NEED_WEAPON)) == SF_COMBAT;
892 if (skill->subtype == unarmed_skills[i])
893 return 1;
894
895 return 0;
896} 847}
897 848
898/* This finds the first unarmed skill the player has, and returns it. 849/* This finds the first unarmed skill the player has, and returns it.
899 */ 850 */
900static object * 851static object *
914 * tmp is the targetted monster. 865 * tmp is the targetted monster.
915 * op is what is attacking 866 * op is what is attacking
916 * string is passed along to describe what messages to describe 867 * string is passed along to describe what messages to describe
917 * the damage. 868 * the damage.
918 */ 869 */
919
920static int 870static int
921do_skill_attack (object *tmp, object *op, const char *string, object *skill) 871do_skill_attack (object *tmp, object *op, const char *string, object *skill)
922{ 872{
923 int success;
924
925 if (INVOKE_OBJECT (SKILL_ATTACK, op, ARG_OBJECT (tmp), ARG_STRING (string), ARG_OBJECT (skill))) 873 if (INVOKE_OBJECT (SKILL_ATTACK, op, ARG_OBJECT (tmp), ARG_STRING (string), ARG_OBJECT (skill)))
926 return RESULT_INT (0); 874 return RESULT_INT (0);
927 875
928 /* For Players only: if there is no ready weapon, and no "attack" skill 876 /* For Players only: if there is no ready weapon, and no "attack" skill
929 * is readied either then try to find a skill for the player to use. 877 * is readied either then try to find a skill for the player to use.
930 * it is presumed that if skill is set, it is a valid attack skill (eg, 878 * it is presumed that if skill is set, it is a valid attack skill (eg,
931 * the caller should have set it appropriately). We still want to pass 879 * the caller should have set it appropriately). We still want to pass
932 * through that code if skill is set to change to the skill. 880 * through that code if skill is set to change to the skill.
933 */ 881 */
934 if (op->type == PLAYER) 882 if (player *pl = op->contr)
935 { 883 {
936 if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) 884 if (!pl->combat_ob)
937 { 885 {
938 if (!skill) 886 if (QUERY_FLAG (op, FLAG_READY_WEAPON))
939 { 887 {
940 /* See if the players chosen skill is a combat skill, and use 888 for (tmp = op->inv; tmp; tmp = tmp->below)
941 * it if appropriate. 889 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_APPLIED))
942 */ 890 break;
943 if (op->chosen_skill && hth_skill_p (op->chosen_skill)) 891
944 skill = op->chosen_skill; 892 if (!tmp)
945 else
946 { 893 {
947 skill = find_player_hth_skill (op); 894 LOG (llevError, "Could not find applied weapon on %s\n", &op->name);
895 return 0;
896 }
948 897
898 change_skill (op, find_skill_by_name (op, tmp->skill), 1);
899 }
900 else
901 {
949 if (!skill) 902 if (!skill)
903 {
904 /* See if the players chosen skill is a combat skill, and use
905 * it if appropriate.
906 */
907 if (op->chosen_skill && hth_skill_p (op->chosen_skill))
908 skill = op->chosen_skill;
909 else
950 { 910 {
911 skill = find_player_hth_skill (op);
912
913 if (!skill)
914 {
951 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); 915 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!");
952 return 0; 916 return 0;
917 }
953 } 918 }
954 } 919 }
920
921 /* now try to ready the new skill */
922 if (!change_skill (op, skill, 0))
923 { /* oh oh, trouble! */
924 new_draw_info_format (NDI_UNIQUE, 0, op, "Couldn't change to skill %s", &skill->name);
925 return 0;
926 }
955 } 927 }
956 928
957 /* now try to ready the new skill */ 929 if (!pl->combat_ob)
958 if (!change_skill (op, skill, 0)) 930 {
959 { /* oh oh, trouble! */ 931 LOG (llevError, "Could not find anything to attack on %s\n", &op->name);
960 new_draw_info_format (NDI_UNIQUE, 0, tmp, "Couldn't change to skill %s", &skill->name);
961 return 0; 932 return 0;
962 } 933 }
963 } 934 }
964 else 935
936 if (!op->change_weapon (pl->combat_ob))
937 return 0;
938
939 /* lose invisiblity/hiding status for running attacks */
940 if (pl->tmp_invis)
965 { 941 {
966 /* Seen some crashes below where current_weapon is not set, 942 pl->tmp_invis = 0;
967 * even though the flag says it is. So if current weapon isn't set, 943 op->invisible = 0;
968 * do some work in trying to find the object to use. 944 op->hide = 0;
969 */ 945 update_object (op, UP_OBJ_CHANGE);
970 if (!op->current_weapon)
971 {
972 object *tmp;
973
974 LOG (llevError, "Player %s does not have current weapon set but flag_ready_weapon is set\n", &op->name);
975 for (tmp = op->inv; tmp; tmp = tmp->below)
976 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_APPLIED))
977 break;
978
979 if (!tmp)
980 {
981 LOG (llevError, "Could not find applied weapon on %s\n", &op->name);
982 op->current_weapon = NULL;
983 return 0;
984 }
985 else
986 {
987 op->current_weapon = tmp;
988 }
989 }
990
991 change_skill (op, find_skill_by_name (op, op->current_weapon->skill), 1);
992 } 946 }
993 } 947 }
994 948
995 /* lose invisiblity/hiding status for running attacks */
996
997 if (op->type == PLAYER && op->contr->tmp_invis)
998 {
999 op->contr->tmp_invis = 0;
1000 op->invisible = 0;
1001 op->hide = 0;
1002 update_object (op, UP_OBJ_FACE);
1003 }
1004
1005 success = attack_ob (tmp, op); 949 int success = attack_ob (tmp, op);
1006 950
1007 /* print appropriate messages to the player */ 951 /* print appropriate messages to the player */
1008 952
1009 if (success && string != NULL && tmp && !QUERY_FLAG (tmp, FLAG_FREED)) 953 if (success && string && tmp && !QUERY_FLAG (tmp, FLAG_FREED))
1010 { 954 {
1011 if (op->type == PLAYER) 955 if (op->type == PLAYER)
1012 new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp)); 956 new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp));
1013 else if (tmp->type == PLAYER) 957 else if (tmp->type == PLAYER)
1014 new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string); 958 new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string);
1015 } 959 }
960
1016 return success; 961 return success;
1017} 962}
1018
1019 963
1020/* skill_attack() - Core routine for use when we attack using a skills 964/* skill_attack() - Core routine for use when we attack using a skills
1021 * system. In essence, this code handles 965 * system. In essence, this code handles
1022 * all skill-based attacks, ie hth, missile and melee weapons should be 966 * all skill-based attacks, ie hth, missile and melee weapons should be
1023 * treated here. If an opponent is already supplied by move_player(), 967 * treated here. If an opponent is already supplied by move_player(),
1026 * 970 *
1027 * This is called by move_player() and attack_hth() 971 * This is called by move_player() and attack_hth()
1028 * 972 *
1029 * Initial implementation by -bt thomas@astro.psu.edu 973 * Initial implementation by -bt thomas@astro.psu.edu
1030 */ 974 */
1031
1032int 975int
1033skill_attack (object *tmp, object *pl, int dir, const char *string, object *skill) 976skill_attack (object *tmp, object *pl, int dir, const char *string, object *skill)
1034{ 977{
1035 sint16 tx, ty; 978 sint16 tx, ty;
1036 maptile *m; 979 maptile *m;
1043 ty = freearr_y[dir]; 986 ty = freearr_y[dir];
1044 987
1045 /* If we don't yet have an opponent, find if one exists, and attack. 988 /* If we don't yet have an opponent, find if one exists, and attack.
1046 * Legal opponents are the same as outlined in move_player_attack() 989 * Legal opponents are the same as outlined in move_player_attack()
1047 */ 990 */
1048 991 if (!tmp)
1049 if (tmp == NULL)
1050 { 992 {
1051 m = pl->map; 993 m = pl->map;
1052 tx = pl->x + freearr_x[dir]; 994 tx = pl->x + freearr_x[dir];
1053 ty = pl->y + freearr_y[dir]; 995 ty = pl->y + freearr_y[dir];
1054 996
1064 if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR) 1006 if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR)
1065 { 1007 {
1066 /* Don't attack party members */ 1008 /* Don't attack party members */
1067 if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party)) 1009 if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party))
1068 return 0; 1010 return 0;
1011
1069 break; 1012 break;
1070 } 1013 }
1071 } 1014 }
1015
1072 if (!tmp) 1016 if (!tmp)
1073 { 1017 {
1074 if (pl->type == PLAYER) 1018 if (pl->type == PLAYER)
1075 new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to attack!"); 1019 new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to attack!");
1020
1076 return 0; 1021 return 0;
1077 } 1022 }
1078 1023
1079 return do_skill_attack (tmp, pl, string, skill); 1024 return do_skill_attack (tmp, pl, string, skill);
1080} 1025}
1081
1082 1026
1083/* attack_hth() - this handles all hand-to-hand attacks -b.t. */ 1027/* attack_hth() - this handles all hand-to-hand attacks -b.t. */
1084 1028
1085/* July 5, 1995 - I broke up attack_hth() into 2 parts. In the first 1029/* July 5, 1995 - I broke up attack_hth() into 2 parts. In the first
1086 * (attack_hth) we check for weapon use, etc in the second (the new 1030 * (attack_hth) we check for weapon use, etc in the second (the new
1087 * function skill_attack() we actually attack. 1031 * function skill_attack() we actually attack.
1088 */ 1032 */
1089
1090static int 1033static int
1091attack_hth (object *pl, int dir, const char *string, object *skill) 1034attack_hth (object *pl, int dir, const char *string, object *skill)
1092{ 1035{
1093 object *enemy = NULL, *weapon; 1036 object *enemy = NULL, *weapon;
1094 1037
1097 { 1040 {
1098 if (weapon->type == WEAPON && QUERY_FLAG (weapon, FLAG_APPLIED)) 1041 if (weapon->type == WEAPON && QUERY_FLAG (weapon, FLAG_APPLIED))
1099 { 1042 {
1100 CLEAR_FLAG (weapon, FLAG_APPLIED); 1043 CLEAR_FLAG (weapon, FLAG_APPLIED);
1101 CLEAR_FLAG (pl, FLAG_READY_WEAPON); 1044 CLEAR_FLAG (pl, FLAG_READY_WEAPON);
1102 fix_player (pl); 1045 pl->update_stats ();
1103 if (pl->type == PLAYER) 1046 if (pl->type == PLAYER)
1104 { 1047 {
1105 new_draw_info (NDI_UNIQUE, 0, pl, "You unwield your weapon in order to attack."); 1048 new_draw_info (NDI_UNIQUE, 0, pl, "You unwield your weapon in order to attack.");
1106 esrv_update_item (UPD_FLAGS, pl, weapon); 1049 esrv_update_item (UPD_FLAGS, pl, weapon);
1107 } 1050 }
1051
1108 break; 1052 break;
1109 } 1053 }
1110 } 1054 }
1055
1111 return skill_attack (enemy, pl, dir, string, skill); 1056 return skill_attack (enemy, pl, dir, string, skill);
1112} 1057}
1113
1114 1058
1115/* attack_melee_weapon() - this handles melee weapon attacks -b.t. 1059/* attack_melee_weapon() - this handles melee weapon attacks -b.t.
1116 * For now we are just checking to see if we have a ready weapon here. 1060 * For now we are just checking to see if we have a ready weapon here.
1117 * But there is a real neato possible feature of this scheme which 1061 * But there is a real neato possible feature of this scheme which
1118 * bears mentioning: 1062 * bears mentioning:
1119 * Since we are only calling this from do_skill() in the future 1063 * Since we are only calling this from do_skill() in the future
1120 * we may make this routine handle 'special' melee weapons attacks 1064 * we may make this routine handle 'special' melee weapons attacks
1121 * (like disarming manuever with sai) based on player SK_level and 1065 * (like disarming manuever with sai) based on player SK_level and
1122 * weapon type. 1066 * weapon type.
1123 */ 1067 */
1124
1125static int 1068static int
1126attack_melee_weapon (object *op, int dir, const char *string, object *skill) 1069attack_melee_weapon (object *op, int dir, const char *string, object *skill)
1127{ 1070{
1128 1071
1129 if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) 1072 if (!QUERY_FLAG (op, FLAG_READY_WEAPON))
1130 { 1073 {
1131 if (op->type == PLAYER) 1074 if (op->type == PLAYER)
1132 new_draw_info (NDI_UNIQUE, 0, op, "You have no ready weapon to attack with!"); 1075 new_draw_info (NDI_UNIQUE, 0, op, "You have no ready weapon to attack with!");
1076
1133 return 0; 1077 return 0;
1134 } 1078 }
1079
1135 return skill_attack (NULL, op, dir, string, skill); 1080 return skill_attack (NULL, op, dir, string, skill);
1136 1081
1137} 1082}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines