1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT 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 <crossfire@schmorp.de> |
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 <loader.h> |
26 | #include <sproto.h> |
27 | #include <sproto.h> |
27 | |
28 | |
28 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
29 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
29 | |
30 | |
30 | int |
|
|
31 | command_motd (object *op, char *params) |
|
|
32 | { |
|
|
33 | display_motd (op); |
|
|
34 | return 1; |
|
|
35 | } |
|
|
36 | |
|
|
37 | #ifdef DEBUG_MALLOC_LEVEL |
|
|
38 | int |
|
|
39 | command_malloc_verify (object *op, char *parms) |
|
|
40 | { |
|
|
41 | extern int malloc_verify (void); |
|
|
42 | |
|
|
43 | if (!malloc_verify ()) |
|
|
44 | new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
|
|
45 | else |
|
|
46 | new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
|
|
47 | return 1; |
|
|
48 | } |
|
|
49 | #endif |
|
|
50 | |
|
|
51 | typedef struct |
31 | typedef struct |
52 | { |
32 | { |
53 | char namebuf[MAX_BUF]; |
33 | char namebuf[MAX_BUF]; |
54 | int login_order; |
34 | int login_order; |
55 | } chars_names; |
35 | } chars_names; |
… | |
… | |
78 | |
58 | |
79 | sprintf (buf, "Set debug level to %d.", i); |
59 | sprintf (buf, "Set debug level to %d.", i); |
80 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
81 | return 1; |
61 | return 1; |
82 | } |
62 | } |
83 | |
|
|
84 | |
63 | |
85 | /* |
64 | /* |
86 | * Those dumps should be just one dump with good parser |
65 | * Those dumps should be just one dump with good parser |
87 | */ |
66 | */ |
88 | |
67 | |
… | |
… | |
99 | } |
78 | } |
100 | return 0; |
79 | return 0; |
101 | } |
80 | } |
102 | |
81 | |
103 | int |
82 | int |
104 | command_dumpfriendlyobjects (object *op, char *params) |
|
|
105 | { |
|
|
106 | dump_friendly_objects (); |
|
|
107 | return 0; |
|
|
108 | } |
|
|
109 | |
|
|
110 | int |
|
|
111 | command_printlos (object *op, char *params) |
|
|
112 | { |
|
|
113 | if (op) |
|
|
114 | print_los (op); |
|
|
115 | return 0; |
|
|
116 | } |
|
|
117 | |
|
|
118 | |
|
|
119 | int |
|
|
120 | command_version (object *op, char *params) |
83 | command_version (object *op, char *params) |
121 | { |
84 | { |
122 | version (op); |
85 | version (op); |
123 | return 0; |
86 | return 0; |
124 | } |
|
|
125 | |
|
|
126 | #ifndef BUG_LOG |
|
|
127 | # define BUG_LOG "bug_log" |
|
|
128 | #endif |
|
|
129 | void |
|
|
130 | bug_report (const char *reportstring) |
|
|
131 | { |
|
|
132 | FILE *fp; |
|
|
133 | |
|
|
134 | if ((fp = fopen (BUG_LOG, "a")) != NULL) |
|
|
135 | { |
|
|
136 | fprintf (fp, "%s\n", reportstring); |
|
|
137 | fclose (fp); |
|
|
138 | } |
|
|
139 | else |
|
|
140 | { |
|
|
141 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
|
|
142 | } |
|
|
143 | } |
87 | } |
144 | |
88 | |
145 | /* Prints out some useful information for the character. Everything we print |
89 | /* Prints out some useful information for the character. Everything we print |
146 | * out can be determined by the docs, so we aren't revealing anything extra - |
90 | * out can be determined by the docs, so we aren't revealing anything extra - |
147 | * rather, we are making it convenient to find the values. params have |
91 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
150 | int |
94 | int |
151 | command_statistics (object *pl, char *params) |
95 | command_statistics (object *pl, char *params) |
152 | { |
96 | { |
153 | if (!pl->contr) |
97 | if (!pl->contr) |
154 | return 1; |
98 | return 1; |
155 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
|
|
156 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
|
|
157 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
158 | |
99 | |
159 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
100 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
160 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->stats.Str); |
101 | |
161 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
102 | msg << " Experience: " << pl->stats.exp << '\n' |
162 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->stats.Dex); |
103 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
163 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
104 | << "\n Stat Nat/Real/Max\n"; |
164 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->stats.Con); |
105 | |
165 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
106 | for (int i = 0; i < NUM_STATS; ++i) |
166 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->stats.Int); |
107 | 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)); |
167 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
108 | |
168 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->stats.Wis); |
109 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
169 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
110 | |
170 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->stats.Pow); |
111 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
171 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
|
|
172 | pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->stats.Cha); |
|
|
173 | new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
|
|
174 | |
112 | |
175 | /* Can't think of anything else to print right now */ |
113 | /* Can't think of anything else to print right now */ |
176 | return 0; |
114 | return 0; |
177 | } |
115 | } |
178 | |
116 | |
179 | int |
117 | int |
180 | command_fix_me (object *op, char *params) |
118 | command_fix_me (object *op, char *params) |
181 | { |
119 | { |
182 | sum_weight (op); |
120 | op->update_weight (); |
183 | op->update_stats (); |
121 | op->update_stats (); |
184 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
122 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
185 | |
123 | |
186 | return 1; |
124 | return 1; |
187 | } |
125 | } |
188 | |
126 | |
189 | int |
127 | int |
190 | command_logs (object *op, char *params) |
|
|
191 | { |
|
|
192 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
193 | |
|
|
194 | return 1; |
|
|
195 | } |
|
|
196 | |
|
|
197 | int |
|
|
198 | command_bowmode (object *op, char *params) |
128 | command_bowmode (object *op, char *params) |
199 | { |
129 | { |
200 | bowtype_t oldtype = op->contr->bowtype; |
130 | bowtype_t oldtype = op->contr->bowtype; |
201 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
131 | static const char *const types[] = { |
|
|
132 | "normal", "threewide", "spreadshot", "firenorth", |
202 | "firene", "fireeast", "firese", "firesouth", |
133 | "firene", "fireeast", "firese", "firesouth", |
203 | "firesw", "firewest", "firenw", "bestarrow" |
134 | "firesw", "firewest", "firenw", "bestarrow" |
204 | }; |
135 | }; |
205 | char buf[MAX_BUF]; |
136 | char buf[MAX_BUF]; |
206 | int i, found; |
137 | int i, found; |
… | |
… | |
222 | } |
153 | } |
223 | |
154 | |
224 | if (!found) |
155 | if (!found) |
225 | { |
156 | { |
226 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
157 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
158 | |
227 | for (i = 0; i <= bow_bestarrow; i++) |
159 | for (i = 0; i <= bow_bestarrow; i++) |
228 | { |
160 | { |
229 | strcat (buf, " "); |
161 | strcat (buf, " "); |
230 | strcat (buf, types[i]); |
162 | strcat (buf, types[i]); |
231 | if (i < bow_nw) |
163 | if (i < bow_nw) |
… | |
… | |
242 | } |
174 | } |
243 | |
175 | |
244 | int |
176 | int |
245 | command_showpets (object *op, char *params) |
177 | command_showpets (object *op, char *params) |
246 | { |
178 | { |
247 | objectlink *obl, *next; |
|
|
248 | int counter = 0, target = 0; |
179 | int counter = 0, target = 0; |
249 | int have_shown_pet = 0; |
180 | int have_shown_pet = 0; |
250 | |
181 | |
|
|
182 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
183 | |
251 | if (params != NULL) |
184 | if (params) |
252 | target = atoi (params); |
185 | target = atoi (params); |
|
|
186 | |
253 | for (obl = first_friendly_object; obl != NULL; obl = next) |
187 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
254 | { |
188 | { |
255 | object *ob = obl->ob; |
189 | object *ob = obl->ob; |
256 | |
190 | |
257 | next = obl->next; |
|
|
258 | if (ob->owner == op) |
191 | if (ob->owner == op) |
259 | { |
192 | { |
260 | if (target == 0) |
193 | if (target == 0) |
261 | { |
194 | { |
262 | if (counter == 0) |
195 | if (counter == 0) |
263 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
196 | msg << "T<Pets>\n\n"; |
|
|
197 | |
264 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
198 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
265 | } |
199 | } |
266 | else if (!have_shown_pet && ++counter == target) |
200 | else if (!have_shown_pet && ++counter == target) |
267 | { |
201 | { |
268 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
202 | msg.printf ("T<%s>\n\n" |
269 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); |
203 | " level %d\n" |
270 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
204 | " %d/%d HP, %d/%d SP\n" |
271 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
205 | " Str %2d\n" |
272 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
206 | " Dex %2d\n" |
273 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
207 | " Con %2d\n" |
274 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
208 | " Int %2d\n" |
275 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
209 | " Wis %2d\n" |
276 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
210 | " Cha %2d\n" |
277 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
211 | " Pow %2d\n" |
278 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
212 | " wc %d damage %d ac %d\n", |
|
|
213 | &ob->name, |
|
|
214 | ob->level, |
|
|
215 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
216 | ob->stats.Str, |
|
|
217 | ob->stats.Dex, |
|
|
218 | ob->stats.Con, |
|
|
219 | ob->stats.Int, |
|
|
220 | ob->stats.Wis, |
|
|
221 | ob->stats.Cha, |
|
|
222 | ob->stats.Pow, |
|
|
223 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
224 | |
279 | have_shown_pet = 1; |
225 | have_shown_pet = 1; |
280 | } |
226 | } |
281 | } |
227 | } |
282 | } |
228 | } |
|
|
229 | |
283 | if (counter == 0) |
230 | if (counter == 0) |
284 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
231 | msg << "you have no pets."; |
285 | else if (target != 0 && have_shown_pet == 0) |
232 | else if (target != 0 && have_shown_pet == 0) |
286 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
233 | msg << "no such pet."; |
|
|
234 | |
|
|
235 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
|
|
236 | |
287 | return 0; |
237 | return 0; |
288 | } |
238 | } |
289 | |
239 | |
290 | int |
240 | int |
291 | command_resistances (object *op, char *params) |
241 | command_resistances (object *op, char *params) |
292 | { |
242 | { |
293 | int i; |
243 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
294 | |
244 | |
295 | if (!op) |
245 | msg << "Resistances:\n\n"; |
296 | return 0; |
|
|
297 | |
246 | |
298 | for (i = 0; i < NROFATTACKS; i++) |
247 | for (int i = 0; i < NROFATTACKS; i++) |
299 | { |
|
|
300 | if (i == ATNR_INTERNAL) |
248 | if (i != ATNR_INTERNAL) |
301 | continue; |
249 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
302 | |
|
|
303 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
304 | } |
|
|
305 | |
250 | |
306 | /* If dragon player, let's display natural resistances */ |
251 | /* If dragon player, let's display natural resistances */ |
307 | if (is_dragon_pl (op)) |
252 | if (is_dragon_pl (op)) |
308 | { |
|
|
309 | int attack; |
|
|
310 | object *tmp; |
|
|
311 | |
|
|
312 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
253 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
313 | { |
|
|
314 | if ((tmp->type == FORCE) && (strcmp (tmp->arch->archname, "dragon_skin_force") == 0)) |
254 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
315 | { |
255 | { |
316 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
256 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
257 | |
317 | for (attack = 0; attack < NROFATTACKS; attack++) |
258 | for (int attack = 0; attack < NROFATTACKS; attack++) |
318 | { |
|
|
319 | if (atnr_is_dragon_enabled (attack)) |
259 | if (atnr_is_dragon_enabled (attack)) |
320 | { |
260 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
321 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
261 | |
322 | } |
|
|
323 | } |
|
|
324 | break; |
262 | break; |
325 | } |
263 | } |
326 | } |
|
|
327 | } |
|
|
328 | |
264 | |
329 | return 0; |
265 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
330 | } |
|
|
331 | |
266 | |
332 | /* |
267 | return 0; |
333 | * Actual commands. |
|
|
334 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
335 | */ |
|
|
336 | |
|
|
337 | int |
|
|
338 | onoff_value (const char *line) |
|
|
339 | { |
|
|
340 | int i; |
|
|
341 | |
|
|
342 | if (sscanf (line, "%d", &i)) |
|
|
343 | return (i != 0); |
|
|
344 | switch (line[0]) |
|
|
345 | { |
|
|
346 | case 'o': |
|
|
347 | switch (line[1]) |
|
|
348 | { |
|
|
349 | case 'n': |
|
|
350 | return 1; /* on */ |
|
|
351 | default: |
|
|
352 | return 0; /* o[ff] */ |
|
|
353 | } |
|
|
354 | case 'y': /* y[es] */ |
|
|
355 | case 'k': /* k[ylla] */ |
|
|
356 | case 's': |
|
|
357 | case 'd': |
|
|
358 | return 1; |
|
|
359 | case 'n': /* n[o] */ |
|
|
360 | case 'e': /* e[i] */ |
|
|
361 | case 'u': |
|
|
362 | default: |
|
|
363 | return 0; |
|
|
364 | } |
|
|
365 | } |
268 | } |
366 | |
269 | |
367 | int |
270 | int |
368 | command_title (object *op, char *params) |
271 | command_title (object *op, char *params) |
369 | { |
272 | { |