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.71 by root, Wed Dec 31 18:07:41 2008 UTC vs.
Revision 1.76 by root, Mon Apr 27 01:38:49 2009 UTC

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
109 } 109 }
110 } 110 }
111} 111}
112 112
113static object * 113static object *
114find_skill (object *who, const shstr &name) 114find_skill (object *who, shstr_cmp name)
115{ 115{
116 if (who->chosen_skill 116 if (who->chosen_skill
117 && who->chosen_skill->skill == name 117 && who->chosen_skill->skill == name
118 && who->chosen_skill->type == SKILL) 118 && who->chosen_skill->type == SKILL)
119 return who->chosen_skill; 119 return who->chosen_skill;
123 return splay (tmp); 123 return splay (tmp);
124 124
125 return 0; 125 return 0;
126} 126}
127 127
128object *player::find_skill (const shstr &name) const 128object *player::find_skill (shstr_cmp name) const
129{ 129{
130 // might want to use last_skill_obj at one point, or maybe not 130 // might want to use last_skill_obj at one point, or maybe not
131 return ::find_skill (ob, name); 131 return ::find_skill (ob, name);
132}
133
134object *player::find_skill (const char *name) const
135{
136 return find_skill (shstr (name));
137} 132}
138 133
139/* This returns the skill pointer of the given name (the 134/* This returns the skill pointer of the given name (the
140 * one that accumulates exp, has the level, etc). 135 * one that accumulates exp, has the level, etc).
141 * 136 *
142 * It is presumed that the player will be needing to actually 137 * It is presumed that the player will be needing to actually
143 * use the skill, so thus if use of the skill requires a skill 138 * use the skill, so thus if use of the skill requires a skill
144 * tool, this code will equip it. 139 * tool, this code will equip it.
145 */ 140 */
146object * 141object *
147find_skill_by_name (object *who, shstr_tmp sh) 142find_skill_by_name (object *who, shstr_cmp sh)
148{ 143{
149 object *skill_tool = 0; 144 object *skill_tool = 0;
150 145
151 for (object *tmp = who->inv; tmp; tmp = tmp->below) 146 for (object *tmp = who->inv; tmp; tmp = tmp->below)
152 if (tmp->skill == sh) 147 if (tmp->skill == sh)
179 174
180 return splay (skill); 175 return splay (skill);
181} 176}
182 177
183object * 178object *
184find_skill_by_name (object *who, const char *name) 179find_skill_by_name_fuzzy (object *who, const char *name)
185{ 180{
186 if (!name) 181 if (!name)
187 return 0; 182 return 0;
188 183
189 for (object *tmp = who->inv; tmp; tmp = tmp->below) 184 for (object *tmp = who->inv; tmp; tmp = tmp->below)
265 */ 260 */
266int 261int
267do_skill (object *op, object *part, object *skill, int dir, const char *string) 262do_skill (object *op, object *part, object *skill, int dir, const char *string)
268{ 263{
269 int success = 0, exp = 0; 264 int success = 0, exp = 0;
270 int did_alc = 0;
271 265
272 if (!skill) 266 if (!skill)
273 return 0; 267 return 0;
274 268
275 /* 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
400 case SK_LITERACY: 394 case SK_LITERACY:
401 case SK_WOODSMAN: 395 case SK_WOODSMAN:
402 /* 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.
403 * failing that, we go and identify stuff. 397 * failing that, we go and identify stuff.
404 */ 398 */
399 {
400 bool found_cauldron = false;
401
405 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)
406 { 403 {
407 next = tmp->above; 404 next = tmp->above;
408 405
409 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 406 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
410 { 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
411 attempt_do_alchemy (op, tmp); 418 attempt_do_alchemy (op, tmp, skill);
412 419
413 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 420 if (QUERY_FLAG (tmp, FLAG_APPLIED))
414 esrv_send_inventory (op, tmp); 421 esrv_send_inventory (op, tmp);
415
416 did_alc = 1;
417 } 422 }
418 } 423 }
419 424
420 if (did_alc == 0) 425 if (!found_cauldron)
421 exp = success = skill_ident (op, skill); 426 exp = success = skill_ident (op, skill);
422 427 }
423 break; 428 break;
424 429
425 case SK_DET_MAGIC: 430 case SK_DET_MAGIC:
426 case SK_DET_CURSE: 431 case SK_DET_CURSE:
427 exp = success = skill_ident (op, skill); 432 exp = success = skill_ident (op, skill);
686 691
687 for (object *tmp = op->inv; tmp; tmp = tmp->below) 692 for (object *tmp = op->inv; tmp; tmp = tmp->below)
688 { 693 {
689 if (tmp->type == SKILL) 694 if (tmp->type == SKILL)
690 { 695 {
691 if (search && !strstr (tmp->name, search)) 696 if (search && !tmp->name.contains (search))
692 continue; 697 continue;
693 698
694 char buf[30]; 699 char buf[30];
695 700
696 /* Basically want to fill this out to 30 spaces with periods */ 701 /* Basically want to fill this out to 30 spaces with periods */
717 break; 722 break;
718 } 723 }
719 } 724 }
720 } 725 }
721 726
722 dynbuf_text msg (4096, 1024); 727 dynbuf_text &msg = msg_dynbuf; msg.clear ();
723 728
724 msg << "T<Player skills:>\n\n"; 729 msg << "T<Player skills:>\n\n";
725 if (num_skills_found > 1) 730 if (num_skills_found > 1)
726 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);
727 732

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines