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.46 by root, Sun May 13 15:13:57 2007 UTC vs.
Revision 1.47 by root, Sun May 13 19:56:57 2007 UTC

181 * this replaces find_skill. 181 * this replaces find_skill.
182 */ 182 */
183object * 183object *
184find_skill_by_number (object *who, int skillno) 184find_skill_by_number (object *who, int skillno)
185{ 185{
186 if (!IN_RANGE_EXC (skillno, 1, NUM_SKILLS))
187 return 0;
188
186 object *skill = NULL, *skill_tool = NULL, *tmp; 189 object *skill = NULL, *skill_tool = NULL;
187 190
188 if (skillno < 1 || skillno >= NUM_SKILLS)
189 return NULL;
190
191 for (tmp = who->inv; tmp != NULL; tmp = tmp->below) 191 for (object *tmp = who->inv; tmp; tmp = tmp->below)
192 { 192 {
193 if (tmp->type == SKILL && tmp->subtype == skillno) 193 if (tmp->type == SKILL && tmp->subtype == skillno)
194 skill = tmp; 194 skill = tmp;
195 195
196 /* Try to find appropriate skilltool. If the player has one already 196 /* Try to find appropriate skilltool. If the player has one already
202 skill_tool = tmp; 202 skill_tool = tmp;
203 else if (!skill_tool || !QUERY_FLAG (skill_tool, FLAG_APPLIED)) 203 else if (!skill_tool || !QUERY_FLAG (skill_tool, FLAG_APPLIED))
204 skill_tool = tmp; 204 skill_tool = tmp;
205 } 205 }
206 } 206 }
207
207 /* If this is a skill that can be used without a tool, return it */ 208 /* If this is a skill that can be used without a tool, return it */
208 if (skill && QUERY_FLAG (skill, FLAG_CAN_USE_SKILL)) 209 if (skill && QUERY_FLAG (skill, FLAG_CAN_USE_SKILL))
209 return skill; 210 return skill;
210 211
211 /* Player has a tool to use the skill. IF not applied, apply it - 212 /* Player has a tool to use the skill. If not applied, apply it -
212 * if not successful, return null. If they do have the skill tool 213 * if not successful, return null. If they do have the skill tool
213 * but not the skill itself, give it to them. 214 * but not the skill itself, give it to them.
214 */ 215 */
215 if (skill_tool) 216 if (skill_tool)
216 { 217 {
217 if (!QUERY_FLAG (skill_tool, FLAG_APPLIED)) 218 if (!QUERY_FLAG (skill_tool, FLAG_APPLIED))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines