ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_range.C
(Generate patch)

Comparing deliantra/server/server/c_range.C (file contents):
Revision 1.19 by root, Sun Apr 29 21:44:35 2007 UTC vs.
Revision 1.25 by root, Sat May 12 16:06:42 2007 UTC

137 137
138 if (command == 'i') 138 if (command == 'i')
139 castnow = 1; 139 castnow = 1;
140 140
141 /* Remove control of the golem */ 141 /* Remove control of the golem */
142 if (object *golem = op->contr->ranges[range_golem]) 142 if (object *golem = op->contr->golem)
143 golem->destroy (); 143 golem->destroy ();
144 144
145 if (params) 145 if (params)
146 { 146 {
147 int spellnumber = 0; 147 int spellnumber = 0;
166 cp++; 166 cp++;
167 if (!strncmp (cp, "of ", 3)) 167 if (!strncmp (cp, "of ", 3))
168 cp += 3; 168 cp += 3;
169 } 169 }
170 } 170 }
171 else if (strlen (params) > (size_t) strlen (spob->name)) 171 else if (strlen (params) > strlen (spob->name))
172 { 172 {
173 cp = params + strlen (spob->name); 173 cp = params + strlen (spob->name);
174 *cp = 0; 174 *cp = 0;
175 cp++; 175 cp++;
176 if (!strncmp (cp, "of ", 3)) 176 if (!strncmp (cp, "of ", 3))
177 cp += 3; 177 cp += 3;
178 } 178 }
179 else 179 else
180 cp = NULL; 180 cp = NULL;
181 181
182 if (!spob->skill)
183 {
184 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is a weird spell, please report it to the dungeon master!", &spob->name);
185 LOG (llevError, "spell without skill found: %s", spob->debug_desc ());
186 return 1;
187 }
188
182 if (spob->skill && !find_skill_by_name (op, spob->skill)) 189 object *skill = find_skill_by_name (op, spob->skill);
190
191 if (!skill)
183 { 192 {
184 new_draw_info_format (NDI_UNIQUE, 0, op, "You need the skill %s to cast %s!", &spob->skill, &spob->name); 193 new_draw_info_format (NDI_UNIQUE, 0, op, "You need the skill %s to cast %s!", &spob->skill, &spob->name);
185 return 1; 194 return 1;
186 } 195 }
187 196
188 if (castnow) 197 if (castnow)
189 cast_spell (op, op, op->facing, spob, cp); 198 cast_spell (op, op, op->facing, spob, cp);
190 else 199 else
191 { 200 {
192 op->contr->ranges[range_magic] = spob; 201 op->contr->ranged_ob = spob;
193 op->contr->shoottype = range_magic; 202
194 assign (op->contr->spellparam, cp ? cp : ""); 203 assign (op->contr->spellparam, cp ? cp : "");
195 new_draw_info_format (NDI_UNIQUE, 0, op, "You ready the spell %s", &spob->name); 204 new_draw_info_format (NDI_UNIQUE, 0, op, "You ready the spell %s", &spob->name);
196 } 205 }
197 206
198 return 0; 207 return 0;
200 } /* params supplied */ 209 } /* params supplied */
201 210
202 /* We get here if cast was given without options or we could not find 211 /* We get here if cast was given without options or we could not find
203 * the requested spell. List all the spells the player knows. 212 * the requested spell. List all the spells the player knows.
204 */ 213 */
205 new_draw_info (NDI_UNIQUE, 0, op, "Cast what spell? Choose one of:"); 214 new_draw_info (NDI_UNIQUE, 0, op, "Cast what spell? Choose one of:");
206 show_matching_spells (op, params); 215 show_matching_spells (op, params);
216
207 return 1; 217 return 1;
208} 218}
209 219
210/**************************************************************************/ 220/**************************************************************************/
211 221
212void 222void
213change_spell (object *op, char k) 223change_spell (object *op, char k)
214{ 224{
215 int r = op->contr->shoottype; 225 if (op->contr->combat_ob == op->current_weapon)
216
217 do
218 r = (r + ((k == '+') ? 1 : -1) + range_size) % range_size;
219 while (!op->contr->legal_range ((rangetype) r));
220
221 op->contr->set_range ((rangetype) r);
222
223 /* Legal range has already checked that we have an appropriate item
224 * that uses the slot, so we don't need to be too careful about
225 * checking the status of the object.
226 */
227 switch (op->contr->shoottype)
228 {
229 case range_none:
230 new_draw_info (NDI_UNIQUE, 0, op, "No ranged attack chosen.");
231 break;
232
233 case range_golem:
234 new_draw_info (NDI_UNIQUE, 0, op, "You regain control of your golem.");
235 break;
236
237 case range_bow:
238 new_draw_info_format (NDI_UNIQUE, 0, op, "Switched to %s and %s.", query_name (op->contr->ranges[range_bow]),
239 op->contr->ranges[range_bow]->race ? &op->contr->ranges[range_bow]->race : "nothing");
240 break;
241
242 case range_magic:
243 new_draw_info_format (NDI_UNIQUE, 0, op, "Switched to spells (%s).", &op->contr->ranges[range_magic]->name);
244 break;
245
246 case range_misc:
247 new_draw_info_format (NDI_UNIQUE, 0, op, "Switched to %s.", query_base_name (op->contr->ranges[range_misc], 0));
248 break;
249
250 case range_skill:
251 new_draw_info_format (NDI_UNIQUE, 0, op, "Switched to skill: %s", &op->chosen_skill->name);
252 break;
253 } 226 {
227 if (op->contr->ranged_ob)
228 op->change_weapon (op->contr->ranged_ob);
229 }
230 else if (op->contr->ranged_ob == op->current_weapon)
231 {
232 if (op->contr->combat_ob)
233 op->change_weapon (op->contr->combat_ob);
234 }
235
236 //TODO: maybe switch to golem, if any?
254} 237}
255 238
256int 239int
257command_rotateshoottype (object *op, char *params) 240command_rotateshoottype (object *op, char *params)
258{ 241{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines