1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * 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 |
… | |
… | |
260 | */ |
260 | */ |
261 | int |
261 | int |
262 | do_skill (object *op, object *part, object *skill, int dir, const char *string) |
262 | do_skill (object *op, object *part, object *skill, int dir, const char *string) |
263 | { |
263 | { |
264 | int success = 0, exp = 0; |
264 | int success = 0, exp = 0; |
265 | int did_alc = 0; |
|
|
266 | |
265 | |
267 | if (!skill) |
266 | if (!skill) |
268 | return 0; |
267 | return 0; |
269 | |
268 | |
270 | /* The code below presumes that the skill points to the object that |
269 | /* The code below presumes that the skill points to the object that |
… | |
… | |
395 | case SK_LITERACY: |
394 | case SK_LITERACY: |
396 | case SK_WOODSMAN: |
395 | case SK_WOODSMAN: |
397 | /* first, we try to find a cauldron, and do the alchemy thing. |
396 | /* first, we try to find a cauldron, and do the alchemy thing. |
398 | * failing that, we go and identify stuff. |
397 | * failing that, we go and identify stuff. |
399 | */ |
398 | */ |
|
|
399 | { |
|
|
400 | bool found_cauldron = false; |
|
|
401 | |
400 | for (object *next, *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = next) |
402 | for (object *next, *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = next) |
401 | { |
403 | { |
402 | next = tmp->above; |
404 | next = tmp->above; |
403 | |
405 | |
404 | if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) |
406 | if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) |
405 | { |
407 | { |
|
|
408 | found_cauldron = true; |
|
|
409 | |
|
|
410 | if (tmp->skill != skill->skill) |
|
|
411 | { |
|
|
412 | op->failmsg (format ("You can't use the %s with the %s skill!", |
|
|
413 | query_name (tmp), |
|
|
414 | query_name (skill))); |
|
|
415 | break; |
|
|
416 | } |
|
|
417 | |
406 | attempt_do_alchemy (op, tmp); |
418 | attempt_do_alchemy (op, tmp, skill); |
407 | |
419 | |
408 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
420 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
409 | esrv_send_inventory (op, tmp); |
421 | esrv_send_inventory (op, tmp); |
410 | |
|
|
411 | did_alc = 1; |
|
|
412 | } |
422 | } |
413 | } |
423 | } |
414 | |
424 | |
415 | if (did_alc == 0) |
425 | if (!found_cauldron) |
416 | exp = success = skill_ident (op, skill); |
426 | exp = success = skill_ident (op, skill); |
417 | |
427 | } |
418 | break; |
428 | break; |
419 | |
429 | |
420 | case SK_DET_MAGIC: |
430 | case SK_DET_MAGIC: |
421 | case SK_DET_CURSE: |
431 | case SK_DET_CURSE: |
422 | exp = success = skill_ident (op, skill); |
432 | exp = success = skill_ident (op, skill); |
… | |
… | |
705 | * it so it doesn't crash the server - otherwise, one character may |
715 | * it so it doesn't crash the server - otherwise, one character may |
706 | * crash the server numerous times. |
716 | * crash the server numerous times. |
707 | */ |
717 | */ |
708 | if (num_skills_found >= NUM_SKILLS) |
718 | if (num_skills_found >= NUM_SKILLS) |
709 | { |
719 | { |
710 | new_draw_info (NDI_RED, 0, op, "Your character has too many skills."); |
720 | new_draw_info (NDI_RED | NDI_REPLY, 0, op, "Your character has too many skills."); |
711 | new_draw_info (NDI_RED, 0, op, "Something isn't right - contact the server admin"); |
721 | new_draw_info (NDI_RED | NDI_REPLY, 0, op, "Something isn't right - contact the server admin"); |
712 | break; |
722 | break; |
713 | } |
723 | } |
714 | } |
724 | } |
715 | } |
725 | } |
716 | |
726 | |
717 | dynbuf_text msg (4096, 1024); |
727 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
718 | |
728 | |
719 | msg << "T<Player skills:>\n\n"; |
729 | msg << "T<Player skills:>\n\n"; |
720 | if (num_skills_found > 1) |
730 | if (num_skills_found > 1) |
721 | qsort (skills, num_skills_found, sizeof (skills [0]), (int (*)(const void *, const void *)) std::strcmp); |
731 | qsort (skills, num_skills_found, sizeof (skills [0]), (int (*)(const void *, const void *)) std::strcmp); |
722 | |
732 | |