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,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your 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 GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * 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> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <loader.h> |
|
|
26 | #include <sproto.h> |
26 | #include <sproto.h> |
27 | |
27 | |
28 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
28 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
29 | |
|
|
30 | int |
|
|
31 | command_motd (object *op, char *params) |
|
|
32 | { |
|
|
33 | display_motd (op); |
|
|
34 | return 1; |
|
|
35 | } |
|
|
36 | |
|
|
37 | typedef struct |
|
|
38 | { |
|
|
39 | char namebuf[MAX_BUF]; |
|
|
40 | int login_order; |
|
|
41 | } chars_names; |
|
|
42 | |
29 | |
43 | int |
30 | int |
44 | command_time (object *op, char *params) |
31 | command_time (object *op, char *params) |
45 | { |
32 | { |
46 | print_tod (op); |
33 | print_tod (op); |
… | |
… | |
64 | |
51 | |
65 | sprintf (buf, "Set debug level to %d.", i); |
52 | sprintf (buf, "Set debug level to %d.", i); |
66 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
53 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
67 | return 1; |
54 | return 1; |
68 | } |
55 | } |
69 | |
|
|
70 | |
56 | |
71 | /* |
57 | /* |
72 | * Those dumps should be just one dump with good parser |
58 | * Those dumps should be just one dump with good parser |
73 | */ |
59 | */ |
74 | |
60 | |
… | |
… | |
102 | command_statistics (object *pl, char *params) |
88 | command_statistics (object *pl, char *params) |
103 | { |
89 | { |
104 | if (!pl->contr) |
90 | if (!pl->contr) |
105 | return 1; |
91 | return 1; |
106 | |
92 | |
107 | dynbuf_text msg (2048, 1024); |
93 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
108 | |
94 | |
109 | msg << " Experience: " << pl->stats.exp << '\n' |
95 | msg << " Experience: " << pl->stats.exp << '\n' |
110 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
96 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
111 | << "\n Stat Nat/Real/Max\n"; |
97 | << "\n Stat Nat/Real/Max\n"; |
112 | |
98 | |
… | |
… | |
184 | command_showpets (object *op, char *params) |
170 | command_showpets (object *op, char *params) |
185 | { |
171 | { |
186 | int counter = 0, target = 0; |
172 | int counter = 0, target = 0; |
187 | int have_shown_pet = 0; |
173 | int have_shown_pet = 0; |
188 | |
174 | |
189 | dynbuf_text msg (2048, 1024); |
175 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
190 | |
176 | |
191 | if (params) |
177 | if (params) |
192 | target = atoi (params); |
178 | target = atoi (params); |
193 | |
179 | |
194 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
180 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
… | |
… | |
216 | " Wis %2d\n" |
202 | " Wis %2d\n" |
217 | " Cha %2d\n" |
203 | " Cha %2d\n" |
218 | " Pow %2d\n" |
204 | " Pow %2d\n" |
219 | " wc %d damage %d ac %d\n", |
205 | " wc %d damage %d ac %d\n", |
220 | &ob->name, |
206 | &ob->name, |
221 | &ob->name, |
207 | ob->level, |
222 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
208 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
223 | ob->stats.Str, |
209 | ob->stats.Str, |
224 | ob->stats.Dex, |
210 | ob->stats.Dex, |
225 | ob->stats.Con, |
211 | ob->stats.Con, |
226 | ob->stats.Int, |
212 | ob->stats.Int, |
… | |
… | |
245 | } |
231 | } |
246 | |
232 | |
247 | int |
233 | int |
248 | command_resistances (object *op, char *params) |
234 | command_resistances (object *op, char *params) |
249 | { |
235 | { |
250 | dynbuf_text msg (2048, 1024); |
236 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
251 | |
237 | |
252 | msg << "Resistances:\n\n"; |
238 | msg << "Resistances:\n\n"; |
253 | |
239 | |
254 | for (int i = 0; i < NROFATTACKS; i++) |
240 | for (int i = 0; i < NROFATTACKS; i++) |
255 | if (i != ATNR_INTERNAL) |
241 | if (i != ATNR_INTERNAL) |
256 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
242 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
257 | |
243 | |
258 | /* If dragon player, let's display natural resistances */ |
244 | /* If dragon player, let's display natural resistances */ |
259 | if (is_dragon_pl (op)) |
245 | if (op->is_dragon ()) |
260 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
246 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
261 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
247 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
262 | { |
248 | { |
263 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
249 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
264 | |
250 | |
… | |
… | |
272 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
258 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
273 | |
259 | |
274 | return 0; |
260 | return 0; |
275 | } |
261 | } |
276 | |
262 | |
277 | /* |
|
|
278 | * Actual commands. |
|
|
279 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
280 | */ |
|
|
281 | |
|
|
282 | int |
|
|
283 | onoff_value (const char *line) |
|
|
284 | { |
|
|
285 | int i; |
|
|
286 | |
|
|
287 | if (sscanf (line, "%d", &i)) |
|
|
288 | return (i != 0); |
|
|
289 | 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 | } |
|
|
311 | |
|
|
312 | int |
263 | int |
313 | command_title (object *op, char *params) |
264 | command_title (object *op, char *params) |
314 | { |
265 | { |
315 | char buf[MAX_BUF]; |
266 | char buf[MAX_BUF]; |
316 | |
267 | |
… | |
… | |
319 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
270 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
320 | return 1; |
271 | return 1; |
321 | } |
272 | } |
322 | |
273 | |
323 | /* dragon players cannot change titles */ |
274 | /* dragon players cannot change titles */ |
324 | if (is_dragon_pl (op)) |
275 | if (op->is_dragon ()) |
325 | { |
276 | { |
326 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
277 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
327 | return 1; |
278 | return 1; |
328 | } |
279 | } |
329 | |
280 | |