1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program 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 2 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, write to the Free Software |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <loader.h> |
26 | #include <loader.h> |
27 | #include <sproto.h> |
27 | #include <sproto.h> |
28 | |
28 | |
29 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
30 | * who, etc. |
|
|
31 | */ |
|
|
32 | |
|
|
33 | /* This command dumps the body information for object *op. |
|
|
34 | * it doesn't care what the params are. |
|
|
35 | * This is mostly meant as a debug command. |
|
|
36 | */ |
|
|
37 | int |
|
|
38 | command_body (object *op, char *params) |
|
|
39 | { |
|
|
40 | int i; |
|
|
41 | |
|
|
42 | /* Too hard to try and make a header that lines everything up, so just |
|
|
43 | * give a description. |
|
|
44 | */ |
|
|
45 | new_draw_info (NDI_UNIQUE, 0, op, "The first column is the name of the body location."); |
|
|
46 | new_draw_info (NDI_UNIQUE, 0, op, "The second column is how many of those locations your body has."); |
|
|
47 | new_draw_info (NDI_UNIQUE, 0, op, "The third column is how many slots in that location are available."); |
|
|
48 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
49 | { |
|
|
50 | /* really debugging - normally body_used should not be set to anything |
|
|
51 | * if body_info isn't also set. |
|
|
52 | */ |
|
|
53 | if (op->body_info[i] || op->body_used[i]) |
|
|
54 | { |
|
|
55 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-30s %5d %5d", body_locations[i].use_name, op->body_info[i], op->body_used[i]); |
|
|
56 | } |
|
|
57 | } |
|
|
58 | if (!QUERY_FLAG (op, FLAG_USE_ARMOUR)) |
|
|
59 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to wear armor"); |
|
|
60 | if (!QUERY_FLAG (op, FLAG_USE_WEAPON)) |
|
|
61 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to use weapons"); |
|
|
62 | |
|
|
63 | return 1; |
|
|
64 | } |
|
|
65 | |
|
|
66 | |
|
|
67 | int |
|
|
68 | command_motd (object *op, char *params) |
|
|
69 | { |
|
|
70 | display_motd (op); |
|
|
71 | return 1; |
|
|
72 | } |
|
|
73 | |
|
|
74 | int |
|
|
75 | command_bug (object *op, char *params) |
|
|
76 | { |
|
|
77 | char buf[MAX_BUF]; |
|
|
78 | |
|
|
79 | if (params == NULL) |
|
|
80 | { |
|
|
81 | new_draw_info (NDI_UNIQUE, 0, op, "what bugs?"); |
|
|
82 | return 1; |
|
|
83 | } |
|
|
84 | strcpy (buf, op->name); |
|
|
85 | strcat (buf, " bug-reports: "); |
|
|
86 | strncat (buf, ++params, MAX_BUF - strlen (buf)); |
|
|
87 | buf[MAX_BUF - 1] = '\0'; |
|
|
88 | bug_report (buf); |
|
|
89 | LOG (llevError, "%s\n", buf); |
|
|
90 | new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
|
|
91 | new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!"); |
|
|
92 | return 1; |
|
|
93 | } |
|
|
94 | |
|
|
95 | /* |
|
|
96 | * Pretty much identical to current map_info, but on a bigger scale |
|
|
97 | * This function returns the name of the players current region, and |
|
|
98 | * a description of it. It is there merely for flavour text. |
|
|
99 | */ |
|
|
100 | void |
|
|
101 | current_region_info (object *op) |
|
|
102 | { |
|
|
103 | if (region *reg = op->region ()) |
|
|
104 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s.\n%s", reg->longname, ®->msg); |
|
|
105 | } |
|
|
106 | |
|
|
107 | void |
|
|
108 | current_map_info (object *op) |
|
|
109 | { |
|
|
110 | maptile *m = op->map; |
|
|
111 | |
|
|
112 | if (!m) |
|
|
113 | return; |
|
|
114 | |
|
|
115 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, &op->region ()->name); |
|
|
116 | |
|
|
117 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
118 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
119 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
|
|
120 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
|
|
121 | |
|
|
122 | if (m->msg) |
|
|
123 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
|
|
124 | } |
|
|
125 | |
|
|
126 | #ifdef DEBUG_MALLOC_LEVEL |
|
|
127 | int |
|
|
128 | command_malloc_verify (object *op, char *parms) |
|
|
129 | { |
|
|
130 | extern int malloc_verify (void); |
|
|
131 | |
|
|
132 | if (!malloc_verify ()) |
|
|
133 | new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
|
|
134 | else |
|
|
135 | new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
|
|
136 | return 1; |
|
|
137 | } |
|
|
138 | #endif |
|
|
139 | |
|
|
140 | int |
|
|
141 | command_whereabouts (object *op, char *params) |
|
|
142 | { |
|
|
143 | //TODO: should obviously not waste space in struct region for this. |
|
|
144 | /* |
|
|
145 | * reset the counter on the region, then use it to store the number of |
|
|
146 | * players there. |
|
|
147 | * I don't know how thread-safe this would be, I suspect not very.... |
|
|
148 | */ |
|
|
149 | for (region *reg = first_region; reg; reg = reg->next) |
|
|
150 | reg->counter = 0; |
|
|
151 | |
|
|
152 | for_all_players (pl) |
|
|
153 | if (pl->ob->map) |
|
|
154 | ++pl->ob->region ()->counter; |
|
|
155 | |
|
|
156 | /* we only want to print out by places with a 'longname' field... */ |
|
|
157 | for (region *reg = first_region; reg; reg = reg->next) |
|
|
158 | { |
|
|
159 | if (reg->longname == NULL && reg->counter > 0) |
|
|
160 | { |
|
|
161 | if (reg->parent) |
|
|
162 | { |
|
|
163 | reg->parent->counter += reg->counter; |
|
|
164 | reg->counter = 0; |
|
|
165 | } |
|
|
166 | else /*uh oh, we shouldn't be here. */ |
|
|
167 | LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", ®->name); |
|
|
168 | } |
|
|
169 | } |
|
|
170 | |
|
|
171 | new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
|
|
172 | |
|
|
173 | for (region *reg = first_region; reg; reg = reg->next) |
|
|
174 | if (reg->counter) |
|
|
175 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, reg->longname); |
|
|
176 | |
|
|
177 | return 1; |
|
|
178 | } |
|
|
179 | |
30 | |
180 | typedef struct |
31 | typedef struct |
181 | { |
32 | { |
182 | char namebuf[MAX_BUF]; |
33 | char namebuf[MAX_BUF]; |
183 | int login_order; |
34 | int login_order; |
184 | } chars_names; |
35 | } chars_names; |
185 | |
36 | |
186 | int |
37 | int |
187 | command_afk (object *op, char *params) |
|
|
188 | { |
|
|
189 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
|
|
190 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
191 | else |
|
|
192 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
193 | |
|
|
194 | return 1; |
|
|
195 | } |
|
|
196 | |
|
|
197 | int |
|
|
198 | command_mapinfo (object *op, char *params) |
|
|
199 | { |
|
|
200 | current_map_info (op); |
|
|
201 | return 1; |
|
|
202 | } |
|
|
203 | |
|
|
204 | int |
|
|
205 | command_whereami (object *op, char *params) |
|
|
206 | { |
|
|
207 | current_region_info (op); |
|
|
208 | return 1; |
|
|
209 | } |
|
|
210 | |
|
|
211 | int |
|
|
212 | command_time (object *op, char *params) |
38 | command_time (object *op, char *params) |
213 | { |
39 | { |
214 | print_tod (op); |
40 | print_tod (op); |
215 | return 1; |
|
|
216 | } |
|
|
217 | |
|
|
218 | int |
|
|
219 | command_weather (object *op, char *params) |
|
|
220 | { |
|
|
221 | #if 0 |
|
|
222 | int wx, wy, temp, sky; |
|
|
223 | char buf[MAX_BUF]; |
|
|
224 | |
|
|
225 | if (settings.dynamiclevel < 1) |
|
|
226 | return 1; |
|
|
227 | |
|
|
228 | if (op->map == NULL) |
|
|
229 | return 1; |
|
|
230 | |
|
|
231 | if (worldmap_to_weathermap (op->x, op->y, &wx, &wy, op->map) != 0) |
|
|
232 | return 1; |
|
|
233 | |
|
|
234 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
235 | { |
|
|
236 | /* dump the weather, Dm style! Yo! */ |
|
|
237 | new_draw_info_format (NDI_UNIQUE, 0, op, "Real temp: %d", real_world_temperature (op->x, op->y, op->map)); |
|
|
238 | new_draw_info_format (NDI_UNIQUE, 0, op, "Base temp: %d", weathermap[wx][wy].temp); |
|
|
239 | new_draw_info_format (NDI_UNIQUE, 0, op, "Humid: %d", weathermap[wx][wy].humid); |
|
|
240 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wind: dir=%d speed=%d", weathermap[wx][wy].winddir, weathermap[wx][wy].windspeed); |
|
|
241 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pressure: %d", weathermap[wx][wy].pressure); |
|
|
242 | new_draw_info_format (NDI_UNIQUE, 0, op, "Avg Elevation: %d", weathermap[wx][wy].avgelev); |
|
|
243 | new_draw_info_format (NDI_UNIQUE, 0, op, "Rainfall: %d Water: %d", weathermap[wx][wy].rainfall, weathermap[wx][wy].water); |
|
|
244 | } |
|
|
245 | |
|
|
246 | temp = real_world_temperature (op->x, op->y, op->map); |
|
|
247 | new_draw_info_format (NDI_UNIQUE, 0, op, "It's currently %d degrees " "Centigrade out.", temp); |
|
|
248 | |
|
|
249 | /* humid */ |
|
|
250 | if (weathermap[wx][wy].humid < 20) |
|
|
251 | new_draw_info (NDI_UNIQUE, 0, op, "It is very dry."); |
|
|
252 | else if (weathermap[wx][wy].humid < 40) |
|
|
253 | new_draw_info (NDI_UNIQUE, 0, op, "It is very comfortable today."); |
|
|
254 | else if (weathermap[wx][wy].humid < 60) |
|
|
255 | new_draw_info (NDI_UNIQUE, 0, op, "It is a bit muggy."); |
|
|
256 | else if (weathermap[wx][wy].humid < 80) |
|
|
257 | new_draw_info (NDI_UNIQUE, 0, op, "It is muggy."); |
|
|
258 | else |
|
|
259 | new_draw_info (NDI_UNIQUE, 0, op, "It is uncomfortably muggy."); |
|
|
260 | |
|
|
261 | /* wind */ |
|
|
262 | switch (weathermap[wx][wy].winddir) |
|
|
263 | { |
|
|
264 | case 1: |
|
|
265 | sprintf (buf, "north"); |
|
|
266 | break; |
|
|
267 | case 2: |
|
|
268 | sprintf (buf, "northeast"); |
|
|
269 | break; |
|
|
270 | case 3: |
|
|
271 | sprintf (buf, "east"); |
|
|
272 | break; |
|
|
273 | case 4: |
|
|
274 | sprintf (buf, "southeast"); |
|
|
275 | break; |
|
|
276 | case 5: |
|
|
277 | sprintf (buf, "south"); |
|
|
278 | break; |
|
|
279 | case 6: |
|
|
280 | sprintf (buf, "southwest"); |
|
|
281 | break; |
|
|
282 | case 7: |
|
|
283 | sprintf (buf, "west"); |
|
|
284 | break; |
|
|
285 | case 8: |
|
|
286 | sprintf (buf, "northwest"); |
|
|
287 | break; |
|
|
288 | } |
|
|
289 | if (weathermap[wx][wy].windspeed < 5) |
|
|
290 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a mild breeze " "coming from the %s.", buf); |
|
|
291 | else if (weathermap[wx][wy].windspeed < 10) |
|
|
292 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong breeze " "coming from the %s.", buf); |
|
|
293 | else if (weathermap[wx][wy].windspeed < 15) |
|
|
294 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a light wind " "coming from the %s.", buf); |
|
|
295 | else if (weathermap[wx][wy].windspeed < 25) |
|
|
296 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong wind " "coming from the %s.", buf); |
|
|
297 | else if (weathermap[wx][wy].windspeed < 35) |
|
|
298 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a heavy wind " "coming from the %s.", buf); |
|
|
299 | else |
|
|
300 | new_draw_info_format (NDI_UNIQUE, 0, op, "The wind from the %s is " "incredibly strong!", buf); |
|
|
301 | |
|
|
302 | sky = weathermap[wx][wy].sky; |
|
|
303 | if (temp <= 0 && sky > SKY_OVERCAST && sky < SKY_FOG) |
|
|
304 | sky += 10; /*let it snow */ |
|
|
305 | switch (sky) |
|
|
306 | { |
|
|
307 | case SKY_CLEAR: |
|
|
308 | new_draw_info (NDI_UNIQUE, 0, op, "There isn''t a cloud in the sky."); |
|
|
309 | break; |
|
|
310 | case SKY_LIGHTCLOUD: |
|
|
311 | new_draw_info (NDI_UNIQUE, 0, op, "There are a few light clouds in the sky."); |
|
|
312 | break; |
|
|
313 | case SKY_OVERCAST: |
|
|
314 | new_draw_info (NDI_UNIQUE, 0, op, "The sky is cloudy and dreary."); |
|
|
315 | break; |
|
|
316 | case SKY_LIGHT_RAIN: |
|
|
317 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining softly."); |
|
|
318 | break; |
|
|
319 | case SKY_RAIN: |
|
|
320 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining."); |
|
|
321 | break; |
|
|
322 | case SKY_HEAVY_RAIN: |
|
|
323 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining heavily."); |
|
|
324 | break; |
|
|
325 | case SKY_HURRICANE: |
|
|
326 | new_draw_info (NDI_UNIQUE, 0, op, "There is a heavy storm! You should go inside!"); |
|
|
327 | break; |
|
|
328 | case SKY_FOG: |
|
|
329 | new_draw_info (NDI_UNIQUE, 0, op, "It''s foggy and miserable."); |
|
|
330 | break; |
|
|
331 | case SKY_HAIL: |
|
|
332 | new_draw_info (NDI_UNIQUE, 0, op, "It''s hailing out! Take cover!"); |
|
|
333 | break; |
|
|
334 | case SKY_LIGHT_SNOW: |
|
|
335 | new_draw_info (NDI_UNIQUE, 0, op, "Snow is gently falling from the sky."); |
|
|
336 | break; |
|
|
337 | case SKY_SNOW: |
|
|
338 | new_draw_info (NDI_UNIQUE, 0, op, "It''s snowing out."); |
|
|
339 | break; |
|
|
340 | case SKY_HEAVY_SNOW: |
|
|
341 | new_draw_info (NDI_UNIQUE, 0, op, "The snow is falling very heavily now."); |
|
|
342 | break; |
|
|
343 | case SKY_BLIZZARD: |
|
|
344 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
|
|
345 | break; |
|
|
346 | } |
|
|
347 | #endif |
|
|
348 | return 1; |
|
|
349 | } |
|
|
350 | |
|
|
351 | int |
|
|
352 | command_archs (object *op, char *params) |
|
|
353 | { |
|
|
354 | arch_info (op); |
|
|
355 | return 1; |
|
|
356 | } |
|
|
357 | |
|
|
358 | int |
|
|
359 | command_hiscore (object *op, char *params) |
|
|
360 | { |
|
|
361 | display_high_score (op, op == NULL ? 9999 : 50, params); |
|
|
362 | return 1; |
41 | return 1; |
363 | } |
42 | } |
364 | |
43 | |
365 | int |
44 | int |
366 | command_debug (object *op, char *params) |
45 | command_debug (object *op, char *params) |
… | |
… | |
372 | { |
51 | { |
373 | sprintf (buf, "Global debug level is %d.", settings.debug); |
52 | sprintf (buf, "Global debug level is %d.", settings.debug); |
374 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
53 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
375 | return 1; |
54 | return 1; |
376 | } |
55 | } |
377 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
56 | |
378 | { |
57 | settings.debug = i; |
379 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
58 | |
380 | return 1; |
|
|
381 | } |
|
|
382 | settings.debug = (enum LogLevel) FABS (i); |
|
|
383 | sprintf (buf, "Set debug level to %d.", i); |
59 | sprintf (buf, "Set debug level to %d.", i); |
384 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
385 | return 1; |
61 | return 1; |
386 | } |
62 | } |
387 | |
63 | |
… | |
… | |
403 | } |
79 | } |
404 | return 0; |
80 | return 0; |
405 | } |
81 | } |
406 | |
82 | |
407 | int |
83 | int |
408 | command_dumpfriendlyobjects (object *op, char *params) |
|
|
409 | { |
|
|
410 | dump_friendly_objects (); |
|
|
411 | return 0; |
|
|
412 | } |
|
|
413 | |
|
|
414 | int |
|
|
415 | command_printlos (object *op, char *params) |
|
|
416 | { |
|
|
417 | if (op) |
|
|
418 | print_los (op); |
|
|
419 | return 0; |
|
|
420 | } |
|
|
421 | |
|
|
422 | |
|
|
423 | int |
|
|
424 | command_version (object *op, char *params) |
84 | command_version (object *op, char *params) |
425 | { |
85 | { |
426 | version (op); |
86 | version (op); |
427 | return 0; |
87 | return 0; |
428 | } |
|
|
429 | |
|
|
430 | #ifndef BUG_LOG |
|
|
431 | # define BUG_LOG "bug_log" |
|
|
432 | #endif |
|
|
433 | void |
|
|
434 | bug_report (const char *reportstring) |
|
|
435 | { |
|
|
436 | FILE *fp; |
|
|
437 | |
|
|
438 | if ((fp = fopen (BUG_LOG, "a")) != NULL) |
|
|
439 | { |
|
|
440 | fprintf (fp, "%s\n", reportstring); |
|
|
441 | fclose (fp); |
|
|
442 | } |
|
|
443 | else |
|
|
444 | { |
|
|
445 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
|
|
446 | } |
|
|
447 | } |
|
|
448 | |
|
|
449 | int |
|
|
450 | command_output_sync (object *op, char *params) |
|
|
451 | { |
|
|
452 | int val; |
|
|
453 | |
|
|
454 | if (!params) |
|
|
455 | { |
|
|
456 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
457 | return 1; |
|
|
458 | } |
|
|
459 | val = atoi (params); |
|
|
460 | if (val > 0) |
|
|
461 | { |
|
|
462 | op->contr->outputs_sync = val; |
|
|
463 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
464 | } |
|
|
465 | else |
|
|
466 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
467 | |
|
|
468 | return 1; |
|
|
469 | } |
|
|
470 | |
|
|
471 | int |
|
|
472 | command_output_count (object *op, char *params) |
|
|
473 | { |
|
|
474 | int val; |
|
|
475 | |
|
|
476 | if (!params) |
|
|
477 | { |
|
|
478 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
479 | return 1; |
|
|
480 | } |
|
|
481 | val = atoi (params); |
|
|
482 | if (val > 0) |
|
|
483 | { |
|
|
484 | op->contr->outputs_count = val; |
|
|
485 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
486 | } |
|
|
487 | else |
|
|
488 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
489 | |
|
|
490 | return 1; |
|
|
491 | } |
|
|
492 | |
|
|
493 | int |
|
|
494 | command_listen (object *op, char *params) |
|
|
495 | { |
|
|
496 | int i; |
|
|
497 | |
|
|
498 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
499 | { |
|
|
500 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
501 | return 1; |
|
|
502 | } |
|
|
503 | op->contr->listening = (char) i; |
|
|
504 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
505 | return 1; |
|
|
506 | } |
88 | } |
507 | |
89 | |
508 | /* Prints out some useful information for the character. Everything we print |
90 | /* Prints out some useful information for the character. Everything we print |
509 | * out can be determined by the docs, so we aren't revealing anything extra - |
91 | * out can be determined by the docs, so we aren't revealing anything extra - |
510 | * rather, we are making it convenient to find the values. params have |
92 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
513 | int |
95 | int |
514 | command_statistics (object *pl, char *params) |
96 | command_statistics (object *pl, char *params) |
515 | { |
97 | { |
516 | if (!pl->contr) |
98 | if (!pl->contr) |
517 | return 1; |
99 | return 1; |
518 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
|
|
519 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
|
|
520 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
521 | |
100 | |
522 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
101 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
523 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
102 | |
524 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
103 | msg << " Experience: " << pl->stats.exp << '\n' |
525 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
104 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
526 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
105 | << "\n Stat Nat/Real/Max\n"; |
527 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
106 | |
528 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
107 | for (int i = 0; i < NUM_STATS; ++i) |
529 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
108 | 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)); |
530 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
109 | |
531 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
110 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
532 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
111 | |
533 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
112 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
534 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
|
|
535 | pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->clone.stats.Cha); |
|
|
536 | new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
|
|
537 | |
113 | |
538 | /* Can't think of anything else to print right now */ |
114 | /* Can't think of anything else to print right now */ |
539 | return 0; |
115 | return 0; |
540 | } |
116 | } |
541 | |
117 | |
542 | int |
118 | int |
543 | command_fix_me (object *op, char *params) |
119 | command_fix_me (object *op, char *params) |
544 | { |
120 | { |
545 | sum_weight (op); |
121 | op->update_weight (); |
546 | op->update_stats (); |
122 | op->update_stats (); |
547 | return 1; |
123 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
548 | } |
|
|
549 | |
124 | |
550 | int |
|
|
551 | command_logs (object *op, char *params) |
|
|
552 | { |
|
|
553 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
554 | |
|
|
555 | return 1; |
|
|
556 | } |
|
|
557 | |
|
|
558 | int |
|
|
559 | command_applymode (object *op, char *params) |
|
|
560 | { |
|
|
561 | unapplymode unapply = op->contr->unapply; |
|
|
562 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
563 | |
|
|
564 | if (!params) |
|
|
565 | { |
|
|
566 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
567 | return 1; |
|
|
568 | } |
|
|
569 | |
|
|
570 | if (!strcmp (params, "nochoice")) |
|
|
571 | op->contr->unapply = unapply_nochoice; |
|
|
572 | else if (!strcmp (params, "never")) |
|
|
573 | op->contr->unapply = unapply_never; |
|
|
574 | else if (!strcmp (params, "always")) |
|
|
575 | op->contr->unapply = unapply_always; |
|
|
576 | else |
|
|
577 | { |
|
|
578 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
579 | return 0; |
|
|
580 | } |
|
|
581 | |
|
|
582 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
583 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
584 | return 1; |
125 | return 1; |
585 | } |
126 | } |
586 | |
127 | |
587 | int |
128 | int |
588 | command_bowmode (object *op, char *params) |
129 | command_bowmode (object *op, char *params) |
589 | { |
130 | { |
590 | bowtype_t oldtype = op->contr->bowtype; |
131 | bowtype_t oldtype = op->contr->bowtype; |
591 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
132 | static const char *const types[] = { |
|
|
133 | "normal", "threewide", "spreadshot", "firenorth", |
592 | "firene", "fireeast", "firese", "firesouth", |
134 | "firene", "fireeast", "firese", "firesouth", |
593 | "firesw", "firewest", "firenw", "bestarrow" |
135 | "firesw", "firewest", "firenw", "bestarrow" |
594 | }; |
136 | }; |
595 | char buf[MAX_BUF]; |
137 | char buf[MAX_BUF]; |
596 | int i, found; |
138 | int i, found; |
… | |
… | |
612 | } |
154 | } |
613 | |
155 | |
614 | if (!found) |
156 | if (!found) |
615 | { |
157 | { |
616 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
158 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
159 | |
617 | for (i = 0; i <= bow_bestarrow; i++) |
160 | for (i = 0; i <= bow_bestarrow; i++) |
618 | { |
161 | { |
619 | strcat (buf, " "); |
162 | strcat (buf, " "); |
620 | strcat (buf, types[i]); |
163 | strcat (buf, types[i]); |
621 | if (i < bow_nw) |
164 | if (i < bow_nw) |
… | |
… | |
630 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
173 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
631 | return 1; |
174 | return 1; |
632 | } |
175 | } |
633 | |
176 | |
634 | int |
177 | int |
635 | command_petmode (object *op, char *params) |
|
|
636 | { |
|
|
637 | petmode_t oldtype = op->contr->petmode; |
|
|
638 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
639 | |
|
|
640 | if (!params) |
|
|
641 | { |
|
|
642 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
643 | return 1; |
|
|
644 | } |
|
|
645 | |
|
|
646 | if (!strcmp (params, "normal")) |
|
|
647 | op->contr->petmode = pet_normal; |
|
|
648 | else if (!strcmp (params, "sad")) |
|
|
649 | op->contr->petmode = pet_sad; |
|
|
650 | else if (!strcmp (params, "defend")) |
|
|
651 | op->contr->petmode = pet_defend; |
|
|
652 | else if (!strcmp (params, "arena")) |
|
|
653 | op->contr->petmode = pet_arena; |
|
|
654 | else |
|
|
655 | { |
|
|
656 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
657 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
658 | return 0; |
|
|
659 | } |
|
|
660 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
661 | return 1; |
|
|
662 | } |
|
|
663 | |
|
|
664 | int |
|
|
665 | command_showpets (object *op, char *params) |
178 | command_showpets (object *op, char *params) |
666 | { |
179 | { |
667 | objectlink *obl, *next; |
|
|
668 | int counter = 0, target = 0; |
180 | int counter = 0, target = 0; |
669 | int have_shown_pet = 0; |
181 | int have_shown_pet = 0; |
670 | |
182 | |
|
|
183 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
184 | |
671 | if (params != NULL) |
185 | if (params) |
672 | target = atoi (params); |
186 | target = atoi (params); |
|
|
187 | |
673 | for (obl = first_friendly_object; obl != NULL; obl = next) |
188 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
674 | { |
189 | { |
675 | object *ob = obl->ob; |
190 | object *ob = obl->ob; |
676 | |
191 | |
677 | next = obl->next; |
|
|
678 | if (ob->owner == op) |
192 | if (ob->owner == op) |
679 | { |
193 | { |
680 | if (target == 0) |
194 | if (target == 0) |
681 | { |
195 | { |
682 | if (counter == 0) |
196 | if (counter == 0) |
683 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
197 | msg << "T<Pets>\n\n"; |
|
|
198 | |
684 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
199 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
685 | } |
200 | } |
686 | else if (!have_shown_pet && ++counter == target) |
201 | else if (!have_shown_pet && ++counter == target) |
687 | { |
202 | { |
688 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
203 | msg.printf ("T<%s>\n\n" |
689 | 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); |
204 | " level %d\n" |
690 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
205 | " %d/%d HP, %d/%d SP\n" |
691 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
206 | " Str %2d\n" |
692 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
207 | " Dex %2d\n" |
693 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
208 | " Con %2d\n" |
694 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
209 | " Int %2d\n" |
695 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
210 | " Wis %2d\n" |
696 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
211 | " Cha %2d\n" |
697 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
212 | " Pow %2d\n" |
698 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
213 | " wc %d damage %d ac %d\n", |
|
|
214 | &ob->name, |
|
|
215 | &ob->name, |
|
|
216 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
217 | ob->stats.Str, |
|
|
218 | ob->stats.Dex, |
|
|
219 | ob->stats.Con, |
|
|
220 | ob->stats.Int, |
|
|
221 | ob->stats.Wis, |
|
|
222 | ob->stats.Cha, |
|
|
223 | ob->stats.Pow, |
|
|
224 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
225 | |
699 | have_shown_pet = 1; |
226 | have_shown_pet = 1; |
700 | } |
227 | } |
701 | } |
228 | } |
702 | } |
229 | } |
|
|
230 | |
703 | if (counter == 0) |
231 | if (counter == 0) |
704 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
232 | msg << "you have no pets."; |
705 | else if (target != 0 && have_shown_pet == 0) |
233 | else if (target != 0 && have_shown_pet == 0) |
706 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
234 | msg << "no such pet."; |
707 | return 0; |
|
|
708 | } |
|
|
709 | |
235 | |
710 | int |
236 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
711 | command_usekeys (object *op, char *params) |
|
|
712 | { |
|
|
713 | usekeytype oldtype = op->contr->usekeys; |
|
|
714 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
715 | |
237 | |
716 | if (!params) |
|
|
717 | { |
|
|
718 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
719 | return 1; |
|
|
720 | } |
|
|
721 | |
|
|
722 | if (!strcmp (params, "inventory")) |
|
|
723 | op->contr->usekeys = key_inventory; |
|
|
724 | else if (!strcmp (params, "keyrings")) |
|
|
725 | op->contr->usekeys = keyrings; |
|
|
726 | else if (!strcmp (params, "containers")) |
|
|
727 | op->contr->usekeys = containers; |
|
|
728 | else |
|
|
729 | { |
|
|
730 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
731 | return 0; |
|
|
732 | } |
|
|
733 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
734 | return 1; |
238 | return 0; |
735 | } |
239 | } |
736 | |
240 | |
737 | int |
241 | int |
738 | command_resistances (object *op, char *params) |
242 | command_resistances (object *op, char *params) |
739 | { |
243 | { |
740 | int i; |
244 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
741 | |
245 | |
742 | if (!op) |
246 | msg << "Resistances:\n\n"; |
743 | return 0; |
|
|
744 | |
247 | |
745 | for (i = 0; i < NROFATTACKS; i++) |
248 | for (int i = 0; i < NROFATTACKS; i++) |
746 | { |
|
|
747 | if (i == ATNR_INTERNAL) |
249 | if (i != ATNR_INTERNAL) |
748 | continue; |
250 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
749 | |
|
|
750 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
751 | } |
|
|
752 | |
251 | |
753 | /* If dragon player, let's display natural resistances */ |
252 | /* If dragon player, let's display natural resistances */ |
754 | if (is_dragon_pl (op)) |
253 | if (is_dragon_pl (op)) |
755 | { |
|
|
756 | int attack; |
|
|
757 | object *tmp; |
|
|
758 | |
|
|
759 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
254 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
760 | { |
|
|
761 | if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
255 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
762 | { |
256 | { |
763 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
257 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
258 | |
764 | for (attack = 0; attack < NROFATTACKS; attack++) |
259 | for (int attack = 0; attack < NROFATTACKS; attack++) |
765 | { |
|
|
766 | if (atnr_is_dragon_enabled (attack)) |
260 | if (atnr_is_dragon_enabled (attack)) |
767 | { |
261 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
768 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
262 | |
769 | } |
|
|
770 | } |
|
|
771 | break; |
263 | break; |
772 | } |
264 | } |
773 | } |
265 | |
774 | } |
266 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
775 | |
267 | |
776 | return 0; |
268 | return 0; |
777 | } |
269 | } |
778 | |
270 | |
779 | /* |
271 | /* |
780 | * Actual commands. |
272 | * Actual commands. |
781 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
273 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
782 | */ |
274 | */ |
783 | |
|
|
784 | |
|
|
785 | static void |
|
|
786 | help_topics (object *op, int what) |
|
|
787 | { |
|
|
788 | DIR *dirp; |
|
|
789 | struct dirent *de; |
|
|
790 | char filename[MAX_BUF], line[80]; |
|
|
791 | int namelen, linelen = 0; |
|
|
792 | |
|
|
793 | switch (what) |
|
|
794 | { |
|
|
795 | case 1: |
|
|
796 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
797 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
798 | break; |
|
|
799 | case 3: |
|
|
800 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
801 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
802 | break; |
|
|
803 | default: |
|
|
804 | sprintf (filename, "%s/help", settings.datadir); |
|
|
805 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
806 | break; |
|
|
807 | } |
|
|
808 | |
|
|
809 | if (!(dirp = opendir (filename))) |
|
|
810 | return; |
|
|
811 | |
|
|
812 | line[0] = '\0'; |
|
|
813 | while (de = readdir (dirp)) |
|
|
814 | { |
|
|
815 | namelen = strlen (de->d_name); |
|
|
816 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
817 | continue; |
|
|
818 | linelen += namelen + 1; |
|
|
819 | if (linelen > 42) |
|
|
820 | { |
|
|
821 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
822 | sprintf (line, " %s", de->d_name); |
|
|
823 | linelen = namelen + 1; |
|
|
824 | continue; |
|
|
825 | } |
|
|
826 | strcat (line, " "); |
|
|
827 | strcat (line, de->d_name); |
|
|
828 | } |
|
|
829 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
830 | closedir (dirp); |
|
|
831 | } |
|
|
832 | |
|
|
833 | static void |
|
|
834 | show_commands (object *op, int what) |
|
|
835 | { |
|
|
836 | char line[80]; |
|
|
837 | int i, size, namelen, linelen = 0; |
|
|
838 | CommArray_s *ap; |
|
|
839 | extern CommArray_s Commands[], WizCommands[]; |
|
|
840 | extern const int CommandsSize, WizCommandsSize; |
|
|
841 | |
|
|
842 | switch (what) |
|
|
843 | { |
|
|
844 | case 1: |
|
|
845 | ap = WizCommands; |
|
|
846 | size = WizCommandsSize; |
|
|
847 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
848 | break; |
|
|
849 | case 2: |
|
|
850 | ap = CommunicationCommands; |
|
|
851 | size = CommunicationCommandSize; |
|
|
852 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
853 | break; |
|
|
854 | default: |
|
|
855 | ap = Commands; |
|
|
856 | size = CommandsSize; |
|
|
857 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
858 | break; |
|
|
859 | } |
|
|
860 | |
|
|
861 | line[0] = '\0'; |
|
|
862 | for (i = 0; i < size; i++) |
|
|
863 | { |
|
|
864 | namelen = strlen (ap[i].name); |
|
|
865 | linelen += namelen + 1; |
|
|
866 | if (linelen > 42) |
|
|
867 | { |
|
|
868 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
869 | sprintf (line, " %s", ap[i].name); |
|
|
870 | linelen = namelen + 1; |
|
|
871 | continue; |
|
|
872 | } |
|
|
873 | strcat (line, " "); |
|
|
874 | strcat (line, ap[i].name); |
|
|
875 | } |
|
|
876 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
877 | } |
|
|
878 | |
|
|
879 | |
|
|
880 | int |
|
|
881 | command_help (object *op, char *params) |
|
|
882 | { |
|
|
883 | struct stat st; |
|
|
884 | FILE *fp; |
|
|
885 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
886 | int len; |
|
|
887 | |
|
|
888 | if (op != NULL) |
|
|
889 | clear_win_info (op); |
|
|
890 | |
|
|
891 | /* |
|
|
892 | * Main help page? |
|
|
893 | */ |
|
|
894 | if (!params) |
|
|
895 | { |
|
|
896 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
897 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
898 | { |
|
|
899 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
900 | return 0; |
|
|
901 | } |
|
|
902 | while (fgets (line, MAX_BUF, fp)) |
|
|
903 | { |
|
|
904 | line[MAX_BUF - 1] = '\0'; |
|
|
905 | len = strlen (line) - 1; |
|
|
906 | if (line[len] == '\n') |
|
|
907 | line[len] = '\0'; |
|
|
908 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
909 | } |
|
|
910 | fclose (fp); |
|
|
911 | return 0; |
|
|
912 | } |
|
|
913 | |
|
|
914 | /* |
|
|
915 | * Topics list |
|
|
916 | */ |
|
|
917 | if (!strcmp (params, "topics")) |
|
|
918 | { |
|
|
919 | help_topics (op, 3); |
|
|
920 | help_topics (op, 0); |
|
|
921 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
922 | help_topics (op, 1); |
|
|
923 | return 0; |
|
|
924 | } |
|
|
925 | |
|
|
926 | /* |
|
|
927 | * Commands list |
|
|
928 | */ |
|
|
929 | if (!strcmp (params, "commands")) |
|
|
930 | { |
|
|
931 | show_commands (op, 0); |
|
|
932 | show_commands (op, 2); /* show comm commands */ |
|
|
933 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
934 | show_commands (op, 1); |
|
|
935 | return 0; |
|
|
936 | } |
|
|
937 | |
|
|
938 | /* |
|
|
939 | * User wants info about command |
|
|
940 | */ |
|
|
941 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
942 | { |
|
|
943 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
944 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
945 | return 0; |
|
|
946 | } |
|
|
947 | |
|
|
948 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
949 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
950 | { |
|
|
951 | if (op) |
|
|
952 | { |
|
|
953 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
954 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
955 | { |
|
|
956 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
957 | { |
|
|
958 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
959 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
960 | goto nohelp; |
|
|
961 | } |
|
|
962 | else |
|
|
963 | goto nohelp; |
|
|
964 | } |
|
|
965 | } |
|
|
966 | } |
|
|
967 | |
|
|
968 | /* |
|
|
969 | * Found that. Just cat it to screen. |
|
|
970 | */ |
|
|
971 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
972 | { |
|
|
973 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
974 | return 0; |
|
|
975 | } |
|
|
976 | sprintf (line, "Help about '%s'", params); |
|
|
977 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
978 | while (fgets (line, MAX_BUF, fp)) |
|
|
979 | { |
|
|
980 | line[MAX_BUF - 1] = '\0'; |
|
|
981 | len = strlen (line) - 1; |
|
|
982 | if (line[len] == '\n') |
|
|
983 | line[len] = '\0'; |
|
|
984 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
985 | } |
|
|
986 | fclose (fp); |
|
|
987 | return 0; |
|
|
988 | |
|
|
989 | /* |
|
|
990 | * No_help -escape |
|
|
991 | */ |
|
|
992 | nohelp: |
|
|
993 | sprintf (line, "No help available on '%s'", params); |
|
|
994 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
995 | return 0; |
|
|
996 | } |
|
|
997 | |
|
|
998 | |
275 | |
999 | int |
276 | int |
1000 | onoff_value (const char *line) |
277 | onoff_value (const char *line) |
1001 | { |
278 | { |
1002 | int i; |
279 | int i; |
… | |
… | |
1025 | return 0; |
302 | return 0; |
1026 | } |
303 | } |
1027 | } |
304 | } |
1028 | |
305 | |
1029 | int |
306 | int |
1030 | command_sound (object *op, char *params) |
|
|
1031 | { |
|
|
1032 | if (op->contr->ns->sound) |
|
|
1033 | { |
|
|
1034 | op->contr->ns->sound = 0; |
|
|
1035 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1036 | } |
|
|
1037 | else |
|
|
1038 | { |
|
|
1039 | op->contr->ns->sound = 1; |
|
|
1040 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1041 | } |
|
|
1042 | |
|
|
1043 | return 1; |
|
|
1044 | } |
|
|
1045 | |
|
|
1046 | int |
|
|
1047 | command_title (object *op, char *params) |
307 | command_title (object *op, char *params) |
1048 | { |
308 | { |
1049 | char buf[MAX_BUF]; |
309 | char buf[MAX_BUF]; |
1050 | |
310 | |
1051 | if (settings.set_title == FALSE) |
311 | if (settings.set_title == FALSE) |
… | |
… | |
1088 | strcpy (op->contr->own_title, params); |
348 | strcpy (op->contr->own_title, params); |
1089 | return 1; |
349 | return 1; |
1090 | } |
350 | } |
1091 | |
351 | |
1092 | int |
352 | int |
1093 | command_peaceful (object *op, char *params) |
|
|
1094 | { |
|
|
1095 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1096 | "You cannot change your peaceful setting with this command." |
|
|
1097 | " Please speak to the priest in the temple of Gorokh" |
|
|
1098 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1099 | |
|
|
1100 | /* |
|
|
1101 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1102 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1103 | else |
|
|
1104 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1105 | */ |
|
|
1106 | return 1; |
|
|
1107 | } |
|
|
1108 | |
|
|
1109 | int |
|
|
1110 | command_wimpy (object *op, char *params) |
|
|
1111 | { |
|
|
1112 | int i; |
|
|
1113 | char buf[MAX_BUF]; |
|
|
1114 | |
|
|
1115 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1116 | { |
|
|
1117 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1118 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1119 | return 1; |
|
|
1120 | } |
|
|
1121 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1122 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1123 | op->run_away = i; |
|
|
1124 | return 1; |
|
|
1125 | } |
|
|
1126 | |
|
|
1127 | int |
|
|
1128 | command_brace (object *op, char *params) |
|
|
1129 | { |
|
|
1130 | if (!params) |
|
|
1131 | op->contr->braced = !op->contr->braced; |
|
|
1132 | else |
|
|
1133 | op->contr->braced = onoff_value (params); |
|
|
1134 | |
|
|
1135 | if (op->contr->braced) |
|
|
1136 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1137 | else |
|
|
1138 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1139 | |
|
|
1140 | op->update_stats (); |
|
|
1141 | return 0; |
|
|
1142 | } |
|
|
1143 | |
|
|
1144 | int |
|
|
1145 | command_kill_pets (object *op, char *params) |
353 | command_kill_pets (object *op, char *params) |
1146 | { |
354 | { |
1147 | objectlink *obl, *next; |
355 | objectlink *obl, *next; |
1148 | int counter = 0, removecount = 0; |
356 | int counter = 0, removecount = 0; |
1149 | |
357 | |
1150 | if (params == NULL) |
358 | if (!params) |
1151 | { |
359 | { |
1152 | terminate_all_pets (op); |
360 | terminate_all_pets (op); |
1153 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
361 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1154 | } |
362 | } |
1155 | else |
363 | else |
1156 | { |
364 | { |
1157 | int target = atoi (params); |
365 | int target = atoi (params); |
1158 | |
366 | |
1159 | for (obl = first_friendly_object; obl != NULL; obl = next) |
367 | for (obl = first_friendly_object; obl; obl = next) |
1160 | { |
368 | { |
1161 | object *ob = obl->ob; |
369 | object *ob = obl->ob; |
1162 | |
370 | |
1163 | next = obl->next; |
371 | next = obl->next; |
|
|
372 | |
1164 | if (ob->owner == op) |
373 | if (ob->owner == op) |
1165 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
374 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1166 | { |
375 | { |
1167 | ob->destroy (); |
376 | ob->destroy (); |
1168 | removecount++; |
377 | removecount++; |
1169 | } |
378 | } |
1170 | } |
379 | } |
|
|
380 | |
1171 | if (removecount != 0) |
381 | if (removecount != 0) |
1172 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
382 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1173 | else |
383 | else |
1174 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
384 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1175 | } |
385 | } |
|
|
386 | |
1176 | return 0; |
387 | return 0; |
1177 | } |
388 | } |