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.83 by root, Fri Mar 26 20:17:48 2010 UTC vs.
Revision 1.92 by root, Sat Apr 10 04:54:10 2010 UTC

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
179object * 179object *
180find_skill_by_name_fuzzy (object *who, const char *name) 180find_skill_by_name_fuzzy (object *who, const char *name)
181{ 181{
182 if (!name) 182 if (name)
183 return 0;
184
185 for (object *tmp = who->inv; tmp; tmp = tmp->below) 183 for (object *tmp = who->inv; tmp; tmp = tmp->below)
186 if ((tmp->type == SKILL || tmp->type == SKILL_TOOL) 184 if ((tmp->type == SKILL || tmp->type == SKILL_TOOL)
187 && tmp->skill.starts_with (name)) 185 && tmp->skill.starts_with (name))
188 if (object *skop = find_skill_by_name (who, tmp->skill)) 186 if (object *skop = find_skill_by_name (who, tmp->skill))
189 return skop; 187 return skop;
190 188
191 return 0; 189 return 0;
192} 190}
193 191
194/* This returns the skill pointer of the given name (the 192/* This returns the skill pointer of the given name (the
408 { 406 {
409 found_cauldron = true; 407 found_cauldron = true;
410 408
411 if (tmp->skill != skill->skill) 409 if (tmp->skill != skill->skill)
412 { 410 {
413 op->failmsg (format ("You can't use the %s with the %s skill!", 411 op->failmsgf ("You can't use the %s with the %s skill!",
414 query_name (tmp), 412 query_name (tmp),
415 query_name (skill))); 413 query_name (skill));
416 break; 414 break;
417 } 415 }
418 416
419 attempt_do_alchemy (op, tmp, skill); 417 attempt_do_alchemy (op, tmp, skill);
420 418
462 case SK_EVOCATION: 460 case SK_EVOCATION:
463 case SK_PYROMANCY: 461 case SK_PYROMANCY:
464 case SK_SUMMONING: 462 case SK_SUMMONING:
465 case SK_CLIMBING: 463 case SK_CLIMBING:
466 new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect."); 464 new_draw_info (NDI_UNIQUE, 0, op, "This skill is already in effect.");
465 break;
466
467 case SK_MINING:
468 success = skill_mining (op, part, skill, dir, string);
469 break;
470
471 case SK_FISHING:
472 success = skill_fishing (op, part, skill, dir, string);
467 break; 473 break;
468 474
469 default: 475 default:
470 LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp); 476 LOG (llevDebug, "%s attempted to use unknown skill: %d\n", query_name (op), op->chosen_skill->stats.sp);
471 break; 477 break;
760 766
761 if (!string) 767 if (!string)
762 return 0; 768 return 0;
763 769
764 for (skop = op->inv; skop; skop = skop->below) 770 for (skop = op->inv; skop; skop = skop->below)
765 { 771 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)))) 772 && !strncmp (string, skop->skill, min (strlen (string), strlen (skop->skill))))
773 {
774 skop = find_skill_by_name (op, skop->skill);
769 break; 775 break;
770 else if (skop->type == SKILL_TOOL
771 && !strncasecmp (string, skop->skill, min (strlen (string), (size_t) strlen (skop->skill))))
772 break;
773 } 776 }
774 777
775 if (!skop) 778 if (!skop)
776 { 779 {
777 new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find skill %s", string); 780 op->failmsgf ("Unable to find skill %s.", string);
781 return 0;
782 }
783
784 if (!(skill_flags [skop->subtype] & SF_USE))
785 {
786 op->failmsgf (
787 "You feel as if you wanted to do something funny, but you can't remember what. "
788 "H<The %s skill cannot be C<use_skill>'ed - maybe you need to C<ready_skill> it, "
789 "use it with some item, or it's always active.>",
790 &skop->skill
791 );
778 return 0; 792 return 0;
779 } 793 }
780 794
781 len = strlen (skop->skill); 795 len = strlen (skop->skill);
782 796
847 * through that code if skill is set to change to the skill. 861 * through that code if skill is set to change to the skill.
848 */ 862 */
849 if (player *pl = op->contr) 863 if (player *pl = op->contr)
850 { 864 {
851 if (skill) 865 if (skill)
852 op->change_skill (skill); 866 {
867 if (!op->apply (skill))
868 return 0;
869 }
853 else 870 else
854 { 871 {
855 if (!pl->combat_ob) 872 if (!pl->combat_ob)
856 { 873 {
857 if (QUERY_FLAG (op, FLAG_READY_WEAPON)) 874 if (QUERY_FLAG (op, FLAG_READY_WEAPON))
879 896
880 if (!skill) 897 if (!skill)
881 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); 898 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!");
882 } 899 }
883 900
884 if (skill) 901 op->apply (skill);
885 {
886 op->change_skill (0);
887 apply_special (op, skill, AP_APPLY);
888 }
889 } 902 }
890 903
891 if (!pl->combat_ob) 904 if (!pl->combat_ob)
892 { 905 {
893 LOG (llevError, "Could not find anything to attack on %s\n", &op->name); 906 LOG (llevError, "Could not find anything to attack on %s\n", &op->name);
894 return 0; 907 return 0;
895 } 908 }
896 } 909 }
897 910
898 if (!op->change_weapon (pl->combat_ob)) 911 if (!op->apply (pl->combat_ob))
899 return 0; 912 return 0;
900 } 913 }
901 914
902 /* lose invisiblity/hiding status for running attacks */ 915 /* lose invisiblity/hiding status for running attacks */
903 if (pl->tmp_invis) 916 if (pl->tmp_invis)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines