1 |
elmex |
1.1 |
/* |
2 |
root |
1.59 |
* This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 |
pippijn |
1.36 |
* |
4 |
root |
1.59 |
* Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 |
|
|
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 |
|
|
* Copyright (©) 1992,2007 Frank Tore Johansen |
7 |
pippijn |
1.36 |
* |
8 |
root |
1.59 |
* Crossfire TRT is free software; you can redistribute it and/or modify it |
9 |
|
|
* under the terms of the GNU General Public License as published by the Free |
10 |
|
|
* Software Foundation; either version 2 of the License, or (at your option) |
11 |
|
|
* any later version. |
12 |
pippijn |
1.36 |
* |
13 |
root |
1.59 |
* This program is distributed in the hope that it will be useful, but |
14 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16 |
|
|
* for more details. |
17 |
pippijn |
1.36 |
* |
18 |
root |
1.59 |
* You should have received a copy of the GNU General Public License along |
19 |
|
|
* with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
20 |
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 |
|
|
* |
22 |
|
|
* The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 |
pippijn |
1.36 |
*/ |
24 |
elmex |
1.1 |
|
25 |
|
|
#include <global.h> |
26 |
|
|
#include <loader.h> |
27 |
root |
1.21 |
#include <sproto.h> |
28 |
|
|
|
29 |
pippijn |
1.55 |
/* Handles misc. input request - things like hash table, malloc, maps, etc */ |
30 |
elmex |
1.1 |
|
31 |
root |
1.7 |
int |
32 |
|
|
command_motd (object *op, char *params) |
33 |
elmex |
1.1 |
{ |
34 |
root |
1.7 |
display_motd (op); |
35 |
|
|
return 1; |
36 |
elmex |
1.1 |
} |
37 |
|
|
|
38 |
|
|
#ifdef DEBUG_MALLOC_LEVEL |
39 |
root |
1.7 |
int |
40 |
|
|
command_malloc_verify (object *op, char *parms) |
41 |
elmex |
1.1 |
{ |
42 |
root |
1.7 |
extern int malloc_verify (void); |
43 |
pippijn |
1.54 |
|
44 |
root |
1.7 |
if (!malloc_verify ()) |
45 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
46 |
|
|
else |
47 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
48 |
|
|
return 1; |
49 |
|
|
} |
50 |
elmex |
1.1 |
#endif |
51 |
|
|
|
52 |
root |
1.7 |
int |
53 |
|
|
command_whereabouts (object *op, char *params) |
54 |
|
|
{ |
55 |
root |
1.38 |
//TODO: should obviously not waste space in struct region for this. |
56 |
root |
1.7 |
/* |
57 |
|
|
* reset the counter on the region, then use it to store the number of |
58 |
|
|
* players there. |
59 |
|
|
* I don't know how thread-safe this would be, I suspect not very.... |
60 |
|
|
*/ |
61 |
root |
1.41 |
for_all_regions (rgn) |
62 |
|
|
rgn->counter = 0; |
63 |
root |
1.38 |
|
64 |
root |
1.28 |
for_all_players (pl) |
65 |
root |
1.38 |
if (pl->ob->map) |
66 |
|
|
++pl->ob->region ()->counter; |
67 |
root |
1.7 |
|
68 |
|
|
/* we only want to print out by places with a 'longname' field... */ |
69 |
root |
1.41 |
for_all_regions (rgn) |
70 |
root |
1.7 |
{ |
71 |
root |
1.41 |
if (!rgn->longname && rgn->counter > 0) |
72 |
root |
1.7 |
{ |
73 |
root |
1.41 |
if (rgn->parent) |
74 |
root |
1.7 |
{ |
75 |
root |
1.41 |
rgn->parent->counter += rgn->counter; |
76 |
|
|
rgn->counter = 0; |
77 |
root |
1.3 |
} |
78 |
root |
1.7 |
else /*uh oh, we shouldn't be here. */ |
79 |
root |
1.41 |
LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &rgn->name); |
80 |
root |
1.3 |
} |
81 |
|
|
} |
82 |
root |
1.38 |
|
83 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
84 |
root |
1.38 |
|
85 |
root |
1.41 |
for_all_regions (rgn) |
86 |
|
|
if (rgn->counter) |
87 |
root |
1.44 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname); |
88 |
root |
1.38 |
|
89 |
root |
1.7 |
return 1; |
90 |
elmex |
1.1 |
} |
91 |
|
|
|
92 |
|
|
typedef struct |
93 |
root |
1.7 |
{ |
94 |
|
|
char namebuf[MAX_BUF]; |
95 |
|
|
int login_order; |
96 |
|
|
} chars_names; |
97 |
elmex |
1.1 |
|
98 |
root |
1.7 |
int |
99 |
|
|
command_time (object *op, char *params) |
100 |
elmex |
1.1 |
{ |
101 |
root |
1.2 |
print_tod (op); |
102 |
|
|
return 1; |
103 |
|
|
} |
104 |
elmex |
1.1 |
|
105 |
root |
1.7 |
int |
106 |
|
|
command_weather (object *op, char *params) |
107 |
elmex |
1.1 |
{ |
108 |
root |
1.33 |
#if 0 |
109 |
root |
1.7 |
int wx, wy, temp, sky; |
110 |
|
|
char buf[MAX_BUF]; |
111 |
|
|
|
112 |
|
|
if (settings.dynamiclevel < 1) |
113 |
|
|
return 1; |
114 |
|
|
|
115 |
|
|
if (op->map == NULL) |
116 |
|
|
return 1; |
117 |
|
|
|
118 |
|
|
if (worldmap_to_weathermap (op->x, op->y, &wx, &wy, op->map) != 0) |
119 |
|
|
return 1; |
120 |
|
|
|
121 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
122 |
|
|
{ |
123 |
|
|
/* dump the weather, Dm style! Yo! */ |
124 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Real temp: %d", real_world_temperature (op->x, op->y, op->map)); |
125 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Base temp: %d", weathermap[wx][wy].temp); |
126 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Humid: %d", weathermap[wx][wy].humid); |
127 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Wind: dir=%d speed=%d", weathermap[wx][wy].winddir, weathermap[wx][wy].windspeed); |
128 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Pressure: %d", weathermap[wx][wy].pressure); |
129 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Avg Elevation: %d", weathermap[wx][wy].avgelev); |
130 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Rainfall: %d Water: %d", weathermap[wx][wy].rainfall, weathermap[wx][wy].water); |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
temp = real_world_temperature (op->x, op->y, op->map); |
134 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "It's currently %d degrees " "Centigrade out.", temp); |
135 |
|
|
|
136 |
|
|
/* humid */ |
137 |
|
|
if (weathermap[wx][wy].humid < 20) |
138 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is very dry."); |
139 |
|
|
else if (weathermap[wx][wy].humid < 40) |
140 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is very comfortable today."); |
141 |
|
|
else if (weathermap[wx][wy].humid < 60) |
142 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is a bit muggy."); |
143 |
|
|
else if (weathermap[wx][wy].humid < 80) |
144 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is muggy."); |
145 |
|
|
else |
146 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is uncomfortably muggy."); |
147 |
elmex |
1.1 |
|
148 |
root |
1.7 |
/* wind */ |
149 |
|
|
switch (weathermap[wx][wy].winddir) |
150 |
|
|
{ |
151 |
|
|
case 1: |
152 |
|
|
sprintf (buf, "north"); |
153 |
|
|
break; |
154 |
|
|
case 2: |
155 |
|
|
sprintf (buf, "northeast"); |
156 |
|
|
break; |
157 |
|
|
case 3: |
158 |
|
|
sprintf (buf, "east"); |
159 |
|
|
break; |
160 |
|
|
case 4: |
161 |
|
|
sprintf (buf, "southeast"); |
162 |
|
|
break; |
163 |
|
|
case 5: |
164 |
|
|
sprintf (buf, "south"); |
165 |
|
|
break; |
166 |
|
|
case 6: |
167 |
|
|
sprintf (buf, "southwest"); |
168 |
|
|
break; |
169 |
|
|
case 7: |
170 |
|
|
sprintf (buf, "west"); |
171 |
|
|
break; |
172 |
|
|
case 8: |
173 |
|
|
sprintf (buf, "northwest"); |
174 |
|
|
break; |
175 |
|
|
} |
176 |
|
|
if (weathermap[wx][wy].windspeed < 5) |
177 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a mild breeze " "coming from the %s.", buf); |
178 |
|
|
else if (weathermap[wx][wy].windspeed < 10) |
179 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong breeze " "coming from the %s.", buf); |
180 |
|
|
else if (weathermap[wx][wy].windspeed < 15) |
181 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a light wind " "coming from the %s.", buf); |
182 |
|
|
else if (weathermap[wx][wy].windspeed < 25) |
183 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong wind " "coming from the %s.", buf); |
184 |
|
|
else if (weathermap[wx][wy].windspeed < 35) |
185 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a heavy wind " "coming from the %s.", buf); |
186 |
|
|
else |
187 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "The wind from the %s is " "incredibly strong!", buf); |
188 |
elmex |
1.1 |
|
189 |
root |
1.7 |
sky = weathermap[wx][wy].sky; |
190 |
|
|
if (temp <= 0 && sky > SKY_OVERCAST && sky < SKY_FOG) |
191 |
|
|
sky += 10; /*let it snow */ |
192 |
|
|
switch (sky) |
193 |
|
|
{ |
194 |
|
|
case SKY_CLEAR: |
195 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There isn''t a cloud in the sky."); |
196 |
|
|
break; |
197 |
|
|
case SKY_LIGHTCLOUD: |
198 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There are a few light clouds in the sky."); |
199 |
|
|
break; |
200 |
|
|
case SKY_OVERCAST: |
201 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The sky is cloudy and dreary."); |
202 |
|
|
break; |
203 |
|
|
case SKY_LIGHT_RAIN: |
204 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining softly."); |
205 |
|
|
break; |
206 |
|
|
case SKY_RAIN: |
207 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining."); |
208 |
|
|
break; |
209 |
|
|
case SKY_HEAVY_RAIN: |
210 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining heavily."); |
211 |
|
|
break; |
212 |
|
|
case SKY_HURRICANE: |
213 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There is a heavy storm! You should go inside!"); |
214 |
|
|
break; |
215 |
|
|
case SKY_FOG: |
216 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s foggy and miserable."); |
217 |
|
|
break; |
218 |
|
|
case SKY_HAIL: |
219 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s hailing out! Take cover!"); |
220 |
|
|
break; |
221 |
|
|
case SKY_LIGHT_SNOW: |
222 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Snow is gently falling from the sky."); |
223 |
|
|
break; |
224 |
|
|
case SKY_SNOW: |
225 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s snowing out."); |
226 |
|
|
break; |
227 |
|
|
case SKY_HEAVY_SNOW: |
228 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The snow is falling very heavily now."); |
229 |
|
|
break; |
230 |
|
|
case SKY_BLIZZARD: |
231 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
232 |
|
|
break; |
233 |
elmex |
1.1 |
} |
234 |
root |
1.33 |
#endif |
235 |
root |
1.7 |
return 1; |
236 |
elmex |
1.1 |
} |
237 |
|
|
|
238 |
root |
1.7 |
int |
239 |
|
|
command_hiscore (object *op, char *params) |
240 |
elmex |
1.1 |
{ |
241 |
root |
1.7 |
display_high_score (op, op == NULL ? 9999 : 50, params); |
242 |
|
|
return 1; |
243 |
|
|
} |
244 |
elmex |
1.1 |
|
245 |
root |
1.7 |
int |
246 |
|
|
command_debug (object *op, char *params) |
247 |
elmex |
1.1 |
{ |
248 |
root |
1.7 |
int i; |
249 |
|
|
char buf[MAX_BUF]; |
250 |
|
|
|
251 |
|
|
if (params == NULL || !sscanf (params, "%d", &i)) |
252 |
|
|
{ |
253 |
|
|
sprintf (buf, "Global debug level is %d.", settings.debug); |
254 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
255 |
elmex |
1.1 |
return 1; |
256 |
|
|
} |
257 |
root |
1.58 |
|
258 |
|
|
settings.debug = i; |
259 |
|
|
|
260 |
root |
1.7 |
sprintf (buf, "Set debug level to %d.", i); |
261 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
262 |
|
|
return 1; |
263 |
|
|
} |
264 |
elmex |
1.1 |
|
265 |
|
|
|
266 |
|
|
/* |
267 |
|
|
* Those dumps should be just one dump with good parser |
268 |
|
|
*/ |
269 |
|
|
|
270 |
root |
1.7 |
int |
271 |
|
|
command_dumpbelow (object *op, char *params) |
272 |
elmex |
1.1 |
{ |
273 |
root |
1.7 |
if (op && op->below) |
274 |
|
|
{ |
275 |
root |
1.14 |
char *dump = dump_object (op->below); |
276 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, dump); |
277 |
|
|
free (dump); |
278 |
elmex |
1.1 |
/* Let's push that item on the dm's stack */ |
279 |
root |
1.7 |
dm_stack_push (op->contr, op->below->count); |
280 |
|
|
} |
281 |
elmex |
1.1 |
return 0; |
282 |
|
|
} |
283 |
|
|
|
284 |
root |
1.7 |
int |
285 |
|
|
command_dumpfriendlyobjects (object *op, char *params) |
286 |
elmex |
1.1 |
{ |
287 |
root |
1.7 |
dump_friendly_objects (); |
288 |
elmex |
1.1 |
return 0; |
289 |
|
|
} |
290 |
|
|
|
291 |
root |
1.7 |
int |
292 |
|
|
command_printlos (object *op, char *params) |
293 |
elmex |
1.1 |
{ |
294 |
|
|
if (op) |
295 |
root |
1.7 |
print_los (op); |
296 |
elmex |
1.1 |
return 0; |
297 |
|
|
} |
298 |
|
|
|
299 |
|
|
|
300 |
root |
1.7 |
int |
301 |
|
|
command_version (object *op, char *params) |
302 |
elmex |
1.1 |
{ |
303 |
root |
1.7 |
version (op); |
304 |
|
|
return 0; |
305 |
elmex |
1.1 |
} |
306 |
|
|
|
307 |
|
|
#ifndef BUG_LOG |
308 |
root |
1.7 |
# define BUG_LOG "bug_log" |
309 |
elmex |
1.1 |
#endif |
310 |
root |
1.7 |
void |
311 |
|
|
bug_report (const char *reportstring) |
312 |
|
|
{ |
313 |
|
|
FILE *fp; |
314 |
|
|
|
315 |
|
|
if ((fp = fopen (BUG_LOG, "a")) != NULL) |
316 |
|
|
{ |
317 |
|
|
fprintf (fp, "%s\n", reportstring); |
318 |
|
|
fclose (fp); |
319 |
|
|
} |
320 |
|
|
else |
321 |
|
|
{ |
322 |
|
|
LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
323 |
elmex |
1.1 |
} |
324 |
root |
1.7 |
} |
325 |
|
|
|
326 |
elmex |
1.1 |
/* Prints out some useful information for the character. Everything we print |
327 |
|
|
* out can be determined by the docs, so we aren't revealing anything extra - |
328 |
|
|
* rather, we are making it convenient to find the values. params have |
329 |
|
|
* no meaning here. |
330 |
|
|
*/ |
331 |
root |
1.7 |
int |
332 |
|
|
command_statistics (object *pl, char *params) |
333 |
elmex |
1.1 |
{ |
334 |
root |
1.7 |
if (!pl->contr) |
335 |
|
|
return 1; |
336 |
root |
1.18 |
new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
337 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
338 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
339 |
elmex |
1.1 |
|
340 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
341 |
root |
1.61 |
pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->stats.Str); |
342 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
343 |
root |
1.61 |
pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->stats.Dex); |
344 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
345 |
root |
1.61 |
pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->stats.Con); |
346 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
347 |
root |
1.61 |
pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->stats.Int); |
348 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
349 |
root |
1.61 |
pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->stats.Wis); |
350 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
351 |
root |
1.61 |
pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->stats.Pow); |
352 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
353 |
root |
1.61 |
pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->stats.Cha); |
354 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
355 |
elmex |
1.1 |
|
356 |
root |
1.7 |
/* Can't think of anything else to print right now */ |
357 |
|
|
return 0; |
358 |
elmex |
1.1 |
} |
359 |
|
|
|
360 |
root |
1.7 |
int |
361 |
|
|
command_fix_me (object *op, char *params) |
362 |
elmex |
1.1 |
{ |
363 |
root |
1.7 |
sum_weight (op); |
364 |
root |
1.27 |
op->update_stats (); |
365 |
pippijn |
1.51 |
new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
366 |
|
|
|
367 |
root |
1.7 |
return 1; |
368 |
elmex |
1.1 |
} |
369 |
|
|
|
370 |
root |
1.7 |
int |
371 |
|
|
command_logs (object *op, char *params) |
372 |
elmex |
1.1 |
{ |
373 |
root |
1.10 |
new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
374 |
elmex |
1.1 |
|
375 |
root |
1.7 |
return 1; |
376 |
elmex |
1.1 |
} |
377 |
|
|
|
378 |
root |
1.7 |
int |
379 |
|
|
command_bowmode (object *op, char *params) |
380 |
elmex |
1.1 |
{ |
381 |
root |
1.7 |
bowtype_t oldtype = op->contr->bowtype; |
382 |
|
|
static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
383 |
|
|
"firene", "fireeast", "firese", "firesouth", |
384 |
|
|
"firesw", "firewest", "firenw", "bestarrow" |
385 |
|
|
}; |
386 |
|
|
char buf[MAX_BUF]; |
387 |
|
|
int i, found; |
388 |
|
|
|
389 |
|
|
if (!params) |
390 |
|
|
{ |
391 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode is set to %s", types[op->contr->bowtype]); |
392 |
|
|
return 1; |
393 |
|
|
} |
394 |
|
|
|
395 |
|
|
for (i = 0, found = 0; i <= bow_bestarrow; i++) |
396 |
|
|
{ |
397 |
|
|
if (!strcmp (params, types[i])) |
398 |
|
|
{ |
399 |
|
|
found++; |
400 |
|
|
op->contr->bowtype = (bowtype_t) i; |
401 |
|
|
break; |
402 |
root |
1.3 |
} |
403 |
elmex |
1.1 |
} |
404 |
root |
1.38 |
|
405 |
root |
1.7 |
if (!found) |
406 |
|
|
{ |
407 |
|
|
sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
408 |
|
|
for (i = 0; i <= bow_bestarrow; i++) |
409 |
|
|
{ |
410 |
|
|
strcat (buf, " "); |
411 |
|
|
strcat (buf, types[i]); |
412 |
|
|
if (i < bow_nw) |
413 |
|
|
strcat (buf, ","); |
414 |
|
|
else |
415 |
|
|
strcat (buf, "."); |
416 |
root |
1.3 |
} |
417 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
418 |
|
|
return 0; |
419 |
elmex |
1.1 |
} |
420 |
root |
1.38 |
|
421 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
422 |
|
|
return 1; |
423 |
elmex |
1.1 |
} |
424 |
|
|
|
425 |
root |
1.7 |
int |
426 |
|
|
command_showpets (object *op, char *params) |
427 |
elmex |
1.1 |
{ |
428 |
root |
1.7 |
objectlink *obl, *next; |
429 |
|
|
int counter = 0, target = 0; |
430 |
|
|
int have_shown_pet = 0; |
431 |
|
|
|
432 |
|
|
if (params != NULL) |
433 |
|
|
target = atoi (params); |
434 |
|
|
for (obl = first_friendly_object; obl != NULL; obl = next) |
435 |
|
|
{ |
436 |
|
|
object *ob = obl->ob; |
437 |
|
|
|
438 |
|
|
next = obl->next; |
439 |
root |
1.22 |
if (ob->owner == op) |
440 |
root |
1.7 |
{ |
441 |
|
|
if (target == 0) |
442 |
|
|
{ |
443 |
|
|
if (counter == 0) |
444 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
445 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
446 |
|
|
} |
447 |
|
|
else if (!have_shown_pet && ++counter == target) |
448 |
|
|
{ |
449 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
450 |
|
|
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); |
451 |
|
|
/* this is not a nice way to do this, it should be made to be more like the statistics command */ |
452 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
453 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
454 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
455 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
456 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
457 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
458 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
459 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
460 |
|
|
have_shown_pet = 1; |
461 |
root |
1.3 |
} |
462 |
|
|
} |
463 |
elmex |
1.1 |
} |
464 |
root |
1.7 |
if (counter == 0) |
465 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
466 |
|
|
else if (target != 0 && have_shown_pet == 0) |
467 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
468 |
|
|
return 0; |
469 |
elmex |
1.1 |
} |
470 |
|
|
|
471 |
root |
1.7 |
int |
472 |
|
|
command_resistances (object *op, char *params) |
473 |
elmex |
1.1 |
{ |
474 |
root |
1.7 |
int i; |
475 |
elmex |
1.1 |
|
476 |
root |
1.7 |
if (!op) |
477 |
|
|
return 0; |
478 |
|
|
|
479 |
|
|
for (i = 0; i < NROFATTACKS; i++) |
480 |
|
|
{ |
481 |
|
|
if (i == ATNR_INTERNAL) |
482 |
|
|
continue; |
483 |
elmex |
1.1 |
|
484 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
485 |
elmex |
1.1 |
} |
486 |
|
|
|
487 |
root |
1.7 |
/* If dragon player, let's display natural resistances */ |
488 |
|
|
if (is_dragon_pl (op)) |
489 |
|
|
{ |
490 |
|
|
int attack; |
491 |
|
|
object *tmp; |
492 |
|
|
|
493 |
|
|
for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
494 |
elmex |
1.1 |
{ |
495 |
root |
1.60 |
if ((tmp->type == FORCE) && (strcmp (tmp->arch->archname, "dragon_skin_force") == 0)) |
496 |
elmex |
1.1 |
{ |
497 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
498 |
|
|
for (attack = 0; attack < NROFATTACKS; attack++) |
499 |
elmex |
1.1 |
{ |
500 |
root |
1.7 |
if (atnr_is_dragon_enabled (attack)) |
501 |
elmex |
1.1 |
{ |
502 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
503 |
elmex |
1.1 |
} |
504 |
|
|
} |
505 |
root |
1.7 |
break; |
506 |
elmex |
1.1 |
} |
507 |
|
|
} |
508 |
root |
1.7 |
} |
509 |
elmex |
1.1 |
|
510 |
root |
1.7 |
return 0; |
511 |
elmex |
1.1 |
} |
512 |
root |
1.7 |
|
513 |
elmex |
1.1 |
/* |
514 |
|
|
* Actual commands. |
515 |
|
|
* Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
516 |
|
|
*/ |
517 |
|
|
|
518 |
root |
1.7 |
int |
519 |
|
|
onoff_value (const char *line) |
520 |
elmex |
1.1 |
{ |
521 |
|
|
int i; |
522 |
|
|
|
523 |
root |
1.7 |
if (sscanf (line, "%d", &i)) |
524 |
elmex |
1.1 |
return (i != 0); |
525 |
root |
1.7 |
switch (line[0]) |
526 |
|
|
{ |
527 |
|
|
case 'o': |
528 |
|
|
switch (line[1]) |
529 |
|
|
{ |
530 |
|
|
case 'n': |
531 |
|
|
return 1; /* on */ |
532 |
|
|
default: |
533 |
|
|
return 0; /* o[ff] */ |
534 |
|
|
} |
535 |
|
|
case 'y': /* y[es] */ |
536 |
|
|
case 'k': /* k[ylla] */ |
537 |
|
|
case 's': |
538 |
|
|
case 'd': |
539 |
|
|
return 1; |
540 |
|
|
case 'n': /* n[o] */ |
541 |
|
|
case 'e': /* e[i] */ |
542 |
|
|
case 'u': |
543 |
|
|
default: |
544 |
|
|
return 0; |
545 |
|
|
} |
546 |
elmex |
1.1 |
} |
547 |
|
|
|
548 |
root |
1.7 |
int |
549 |
|
|
command_title (object *op, char *params) |
550 |
elmex |
1.1 |
{ |
551 |
root |
1.7 |
char buf[MAX_BUF]; |
552 |
|
|
|
553 |
|
|
if (settings.set_title == FALSE) |
554 |
|
|
{ |
555 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
556 |
|
|
return 1; |
557 |
elmex |
1.1 |
} |
558 |
root |
1.7 |
|
559 |
|
|
/* dragon players cannot change titles */ |
560 |
|
|
if (is_dragon_pl (op)) |
561 |
|
|
{ |
562 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
563 |
|
|
return 1; |
564 |
|
|
} |
565 |
|
|
|
566 |
|
|
if (params == NULL) |
567 |
|
|
{ |
568 |
|
|
if (op->contr->own_title[0] == '\0') |
569 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->title); |
570 |
|
|
else |
571 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->own_title); |
572 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
573 |
|
|
return 1; |
574 |
|
|
} |
575 |
|
|
if (strcmp (params, "clear") == 0 || strcmp (params, "default") == 0) |
576 |
|
|
{ |
577 |
|
|
if (op->contr->own_title[0] == '\0') |
578 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your title is the default title."); |
579 |
|
|
else |
580 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title set to default."); |
581 |
|
|
op->contr->own_title[0] = '\0'; |
582 |
|
|
return 1; |
583 |
|
|
} |
584 |
|
|
|
585 |
|
|
if ((int) strlen (params) >= MAX_NAME) |
586 |
|
|
{ |
587 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
588 |
|
|
return 1; |
589 |
|
|
} |
590 |
|
|
strcpy (op->contr->own_title, params); |
591 |
|
|
return 1; |
592 |
elmex |
1.1 |
} |
593 |
|
|
|
594 |
root |
1.7 |
int |
595 |
|
|
command_kill_pets (object *op, char *params) |
596 |
elmex |
1.1 |
{ |
597 |
root |
1.7 |
objectlink *obl, *next; |
598 |
|
|
int counter = 0, removecount = 0; |
599 |
|
|
|
600 |
root |
1.57 |
if (!params) |
601 |
root |
1.7 |
{ |
602 |
|
|
terminate_all_pets (op); |
603 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
604 |
|
|
} |
605 |
|
|
else |
606 |
|
|
{ |
607 |
|
|
int target = atoi (params); |
608 |
|
|
|
609 |
root |
1.57 |
for (obl = first_friendly_object; obl; obl = next) |
610 |
root |
1.7 |
{ |
611 |
|
|
object *ob = obl->ob; |
612 |
|
|
|
613 |
|
|
next = obl->next; |
614 |
root |
1.56 |
|
615 |
root |
1.22 |
if (ob->owner == op) |
616 |
root |
1.7 |
if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
617 |
|
|
{ |
618 |
root |
1.20 |
ob->destroy (); |
619 |
root |
1.3 |
removecount++; |
620 |
root |
1.7 |
} |
621 |
root |
1.3 |
} |
622 |
root |
1.56 |
|
623 |
root |
1.7 |
if (removecount != 0) |
624 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
625 |
|
|
else |
626 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
627 |
elmex |
1.1 |
} |
628 |
root |
1.56 |
|
629 |
root |
1.7 |
return 0; |
630 |
elmex |
1.1 |
} |