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 |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
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. */ |
… | |
… | |
58 | /* init_skills basically just sets up the skill_names table |
59 | /* init_skills basically just sets up the skill_names table |
59 | * above. The index into the array is set up by the |
60 | * above. The index into the array is set up by the |
60 | * subtypes. |
61 | * subtypes. |
61 | */ |
62 | */ |
62 | void |
63 | void |
63 | init_skills (void) |
64 | init_skills () |
64 | { |
65 | { |
65 | for_all_archetypes (at) |
66 | for_all_archetypes (at) |
66 | if (at->type == SKILL) |
67 | if (at->type == SKILL) |
67 | { |
68 | { |
68 | if (skill_names[at->subtype]) |
69 | if (skill_names[at->subtype]) |
… | |
… | |
167 | |
168 | |
168 | if (!skill) |
169 | if (!skill) |
169 | skill = give_skill_by_name (who, skill_tool->skill); |
170 | skill = give_skill_by_name (who, skill_tool->skill); |
170 | |
171 | |
171 | if (!skill_tool->flag [FLAG_APPLIED]) |
172 | if (!skill_tool->flag [FLAG_APPLIED]) |
172 | if (apply_special (who, splay (skill_tool), AP_APPLY | AP_NO_READY)) |
173 | if (apply_special (who, splay (skill_tool), AP_APPLY)) |
173 | return 0; |
174 | return 0; |
174 | |
175 | |
175 | return splay (skill); |
176 | return splay (skill); |
176 | } |
177 | } |
177 | |
178 | |
… | |
… | |
715 | * it so it doesn't crash the server - otherwise, one character may |
716 | * it so it doesn't crash the server - otherwise, one character may |
716 | * crash the server numerous times. |
717 | * crash the server numerous times. |
717 | */ |
718 | */ |
718 | if (num_skills_found >= NUM_SKILLS) |
719 | if (num_skills_found >= NUM_SKILLS) |
719 | { |
720 | { |
720 | new_draw_info (NDI_RED, 0, op, "Your character has too many skills."); |
721 | new_draw_info (NDI_RED | NDI_REPLY, 0, op, "Your character has too many skills."); |
721 | new_draw_info (NDI_RED, 0, op, "Something isn't right - contact the server admin"); |
722 | new_draw_info (NDI_RED | NDI_REPLY, 0, op, "Something isn't right - contact the server admin"); |
722 | break; |
723 | break; |
723 | } |
724 | } |
724 | } |
725 | } |
725 | } |
726 | } |
726 | |
727 | |
… | |
… | |
762 | |
763 | |
763 | for (skop = op->inv; skop; skop = skop->below) |
764 | for (skop = op->inv; skop; skop = skop->below) |
764 | { |
765 | { |
765 | if (skop->type == SKILL |
766 | if (skop->type == SKILL |
766 | && QUERY_FLAG (skop, FLAG_CAN_USE_SKILL) |
767 | && QUERY_FLAG (skop, FLAG_CAN_USE_SKILL) |
767 | && !strncasecmp (string, skop->skill, MIN (strlen (string), (size_t) strlen (skop->skill)))) |
768 | && !strncasecmp (string, skop->skill, min (strlen (string), (size_t) strlen (skop->skill)))) |
768 | break; |
769 | break; |
769 | else if (skop->type == SKILL_TOOL |
770 | else if (skop->type == SKILL_TOOL |
770 | && !strncasecmp (string, skop->skill, MIN (strlen (string), (size_t) strlen (skop->skill)))) |
771 | && !strncasecmp (string, skop->skill, min (strlen (string), (size_t) strlen (skop->skill)))) |
771 | break; |
772 | break; |
772 | } |
773 | } |
773 | |
774 | |
774 | if (!skop) |
775 | if (!skop) |
775 | { |
776 | { |
… | |
… | |
807 | } |
808 | } |
808 | |
809 | |
809 | static bool |
810 | static bool |
810 | hth_skill_p (object *skill) |
811 | hth_skill_p (object *skill) |
811 | { |
812 | { |
812 | return (skill_flags [skill->subtype] & (SF_COMBAT | SF_NEED_WEAPON)) == SF_COMBAT; |
813 | return (skill_flags [skill->subtype] & (SF_COMBAT | SF_NEED_ITEM)) == SF_COMBAT; |
813 | } |
814 | } |
814 | |
815 | |
815 | /* This finds the first unarmed skill the player has, and returns it. |
816 | /* This finds the first unarmed skill the player has, and returns it. |
816 | */ |
817 | */ |
817 | static object * |
818 | static object * |
… | |
… | |
892 | LOG (llevError, "Could not find anything to attack on %s\n", &op->name); |
893 | LOG (llevError, "Could not find anything to attack on %s\n", &op->name); |
893 | return 0; |
894 | return 0; |
894 | } |
895 | } |
895 | } |
896 | } |
896 | |
897 | |
897 | if (!op->change_weapon (pl->combat_ob)) |
898 | if (!op->apply (pl->combat_ob)) |
898 | return 0; |
899 | return 0; |
899 | } |
900 | } |
900 | |
901 | |
901 | /* lose invisiblity/hiding status for running attacks */ |
902 | /* lose invisiblity/hiding status for running attacks */ |
902 | if (pl->tmp_invis) |
903 | if (pl->tmp_invis) |