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 | |
… | |
… | |
85 | } |
71 | } |
86 | return 0; |
72 | return 0; |
87 | } |
73 | } |
88 | |
74 | |
89 | int |
75 | int |
90 | command_dumpfriendlyobjects (object *op, char *params) |
|
|
91 | { |
|
|
92 | dump_friendly_objects (); |
|
|
93 | return 0; |
|
|
94 | } |
|
|
95 | |
|
|
96 | int |
|
|
97 | command_printlos (object *op, char *params) |
|
|
98 | { |
|
|
99 | if (op) |
|
|
100 | print_los (op); |
|
|
101 | return 0; |
|
|
102 | } |
|
|
103 | |
|
|
104 | |
|
|
105 | int |
|
|
106 | command_version (object *op, char *params) |
76 | command_version (object *op, char *params) |
107 | { |
77 | { |
108 | version (op); |
78 | version (op); |
109 | return 0; |
79 | return 0; |
110 | } |
|
|
111 | |
|
|
112 | #ifndef BUG_LOG |
|
|
113 | # define BUG_LOG "bug_log" |
|
|
114 | #endif |
|
|
115 | void |
|
|
116 | bug_report (const char *reportstring) |
|
|
117 | { |
|
|
118 | FILE *fp; |
|
|
119 | |
|
|
120 | if ((fp = fopen (BUG_LOG, "a")) != NULL) |
|
|
121 | { |
|
|
122 | fprintf (fp, "%s\n", reportstring); |
|
|
123 | fclose (fp); |
|
|
124 | } |
|
|
125 | else |
|
|
126 | { |
|
|
127 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
|
|
128 | } |
|
|
129 | } |
80 | } |
130 | |
81 | |
131 | /* Prints out some useful information for the character. Everything we print |
82 | /* Prints out some useful information for the character. Everything we print |
132 | * out can be determined by the docs, so we aren't revealing anything extra - |
83 | * out can be determined by the docs, so we aren't revealing anything extra - |
133 | * rather, we are making it convenient to find the values. params have |
84 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
136 | int |
87 | int |
137 | command_statistics (object *pl, char *params) |
88 | command_statistics (object *pl, char *params) |
138 | { |
89 | { |
139 | if (!pl->contr) |
90 | if (!pl->contr) |
140 | return 1; |
91 | return 1; |
141 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
|
|
142 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
|
|
143 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
144 | |
92 | |
145 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
93 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
146 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->stats.Str); |
94 | |
147 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
95 | msg << " Experience: " << pl->stats.exp << '\n' |
148 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->stats.Dex); |
96 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
149 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
97 | << "\n Stat Nat/Real/Max\n"; |
150 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->stats.Con); |
98 | |
151 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
99 | for (int i = 0; i < NUM_STATS; ++i) |
152 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->stats.Int); |
100 | 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)); |
153 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
101 | |
154 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->stats.Wis); |
102 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
155 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
103 | |
156 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->stats.Pow); |
104 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
157 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
|
|
158 | pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->stats.Cha); |
|
|
159 | new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
|
|
160 | |
105 | |
161 | /* Can't think of anything else to print right now */ |
106 | /* Can't think of anything else to print right now */ |
162 | return 0; |
107 | return 0; |
163 | } |
108 | } |
164 | |
109 | |
… | |
… | |
174 | |
119 | |
175 | int |
120 | int |
176 | command_bowmode (object *op, char *params) |
121 | command_bowmode (object *op, char *params) |
177 | { |
122 | { |
178 | bowtype_t oldtype = op->contr->bowtype; |
123 | bowtype_t oldtype = op->contr->bowtype; |
179 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
124 | static const char *const types[] = { |
|
|
125 | "normal", "threewide", "spreadshot", "firenorth", |
180 | "firene", "fireeast", "firese", "firesouth", |
126 | "firene", "fireeast", "firese", "firesouth", |
181 | "firesw", "firewest", "firenw", "bestarrow" |
127 | "firesw", "firewest", "firenw", "bestarrow" |
182 | }; |
128 | }; |
183 | char buf[MAX_BUF]; |
129 | char buf[MAX_BUF]; |
184 | int i, found; |
130 | int i, found; |
… | |
… | |
200 | } |
146 | } |
201 | |
147 | |
202 | if (!found) |
148 | if (!found) |
203 | { |
149 | { |
204 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
150 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
151 | |
205 | for (i = 0; i <= bow_bestarrow; i++) |
152 | for (i = 0; i <= bow_bestarrow; i++) |
206 | { |
153 | { |
207 | strcat (buf, " "); |
154 | strcat (buf, " "); |
208 | strcat (buf, types[i]); |
155 | strcat (buf, types[i]); |
209 | if (i < bow_nw) |
156 | if (i < bow_nw) |
… | |
… | |
220 | } |
167 | } |
221 | |
168 | |
222 | int |
169 | int |
223 | command_showpets (object *op, char *params) |
170 | command_showpets (object *op, char *params) |
224 | { |
171 | { |
225 | objectlink *obl, *next; |
|
|
226 | int counter = 0, target = 0; |
172 | int counter = 0, target = 0; |
227 | int have_shown_pet = 0; |
173 | int have_shown_pet = 0; |
228 | |
174 | |
|
|
175 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
176 | |
229 | if (params != NULL) |
177 | if (params) |
230 | target = atoi (params); |
178 | target = atoi (params); |
|
|
179 | |
231 | for (obl = first_friendly_object; obl != NULL; obl = next) |
180 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
232 | { |
181 | { |
233 | object *ob = obl->ob; |
182 | object *ob = obl->ob; |
234 | |
183 | |
235 | next = obl->next; |
|
|
236 | if (ob->owner == op) |
184 | if (ob->owner == op) |
237 | { |
185 | { |
238 | if (target == 0) |
186 | if (target == 0) |
239 | { |
187 | { |
240 | if (counter == 0) |
188 | if (counter == 0) |
241 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
189 | msg << "T<Pets>\n\n"; |
|
|
190 | |
242 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
191 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
243 | } |
192 | } |
244 | else if (!have_shown_pet && ++counter == target) |
193 | else if (!have_shown_pet && ++counter == target) |
245 | { |
194 | { |
246 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
195 | msg.printf ("T<%s>\n\n" |
247 | 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); |
196 | " level %d\n" |
248 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
197 | " %d/%d HP, %d/%d SP\n" |
249 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
198 | " Str %2d\n" |
250 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
199 | " Dex %2d\n" |
251 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
200 | " Con %2d\n" |
252 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
201 | " Int %2d\n" |
253 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
202 | " Wis %2d\n" |
254 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
203 | " Cha %2d\n" |
255 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
204 | " Pow %2d\n" |
256 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
205 | " wc %d damage %d ac %d\n", |
|
|
206 | &ob->name, |
|
|
207 | ob->level, |
|
|
208 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
209 | ob->stats.Str, |
|
|
210 | ob->stats.Dex, |
|
|
211 | ob->stats.Con, |
|
|
212 | ob->stats.Int, |
|
|
213 | ob->stats.Wis, |
|
|
214 | ob->stats.Cha, |
|
|
215 | ob->stats.Pow, |
|
|
216 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
217 | |
257 | have_shown_pet = 1; |
218 | have_shown_pet = 1; |
258 | } |
219 | } |
259 | } |
220 | } |
260 | } |
221 | } |
|
|
222 | |
261 | if (counter == 0) |
223 | if (counter == 0) |
262 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
224 | msg << "you have no pets."; |
263 | else if (target != 0 && have_shown_pet == 0) |
225 | else if (target != 0 && have_shown_pet == 0) |
264 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
226 | msg << "no such pet."; |
|
|
227 | |
|
|
228 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
|
|
229 | |
265 | return 0; |
230 | return 0; |
266 | } |
231 | } |
267 | |
232 | |
268 | int |
233 | int |
269 | command_resistances (object *op, char *params) |
234 | command_resistances (object *op, char *params) |
270 | { |
235 | { |
271 | int i; |
236 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
272 | |
237 | |
273 | if (!op) |
238 | msg << "Resistances:\n\n"; |
274 | return 0; |
|
|
275 | |
239 | |
276 | for (i = 0; i < NROFATTACKS; i++) |
240 | for (int i = 0; i < NROFATTACKS; i++) |
277 | { |
|
|
278 | if (i == ATNR_INTERNAL) |
241 | if (i != ATNR_INTERNAL) |
279 | continue; |
242 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
280 | |
|
|
281 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
282 | } |
|
|
283 | |
243 | |
284 | /* If dragon player, let's display natural resistances */ |
244 | /* If dragon player, let's display natural resistances */ |
285 | if (is_dragon_pl (op)) |
245 | if (op->is_dragon ()) |
286 | { |
|
|
287 | int attack; |
|
|
288 | object *tmp; |
|
|
289 | |
|
|
290 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
246 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
291 | { |
|
|
292 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
247 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
293 | { |
248 | { |
294 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
249 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
250 | |
295 | for (attack = 0; attack < NROFATTACKS; attack++) |
251 | for (int attack = 0; attack < NROFATTACKS; attack++) |
296 | { |
|
|
297 | if (atnr_is_dragon_enabled (attack)) |
252 | if (atnr_is_dragon_enabled (attack)) |
298 | { |
253 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
299 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
254 | |
300 | } |
|
|
301 | } |
|
|
302 | break; |
255 | break; |
303 | } |
256 | } |
304 | } |
|
|
305 | } |
|
|
306 | |
257 | |
307 | return 0; |
258 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
308 | } |
|
|
309 | |
259 | |
310 | /* |
260 | return 0; |
311 | * Actual commands. |
|
|
312 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
313 | */ |
|
|
314 | |
|
|
315 | int |
|
|
316 | onoff_value (const char *line) |
|
|
317 | { |
|
|
318 | int i; |
|
|
319 | |
|
|
320 | if (sscanf (line, "%d", &i)) |
|
|
321 | return (i != 0); |
|
|
322 | switch (line[0]) |
|
|
323 | { |
|
|
324 | case 'o': |
|
|
325 | switch (line[1]) |
|
|
326 | { |
|
|
327 | case 'n': |
|
|
328 | return 1; /* on */ |
|
|
329 | default: |
|
|
330 | return 0; /* o[ff] */ |
|
|
331 | } |
|
|
332 | case 'y': /* y[es] */ |
|
|
333 | case 'k': /* k[ylla] */ |
|
|
334 | case 's': |
|
|
335 | case 'd': |
|
|
336 | return 1; |
|
|
337 | case 'n': /* n[o] */ |
|
|
338 | case 'e': /* e[i] */ |
|
|
339 | case 'u': |
|
|
340 | default: |
|
|
341 | return 0; |
|
|
342 | } |
|
|
343 | } |
261 | } |
344 | |
262 | |
345 | int |
263 | int |
346 | command_title (object *op, char *params) |
264 | command_title (object *op, char *params) |
347 | { |
265 | { |
… | |
… | |
352 | 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."); |
353 | return 1; |
271 | return 1; |
354 | } |
272 | } |
355 | |
273 | |
356 | /* dragon players cannot change titles */ |
274 | /* dragon players cannot change titles */ |
357 | if (is_dragon_pl (op)) |
275 | if (op->is_dragon ()) |
358 | { |
276 | { |
359 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
277 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
360 | return 1; |
278 | return 1; |
361 | } |
279 | } |
362 | |
280 | |