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.6 by root, Tue Sep 12 17:23:01 2006 UTC vs.
Revision 1.12 by root, Tue Dec 12 21:39:57 2006 UTC

1
2/*
3 * static char *rcsid_c_range_c =
4 * "$Id: c_range.C,v 1.6 2006/09/12 17:23:01 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 22*/
29 23
30/* This file deals with range related commands (casting, shooting, 24/* This file deals with range related commands (casting, shooting,
31 * throwing, etc. 25 * throwing, etc.
32 */ 26 */
37#endif 31#endif
38#include <spells.h> 32#include <spells.h>
39#include <skills.h> 33#include <skills.h>
40#include <newclient.h> 34#include <newclient.h>
41#include <commands.h> 35#include <commands.h>
42
43 36
44int 37int
45command_invoke (object *op, char *params) 38command_invoke (object *op, char *params)
46{ 39{
47 return command_cast_spell (op, params, 'i'); 40 return command_cast_spell (op, params, 'i');
145 138
146 if (command == 'i') 139 if (command == 'i')
147 castnow = 1; 140 castnow = 1;
148 141
149 /* Remove control of the golem */ 142 /* Remove control of the golem */
150 if (op->contr->ranges[range_golem] != NULL) 143 if (op->contr->ranges[range_golem])
151 { 144 {
152 if (op->contr->golem_count == op->contr->ranges[range_golem]->count) 145 op->contr->ranges[range_golem]->destroy ();
153 {
154 remove_friendly_object (op->contr->ranges[range_golem]);
155 remove_ob (op->contr->ranges[range_golem]);
156 free_object (op->contr->ranges[range_golem]);
157 }
158
159 op->contr->ranges[range_golem] = NULL; 146 op->contr->ranges[range_golem] = 0;
160 op->contr->golem_count = 0;
161 } 147 }
162 148
163 if (params != NULL) 149 if (params != NULL)
164 { 150 {
165 int spellnumber = 0; 151 int spellnumber = 0;
166 152
167 if ((spellnumber = atoi (params))) 153 if ((spellnumber = atoi (params)))
168 for (spob = op->inv; spob && spob->count != (tag_t) spellnumber; spob = spob->below) 154 for (spob = op->inv; spob && spob->count != spellnumber; spob = spob->below)
169 /* nop */; 155 /* nop */;
170 else 156 else
171 spob = lookup_spell_by_name (op, params); 157 spob = lookup_spell_by_name (op, params);
172 158
173 if (spob && spob->type == SPELL) 159 if (spob && spob->type == SPELL)
207 cast_spell (op, op, op->facing, spob, cp); 193 cast_spell (op, op, op->facing, spob, cp);
208 else 194 else
209 { 195 {
210 op->contr->ranges[range_magic] = spob; 196 op->contr->ranges[range_magic] = spob;
211 op->contr->shoottype = range_magic; 197 op->contr->shoottype = range_magic;
212 198 assign (op->contr->spellparam, cp ? cp : "");
213 if (cp != NULL)
214 {
215 strncpy (op->contr->spellparam, cp, MAX_BUF);
216 op->contr->spellparam[MAX_BUF - 1] = '\0';
217 }
218 else
219 op->contr->spellparam[0] = '\0';
220
221 new_draw_info_format (NDI_UNIQUE, 0, op, "You ready the spell %s", &spob->name); 199 new_draw_info_format (NDI_UNIQUE, 0, op, "You ready the spell %s", &spob->name);
222 } 200 }
223 201
224 return 0; 202 return 0;
225 } /* else fall through to below and print spells */ 203 } /* else fall through to below and print spells */
248 226
249 switch (r) 227 switch (r)
250 { 228 {
251 case range_none: /* "Nothing" is always legal */ 229 case range_none: /* "Nothing" is always legal */
252 return 1; 230 return 1;
231
253 case range_bow: 232 case range_bow:
254 case range_misc: 233 case range_misc:
255 case range_magic: /* cast spells */ 234 case range_magic: /* cast spells */
256 if (op->contr->ranges[r]) 235 return !!op->contr->ranges[r];
257 return 1;
258 else
259 return 0;
260 236
261 case range_golem: /* Use scrolls */ 237 case range_golem: /* Use scrolls */
262 if (op->contr->ranges[range_golem] && op->contr->ranges[range_golem]->count == op->contr->golem_count) 238 return !!op->contr->ranges[range_golem];
263 return 1;
264 else
265 return 0;
266 239
267 case range_skill: 240 case range_skill:
268 if (op->chosen_skill) 241 return !!op->chosen_skill;
269 return 1;
270 else
271 return 0;
272 } 242 }
243
273 /* No match above, must not be valid */ 244 /* No match above, must not be valid */
274 return 0; 245 return 0;
275} 246}
276 247
277void 248void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines