… | |
… | |
109 | } |
109 | } |
110 | } |
110 | } |
111 | } |
111 | } |
112 | |
112 | |
113 | static object * |
113 | static object * |
114 | find_skill (object *who, const shstr &sh) |
114 | find_skill (object *who, shstr_cmp name) |
115 | { |
115 | { |
|
|
116 | if (who->chosen_skill |
|
|
117 | && who->chosen_skill->skill == name |
|
|
118 | && who->chosen_skill->type == SKILL) |
|
|
119 | return who->chosen_skill; |
|
|
120 | |
116 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
121 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
117 | if (tmp->skill == sh && tmp->type == SKILL) |
122 | if (tmp->skill == name && tmp->type == SKILL) |
118 | return tmp; |
123 | return splay (tmp); |
119 | |
124 | |
120 | return 0; |
125 | return 0; |
|
|
126 | } |
|
|
127 | |
|
|
128 | object *player::find_skill (shstr_cmp name) const |
|
|
129 | { |
|
|
130 | // might want to use last_skill_obj at one point, or maybe not |
|
|
131 | return ::find_skill (ob, name); |
121 | } |
132 | } |
122 | |
133 | |
123 | /* This returns the skill pointer of the given name (the |
134 | /* This returns the skill pointer of the given name (the |
124 | * one that accumulates exp, has the level, etc). |
135 | * one that accumulates exp, has the level, etc). |
125 | * |
136 | * |
126 | * It is presumed that the player will be needing to actually |
137 | * It is presumed that the player will be needing to actually |
127 | * 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 |
128 | * tool, this code will equip it. |
139 | * tool, this code will equip it. |
129 | */ |
140 | */ |
130 | object * |
141 | object * |
131 | find_skill_by_name (object *who, const shstr &sh) |
142 | find_skill_by_name (object *who, shstr_cmp sh) |
132 | { |
143 | { |
133 | object *skill_tool = 0; |
144 | object *skill_tool = 0; |
134 | |
145 | |
135 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
146 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
136 | if (tmp->skill == sh) |
147 | if (tmp->skill == sh) |
… | |
… | |
163 | |
174 | |
164 | return splay (skill); |
175 | return splay (skill); |
165 | } |
176 | } |
166 | |
177 | |
167 | object * |
178 | object * |
168 | find_skill_by_name (object *who, const char *name) |
179 | find_skill_by_name_fuzzy (object *who, const char *name) |
169 | { |
180 | { |
170 | if (!name) |
181 | if (!name) |
171 | return 0; |
182 | return 0; |
172 | |
183 | |
173 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
184 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
174 | if ((tmp->type == SKILL || tmp->type == SKILL_TOOL) |
185 | if ((tmp->type == SKILL || tmp->type == SKILL_TOOL) |
175 | && tmp->skill.begins_with (name)) |
186 | && tmp->skill.starts_with (name)) |
176 | if (object *skop = find_skill_by_name (who, tmp->skill)) |
187 | if (object *skop = find_skill_by_name (who, tmp->skill)) |
177 | return skop; |
188 | return skop; |
178 | |
189 | |
179 | return 0; |
190 | return 0; |
180 | } |
191 | } |
… | |
… | |
670 | |
681 | |
671 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
682 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
672 | { |
683 | { |
673 | if (tmp->type == SKILL) |
684 | if (tmp->type == SKILL) |
674 | { |
685 | { |
675 | if (search && !strstr (tmp->name, search)) |
686 | if (search && !tmp->name.contains (search)) |
676 | continue; |
687 | continue; |
677 | |
688 | |
678 | char buf[30]; |
689 | char buf[30]; |
679 | |
690 | |
680 | /* Basically want to fill this out to 30 spaces with periods */ |
691 | /* Basically want to fill this out to 30 spaces with periods */ |
… | |
… | |
880 | /* lose invisiblity/hiding status for running attacks */ |
891 | /* lose invisiblity/hiding status for running attacks */ |
881 | if (pl->tmp_invis) |
892 | if (pl->tmp_invis) |
882 | { |
893 | { |
883 | pl->tmp_invis = 0; |
894 | pl->tmp_invis = 0; |
884 | op->invisible = 0; |
895 | op->invisible = 0; |
885 | op->hide = 0; |
896 | op->flag [FLAG_HIDDEN] = 0; |
886 | update_object (op, UP_OBJ_CHANGE); |
897 | update_object (op, UP_OBJ_CHANGE); |
887 | } |
898 | } |
888 | } |
899 | } |
889 | |
900 | |
890 | int success = attack_ob (tmp, op); |
901 | int success = attack_ob (tmp, op); |