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,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
166 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is a weird spell, please report it to the dungeon master!", &spob->name); |
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 ()); |
167 | LOG (llevError, "spell without skill found: %s", spob->debug_desc ()); |
168 | return 1; |
168 | return 1; |
169 | } |
169 | } |
170 | |
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) |
171 | if (castnow) |
182 | cast_spell (op, op, op->facing, spob, cp); |
172 | cast_spell (op, op, op->facing, spob, cp); |
183 | else |
173 | 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 | { |
174 | { |
195 | op->change_weapon (op->contr->ranged_ob = spob); |
175 | splay (spob); |
196 | |
|
|
197 | assign (op->contr->spellparam, cp ? cp : ""); |
176 | assign (op->contr->spellparam, cp ? cp : ""); |
198 | op->statusmsg (format ("You ready the spell %s", &spob->name)); |
|
|
199 | } |
|
|
200 | } |
177 | } |
201 | |
178 | |
202 | return 0; |
179 | return 0; |
203 | } /* else fall through to below and print spells */ |
180 | } /* else fall through to below and print spells */ |
204 | } /* params supplied */ |
181 | } /* params supplied */ |
… | |
… | |
233 | /**************************************************************************/ |
210 | /**************************************************************************/ |
234 | |
211 | |
235 | static void |
212 | static void |
236 | change_spell (object *op, char k) |
213 | change_spell (object *op, char k) |
237 | { |
214 | { |
238 | if (op->contr->combat_ob == op->current_weapon) |
215 | if (op->contr->combat_ob && op->contr->ranged_ob) |
239 | { |
216 | op->change_weapon ( |
|
|
217 | op->current_weapon == op->contr->combat_ob |
240 | if (op->contr->ranged_ob) |
218 | ? 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) |
219 | : op->contr->combat_ob |
246 | op->change_weapon (op->contr->combat_ob); |
220 | ); |
247 | } |
|
|
248 | |
221 | |
249 | //TODO: maybe switch to golem, if any? |
222 | //TODO: maybe switch to golem, if any? |
250 | } |
223 | } |
251 | |
224 | |
252 | int |
225 | int |