1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
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 |
49 | /* Table of unarmed attack skills. Terminated by -1. This |
51 | * is also the list that we should try to use skills when |
50 | * is also the list that we should try to use skills when |
52 | * automatically applying one for the player. |
51 | * automatically applying one for the player. |
53 | * Note it is hardcoded in the skill_util.c that dragons always |
|
|
54 | * want clawing if possible. |
|
|
55 | */ |
52 | */ |
56 | static uint8 unarmed_skills[] = { |
53 | static uint8 unarmed_skills[] = { |
57 | SK_KARATE, |
54 | SK_KARATE, |
58 | SK_CLAWING, |
55 | SK_CLAWING, |
59 | SK_FLAME_TOUCH, |
56 | SK_FLAME_TOUCH, |
… | |
… | |
96 | if (!skill_names[i]) |
93 | if (!skill_names[i]) |
97 | LOG (llevError, "init_skills: skill subtype %d doesn't have a name?\n", i); |
94 | LOG (llevError, "init_skills: skill subtype %d doesn't have a name?\n", i); |
98 | } |
95 | } |
99 | } |
96 | } |
100 | |
97 | |
101 | |
|
|
102 | /* This function goes through the player inventory and sets |
98 | /* This function goes through the player inventory and sets |
103 | * up the last_skills[] array in the player object. |
99 | * up the last_skills[] array in the player object. |
104 | * the last_skills[] is used to more quickly lookup skills - |
100 | * the last_skills[] is used to more quickly lookup skills - |
105 | * mostly used for sending exp. |
101 | * mostly used for sending exp. |
106 | */ |
102 | */ |
107 | void |
103 | void |
108 | link_player_skills (object *op) |
104 | link_player_skills (object *op) |
109 | { |
105 | { |
110 | object *tmp; |
|
|
111 | |
|
|
112 | for (tmp = op->inv; tmp; tmp = tmp->below) |
106 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
113 | { |
|
|
114 | if (tmp->type == SKILL) |
107 | if (tmp->type == SKILL) |
115 | { |
108 | { |
116 | /* This is really a warning, hence no else below */ |
109 | /* This is really a warning, hence no else below */ |
117 | if (op->contr->last_skill_ob[tmp->subtype] && op->contr->last_skill_ob[tmp->subtype] != tmp) |
110 | if (op->contr->last_skill_ob[tmp->subtype] && op->contr->last_skill_ob[tmp->subtype] != tmp) |
118 | { |
|
|
119 | LOG (llevError, "Multiple skills with the same subtype? %s, %s\n", |
111 | LOG (llevError, "Multiple skills with the same subtype? %s, %s\n", |
120 | &op->contr->last_skill_ob[tmp->subtype]->skill, &tmp->skill); |
112 | &op->contr->last_skill_ob[tmp->subtype]->skill, &tmp->skill); |
121 | } |
113 | |
122 | if (tmp->subtype >= NUM_SKILLS) |
114 | if (tmp->subtype >= NUM_SKILLS) |
123 | { |
|
|
124 | LOG (llevError, "Invalid subtype number %d (range 0-%d)\n", tmp->subtype, NUM_SKILLS); |
115 | LOG (llevError, "Invalid subtype number %d (range 0-%d)\n", tmp->subtype, NUM_SKILLS); |
125 | } |
|
|
126 | else |
116 | else |
127 | { |
117 | { |
128 | op->contr->last_skill_ob[tmp->subtype] = tmp; |
118 | op->contr->last_skill_ob[tmp->subtype] = tmp; |
129 | op->contr->last_skill_exp[tmp->subtype] = -1; |
119 | op->contr->ns->last_skill_exp[tmp->subtype] = -1; //TODO: this should go |
130 | } |
120 | } |
131 | } |
121 | } |
132 | } |
|
|
133 | } |
122 | } |
134 | |
123 | |
135 | /* This returns the skill pointer of the given name (the |
124 | /* This returns the skill pointer of the given name (the |
136 | * one that accumlates exp, has the level, etc). |
125 | * one that accumlates exp, has the level, etc). |
137 | * |
126 | * |
… | |
… | |
241 | if (!QUERY_FLAG (skill_tool, FLAG_APPLIED)) |
230 | if (!QUERY_FLAG (skill_tool, FLAG_APPLIED)) |
242 | { |
231 | { |
243 | if (apply_special (who, skill_tool, 0)) |
232 | if (apply_special (who, skill_tool, 0)) |
244 | return NULL; |
233 | return NULL; |
245 | } |
234 | } |
|
|
235 | |
246 | if (!skill) |
236 | if (!skill) |
247 | { |
237 | { |
248 | skill = give_skill_by_name (who, skill_tool->skill); |
238 | skill = give_skill_by_name (who, skill_tool->skill); |
249 | link_player_skills (who); |
239 | link_player_skills (who); |
250 | } |
240 | } |
|
|
241 | |
251 | return skill; |
242 | return skill; |
252 | } |
243 | } |
|
|
244 | |
253 | return NULL; |
245 | return NULL; |
254 | } |
246 | } |
255 | |
247 | |
256 | /* This changes the objects skill to new_skill. |
248 | /* This changes the objects skill to new_skill. |
257 | * note that this function doesn't always need to get used - |
249 | * note that this function doesn't always need to get used - |
… | |
… | |
262 | * flag has the current meaning: |
254 | * flag has the current meaning: |
263 | * 0x1: If set, don't update the range pointer. This is useful when we |
255 | * 0x1: If set, don't update the range pointer. This is useful when we |
264 | * need to ready a new skill, but don't want to clobber range. |
256 | * need to ready a new skill, but don't want to clobber range. |
265 | * return 1 on success, 0 on error |
257 | * return 1 on success, 0 on error |
266 | */ |
258 | */ |
267 | |
|
|
268 | int |
259 | int |
269 | change_skill (object *who, object *new_skill, int flag) |
260 | change_skill (object *who, object *new_skill, int flag) |
270 | { |
261 | { |
271 | int old_range; |
262 | int old_range; |
272 | |
263 | |
… | |
… | |
276 | old_range = who->contr->shoottype; |
267 | old_range = who->contr->shoottype; |
277 | |
268 | |
278 | if (who->chosen_skill && who->chosen_skill == new_skill) |
269 | if (who->chosen_skill && who->chosen_skill == new_skill) |
279 | { |
270 | { |
280 | /* optimization for changing skill to current skill */ |
271 | /* optimization for changing skill to current skill */ |
281 | if (who->type == PLAYER && !(flag & 0x1)) |
272 | if (!(flag & 0x1)) |
282 | who->contr->shoottype = range_skill; |
273 | who->contr->set_range (range_skill); |
|
|
274 | |
283 | return 1; |
275 | return 1; |
284 | } |
276 | } |
285 | |
277 | |
286 | if (!new_skill || who->chosen_skill) |
278 | // move skill to front, so it will be preferred next time |
287 | if (who->chosen_skill) |
279 | new_skill->remove (); |
288 | apply_special (who, who->chosen_skill, AP_UNAPPLY); |
280 | who->insert (new_skill); |
289 | |
281 | |
290 | /* Only goal in this case was to unapply a skill */ |
|
|
291 | if (!new_skill) |
282 | if (!new_skill) |
|
|
283 | { |
|
|
284 | if (who->chosen_skill) |
|
|
285 | apply_special (who, who->chosen_skill, AP_UNAPPLY); |
|
|
286 | |
|
|
287 | /* Only goal in this case was to unapply a skill */ |
|
|
288 | return 0; |
|
|
289 | } |
|
|
290 | |
|
|
291 | if (apply_special (who, new_skill, AP_APPLY)) |
292 | return 0; |
292 | return 0; |
293 | |
293 | |
294 | if (apply_special (who, new_skill, AP_APPLY)) |
|
|
295 | { |
|
|
296 | return 0; |
|
|
297 | } |
|
|
298 | if (flag & 0x1) |
294 | if (!(flag & 0x1)) |
299 | who->contr->shoottype = (rangetype) old_range; |
295 | who->contr->set_range ((rangetype) old_range); |
300 | |
296 | |
301 | return 1; |
297 | return 1; |
302 | } |
298 | } |
303 | |
299 | |
304 | /* This function just clears the chosen_skill and range_skill values |
300 | /* This function just clears the chosen_skill and range_skill values |
… | |
… | |
325 | * exp - no caller needed that info, but it also prevented the callers |
321 | * exp - no caller needed that info, but it also prevented the callers |
326 | * from know if a skill was actually used, as many skills don't |
322 | * from know if a skill was actually used, as many skills don't |
327 | * give any exp for their direct use (eg, throwing). |
323 | * give any exp for their direct use (eg, throwing). |
328 | * It returns 0 if no skill was used. |
324 | * It returns 0 if no skill was used. |
329 | */ |
325 | */ |
330 | |
|
|
331 | int |
326 | int |
332 | do_skill (object *op, object *part, object *skill, int dir, const char *string) |
327 | do_skill (object *op, object *part, object *skill, int dir, const char *string) |
333 | { |
328 | { |
334 | int success = 0, exp = 0; |
329 | int success = 0, exp = 0; |
335 | int did_alc = 0; |
330 | int did_alc = 0; |
… | |
… | |
344 | * the player doesn't have a bucket for that, create one. |
339 | * the player doesn't have a bucket for that, create one. |
345 | */ |
340 | */ |
346 | if (skill->type != SKILL && op->type == PLAYER) |
341 | if (skill->type != SKILL && op->type == PLAYER) |
347 | { |
342 | { |
348 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
343 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
349 | { |
|
|
350 | if (tmp->type == SKILL && tmp->skill == skill->skill) |
344 | if (tmp->type == SKILL && tmp->skill == skill->skill) |
351 | break; |
345 | break; |
352 | } |
346 | |
353 | if (!tmp) |
347 | if (!tmp) |
354 | tmp = give_skill_by_name (op, skill->skill); |
348 | tmp = give_skill_by_name (op, skill->skill); |
|
|
349 | |
355 | skill = tmp; |
350 | skill = tmp; |
356 | } |
351 | } |
357 | |
352 | |
358 | // skill, by_whom, on_which_object, which direction, skill_argument |
353 | // skill, by_whom, on_which_object, which direction, skill_argument |
359 | if (INVOKE_OBJECT (USE_SKILL, skill, ARG_OBJECT (op), ARG_OBJECT (part), ARG_INT (dir), ARG_STRING (string))) |
354 | if (INVOKE_OBJECT (USE_SKILL, skill, ARG_OBJECT (op), ARG_OBJECT (part), ARG_INT (dir), ARG_STRING (string))) |
360 | return 0; |
355 | return 0; |
361 | |
356 | |
362 | switch (skill->subtype) |
357 | switch (skill->subtype) |
363 | { |
358 | { |
364 | case SK_LEVITATION: |
359 | case SK_LEVITATION: |
365 | /* Not 100% sure if this will work with new movement code - |
360 | /* Not 100% sure if this will work with new movement code - |
366 | * the levitation skill has move_type for flying, so when |
361 | * the levitation skill has move_type for flying, so when |
367 | * equipped, that should transfer to player, when not, |
362 | * equipped, that should transfer to player, when not, |
368 | * shouldn't. |
363 | * shouldn't. |
369 | */ |
364 | */ |
370 | if (QUERY_FLAG (skill, FLAG_APPLIED)) |
365 | if (QUERY_FLAG (skill, FLAG_APPLIED)) |
371 | { |
366 | { |
372 | CLEAR_FLAG (skill, FLAG_APPLIED); |
367 | CLEAR_FLAG (skill, FLAG_APPLIED); |
373 | new_draw_info (NDI_UNIQUE, 0, op, "You come to earth."); |
368 | new_draw_info (NDI_UNIQUE, 0, op, "You come to earth."); |
374 | } |
369 | } |
375 | else |
370 | else |
376 | { |
371 | { |
377 | SET_FLAG (skill, FLAG_APPLIED); |
372 | SET_FLAG (skill, FLAG_APPLIED); |
378 | new_draw_info (NDI_UNIQUE, 0, op, "You rise into the air!."); |
373 | new_draw_info (NDI_UNIQUE, 0, op, "You rise into the air!."); |
379 | } |
374 | } |
380 | fix_player (op); |
375 | |
|
|
376 | op->update_stats (); |
381 | success = 1; |
377 | success = 1; |
382 | break; |
378 | break; |
383 | |
379 | |
384 | case SK_STEALING: |
380 | case SK_STEALING: |
385 | exp = success = steal (op, dir, skill); |
381 | exp = success = steal (op, dir, skill); |
386 | break; |
382 | break; |
387 | |
383 | |
388 | case SK_LOCKPICKING: |
384 | case SK_LOCKPICKING: |
389 | exp = success = pick_lock (op, dir, skill); |
385 | exp = success = pick_lock (op, dir, skill); |
390 | break; |
386 | break; |
391 | |
387 | |
392 | case SK_HIDING: |
388 | case SK_HIDING: |
393 | exp = success = hide (op, skill); |
389 | exp = success = hide (op, skill); |
394 | break; |
390 | break; |
395 | |
391 | |
396 | case SK_JUMPING: |
392 | case SK_JUMPING: |
397 | success = jump (op, dir, skill); |
393 | success = jump (op, dir, skill); |
398 | break; |
394 | break; |
399 | |
395 | |
400 | case SK_INSCRIPTION: |
396 | case SK_INSCRIPTION: |
401 | exp = success = write_on_item (op, string, skill); |
397 | exp = success = write_on_item (op, string, skill); |
402 | break; |
398 | break; |
403 | |
399 | |
404 | case SK_MEDITATION: |
400 | case SK_MEDITATION: |
405 | meditate (op, skill); |
401 | meditate (op, skill); |
406 | success = 1; |
402 | success = 1; |
407 | break; |
403 | break; |
408 | /* note that the following 'attack' skills gain exp through hit_player() */ |
404 | /* note that the following 'attack' skills gain exp through hit_player() */ |
409 | |
405 | |
410 | case SK_KARATE: |
406 | case SK_KARATE: |
411 | (void) attack_hth (op, dir, "karate-chopped", skill); |
407 | attack_hth (op, dir, "karate-chopped", skill); |
412 | break; |
408 | break; |
413 | |
409 | |
414 | case SK_PUNCHING: |
410 | case SK_PUNCHING: |
415 | (void) attack_hth (op, dir, "punched", skill); |
411 | attack_hth (op, dir, "punched", skill); |
416 | break; |
412 | break; |
417 | |
413 | |
418 | case SK_FLAME_TOUCH: |
414 | case SK_FLAME_TOUCH: |
419 | (void) attack_hth (op, dir, "flamed", skill); |
415 | attack_hth (op, dir, "flamed", skill); |
420 | break; |
416 | break; |
421 | |
417 | |
422 | case SK_SPARK_TOUCH: |
418 | case SK_SPARK_TOUCH: |
423 | (void) attack_hth (op, dir, "zapped", skill); |
419 | attack_hth (op, dir, "zapped", skill); |
424 | break; |
420 | break; |
425 | |
421 | |
426 | case SK_SHIVER: |
422 | case SK_SHIVER: |
427 | (void) attack_hth (op, dir, "froze", skill); |
423 | attack_hth (op, dir, "froze", skill); |
428 | break; |
424 | break; |
429 | |
425 | |
430 | case SK_ACID_SPLASH: |
426 | case SK_ACID_SPLASH: |
431 | (void) attack_hth (op, dir, "dissolved", skill); |
427 | attack_hth (op, dir, "dissolved", skill); |
432 | break; |
428 | break; |
433 | |
429 | |
434 | case SK_POISON_NAIL: |
430 | case SK_POISON_NAIL: |
435 | (void) attack_hth (op, dir, "injected poison into", skill); |
431 | attack_hth (op, dir, "injected poison into", skill); |
436 | break; |
432 | break; |
437 | |
433 | |
438 | case SK_CLAWING: |
434 | case SK_CLAWING: |
439 | (void) attack_hth (op, dir, "clawed", skill); |
435 | attack_hth (op, dir, "clawed", skill); |
440 | break; |
436 | break; |
441 | |
437 | |
442 | case SK_ONE_HANDED_WEAPON: |
438 | case SK_ONE_HANDED_WEAPON: |
443 | case SK_TWO_HANDED_WEAPON: |
439 | case SK_TWO_HANDED_WEAPON: |
444 | (void) attack_melee_weapon (op, dir, NULL, skill); |
440 | attack_melee_weapon (op, dir, NULL, skill); |
445 | break; |
441 | break; |
446 | |
442 | |
447 | case SK_FIND_TRAPS: |
443 | case SK_FIND_TRAPS: |
448 | exp = success = find_traps (op, skill); |
444 | exp = success = find_traps (op, skill); |
449 | break; |
445 | break; |
450 | |
446 | |
451 | case SK_SINGING: |
447 | case SK_SINGING: |
452 | exp = success = singing (op, dir, skill); |
448 | exp = success = singing (op, dir, skill); |
453 | break; |
449 | break; |
454 | |
450 | |
455 | case SK_ORATORY: |
451 | case SK_ORATORY: |
456 | exp = success = use_oratory (op, dir, skill); |
452 | exp = success = use_oratory (op, dir, skill); |
457 | break; |
453 | break; |
458 | |
454 | |
459 | case SK_SMITHERY: |
455 | case SK_SMITHERY: |
460 | case SK_BOWYER: |
456 | case SK_BOWYER: |
461 | case SK_JEWELER: |
457 | case SK_JEWELER: |
462 | case SK_ALCHEMY: |
458 | case SK_ALCHEMY: |
463 | case SK_THAUMATURGY: |
459 | case SK_THAUMATURGY: |
464 | case SK_LITERACY: |
460 | case SK_LITERACY: |
465 | case SK_WOODSMAN: |
461 | case SK_WOODSMAN: |
466 | /* first, we try to find a cauldron, and do the alchemy thing. |
462 | /* first, we try to find a cauldron, and do the alchemy thing. |
467 | * failing that, we go and identify stuff. |
463 | * failing that, we go and identify stuff. |
468 | */ |
464 | */ |
469 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = next) |
465 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = next) |
470 | { |
466 | { |
471 | next = tmp->above; |
467 | next = tmp->above; |
|
|
468 | |
472 | if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) |
469 | if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) |
473 | { |
470 | { |
474 | attempt_do_alchemy (op, tmp); |
471 | attempt_do_alchemy (op, tmp); |
|
|
472 | |
475 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
473 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
476 | esrv_send_inventory (op, tmp); |
474 | esrv_send_inventory (op, tmp); |
|
|
475 | |
477 | did_alc = 1; |
476 | did_alc = 1; |
478 | } |
477 | } |
479 | } |
478 | } |
|
|
479 | |
480 | if (did_alc == 0) |
480 | if (did_alc == 0) |
481 | exp = success = skill_ident (op, skill); |
|
|
482 | break; |
|
|
483 | |
|
|
484 | case SK_DET_MAGIC: |
|
|
485 | case SK_DET_CURSE: |
|
|
486 | exp = success = skill_ident (op, skill); |
481 | exp = success = skill_ident (op, skill); |
|
|
482 | |
487 | break; |
483 | break; |
488 | |
484 | |
|
|
485 | case SK_DET_MAGIC: |
|
|
486 | case SK_DET_CURSE: |
|
|
487 | exp = success = skill_ident (op, skill); |
|
|
488 | break; |
|
|
489 | |
489 | case SK_DISARM_TRAPS: |
490 | case SK_DISARM_TRAPS: |
490 | exp = success = remove_trap (op, dir, skill); |
491 | exp = success = remove_trap (op, dir, skill); |
491 | break; |
492 | break; |
492 | |
493 | |
493 | case SK_THROWING: |
494 | case SK_THROWING: |
494 | success = skill_throw (op, part, dir, string, skill); |
495 | success = skill_throw (op, part, dir, string, skill); |
495 | break; |
496 | break; |
496 | |
497 | |
497 | case SK_SET_TRAP: |
498 | case SK_SET_TRAP: |
498 | new_draw_info (NDI_UNIQUE, 0, op, "This skill is not currently implemented."); |
499 | new_draw_info (NDI_UNIQUE, 0, op, "This skill is not currently implemented."); |
499 | break; |
500 | break; |
500 | |
501 | |
501 | case SK_USE_MAGIC_ITEM: |
502 | case SK_USE_MAGIC_ITEM: |
502 | case SK_MISSILE_WEAPON: |
503 | case SK_MISSILE_WEAPON: |
503 | new_draw_info (NDI_UNIQUE, 0, op, "There is no special attack for this skill."); |
504 | new_draw_info (NDI_UNIQUE, 0, op, "There is no special attack for this skill."); |
504 | break; |
505 | break; |
505 | |
506 | |
506 | case SK_PRAYING: |
507 | case SK_PRAYING: |
507 | success = pray (op, skill); |
508 | success = pray (op, skill); |
508 | break; |
509 | break; |
509 | |
510 | |
510 | case SK_BARGAINING: |
511 | case SK_BARGAINING: |
511 | success = describe_shop (op); |
512 | success = describe_shop (op); |
512 | break; |
513 | break; |
513 | |
514 | |
514 | case SK_SORCERY: |
515 | case SK_SORCERY: |
515 | case SK_EVOCATION: |
516 | case SK_EVOCATION: |
516 | case SK_PYROMANCY: |
517 | case SK_PYROMANCY: |
517 | case SK_SUMMONING: |
518 | case SK_SUMMONING: |
518 | case SK_CLIMBING: |
519 | case SK_CLIMBING: |
519 | new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect."); |
520 | new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect."); |
520 | break; |
521 | break; |
521 | |
522 | |
522 | default: |
523 | default: |
523 | LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp); |
524 | LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp); |
524 | break; |
525 | break; |
525 | } |
526 | } |
526 | |
527 | |
527 | /* For players we now update the speed_left from using the skill. |
528 | /* For players we now update the speed_left from using the skill. |
528 | * Monsters have no skill use time because of the random nature in |
529 | * Monsters have no skill use time because of the random nature in |
529 | * which use_monster_skill is called already simulates this. |
530 | * which use_monster_skill is called already simulates this. |
… | |
… | |
691 | |
692 | |
692 | /* player already knows it */ |
693 | /* player already knows it */ |
693 | if (tmp && QUERY_FLAG (tmp, FLAG_CAN_USE_SKILL)) |
694 | if (tmp && QUERY_FLAG (tmp, FLAG_CAN_USE_SKILL)) |
694 | return 0; |
695 | return 0; |
695 | |
696 | |
696 | |
|
|
697 | |
|
|
698 | /* now a random change to learn, based on player Int. |
697 | /* now a random change to learn, based on player Int. |
699 | * give bonus based on level - otherwise stupid characters |
698 | * give bonus based on level - otherwise stupid characters |
700 | * might never be able to learn anything. |
699 | * might never be able to learn anything. |
701 | */ |
700 | */ |
702 | if (random_roll (0, 99, pl, PREFER_LOW) > (learn_spell[pl->stats.Int] + (pl->level / 5))) |
701 | if (random_roll (0, 99, pl, PREFER_LOW) > (learn_spell[pl->stats.Int] + (pl->level / 5))) |
… | |
… | |
771 | sprintf (buf, "%s%s", &tmp->name, periods); |
770 | sprintf (buf, "%s%s", &tmp->name, periods); |
772 | buf[40] = 0; |
771 | buf[40] = 0; |
773 | |
772 | |
774 | if (settings.permanent_exp_ratio) |
773 | if (settings.permanent_exp_ratio) |
775 | { |
774 | { |
776 | sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%lld/%lld/%d%%)", |
775 | sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)", |
777 | buf, tmp->level, |
776 | buf, tmp->level, tmp->stats.exp, |
778 | (long long) tmp->stats.exp, |
|
|
779 | (long long) level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp)); |
777 | level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp)); |
780 | } |
778 | } |
781 | else |
779 | else |
782 | { |
780 | { |
783 | sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%lld/%lld)", |
781 | sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")", |
784 | buf, tmp->level, (long long) tmp->stats.exp, (long long) level_exp (tmp->level + 1, op->expmul)); |
782 | buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul)); |
785 | } |
783 | } |
786 | /* I don't know why some characters get a bunch of skills, but |
784 | /* I don't know why some characters get a bunch of skills, but |
787 | * it sometimes happens (maybe a leftover from bugier earlier code |
785 | * it sometimes happens (maybe a leftover from bugier earlier code |
788 | * and those character are still about). In any case, lets handle |
786 | * and those character are still about). In any case, lets handle |
789 | * it so it doesn't crash the server - otherwise, one character may |
787 | * it so it doesn't crash the server - otherwise, one character may |
… | |
… | |
799 | } |
797 | } |
800 | |
798 | |
801 | clear_win_info (op); |
799 | clear_win_info (op); |
802 | new_draw_info (NDI_UNIQUE, 0, op, "Player skills:"); |
800 | new_draw_info (NDI_UNIQUE, 0, op, "Player skills:"); |
803 | if (num_skills_found > 1) |
801 | if (num_skills_found > 1) |
804 | qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) strcmp); |
802 | qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp); |
805 | |
803 | |
806 | for (i = 0; i < num_skills_found; i++) |
804 | for (i = 0; i < num_skills_found; i++) |
807 | { |
|
|
808 | new_draw_info (NDI_UNIQUE, 0, op, skills[i]); |
805 | new_draw_info (NDI_UNIQUE, 0, op, skills[i]); |
809 | } |
|
|
810 | |
806 | |
811 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can handle %d weapon improvements.", op->level / 5 + 5); |
807 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can handle %d weapon improvements.", op->level / 5 + 5); |
812 | |
808 | |
813 | cp = determine_god (op); |
809 | cp = determine_god (op); |
814 | new_draw_info_format (NDI_UNIQUE, 0, op, "You worship %s.", cp ? cp : "no god at current time"); |
810 | new_draw_info_format (NDI_UNIQUE, 0, op, "You worship %s.", cp ? cp : "no god at current time"); |
… | |
… | |
876 | return 1; |
872 | return 1; |
877 | |
873 | |
878 | return 0; |
874 | return 0; |
879 | } |
875 | } |
880 | |
876 | |
|
|
877 | static bool |
|
|
878 | hth_skill_p (object *skill) |
|
|
879 | { |
|
|
880 | for (unsigned int i = 0; i < sizeof (unarmed_skills); ++i) |
|
|
881 | if (skill->subtype == unarmed_skills[i]) |
|
|
882 | return 1; |
881 | |
883 | |
|
|
884 | return 0; |
|
|
885 | } |
882 | |
886 | |
883 | /* This finds the best unarmed skill the player has, and returns |
887 | /* This finds the first unarmed skill the player has, and returns it. |
884 | * it. Best can vary a little - we consider clawing to always |
|
|
885 | * be the best for dragons. |
|
|
886 | * This could be more intelligent, eg, look at the skill level |
|
|
887 | * of the skill and go from there (eg, a level 40 puncher is |
|
|
888 | * is probably better than level 1 karate). OTOH, if you |
|
|
889 | * don't bother to set up your skill properly, that is the players |
|
|
890 | * problem (although, it might be nice to have a preferred skill |
|
|
891 | * field the player can set. |
|
|
892 | * Unlike the old code, we don't give out any skills - it is |
|
|
893 | * possible you just don't have any ability to get into unarmed |
|
|
894 | * combat. If everyone race/class should have one, this should |
|
|
895 | * be handled in the starting treasurelists, not in the code. |
|
|
896 | */ |
888 | */ |
897 | static object * |
889 | static object * |
898 | find_best_player_hth_skill (object *op) |
890 | find_player_hth_skill (object *op) |
899 | { |
891 | { |
900 | object *tmp, *best_skill = NULL; |
|
|
901 | int dragon = is_dragon_pl (op), last_skill = sizeof (unarmed_skills), i; |
|
|
902 | |
|
|
903 | for (tmp = op->inv; tmp; tmp = tmp->below) |
892 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
904 | { |
893 | if (tmp->type == SKILL && QUERY_FLAG (tmp, FLAG_CAN_USE_SKILL) && hth_skill_p (tmp)) |
905 | if (tmp->type == SKILL) |
|
|
906 | { |
|
|
907 | if (dragon && tmp->subtype == SK_CLAWING) |
|
|
908 | return tmp; |
894 | return tmp; |
909 | |
895 | |
910 | /* The order in the array is preferred order. So basically, |
896 | return 0; |
911 | * we just cut down the number to search - eg, if we find a skill |
|
|
912 | * early on in flame touch, then we only need to look into the unarmed_array |
|
|
913 | * to the entry before flame touch - don't care about the entries afterward, |
|
|
914 | * because they are infrerior skills. |
|
|
915 | * if we end up finding the best skill (i==0) might as well return |
|
|
916 | * right away - can't get any better than that. |
|
|
917 | */ |
|
|
918 | for (i = 0; i < last_skill; i++) |
|
|
919 | { |
|
|
920 | if (tmp->subtype == unarmed_skills[i] && QUERY_FLAG (tmp, FLAG_CAN_USE_SKILL)) |
|
|
921 | { |
|
|
922 | best_skill = tmp; |
|
|
923 | last_skill = i; |
|
|
924 | if (i == 0) |
|
|
925 | return best_skill; |
|
|
926 | } |
|
|
927 | } |
|
|
928 | } |
|
|
929 | } |
|
|
930 | return best_skill; |
|
|
931 | } |
897 | } |
932 | |
898 | |
933 | /* do_skill_attack() - We have got an appropriate opponent from either |
899 | /* do_skill_attack() - We have got an appropriate opponent from either |
934 | * move_player_attack() or skill_attack(). In this part we get on with |
900 | * move_player_attack() or skill_attack(). In this part we get on with |
935 | * attacking, take care of messages from the attack and changes in invisible. |
901 | * attacking, take care of messages from the attack and changes in invisible. |
… | |
… | |
937 | * tmp is the targetted monster. |
903 | * tmp is the targetted monster. |
938 | * op is what is attacking |
904 | * op is what is attacking |
939 | * string is passed along to describe what messages to describe |
905 | * string is passed along to describe what messages to describe |
940 | * the damage. |
906 | * the damage. |
941 | */ |
907 | */ |
942 | |
|
|
943 | static int |
908 | static int |
944 | do_skill_attack (object *tmp, object *op, const char *string, object *skill) |
909 | do_skill_attack (object *tmp, object *op, const char *string, object *skill) |
945 | { |
910 | { |
946 | int success; |
|
|
947 | |
|
|
948 | if (INVOKE_OBJECT (SKILL_ATTACK, op, ARG_OBJECT (tmp), ARG_STRING (string), ARG_OBJECT (skill))) |
911 | if (INVOKE_OBJECT (SKILL_ATTACK, op, ARG_OBJECT (tmp), ARG_STRING (string), ARG_OBJECT (skill))) |
949 | return RESULT_INT (0); |
912 | return RESULT_INT (0); |
950 | |
913 | |
951 | /* For Players only: if there is no ready weapon, and no "attack" skill |
914 | /* For Players only: if there is no ready weapon, and no "attack" skill |
952 | * is readied either then try to find a skill for the player to use. |
915 | * is readied either then try to find a skill for the player to use. |
… | |
… | |
956 | */ |
919 | */ |
957 | if (op->type == PLAYER) |
920 | if (op->type == PLAYER) |
958 | { |
921 | { |
959 | if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) |
922 | if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) |
960 | { |
923 | { |
961 | size_t i; |
|
|
962 | |
|
|
963 | if (!skill) |
924 | if (!skill) |
964 | { |
925 | { |
965 | /* See if the players chosen skill is a combat skill, and use |
926 | /* See if the players chosen skill is a combat skill, and use |
966 | * it if appropriate. |
927 | * it if appropriate. |
967 | */ |
928 | */ |
|
|
929 | if (op->chosen_skill && hth_skill_p (op->chosen_skill)) |
968 | if (op->chosen_skill) |
930 | skill = op->chosen_skill; |
|
|
931 | else |
969 | { |
932 | { |
970 | for (i = 0; i < sizeof (unarmed_skills); i++) |
|
|
971 | if (op->chosen_skill->subtype == unarmed_skills[i]) |
|
|
972 | { |
|
|
973 | skill = op->chosen_skill; |
|
|
974 | break; |
|
|
975 | } |
|
|
976 | } |
|
|
977 | /* If we didn't find a skill above, look harder for a good skill */ |
|
|
978 | if (!skill) |
|
|
979 | { |
|
|
980 | skill = find_best_player_hth_skill (op); |
933 | skill = find_player_hth_skill (op); |
981 | |
934 | |
982 | if (!skill) |
935 | if (!skill) |
983 | { |
936 | { |
984 | new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); |
937 | new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); |
985 | return 0; |
938 | return 0; |
986 | } |
939 | } |
987 | } |
940 | } |
988 | } |
941 | } |
989 | if (skill != op->chosen_skill) |
942 | |
990 | { |
|
|
991 | /* now try to ready the new skill */ |
943 | /* now try to ready the new skill */ |
992 | if (!change_skill (op, skill, 0)) |
944 | if (!change_skill (op, skill, 0)) |
993 | { /* oh oh, trouble! */ |
945 | { /* oh oh, trouble! */ |
994 | new_draw_info_format (NDI_UNIQUE, 0, tmp, "Couldn't change to skill %s", &skill->name); |
946 | new_draw_info_format (NDI_UNIQUE, 0, tmp, "Couldn't change to skill %s", &skill->name); |
995 | return 0; |
947 | return 0; |
996 | } |
|
|
997 | } |
948 | } |
998 | } |
949 | } |
999 | else |
950 | else |
1000 | { |
951 | { |
1001 | /* Seen some crashes below where current_weapon is not set, |
952 | /* Seen some crashes below where current_weapon is not set, |
… | |
… | |
1016 | LOG (llevError, "Could not find applied weapon on %s\n", &op->name); |
967 | LOG (llevError, "Could not find applied weapon on %s\n", &op->name); |
1017 | op->current_weapon = NULL; |
968 | op->current_weapon = NULL; |
1018 | return 0; |
969 | return 0; |
1019 | } |
970 | } |
1020 | else |
971 | else |
1021 | { |
|
|
1022 | op->current_weapon = tmp; |
972 | op->current_weapon = tmp; |
1023 | } |
|
|
1024 | } |
973 | } |
1025 | |
974 | |
1026 | /* Has ready weapon - make sure chosen_skill is set up properly */ |
|
|
1027 | if (!op->chosen_skill || op->current_weapon->skill != op->chosen_skill->skill) |
|
|
1028 | { |
|
|
1029 | change_skill (op, find_skill_by_name (op, op->current_weapon->skill), 1); |
975 | change_skill (op, find_skill_by_name (op, op->current_weapon->skill), 1); |
1030 | } |
|
|
1031 | } |
976 | } |
1032 | } |
977 | } |
1033 | |
978 | |
1034 | /* lose invisiblity/hiding status for running attacks */ |
979 | /* lose invisiblity/hiding status for running attacks */ |
1035 | |
980 | |
1036 | if (op->type == PLAYER && op->contr->tmp_invis) |
981 | if (op->type == PLAYER && op->contr->tmp_invis) |
1037 | { |
982 | { |
1038 | op->contr->tmp_invis = 0; |
983 | op->contr->tmp_invis = 0; |
1039 | op->invisible = 0; |
984 | op->invisible = 0; |
1040 | op->hide = 0; |
985 | op->hide = 0; |
1041 | update_object (op, UP_OBJ_FACE); |
986 | update_object (op, UP_OBJ_CHANGE); |
1042 | } |
987 | } |
1043 | |
988 | |
1044 | success = attack_ob (tmp, op); |
989 | int success = attack_ob (tmp, op); |
1045 | |
990 | |
1046 | /* print appropriate messages to the player */ |
991 | /* print appropriate messages to the player */ |
1047 | |
992 | |
1048 | if (success && string != NULL && tmp && !QUERY_FLAG (tmp, FLAG_FREED)) |
993 | if (success && string && tmp && !QUERY_FLAG (tmp, FLAG_FREED)) |
1049 | { |
994 | { |
1050 | if (op->type == PLAYER) |
995 | if (op->type == PLAYER) |
1051 | new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp)); |
996 | new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp)); |
1052 | else if (tmp->type == PLAYER) |
997 | else if (tmp->type == PLAYER) |
1053 | new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string); |
998 | new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string); |
1054 | } |
999 | } |
|
|
1000 | |
1055 | return success; |
1001 | return success; |
1056 | } |
1002 | } |
1057 | |
|
|
1058 | |
1003 | |
1059 | /* skill_attack() - Core routine for use when we attack using a skills |
1004 | /* skill_attack() - Core routine for use when we attack using a skills |
1060 | * system. In essence, this code handles |
1005 | * system. In essence, this code handles |
1061 | * all skill-based attacks, ie hth, missile and melee weapons should be |
1006 | * all skill-based attacks, ie hth, missile and melee weapons should be |
1062 | * treated here. If an opponent is already supplied by move_player(), |
1007 | * treated here. If an opponent is already supplied by move_player(), |
… | |
… | |
1065 | * |
1010 | * |
1066 | * This is called by move_player() and attack_hth() |
1011 | * This is called by move_player() and attack_hth() |
1067 | * |
1012 | * |
1068 | * Initial implementation by -bt thomas@astro.psu.edu |
1013 | * Initial implementation by -bt thomas@astro.psu.edu |
1069 | */ |
1014 | */ |
1070 | |
|
|
1071 | int |
1015 | int |
1072 | skill_attack (object *tmp, object *pl, int dir, const char *string, object *skill) |
1016 | skill_attack (object *tmp, object *pl, int dir, const char *string, object *skill) |
1073 | { |
1017 | { |
1074 | sint16 tx, ty; |
1018 | sint16 tx, ty; |
1075 | maptile *m; |
1019 | maptile *m; |
1076 | int mflags; |
1020 | int mflags; |
1077 | |
1021 | |
1078 | if (!dir) |
1022 | if (!dir) |
1079 | dir = pl->facing; |
1023 | dir = pl->facing; |
|
|
1024 | |
1080 | tx = freearr_x[dir]; |
1025 | tx = freearr_x[dir]; |
1081 | ty = freearr_y[dir]; |
1026 | ty = freearr_y[dir]; |
1082 | |
1027 | |
1083 | /* If we don't yet have an opponent, find if one exists, and attack. |
1028 | /* If we don't yet have an opponent, find if one exists, and attack. |
1084 | * Legal opponents are the same as outlined in move_player_attack() |
1029 | * Legal opponents are the same as outlined in move_player_attack() |
1085 | */ |
1030 | */ |
1086 | |
1031 | if (!tmp) |
1087 | if (tmp == NULL) |
|
|
1088 | { |
1032 | { |
1089 | m = pl->map; |
1033 | m = pl->map; |
1090 | tx = pl->x + freearr_x[dir]; |
1034 | tx = pl->x + freearr_x[dir]; |
1091 | ty = pl->y + freearr_y[dir]; |
1035 | ty = pl->y + freearr_y[dir]; |
1092 | |
1036 | |
… | |
… | |
1096 | |
1040 | |
1097 | /* space must be blocked for there to be anything interesting to do */ |
1041 | /* space must be blocked for there to be anything interesting to do */ |
1098 | if (!OB_TYPE_MOVE_BLOCK (pl, GET_MAP_MOVE_BLOCK (m, tx, ty))) |
1042 | if (!OB_TYPE_MOVE_BLOCK (pl, GET_MAP_MOVE_BLOCK (m, tx, ty))) |
1099 | return 0; |
1043 | return 0; |
1100 | |
1044 | |
1101 | for (tmp = get_map_ob (m, tx, ty); tmp; tmp = tmp->above) |
1045 | for (tmp = GET_MAP_OB (m, tx, ty); tmp; tmp = tmp->above) |
1102 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR) |
1046 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR) |
1103 | { |
1047 | { |
1104 | /* Don't attack party members */ |
1048 | /* Don't attack party members */ |
1105 | if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party)) |
1049 | if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party)) |
1106 | return 0; |
1050 | return 0; |
|
|
1051 | |
1107 | break; |
1052 | break; |
1108 | } |
1053 | } |
1109 | } |
1054 | } |
|
|
1055 | |
1110 | if (!tmp) |
1056 | if (!tmp) |
1111 | { |
1057 | { |
1112 | if (pl->type == PLAYER) |
1058 | if (pl->type == PLAYER) |
1113 | new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to attack!"); |
1059 | new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to attack!"); |
|
|
1060 | |
1114 | return 0; |
1061 | return 0; |
1115 | } |
1062 | } |
1116 | |
1063 | |
1117 | return do_skill_attack (tmp, pl, string, skill); |
1064 | return do_skill_attack (tmp, pl, string, skill); |
1118 | } |
1065 | } |
… | |
… | |
1135 | { |
1082 | { |
1136 | if (weapon->type == WEAPON && QUERY_FLAG (weapon, FLAG_APPLIED)) |
1083 | if (weapon->type == WEAPON && QUERY_FLAG (weapon, FLAG_APPLIED)) |
1137 | { |
1084 | { |
1138 | CLEAR_FLAG (weapon, FLAG_APPLIED); |
1085 | CLEAR_FLAG (weapon, FLAG_APPLIED); |
1139 | CLEAR_FLAG (pl, FLAG_READY_WEAPON); |
1086 | CLEAR_FLAG (pl, FLAG_READY_WEAPON); |
1140 | fix_player (pl); |
1087 | pl->update_stats (); |
1141 | if (pl->type == PLAYER) |
1088 | if (pl->type == PLAYER) |
1142 | { |
1089 | { |
1143 | new_draw_info (NDI_UNIQUE, 0, pl, "You unwield your weapon in order to attack."); |
1090 | new_draw_info (NDI_UNIQUE, 0, pl, "You unwield your weapon in order to attack."); |
1144 | esrv_update_item (UPD_FLAGS, pl, weapon); |
1091 | esrv_update_item (UPD_FLAGS, pl, weapon); |
1145 | } |
1092 | } |
1146 | break; |
1093 | break; |
1147 | } |
1094 | } |
1148 | } |
1095 | } |
|
|
1096 | |
1149 | return skill_attack (enemy, pl, dir, string, skill); |
1097 | return skill_attack (enemy, pl, dir, string, skill); |
1150 | } |
1098 | } |
1151 | |
|
|
1152 | |
1099 | |
1153 | /* attack_melee_weapon() - this handles melee weapon attacks -b.t. |
1100 | /* attack_melee_weapon() - this handles melee weapon attacks -b.t. |
1154 | * For now we are just checking to see if we have a ready weapon here. |
1101 | * For now we are just checking to see if we have a ready weapon here. |
1155 | * But there is a real neato possible feature of this scheme which |
1102 | * But there is a real neato possible feature of this scheme which |
1156 | * bears mentioning: |
1103 | * bears mentioning: |
1157 | * Since we are only calling this from do_skill() in the future |
1104 | * Since we are only calling this from do_skill() in the future |
1158 | * we may make this routine handle 'special' melee weapons attacks |
1105 | * we may make this routine handle 'special' melee weapons attacks |
1159 | * (like disarming manuever with sai) based on player SK_level and |
1106 | * (like disarming manuever with sai) based on player SK_level and |
1160 | * weapon type. |
1107 | * weapon type. |
1161 | */ |
1108 | */ |
1162 | |
|
|
1163 | static int |
1109 | static int |
1164 | attack_melee_weapon (object *op, int dir, const char *string, object *skill) |
1110 | attack_melee_weapon (object *op, int dir, const char *string, object *skill) |
1165 | { |
1111 | { |
1166 | |
1112 | |
1167 | if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) |
1113 | if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) |
1168 | { |
1114 | { |
1169 | if (op->type == PLAYER) |
1115 | if (op->type == PLAYER) |
1170 | new_draw_info (NDI_UNIQUE, 0, op, "You have no ready weapon to attack with!"); |
1116 | new_draw_info (NDI_UNIQUE, 0, op, "You have no ready weapon to attack with!"); |
|
|
1117 | |
1171 | return 0; |
1118 | return 0; |
1172 | } |
1119 | } |
|
|
1120 | |
1173 | return skill_attack (NULL, op, dir, string, skill); |
1121 | return skill_attack (NULL, op, dir, string, skill); |
1174 | |
1122 | |
1175 | } |
1123 | } |