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,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
59 | /* init_skills basically just sets up the skill_names table |
59 | /* init_skills basically just sets up the skill_names table |
60 | * above. The index into the array is set up by the |
60 | * above. The index into the array is set up by the |
61 | * subtypes. |
61 | * subtypes. |
62 | */ |
62 | */ |
63 | void |
63 | void |
64 | init_skills (void) |
64 | init_skills () |
65 | { |
65 | { |
66 | for_all_archetypes (at) |
66 | for_all_archetypes (at) |
67 | if (at->type == SKILL) |
67 | if (at->type == SKILL) |
68 | { |
68 | { |
69 | if (skill_names[at->subtype]) |
69 | if (skill_names[at->subtype]) |
… | |
… | |
168 | |
168 | |
169 | if (!skill) |
169 | if (!skill) |
170 | skill = give_skill_by_name (who, skill_tool->skill); |
170 | skill = give_skill_by_name (who, skill_tool->skill); |
171 | |
171 | |
172 | if (!skill_tool->flag [FLAG_APPLIED]) |
172 | if (!skill_tool->flag [FLAG_APPLIED]) |
173 | if (apply_special (who, splay (skill_tool), AP_APPLY | AP_NO_READY)) |
173 | if (!who->apply (splay (skill_tool))) |
174 | return 0; |
174 | return 0; |
175 | |
175 | |
176 | return splay (skill); |
176 | return splay (skill); |
177 | } |
177 | } |
178 | |
178 | |
… | |
… | |
462 | case SK_EVOCATION: |
462 | case SK_EVOCATION: |
463 | case SK_PYROMANCY: |
463 | case SK_PYROMANCY: |
464 | case SK_SUMMONING: |
464 | case SK_SUMMONING: |
465 | case SK_CLIMBING: |
465 | case SK_CLIMBING: |
466 | new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect."); |
466 | new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect."); |
|
|
467 | break; |
|
|
468 | |
|
|
469 | case SK_MINING: |
|
|
470 | success = skill_mining (op, part, skill, dir, string); |
|
|
471 | break; |
|
|
472 | |
|
|
473 | case SK_FISHING: |
|
|
474 | success = skill_fishing (op, part, skill, dir, string); |
467 | break; |
475 | break; |
468 | |
476 | |
469 | default: |
477 | default: |
470 | LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp); |
478 | LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp); |
471 | break; |
479 | break; |
… | |
… | |
760 | |
768 | |
761 | if (!string) |
769 | if (!string) |
762 | return 0; |
770 | return 0; |
763 | |
771 | |
764 | for (skop = op->inv; skop; skop = skop->below) |
772 | for (skop = op->inv; skop; skop = skop->below) |
765 | { |
773 | if ((skop->type == SKILL || skop->type == SKILL_TOOL) |
766 | if (skop->type == SKILL |
|
|
767 | && QUERY_FLAG (skop, FLAG_CAN_USE_SKILL) |
|
|
768 | && !strncasecmp (string, skop->skill, min (strlen (string), (size_t) strlen (skop->skill)))) |
774 | && !strncmp (string, skop->skill, min (strlen (string), strlen (skop->skill)))) |
|
|
775 | { |
|
|
776 | skop = find_skill_by_name (op, skop->skill); |
769 | break; |
777 | break; |
770 | else if (skop->type == SKILL_TOOL |
|
|
771 | && !strncasecmp (string, skop->skill, min (strlen (string), (size_t) strlen (skop->skill)))) |
|
|
772 | break; |
|
|
773 | } |
778 | } |
774 | |
779 | |
775 | if (!skop) |
780 | if (!skop) |
776 | { |
781 | { |
777 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find skill %s", string); |
782 | op->failmsg (format ("Unable to find skill %s.", string)); |
|
|
783 | return 0; |
|
|
784 | } |
|
|
785 | |
|
|
786 | if (!(skill_flags [skop->subtype] & SF_USE)) |
|
|
787 | { |
|
|
788 | op->failmsg (format ( |
|
|
789 | "You feel as if you wanted to do something funny, but you can't remember what. " |
|
|
790 | "H<The %s skill cannot be C<use_skill>'ed - maybe you need to C<ready_skill> it, " |
|
|
791 | "use it with some item, or it's always active.>", |
|
|
792 | &skop->skill |
|
|
793 | )); |
778 | return 0; |
794 | return 0; |
779 | } |
795 | } |
780 | |
796 | |
781 | len = strlen (skop->skill); |
797 | len = strlen (skop->skill); |
782 | |
798 | |
… | |
… | |
808 | } |
824 | } |
809 | |
825 | |
810 | static bool |
826 | static bool |
811 | hth_skill_p (object *skill) |
827 | hth_skill_p (object *skill) |
812 | { |
828 | { |
813 | return (skill_flags [skill->subtype] & (SF_COMBAT | SF_NEED_WEAPON)) == SF_COMBAT; |
829 | return (skill_flags [skill->subtype] & (SF_COMBAT | SF_NEED_ITEM)) == SF_COMBAT; |
814 | } |
830 | } |
815 | |
831 | |
816 | /* This finds the first unarmed skill the player has, and returns it. |
832 | /* This finds the first unarmed skill the player has, and returns it. |
817 | */ |
833 | */ |
818 | static object * |
834 | static object * |
… | |
… | |
847 | * through that code if skill is set to change to the skill. |
863 | * through that code if skill is set to change to the skill. |
848 | */ |
864 | */ |
849 | if (player *pl = op->contr) |
865 | if (player *pl = op->contr) |
850 | { |
866 | { |
851 | if (skill) |
867 | if (skill) |
852 | op->change_skill (skill); |
868 | { |
|
|
869 | if (!op->apply (skill)) |
|
|
870 | return 0; |
|
|
871 | } |
853 | else |
872 | else |
854 | { |
873 | { |
855 | if (!pl->combat_ob) |
874 | if (!pl->combat_ob) |
856 | { |
875 | { |
857 | if (QUERY_FLAG (op, FLAG_READY_WEAPON)) |
876 | if (QUERY_FLAG (op, FLAG_READY_WEAPON)) |
… | |
… | |
879 | |
898 | |
880 | if (!skill) |
899 | if (!skill) |
881 | new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); |
900 | new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); |
882 | } |
901 | } |
883 | |
902 | |
884 | if (skill) |
903 | op->apply (skill); |
885 | { |
|
|
886 | op->change_skill (0); |
|
|
887 | apply_special (op, skill, AP_APPLY); |
|
|
888 | } |
|
|
889 | } |
904 | } |
890 | |
905 | |
891 | if (!pl->combat_ob) |
906 | if (!pl->combat_ob) |
892 | { |
907 | { |
893 | LOG (llevError, "Could not find anything to attack on %s\n", &op->name); |
908 | LOG (llevError, "Could not find anything to attack on %s\n", &op->name); |
894 | return 0; |
909 | return 0; |
895 | } |
910 | } |
896 | } |
911 | } |
897 | |
912 | |
898 | if (!op->change_weapon (pl->combat_ob)) |
913 | if (!op->apply (pl->combat_ob)) |
899 | return 0; |
914 | return 0; |
900 | } |
915 | } |
901 | |
916 | |
902 | /* lose invisiblity/hiding status for running attacks */ |
917 | /* lose invisiblity/hiding status for running attacks */ |
903 | if (pl->tmp_invis) |
918 | if (pl->tmp_invis) |