… | |
… | |
28 | |
28 | |
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <sproto.h> |
30 | #include <sproto.h> |
31 | #include <spells.h> |
31 | #include <spells.h> |
32 | #include <skills.h> |
32 | #include <skills.h> |
33 | #include <commands.h> |
|
|
34 | |
33 | |
35 | /* Shows all spells that op knows. If params is supplied, the must match |
34 | /* Shows all spells that op knows. If params is supplied, the must match |
36 | * that. Given there is more than one skill, we can't supply break |
35 | * that. Given there is more than one skill, we can't supply break |
37 | * them down to cleric/wizardry. |
36 | * them down to cleric/wizardry. |
38 | */ |
37 | */ |
… | |
… | |
159 | cp += 3; |
158 | cp += 3; |
160 | } |
159 | } |
161 | else |
160 | else |
162 | cp = NULL; |
161 | cp = NULL; |
163 | |
162 | |
164 | if (!spob->skill) |
|
|
165 | { |
|
|
166 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is a weird spell, please report it to the dungeon master!", &spob->name); |
|
|
167 | LOG (llevError, "spell without skill found: %s", spob->debug_desc ()); |
|
|
168 | return 1; |
|
|
169 | } |
|
|
170 | |
|
|
171 | object *skill = find_skill_by_name (op, spob->skill); |
|
|
172 | |
|
|
173 | if (!skill) |
|
|
174 | { |
|
|
175 | op->failmsg (format ("You need the skill %s to cast %s!", &spob->skill, &spob->name)); |
|
|
176 | return 1; |
|
|
177 | } |
|
|
178 | |
|
|
179 | splay (spob); |
|
|
180 | |
|
|
181 | if (castnow) |
163 | if (castnow) |
182 | cast_spell (op, op, op->facing, spob, cp); |
164 | cast_spell (op, op, op->facing, spob, cp); |
183 | else |
165 | else if (op->apply (spob)) |
184 | { |
|
|
185 | if (op->contr->ranged_ob) |
|
|
186 | if (op->contr->ranged_ob->flag [FLAG_APPLIED]) |
|
|
187 | apply_special (op, op->contr->ranged_ob, AP_UNAPPLY); |
|
|
188 | else |
|
|
189 | op->contr->ranged_ob = 0; |
|
|
190 | |
|
|
191 | if (op->contr->ranged_ob) |
|
|
192 | op->failmsg (format ("You have to unapply the %s first to ready a spell.", &op->contr->ranged_ob->name)); |
|
|
193 | else |
|
|
194 | { |
166 | { |
195 | op->change_weapon (op->contr->ranged_ob = spob); |
167 | splay (spob); |
196 | |
|
|
197 | assign (op->contr->spellparam, cp ? cp : ""); |
168 | assign (op->contr->spellparam, cp ? cp : ""); |
198 | op->statusmsg (format ("You ready the spell %s", &spob->name)); |
|
|
199 | } |
|
|
200 | } |
169 | } |
201 | |
170 | |
202 | return 0; |
171 | return 0; |
203 | } /* else fall through to below and print spells */ |
172 | } /* else fall through to below and print spells */ |
204 | } /* params supplied */ |
173 | } /* params supplied */ |
… | |
… | |
230 | return command_cast_spell (op, params, 'p'); |
199 | return command_cast_spell (op, params, 'p'); |
231 | } |
200 | } |
232 | |
201 | |
233 | /**************************************************************************/ |
202 | /**************************************************************************/ |
234 | |
203 | |
235 | static void |
204 | int |
236 | change_spell (object *op, char k) |
205 | command_rotateshoottype (object *op, char *params) |
237 | { |
206 | { |
238 | if (op->contr->combat_ob == op->current_weapon) |
207 | if (op->contr->combat_ob && op->contr->ranged_ob) |
239 | { |
208 | op->apply ( |
|
|
209 | op->current_weapon == op->contr->combat_ob |
240 | if (op->contr->ranged_ob) |
210 | ? op->contr->ranged_ob |
241 | op->change_weapon (op->contr->ranged_ob); |
|
|
242 | } |
|
|
243 | else if (op->contr->ranged_ob == op->current_weapon) |
|
|
244 | { |
|
|
245 | if (op->contr->combat_ob) |
211 | : op->contr->combat_ob |
246 | op->change_weapon (op->contr->combat_ob); |
212 | ); |
247 | } |
|
|
248 | |
213 | |
249 | //TODO: maybe switch to golem, if any? |
214 | //TODO: maybe switch to golem, if any? |
250 | } |
|
|
251 | |
|
|
252 | int |
|
|
253 | command_rotateshoottype (object *op, char *params) |
|
|
254 | { |
|
|
255 | if (!params) |
|
|
256 | change_spell (op, '+'); |
|
|
257 | else |
|
|
258 | change_spell (op, params[0]); |
|
|
259 | |
215 | |
260 | return 0; |
216 | return 0; |
261 | } |
217 | } |
|
|
218 | |