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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
|
|
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * 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 |
10 | * 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 |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the GNU General Public License |
19 | * 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/>. |
20 | * and the GNU General Public License along with this program. If not, see |
|
|
21 | * <http://www.gnu.org/licenses/>. |
20 | * |
22 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
24 | */ |
23 | |
25 | |
24 | #include <global.h> |
26 | #include <global.h> |
25 | #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 | 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 | |
30 | |
43 | int |
31 | int |
44 | command_time (object *op, char *params) |
32 | command_time (object *op, char *params) |
45 | { |
33 | { |
46 | print_tod (op); |
34 | print_tod (op); |
… | |
… | |
64 | |
52 | |
65 | sprintf (buf, "Set debug level to %d.", i); |
53 | sprintf (buf, "Set debug level to %d.", i); |
66 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
54 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
67 | return 1; |
55 | return 1; |
68 | } |
56 | } |
69 | |
|
|
70 | |
57 | |
71 | /* |
58 | /* |
72 | * Those dumps should be just one dump with good parser |
59 | * Those dumps should be just one dump with good parser |
73 | */ |
60 | */ |
74 | |
61 | |
… | |
… | |
85 | } |
72 | } |
86 | return 0; |
73 | return 0; |
87 | } |
74 | } |
88 | |
75 | |
89 | int |
76 | 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) |
77 | command_version (object *op, char *params) |
107 | { |
78 | { |
108 | version (op); |
79 | version (op); |
109 | return 0; |
80 | 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 | } |
81 | } |
130 | |
82 | |
131 | /* Prints out some useful information for the character. Everything we print |
83 | /* 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 - |
84 | * 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 |
85 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
136 | int |
88 | int |
137 | command_statistics (object *pl, char *params) |
89 | command_statistics (object *pl, char *params) |
138 | { |
90 | { |
139 | if (!pl->contr) |
91 | if (!pl->contr) |
140 | return 1; |
92 | 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 | |
93 | |
145 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
94 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
146 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->stats.Str); |
95 | |
147 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
96 | msg << " Experience: " << pl->stats.exp << '\n' |
148 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->stats.Dex); |
97 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
149 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
98 | << "\n Stat Nat/Real/Max\n"; |
150 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->stats.Con); |
99 | |
151 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
100 | for (int i = 0; i < NUM_STATS; ++i) |
152 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->stats.Int); |
101 | 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", |
102 | |
154 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->stats.Wis); |
103 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
155 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
104 | |
156 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->stats.Pow); |
105 | 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 | |
106 | |
161 | /* Can't think of anything else to print right now */ |
107 | /* Can't think of anything else to print right now */ |
162 | return 0; |
108 | return 0; |
163 | } |
109 | } |
164 | |
110 | |
… | |
… | |
171 | |
117 | |
172 | return 1; |
118 | return 1; |
173 | } |
119 | } |
174 | |
120 | |
175 | int |
121 | int |
176 | command_logs (object *op, char *params) |
|
|
177 | { |
|
|
178 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
179 | |
|
|
180 | return 1; |
|
|
181 | } |
|
|
182 | |
|
|
183 | int |
|
|
184 | command_bowmode (object *op, char *params) |
122 | command_bowmode (object *op, char *params) |
185 | { |
123 | { |
186 | bowtype_t oldtype = op->contr->bowtype; |
124 | bowtype_t oldtype = op->contr->bowtype; |
187 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
125 | static const char *const types[] = { |
|
|
126 | "normal", "threewide", "spreadshot", "firenorth", |
188 | "firene", "fireeast", "firese", "firesouth", |
127 | "firene", "fireeast", "firese", "firesouth", |
189 | "firesw", "firewest", "firenw", "bestarrow" |
128 | "firesw", "firewest", "firenw", "bestarrow" |
190 | }; |
129 | }; |
191 | char buf[MAX_BUF]; |
130 | char buf[MAX_BUF]; |
192 | int i, found; |
131 | int i, found; |
… | |
… | |
208 | } |
147 | } |
209 | |
148 | |
210 | if (!found) |
149 | if (!found) |
211 | { |
150 | { |
212 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
151 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
152 | |
213 | for (i = 0; i <= bow_bestarrow; i++) |
153 | for (i = 0; i <= bow_bestarrow; i++) |
214 | { |
154 | { |
215 | strcat (buf, " "); |
155 | strcat (buf, " "); |
216 | strcat (buf, types[i]); |
156 | strcat (buf, types[i]); |
217 | if (i < bow_nw) |
157 | if (i < bow_nw) |
… | |
… | |
228 | } |
168 | } |
229 | |
169 | |
230 | int |
170 | int |
231 | command_showpets (object *op, char *params) |
171 | command_showpets (object *op, char *params) |
232 | { |
172 | { |
233 | objectlink *obl, *next; |
|
|
234 | int counter = 0, target = 0; |
173 | int counter = 0, target = 0; |
235 | int have_shown_pet = 0; |
174 | int have_shown_pet = 0; |
236 | |
175 | |
|
|
176 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
177 | |
237 | if (params != NULL) |
178 | if (params) |
238 | target = atoi (params); |
179 | target = atoi (params); |
|
|
180 | |
239 | for (obl = first_friendly_object; obl != NULL; obl = next) |
181 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
240 | { |
182 | { |
241 | object *ob = obl->ob; |
183 | object *ob = obl->ob; |
242 | |
184 | |
243 | next = obl->next; |
|
|
244 | if (ob->owner == op) |
185 | if (ob->owner == op) |
245 | { |
186 | { |
246 | if (target == 0) |
187 | if (target == 0) |
247 | { |
188 | { |
248 | if (counter == 0) |
189 | if (counter == 0) |
249 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
190 | msg << "T<Pets>\n\n"; |
|
|
191 | |
250 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
192 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
251 | } |
193 | } |
252 | else if (!have_shown_pet && ++counter == target) |
194 | else if (!have_shown_pet && ++counter == target) |
253 | { |
195 | { |
254 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
196 | msg.printf ("T<%s>\n\n" |
255 | 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); |
197 | " level %d\n" |
256 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
198 | " %d/%d HP, %d/%d SP\n" |
257 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
199 | " Str %2d\n" |
258 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
200 | " Dex %2d\n" |
259 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
201 | " Con %2d\n" |
260 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
202 | " Int %2d\n" |
261 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
203 | " Wis %2d\n" |
262 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
204 | " Cha %2d\n" |
263 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
205 | " Pow %2d\n" |
264 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
206 | " wc %d damage %d ac %d\n", |
|
|
207 | &ob->name, |
|
|
208 | ob->level, |
|
|
209 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
210 | ob->stats.Str, |
|
|
211 | ob->stats.Dex, |
|
|
212 | ob->stats.Con, |
|
|
213 | ob->stats.Int, |
|
|
214 | ob->stats.Wis, |
|
|
215 | ob->stats.Cha, |
|
|
216 | ob->stats.Pow, |
|
|
217 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
218 | |
265 | have_shown_pet = 1; |
219 | have_shown_pet = 1; |
266 | } |
220 | } |
267 | } |
221 | } |
268 | } |
222 | } |
|
|
223 | |
269 | if (counter == 0) |
224 | if (counter == 0) |
270 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
225 | msg << "you have no pets."; |
271 | else if (target != 0 && have_shown_pet == 0) |
226 | else if (target != 0 && have_shown_pet == 0) |
272 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
227 | msg << "no such pet."; |
|
|
228 | |
|
|
229 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
|
|
230 | |
273 | return 0; |
231 | return 0; |
274 | } |
232 | } |
275 | |
233 | |
276 | int |
234 | int |
277 | command_resistances (object *op, char *params) |
235 | command_resistances (object *op, char *params) |
278 | { |
236 | { |
279 | int i; |
237 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
280 | |
238 | |
281 | if (!op) |
239 | msg << "Resistances:\n\n"; |
282 | return 0; |
|
|
283 | |
240 | |
284 | for (i = 0; i < NROFATTACKS; i++) |
241 | for (int i = 0; i < NROFATTACKS; i++) |
285 | { |
|
|
286 | if (i == ATNR_INTERNAL) |
242 | if (i != ATNR_INTERNAL) |
287 | continue; |
243 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
288 | |
|
|
289 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
290 | } |
|
|
291 | |
244 | |
292 | /* If dragon player, let's display natural resistances */ |
245 | /* If dragon player, let's display natural resistances */ |
293 | if (is_dragon_pl (op)) |
246 | if (op->is_dragon ()) |
294 | { |
|
|
295 | int attack; |
|
|
296 | object *tmp; |
|
|
297 | |
|
|
298 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
247 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
299 | { |
|
|
300 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
248 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
301 | { |
249 | { |
302 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
250 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
251 | |
303 | for (attack = 0; attack < NROFATTACKS; attack++) |
252 | for (int attack = 0; attack < NROFATTACKS; attack++) |
304 | { |
|
|
305 | if (atnr_is_dragon_enabled (attack)) |
253 | if (atnr_is_dragon_enabled (attack)) |
306 | { |
254 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
307 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
255 | |
308 | } |
|
|
309 | } |
|
|
310 | break; |
256 | break; |
311 | } |
257 | } |
312 | } |
|
|
313 | } |
|
|
314 | |
258 | |
315 | return 0; |
259 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
316 | } |
|
|
317 | |
260 | |
318 | /* |
261 | return 0; |
319 | * Actual commands. |
|
|
320 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
321 | */ |
|
|
322 | |
|
|
323 | int |
|
|
324 | onoff_value (const char *line) |
|
|
325 | { |
|
|
326 | int i; |
|
|
327 | |
|
|
328 | if (sscanf (line, "%d", &i)) |
|
|
329 | return (i != 0); |
|
|
330 | switch (line[0]) |
|
|
331 | { |
|
|
332 | case 'o': |
|
|
333 | switch (line[1]) |
|
|
334 | { |
|
|
335 | case 'n': |
|
|
336 | return 1; /* on */ |
|
|
337 | default: |
|
|
338 | return 0; /* o[ff] */ |
|
|
339 | } |
|
|
340 | case 'y': /* y[es] */ |
|
|
341 | case 'k': /* k[ylla] */ |
|
|
342 | case 's': |
|
|
343 | case 'd': |
|
|
344 | return 1; |
|
|
345 | case 'n': /* n[o] */ |
|
|
346 | case 'e': /* e[i] */ |
|
|
347 | case 'u': |
|
|
348 | default: |
|
|
349 | return 0; |
|
|
350 | } |
|
|
351 | } |
262 | } |
352 | |
263 | |
353 | int |
264 | int |
354 | command_title (object *op, char *params) |
265 | command_title (object *op, char *params) |
355 | { |
266 | { |
… | |
… | |
360 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
271 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
361 | return 1; |
272 | return 1; |
362 | } |
273 | } |
363 | |
274 | |
364 | /* dragon players cannot change titles */ |
275 | /* dragon players cannot change titles */ |
365 | if (is_dragon_pl (op)) |
276 | if (op->is_dragon ()) |
366 | { |
277 | { |
367 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
278 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
368 | return 1; |
279 | return 1; |
369 | } |
280 | } |
370 | |
281 | |