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.44 by root, Fri Apr 2 03:41:24 2010 UTC vs.
Revision 1.52 by root, Wed Nov 21 12:12:03 2012 UTC

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,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 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
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25/* This file deals with range related commands (casting, shooting, 25/* This file deals with range related commands (casting, shooting,
26 * throwing, etc. 26 * throwing, etc.
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 */
104 } 103 }
105 } 104 }
106} 105}
107 106
108/* sets up to cast a spell. op is the caster, params is the spell name, 107/* sets up to cast a spell. op is the caster, params is the spell name,
109 * and command is the first letter of the spell type (c=cast, i=invoke, 108 * and command is the first letter of the spell type (c=cast, i=invoke,
110 * p=prepare). Invoke casts a spell immediately, where as cast (and I believe 109 * p=prepare). Invoke casts a spell immediately, where as cast (and I believe
111 * prepare) just set up the range type. 110 * prepare) just set up the range type.
112 */ 111 */
113static int 112static int
114command_cast_spell (object *op, char *params, char command) 113command_cast_spell (object *op, char *params, char command)
130 129
131 if ((spellnumber = atoi (params))) 130 if ((spellnumber = atoi (params)))
132 for (spob = op->inv; spob && spob->count != spellnumber; spob = spob->below) 131 for (spob = op->inv; spob && spob->count != spellnumber; spob = spob->below)
133 /* nop */; 132 /* nop */;
134 else 133 else
135 spob = lookup_spell_by_name (op, params); 134 spob = op->find_spell (params);
136 135
137 if (spob && spob->type == SPELL) 136 if (spob && spob->type == SPELL)
138 { 137 {
139 /* Now grab any extra data, if there is any. Forward pass 138 /* Now grab any extra data, if there is any. Forward pass
140 * any 'of' delimiter 139 * any 'of' delimiter
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 if (castnow) 163 if (castnow)
172 cast_spell (op, op, op->facing, spob, cp); 164 cast_spell (op, op, op->facing, spob, cp);
173 else if (op->apply (spob)) 165 else if (op->apply (spob))
174 { 166 {
175 splay (spob); 167 splay (spob);
207 return command_cast_spell (op, params, 'p'); 199 return command_cast_spell (op, params, 'p');
208} 200}
209 201
210/**************************************************************************/ 202/**************************************************************************/
211 203
212static void 204int
213change_spell (object *op, char k) 205command_rotateshoottype (object *op, char *params)
214{ 206{
215 if (op->contr->combat_ob && op->contr->ranged_ob) 207 if (op->contr->combat_ob && op->contr->ranged_ob)
216 op->change_weapon ( 208 op->apply (
217 op->current_weapon == op->contr->combat_ob 209 op->current_weapon == op->contr->combat_ob
218 ? op->contr->ranged_ob 210 ? op->contr->ranged_ob
219 : op->contr->combat_ob 211 : op->contr->combat_ob
220 ); 212 );
221 213
222 //TODO: maybe switch to golem, if any? 214 //TODO: maybe switch to golem, if any?
223}
224
225int
226command_rotateshoottype (object *op, char *params)
227{
228 if (!params)
229 change_spell (op, '+');
230 else
231 change_spell (op, params[0]);
232 215
233 return 0; 216 return 0;
234} 217}
218

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines