1 |
elmex |
1.1 |
/* |
2 |
root |
1.65 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
pippijn |
1.36 |
* |
4 |
root |
1.68 |
* Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
root |
1.59 |
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 |
|
|
* Copyright (©) 1992,2007 Frank Tore Johansen |
7 |
pippijn |
1.36 |
* |
8 |
root |
1.65 |
* Deliantra is free software: you can redistribute it and/or modify |
9 |
root |
1.62 |
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
pippijn |
1.36 |
* |
13 |
root |
1.62 |
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
pippijn |
1.36 |
* |
18 |
root |
1.62 |
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 |
root |
1.59 |
* |
21 |
root |
1.65 |
* The authors can be reached via e-mail to <support@deliantra.net> |
22 |
pippijn |
1.36 |
*/ |
23 |
elmex |
1.1 |
|
24 |
|
|
#include <global.h> |
25 |
|
|
#include <loader.h> |
26 |
root |
1.21 |
#include <sproto.h> |
27 |
|
|
|
28 |
pippijn |
1.55 |
/* Handles misc. input request - things like hash table, malloc, maps, etc */ |
29 |
elmex |
1.1 |
|
30 |
root |
1.7 |
int |
31 |
|
|
command_motd (object *op, char *params) |
32 |
elmex |
1.1 |
{ |
33 |
root |
1.7 |
display_motd (op); |
34 |
|
|
return 1; |
35 |
elmex |
1.1 |
} |
36 |
|
|
|
37 |
|
|
typedef struct |
38 |
root |
1.7 |
{ |
39 |
|
|
char namebuf[MAX_BUF]; |
40 |
|
|
int login_order; |
41 |
|
|
} chars_names; |
42 |
elmex |
1.1 |
|
43 |
root |
1.7 |
int |
44 |
|
|
command_time (object *op, char *params) |
45 |
elmex |
1.1 |
{ |
46 |
root |
1.2 |
print_tod (op); |
47 |
|
|
return 1; |
48 |
|
|
} |
49 |
elmex |
1.1 |
|
50 |
root |
1.7 |
int |
51 |
|
|
command_debug (object *op, char *params) |
52 |
elmex |
1.1 |
{ |
53 |
root |
1.7 |
int i; |
54 |
|
|
char buf[MAX_BUF]; |
55 |
|
|
|
56 |
|
|
if (params == NULL || !sscanf (params, "%d", &i)) |
57 |
|
|
{ |
58 |
|
|
sprintf (buf, "Global debug level is %d.", settings.debug); |
59 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 |
elmex |
1.1 |
return 1; |
61 |
|
|
} |
62 |
root |
1.58 |
|
63 |
|
|
settings.debug = i; |
64 |
|
|
|
65 |
root |
1.7 |
sprintf (buf, "Set debug level to %d.", i); |
66 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
67 |
|
|
return 1; |
68 |
|
|
} |
69 |
elmex |
1.1 |
|
70 |
|
|
|
71 |
|
|
/* |
72 |
|
|
* Those dumps should be just one dump with good parser |
73 |
|
|
*/ |
74 |
|
|
|
75 |
root |
1.7 |
int |
76 |
|
|
command_dumpbelow (object *op, char *params) |
77 |
elmex |
1.1 |
{ |
78 |
root |
1.7 |
if (op && op->below) |
79 |
|
|
{ |
80 |
root |
1.14 |
char *dump = dump_object (op->below); |
81 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, dump); |
82 |
|
|
free (dump); |
83 |
elmex |
1.1 |
/* Let's push that item on the dm's stack */ |
84 |
root |
1.7 |
dm_stack_push (op->contr, op->below->count); |
85 |
|
|
} |
86 |
elmex |
1.1 |
return 0; |
87 |
|
|
} |
88 |
|
|
|
89 |
root |
1.7 |
int |
90 |
|
|
command_version (object *op, char *params) |
91 |
elmex |
1.1 |
{ |
92 |
root |
1.7 |
version (op); |
93 |
|
|
return 0; |
94 |
elmex |
1.1 |
} |
95 |
|
|
|
96 |
|
|
/* Prints out some useful information for the character. Everything we print |
97 |
|
|
* out can be determined by the docs, so we aren't revealing anything extra - |
98 |
|
|
* rather, we are making it convenient to find the values. params have |
99 |
|
|
* no meaning here. |
100 |
|
|
*/ |
101 |
root |
1.7 |
int |
102 |
|
|
command_statistics (object *pl, char *params) |
103 |
elmex |
1.1 |
{ |
104 |
root |
1.7 |
if (!pl->contr) |
105 |
|
|
return 1; |
106 |
root |
1.73 |
|
107 |
|
|
dynbuf_text msg (2048, 1024); |
108 |
|
|
|
109 |
|
|
msg << " Experience: " << pl->stats.exp << '\n' |
110 |
|
|
<< " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
111 |
|
|
<< "\n Stat Nat/Real/Max\n"; |
112 |
|
|
|
113 |
|
|
for (int i = 0; i < NUM_STATS; ++i) |
114 |
|
|
msg.printf (" %s %2d/ %3d/%3d\n", short_stat_name [i], pl->contr->orig_stats.stat (i), pl->stats.stat (i), 20 + pl->arch->stats.stat (i)); |
115 |
|
|
|
116 |
|
|
msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
117 |
|
|
|
118 |
|
|
pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
119 |
elmex |
1.1 |
|
120 |
root |
1.7 |
/* Can't think of anything else to print right now */ |
121 |
|
|
return 0; |
122 |
elmex |
1.1 |
} |
123 |
|
|
|
124 |
root |
1.7 |
int |
125 |
|
|
command_fix_me (object *op, char *params) |
126 |
elmex |
1.1 |
{ |
127 |
root |
1.67 |
op->update_weight (); |
128 |
root |
1.27 |
op->update_stats (); |
129 |
pippijn |
1.51 |
new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
130 |
|
|
|
131 |
root |
1.7 |
return 1; |
132 |
elmex |
1.1 |
} |
133 |
|
|
|
134 |
root |
1.7 |
int |
135 |
|
|
command_bowmode (object *op, char *params) |
136 |
elmex |
1.1 |
{ |
137 |
root |
1.7 |
bowtype_t oldtype = op->contr->bowtype; |
138 |
root |
1.73 |
static const char *const types[] = { |
139 |
|
|
"normal", "threewide", "spreadshot", "firenorth", |
140 |
root |
1.7 |
"firene", "fireeast", "firese", "firesouth", |
141 |
|
|
"firesw", "firewest", "firenw", "bestarrow" |
142 |
|
|
}; |
143 |
|
|
char buf[MAX_BUF]; |
144 |
|
|
int i, found; |
145 |
|
|
|
146 |
|
|
if (!params) |
147 |
|
|
{ |
148 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode is set to %s", types[op->contr->bowtype]); |
149 |
|
|
return 1; |
150 |
|
|
} |
151 |
|
|
|
152 |
|
|
for (i = 0, found = 0; i <= bow_bestarrow; i++) |
153 |
|
|
{ |
154 |
|
|
if (!strcmp (params, types[i])) |
155 |
|
|
{ |
156 |
|
|
found++; |
157 |
|
|
op->contr->bowtype = (bowtype_t) i; |
158 |
|
|
break; |
159 |
root |
1.3 |
} |
160 |
elmex |
1.1 |
} |
161 |
root |
1.38 |
|
162 |
root |
1.7 |
if (!found) |
163 |
|
|
{ |
164 |
|
|
sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
165 |
root |
1.73 |
|
166 |
root |
1.7 |
for (i = 0; i <= bow_bestarrow; i++) |
167 |
|
|
{ |
168 |
|
|
strcat (buf, " "); |
169 |
|
|
strcat (buf, types[i]); |
170 |
|
|
if (i < bow_nw) |
171 |
|
|
strcat (buf, ","); |
172 |
|
|
else |
173 |
|
|
strcat (buf, "."); |
174 |
root |
1.3 |
} |
175 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
176 |
|
|
return 0; |
177 |
elmex |
1.1 |
} |
178 |
root |
1.38 |
|
179 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
180 |
|
|
return 1; |
181 |
elmex |
1.1 |
} |
182 |
|
|
|
183 |
root |
1.7 |
int |
184 |
|
|
command_showpets (object *op, char *params) |
185 |
elmex |
1.1 |
{ |
186 |
root |
1.7 |
int counter = 0, target = 0; |
187 |
|
|
int have_shown_pet = 0; |
188 |
|
|
|
189 |
root |
1.73 |
dynbuf_text msg (2048, 1024); |
190 |
|
|
|
191 |
|
|
if (params) |
192 |
root |
1.7 |
target = atoi (params); |
193 |
root |
1.73 |
|
194 |
|
|
for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
195 |
root |
1.7 |
{ |
196 |
|
|
object *ob = obl->ob; |
197 |
|
|
|
198 |
root |
1.22 |
if (ob->owner == op) |
199 |
root |
1.7 |
{ |
200 |
|
|
if (target == 0) |
201 |
|
|
{ |
202 |
|
|
if (counter == 0) |
203 |
root |
1.73 |
msg << "T<Pets>\n\n"; |
204 |
|
|
|
205 |
|
|
msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
206 |
root |
1.7 |
} |
207 |
|
|
else if (!have_shown_pet && ++counter == target) |
208 |
|
|
{ |
209 |
root |
1.73 |
msg.printf ("T<%s>\n\n" |
210 |
|
|
" level %d\n" |
211 |
|
|
" %d/%d HP, %d/%d SP\n" |
212 |
|
|
" Str %2d\n" |
213 |
|
|
" Dex %2d\n" |
214 |
|
|
" Con %2d\n" |
215 |
|
|
" Int %2d\n" |
216 |
|
|
" Wis %2d\n" |
217 |
|
|
" Cha %2d\n" |
218 |
|
|
" Pow %2d\n" |
219 |
|
|
" wc %d damage %d ac %d\n", |
220 |
|
|
&ob->name, |
221 |
|
|
&ob->name, |
222 |
|
|
ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
223 |
|
|
ob->stats.Str, |
224 |
|
|
ob->stats.Dex, |
225 |
|
|
ob->stats.Con, |
226 |
|
|
ob->stats.Int, |
227 |
|
|
ob->stats.Wis, |
228 |
|
|
ob->stats.Cha, |
229 |
|
|
ob->stats.Pow, |
230 |
|
|
ob->stats.wc, ob->stats.dam, ob->stats.ac); |
231 |
|
|
|
232 |
root |
1.7 |
have_shown_pet = 1; |
233 |
root |
1.3 |
} |
234 |
|
|
} |
235 |
elmex |
1.1 |
} |
236 |
root |
1.73 |
|
237 |
root |
1.7 |
if (counter == 0) |
238 |
root |
1.73 |
msg << "you have no pets."; |
239 |
root |
1.7 |
else if (target != 0 && have_shown_pet == 0) |
240 |
root |
1.73 |
msg << "no such pet."; |
241 |
|
|
|
242 |
|
|
op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
243 |
|
|
|
244 |
root |
1.7 |
return 0; |
245 |
elmex |
1.1 |
} |
246 |
|
|
|
247 |
root |
1.7 |
int |
248 |
|
|
command_resistances (object *op, char *params) |
249 |
elmex |
1.1 |
{ |
250 |
root |
1.73 |
dynbuf_text msg (2048, 1024); |
251 |
elmex |
1.1 |
|
252 |
root |
1.73 |
msg << "Resistances:\n\n"; |
253 |
elmex |
1.1 |
|
254 |
root |
1.73 |
for (int i = 0; i < NROFATTACKS; i++) |
255 |
|
|
if (i != ATNR_INTERNAL) |
256 |
|
|
msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
257 |
elmex |
1.1 |
|
258 |
root |
1.7 |
/* If dragon player, let's display natural resistances */ |
259 |
|
|
if (is_dragon_pl (op)) |
260 |
root |
1.73 |
for (object *tmp = op->inv; tmp; tmp = tmp->below) |
261 |
|
|
if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
262 |
|
|
{ |
263 |
|
|
msg << "\nOf those, these are natural skin resistances:\n\n"; |
264 |
|
|
|
265 |
|
|
for (int attack = 0; attack < NROFATTACKS; attack++) |
266 |
|
|
if (atnr_is_dragon_enabled (attack)) |
267 |
|
|
msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
268 |
root |
1.7 |
|
269 |
root |
1.73 |
break; |
270 |
elmex |
1.1 |
} |
271 |
root |
1.73 |
|
272 |
|
|
op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
273 |
elmex |
1.1 |
|
274 |
root |
1.7 |
return 0; |
275 |
elmex |
1.1 |
} |
276 |
root |
1.7 |
|
277 |
elmex |
1.1 |
/* |
278 |
|
|
* Actual commands. |
279 |
|
|
* Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
280 |
|
|
*/ |
281 |
|
|
|
282 |
root |
1.7 |
int |
283 |
|
|
onoff_value (const char *line) |
284 |
elmex |
1.1 |
{ |
285 |
|
|
int i; |
286 |
|
|
|
287 |
root |
1.7 |
if (sscanf (line, "%d", &i)) |
288 |
elmex |
1.1 |
return (i != 0); |
289 |
root |
1.7 |
switch (line[0]) |
290 |
|
|
{ |
291 |
|
|
case 'o': |
292 |
|
|
switch (line[1]) |
293 |
|
|
{ |
294 |
|
|
case 'n': |
295 |
|
|
return 1; /* on */ |
296 |
|
|
default: |
297 |
|
|
return 0; /* o[ff] */ |
298 |
|
|
} |
299 |
|
|
case 'y': /* y[es] */ |
300 |
|
|
case 'k': /* k[ylla] */ |
301 |
|
|
case 's': |
302 |
|
|
case 'd': |
303 |
|
|
return 1; |
304 |
|
|
case 'n': /* n[o] */ |
305 |
|
|
case 'e': /* e[i] */ |
306 |
|
|
case 'u': |
307 |
|
|
default: |
308 |
|
|
return 0; |
309 |
|
|
} |
310 |
elmex |
1.1 |
} |
311 |
|
|
|
312 |
root |
1.7 |
int |
313 |
|
|
command_title (object *op, char *params) |
314 |
elmex |
1.1 |
{ |
315 |
root |
1.7 |
char buf[MAX_BUF]; |
316 |
|
|
|
317 |
|
|
if (settings.set_title == FALSE) |
318 |
|
|
{ |
319 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
320 |
|
|
return 1; |
321 |
elmex |
1.1 |
} |
322 |
root |
1.7 |
|
323 |
|
|
/* dragon players cannot change titles */ |
324 |
|
|
if (is_dragon_pl (op)) |
325 |
|
|
{ |
326 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
327 |
|
|
return 1; |
328 |
|
|
} |
329 |
|
|
|
330 |
|
|
if (params == NULL) |
331 |
|
|
{ |
332 |
|
|
if (op->contr->own_title[0] == '\0') |
333 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->title); |
334 |
|
|
else |
335 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->own_title); |
336 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
337 |
|
|
return 1; |
338 |
|
|
} |
339 |
|
|
if (strcmp (params, "clear") == 0 || strcmp (params, "default") == 0) |
340 |
|
|
{ |
341 |
|
|
if (op->contr->own_title[0] == '\0') |
342 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your title is the default title."); |
343 |
|
|
else |
344 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title set to default."); |
345 |
|
|
op->contr->own_title[0] = '\0'; |
346 |
|
|
return 1; |
347 |
|
|
} |
348 |
|
|
|
349 |
|
|
if ((int) strlen (params) >= MAX_NAME) |
350 |
|
|
{ |
351 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
352 |
|
|
return 1; |
353 |
|
|
} |
354 |
|
|
strcpy (op->contr->own_title, params); |
355 |
|
|
return 1; |
356 |
elmex |
1.1 |
} |
357 |
|
|
|
358 |
root |
1.7 |
int |
359 |
|
|
command_kill_pets (object *op, char *params) |
360 |
elmex |
1.1 |
{ |
361 |
root |
1.7 |
objectlink *obl, *next; |
362 |
|
|
int counter = 0, removecount = 0; |
363 |
|
|
|
364 |
root |
1.57 |
if (!params) |
365 |
root |
1.7 |
{ |
366 |
|
|
terminate_all_pets (op); |
367 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
368 |
|
|
} |
369 |
|
|
else |
370 |
|
|
{ |
371 |
|
|
int target = atoi (params); |
372 |
|
|
|
373 |
root |
1.57 |
for (obl = first_friendly_object; obl; obl = next) |
374 |
root |
1.7 |
{ |
375 |
|
|
object *ob = obl->ob; |
376 |
|
|
|
377 |
|
|
next = obl->next; |
378 |
root |
1.56 |
|
379 |
root |
1.22 |
if (ob->owner == op) |
380 |
root |
1.7 |
if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
381 |
|
|
{ |
382 |
root |
1.71 |
ob->destroy (); |
383 |
root |
1.3 |
removecount++; |
384 |
root |
1.7 |
} |
385 |
root |
1.3 |
} |
386 |
root |
1.56 |
|
387 |
root |
1.7 |
if (removecount != 0) |
388 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
389 |
|
|
else |
390 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
391 |
elmex |
1.1 |
} |
392 |
root |
1.56 |
|
393 |
root |
1.7 |
return 0; |
394 |
elmex |
1.1 |
} |