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 (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | 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, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * |
20 | |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
|
|
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #ifndef __CEXTRACT__ |
|
|
26 | # include <sproto.h> |
25 | #include <sproto.h> |
27 | #endif |
|
|
28 | #include <spells.h> |
26 | #include <spells.h> |
29 | #include <treasure.h> |
27 | #include <treasure.h> |
30 | #include <skills.h> |
28 | #include <skills.h> |
31 | |
29 | |
32 | /** Defines for DM item stack **/ |
30 | /** Defines for DM item stack **/ |
… | |
… | |
87 | op->contr->hidden = 0; |
85 | op->contr->hidden = 0; |
88 | op->invisible = 1; |
86 | op->invisible = 1; |
89 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
87 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
90 | op->map->players++; |
88 | op->map->players++; |
91 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
89 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
|
|
90 | |
92 | if (!silent_dm) |
91 | if (!silent_dm) |
93 | { |
|
|
94 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
92 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
95 | } |
|
|
96 | } |
93 | } |
97 | else |
94 | else |
98 | { |
95 | { |
99 | op->contr->hidden = 1; |
96 | op->contr->hidden = 1; |
100 | new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you."); |
97 | new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you."); |
101 | op->map->players--; |
98 | op->map->players--; |
|
|
99 | |
102 | if (!silent_dm) |
100 | if (!silent_dm) |
103 | { |
|
|
104 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); |
101 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); |
105 | } |
102 | |
106 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name); |
103 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name); |
107 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name); |
104 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name); |
108 | } |
105 | } |
109 | } |
106 | } |
110 | |
107 | |
… | |
… | |
174 | |
171 | |
175 | become_follower (ob, god); |
172 | become_follower (ob, god); |
176 | return 1; |
173 | return 1; |
177 | } |
174 | } |
178 | |
175 | |
179 | /** |
176 | // TODO: Rewrite banish in perl and get rid of the following two functions |
180 | * Add player's IP to ban_file and kick them off the server |
|
|
181 | * I know most people have dynamic IPs but this is more of a short term |
|
|
182 | * solution if they have to get a new IP to play maybe they'll calm down. |
|
|
183 | * This uses the banish_file in the local directory *not* the ban_file |
|
|
184 | * The action is logged with a ! for easy searching. -tm |
|
|
185 | */ |
|
|
186 | int |
|
|
187 | command_banish (object *op, char *params) |
|
|
188 | { |
|
|
189 | player *pl; |
|
|
190 | FILE *banishfile; |
|
|
191 | char buf[MAX_BUF]; |
|
|
192 | time_t now; |
|
|
193 | |
|
|
194 | if (!params) |
|
|
195 | { |
|
|
196 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: banish <player>."); |
|
|
197 | return 1; |
|
|
198 | } |
|
|
199 | |
|
|
200 | pl = get_other_player_from_name (op, params); |
|
|
201 | if (!pl) |
|
|
202 | return 1; |
|
|
203 | |
|
|
204 | sprintf (buf, "%s/%s", settings.localdir, BANISHFILE); |
|
|
205 | |
|
|
206 | if ((banishfile = fopen (buf, "a")) == NULL) |
|
|
207 | { |
|
|
208 | LOG (llevDebug, "Could not find file banish_file.\n"); |
|
|
209 | new_draw_info (NDI_UNIQUE, 0, op, "Could not find banish_file."); |
|
|
210 | return 0; |
|
|
211 | } |
|
|
212 | |
|
|
213 | now = time (NULL); |
|
|
214 | /* |
|
|
215 | * Record this as a comment - then we don't have to worry about changing |
|
|
216 | * the parsing code. |
|
|
217 | */ |
|
|
218 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now)); |
|
|
219 | fprintf (banishfile, "*@%s\n", pl->ns->host); |
|
|
220 | fclose (banishfile); |
|
|
221 | |
|
|
222 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host); |
|
|
223 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name); |
|
|
224 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name); |
|
|
225 | command_kick (op, (char *) &pl->ob->name); |
|
|
226 | return 1; |
|
|
227 | } |
|
|
228 | |
|
|
229 | int |
177 | int |
230 | command_kick (object *op, char *params) |
178 | command_kick (object *op, char *params) |
231 | { |
179 | { |
232 | for_all_players (pl) |
180 | for_all_players (pl) |
233 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
181 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
234 | { |
182 | { |
235 | object *op = pl->ob; |
183 | object *plop = pl->ob; |
236 | |
184 | |
237 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
185 | if (!QUERY_FLAG (plop, FLAG_REMOVED) && !QUERY_FLAG (plop, FLAG_FREED)) |
238 | { |
186 | { |
239 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
187 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &plop->name); |
240 | strcpy (op->contr->killer, "kicked"); |
188 | plop->contr->killer = op; |
241 | } |
189 | } |
242 | |
190 | |
243 | pl->ns->destroy (); |
191 | pl->ns->destroy (); |
244 | } |
192 | } |
245 | |
193 | |
246 | return 1; |
194 | return 1; |
247 | } |
195 | } |
248 | |
196 | |
|
|
197 | //TODO |
|
|
198 | #if 0 |
249 | int |
199 | int |
250 | command_save_overlay (object *op, char *params) |
200 | command_save_overlay (object *op, char *params) |
251 | { |
201 | { |
252 | if (!op) |
202 | if (!op) |
253 | return 0; |
203 | return 0; |
… | |
… | |
264 | |
214 | |
265 | ready_map_name (op->map->path, 0); |
215 | ready_map_name (op->map->path, 0); |
266 | |
216 | |
267 | return 1; |
217 | return 1; |
268 | } |
218 | } |
269 | |
219 | #endif |
270 | int |
|
|
271 | command_shutdown (object *op, char *params) |
|
|
272 | { |
|
|
273 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
274 | { |
|
|
275 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
|
|
276 | return 1; |
|
|
277 | } |
|
|
278 | |
|
|
279 | cleanup (); |
|
|
280 | /* not reached */ |
|
|
281 | return 1; |
|
|
282 | } |
|
|
283 | |
220 | |
284 | int |
221 | int |
285 | command_freeze (object *op, char *params) |
222 | command_freeze (object *op, char *params) |
286 | { |
223 | { |
287 | int ticks; |
224 | int ticks; |
… | |
… | |
323 | object *dummy; |
260 | object *dummy; |
324 | player *pl; |
261 | player *pl; |
325 | |
262 | |
326 | if (!op) |
263 | if (!op) |
327 | return 0; |
264 | return 0; |
|
|
265 | |
328 | if (params == NULL) |
266 | if (params == NULL) |
329 | { |
267 | { |
330 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
268 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
331 | return 1; |
269 | return 1; |
332 | } |
270 | } |
|
|
271 | |
333 | pl = get_other_player_from_name (op, params); |
272 | pl = get_other_player_from_name (op, params); |
334 | if (!pl) |
273 | if (!pl) |
335 | return 1; |
274 | return 1; |
|
|
275 | |
336 | dummy = get_jail_exit (pl->ob); |
276 | dummy = get_jail_exit (pl->ob); |
337 | if (!dummy) |
277 | if (!dummy) |
338 | { |
278 | { |
339 | /* we have nowhere to send the prisoner.... */ |
279 | /* we have nowhere to send the prisoner.... */ |
340 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
280 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
341 | return 0; |
281 | return 0; |
342 | } |
282 | } |
343 | enter_exit (pl->ob, dummy); |
283 | |
|
|
284 | pl->ob->player_goto (dummy->slaying, dummy->stats.hp, dummy->stats.sp);//TODO |
344 | dummy->destroy (); |
285 | dummy->destroy (); |
|
|
286 | |
345 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
287 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
346 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
288 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
347 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
289 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
348 | return 1; |
290 | return 1; |
349 | } |
291 | } |
… | |
… | |
373 | { |
315 | { |
374 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
316 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
375 | return 1; |
317 | return 1; |
376 | } |
318 | } |
377 | |
319 | |
378 | dummy = object::create (); |
320 | pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]); |
379 | EXIT_PATH (dummy) = op->map->path; |
|
|
380 | EXIT_X (dummy) = op->x + freearr_x[i]; |
|
|
381 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
|
|
382 | enter_exit (pl->ob, dummy); |
|
|
383 | dummy->destroy (); |
|
|
384 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
321 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
385 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
322 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
386 | |
323 | |
387 | return 1; |
|
|
388 | } |
|
|
389 | |
|
|
390 | /** |
|
|
391 | * Teleport next to target player. |
|
|
392 | */ |
|
|
393 | |
|
|
394 | /* mids 01/16/2002 */ |
|
|
395 | int |
|
|
396 | command_teleport (object *op, char *params) |
|
|
397 | { |
|
|
398 | int i; |
|
|
399 | object *dummy; |
|
|
400 | player *pl; |
|
|
401 | |
|
|
402 | if (!op) |
|
|
403 | return 0; |
|
|
404 | |
|
|
405 | if (params == NULL) |
|
|
406 | { |
|
|
407 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: teleport <player>."); |
|
|
408 | return 1; |
|
|
409 | } |
|
|
410 | |
|
|
411 | pl = get_other_player_from_name (op, params); |
|
|
412 | if (!pl) |
|
|
413 | return 1; |
|
|
414 | |
|
|
415 | i = find_free_spot (pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9); |
|
|
416 | if (i == -1) |
|
|
417 | { |
|
|
418 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
|
|
419 | return 1; |
|
|
420 | } |
|
|
421 | |
|
|
422 | dummy = object::create (); |
|
|
423 | EXIT_PATH (dummy) = pl->ob->map->path; |
|
|
424 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
|
|
425 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
|
|
426 | enter_exit (op, dummy); |
|
|
427 | dummy->destroy (); |
|
|
428 | if (!op->contr->hidden) |
|
|
429 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
|
|
430 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
431 | return 1; |
324 | return 1; |
432 | } |
325 | } |
433 | |
326 | |
434 | /** |
327 | /** |
435 | * This function is a real mess, because we're stucking getting |
328 | * This function is a real mess, because we're stucking getting |
… | |
… | |
525 | * we also set up spell_name which is only |
418 | * we also set up spell_name which is only |
526 | * the first word. |
419 | * the first word. |
527 | */ |
420 | */ |
528 | |
421 | |
529 | at_spell = archetype::find (cp); |
422 | at_spell = archetype::find (cp); |
530 | if (!at_spell || at_spell->clone.type != SPELL) |
423 | if (!at_spell || at_spell->type != SPELL) |
531 | at_spell = find_archetype_by_object_name (cp); |
424 | at_spell = find_archetype_by_object_name (cp); |
532 | if (!at_spell || at_spell->clone.type != SPELL) |
425 | if (!at_spell || at_spell->type != SPELL) |
533 | { |
426 | { |
534 | strcpy (spell_name, cp); |
427 | assign (spell_name, cp); |
535 | fsp = strchr (spell_name, ' '); |
428 | fsp = strchr (spell_name, ' '); |
536 | if (fsp) |
429 | if (fsp) |
537 | { |
430 | { |
538 | *fsp = 0; |
431 | *fsp = 0; |
539 | fsp++; |
432 | fsp++; |
540 | at_spell = archetype::find (spell_name); |
433 | at_spell = archetype::find (spell_name); |
541 | |
434 | |
542 | /* Got a spell, update the first string pointer */ |
435 | /* Got a spell, update the first string pointer */ |
543 | if (at_spell && at_spell->clone.type == SPELL) |
436 | if (at_spell && at_spell->type == SPELL) |
544 | bp2 = cp + strlen (spell_name) + 1; |
437 | bp2 = cp + strlen (spell_name) + 1; |
545 | else |
438 | else |
546 | at_spell = NULL; |
439 | at_spell = NULL; |
547 | } |
440 | } |
548 | } |
441 | } |
… | |
… | |
550 | /* OK - we didn't find a spell - presume the 'of' |
443 | /* OK - we didn't find a spell - presume the 'of' |
551 | * in this case means its an artifact. |
444 | * in this case means its an artifact. |
552 | */ |
445 | */ |
553 | if (!at_spell) |
446 | if (!at_spell) |
554 | { |
447 | { |
555 | if (find_artifactlist (at->clone.type) == NULL) |
448 | if (find_artifactlist (at->type) == NULL) |
556 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); |
449 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->type); |
557 | else |
450 | else |
558 | { |
451 | { |
559 | art = find_artifactlist (at->clone.type)->items; |
452 | art = find_artifactlist (at->type)->items; |
560 | |
453 | |
561 | do |
454 | while (art) |
562 | { |
455 | { |
563 | if (!strcmp (art->item->name, cp)) |
456 | if (!strcmp (art->item->name, cp)) |
564 | break; |
457 | break; |
|
|
458 | |
565 | art = art->next; |
459 | art = art->next; |
566 | } |
460 | } |
567 | while (art != NULL); |
|
|
568 | |
461 | |
569 | if (!art) |
462 | if (!art) |
570 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); |
463 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->type, cp); |
571 | } |
464 | } |
572 | |
465 | |
573 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
466 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
574 | } |
467 | } |
575 | } /* if cp */ |
468 | } /* if cp */ |
576 | |
469 | |
577 | if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || |
470 | if ((at->type == ROD || at->type == WAND || at->type == SCROLL || |
578 | at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) |
471 | at->type == HORN || at->type == SPELLBOOK) && !at_spell) |
579 | { |
472 | { |
580 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp); |
473 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp); |
581 | return 1; |
474 | return 1; |
582 | } |
475 | } |
583 | |
476 | |
… | |
… | |
585 | * Rather than have two different blocks with a lot of similar code, |
478 | * Rather than have two different blocks with a lot of similar code, |
586 | * just create one object, do all the processing, and then determine |
479 | * just create one object, do all the processing, and then determine |
587 | * if that one object should be inserted or if we need to make copies. |
480 | * if that one object should be inserted or if we need to make copies. |
588 | */ |
481 | */ |
589 | tmp = arch_to_object (at); |
482 | tmp = arch_to_object (at); |
590 | |
|
|
591 | if (settings.real_wiz == FALSE) |
|
|
592 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
|
|
593 | |
483 | |
594 | if (set_magic) |
484 | if (set_magic) |
595 | set_abs_magic (tmp, magic); |
485 | set_abs_magic (tmp, magic); |
596 | |
486 | |
597 | if (art) |
487 | if (art) |
… | |
… | |
677 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
567 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
678 | |
568 | |
679 | bp2 = bp3 + 1; |
569 | bp2 = bp3 + 1; |
680 | } |
570 | } |
681 | |
571 | |
682 | if (at->clone.nrof) |
572 | if (at->nrof) |
683 | { |
573 | { |
684 | if (at_spell) |
574 | if (at_spell) |
685 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
575 | tmp->insert (arch_to_object (at_spell)); |
686 | |
576 | |
687 | tmp->x = op->x; |
577 | tmp->x = op->x; |
688 | tmp->y = op->y; |
578 | tmp->y = op->y; |
|
|
579 | tmp->map = op->map; |
689 | |
580 | |
690 | if (set_nrof) |
581 | if (set_nrof) |
691 | tmp->nrof = nrof; |
582 | tmp->nrof = nrof; |
692 | |
583 | |
693 | tmp->map = op->map; |
584 | op->insert (tmp); |
694 | |
|
|
695 | tmp = insert_ob_in_ob (tmp, op); |
|
|
696 | esrv_send_item (op, tmp); |
|
|
697 | |
585 | |
698 | /* Let's put this created item on stack so dm can access it easily. */ |
586 | /* Let's put this created item on stack so dm can access it easily. */ |
699 | dm_stack_push (op->contr, tmp->count); |
587 | dm_stack_push (op->contr, tmp->count); |
700 | |
588 | |
701 | return 1; |
589 | return 1; |
702 | } |
590 | } |
703 | else |
591 | else |
704 | { |
592 | { |
705 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
593 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
706 | { |
594 | { |
707 | archetype *atmp; |
|
|
708 | object *prev = 0, *head = 0; |
595 | object *prev = 0, *head = 0; |
709 | |
596 | |
710 | for (atmp = at; atmp; atmp = atmp->more) |
597 | for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more) |
711 | { |
598 | { |
712 | object *dup = arch_to_object (atmp); |
599 | object *dup = arch_to_object (atmp); |
713 | |
600 | |
714 | if (at_spell) |
601 | if (at_spell) |
715 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
602 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
… | |
… | |
722 | { |
609 | { |
723 | head = dup; |
610 | head = dup; |
724 | tmp->copy_to (dup); |
611 | tmp->copy_to (dup); |
725 | } |
612 | } |
726 | |
613 | |
727 | if (settings.real_wiz == FALSE) |
|
|
728 | SET_FLAG (dup, FLAG_WAS_WIZ); |
|
|
729 | |
|
|
730 | dup->x = op->x + dup->arch->clone.x; |
614 | dup->x = op->x + dup->arch->x; |
731 | dup->y = op->y + dup->arch->clone.y; |
615 | dup->y = op->y + dup->arch->y; |
732 | dup->map = op->map; |
616 | dup->map = op->map; |
733 | |
617 | |
734 | if (head != dup) |
618 | if (head != dup) |
735 | { |
619 | { |
736 | dup->head = head; |
620 | dup->head = head; |
… | |
… | |
746 | int size_x = 0; |
630 | int size_x = 0; |
747 | int size_y = 0; |
631 | int size_y = 0; |
748 | |
632 | |
749 | while (check) |
633 | while (check) |
750 | { |
634 | { |
751 | size_x = MAX (size_x, check->arch->clone.x); |
635 | size_x = MAX (size_x, check->arch->x); |
752 | size_y = MAX (size_y, check->arch->clone.y); |
636 | size_y = MAX (size_y, check->arch->y); |
753 | check = check->more; |
637 | check = check->more; |
754 | } |
638 | } |
755 | |
639 | |
756 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
640 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
757 | { |
641 | { |
… | |
… | |
783 | /* Wonder if we really want to push all of these, but since |
667 | /* Wonder if we really want to push all of these, but since |
784 | * things like rods have nrof 0, we want to cover those. |
668 | * things like rods have nrof 0, we want to cover those. |
785 | */ |
669 | */ |
786 | dm_stack_push (op->contr, head->count); |
670 | dm_stack_push (op->contr, head->count); |
787 | |
671 | |
788 | if (at->clone.randomitems != NULL && !at_spell) |
672 | if (at->randomitems && !at_spell) |
789 | create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); |
673 | create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0); |
790 | |
|
|
791 | esrv_send_item (op, head); |
|
|
792 | } |
674 | } |
793 | |
675 | |
794 | /* free the one we used to copy */ |
676 | /* free the one we used to copy */ |
795 | tmp->destroy (); |
677 | tmp->destroy (); |
796 | } |
678 | } |
… | |
… | |
803 | */ |
685 | */ |
804 | |
686 | |
805 | int |
687 | int |
806 | command_inventory (object *op, char *params) |
688 | command_inventory (object *op, char *params) |
807 | { |
689 | { |
|
|
690 | int i; |
808 | object *tmp; |
691 | object *tmp; |
809 | int i; |
|
|
810 | |
692 | |
811 | if (!params) |
693 | if (!params || !sscanf (params, "%d", &i) || !(tmp = find_object (i))) |
812 | { |
694 | { |
813 | inventory (op, NULL); |
695 | op->contr->failmsg ("Inventory of what object (nr)?"); |
814 | return 0; |
696 | return 1; |
815 | } |
|
|
816 | |
|
|
817 | if (!sscanf (params, "%d", &i) || (tmp = find_object (i)) == NULL) |
|
|
818 | { |
697 | } |
819 | new_draw_info (NDI_UNIQUE, 0, op, "Inventory of what object (nr)?"); |
|
|
820 | return 1; |
|
|
821 | } |
|
|
822 | |
698 | |
823 | inventory (op, tmp); |
699 | op->contr->infobox (MSG_CHANNEL ("examine"), tmp->query_inventory (op)); |
|
|
700 | |
824 | return 1; |
701 | return 1; |
825 | } |
702 | } |
826 | |
703 | |
827 | /* just show player's their skills for now. Dm's can |
704 | /* just show player's their skills for now. Dm's can |
828 | * already see skills w/ inventory command - b.t. |
705 | * already see skills w/ inventory command - b.t. |
… | |
… | |
849 | free (dump); |
726 | free (dump); |
850 | |
727 | |
851 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
728 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
852 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
729 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
853 | |
730 | |
854 | return 1; |
|
|
855 | } |
|
|
856 | |
|
|
857 | /** |
|
|
858 | * When DM is possessing a monster, flip aggression on and off, to allow |
|
|
859 | * better motion. |
|
|
860 | */ |
|
|
861 | int |
|
|
862 | command_mon_aggr (object *op, char *params) |
|
|
863 | { |
|
|
864 | if (op->enemy || !QUERY_FLAG (op, FLAG_UNAGGRESSIVE)) |
|
|
865 | { |
|
|
866 | op->enemy = NULL; |
|
|
867 | SET_FLAG (op, FLAG_UNAGGRESSIVE); |
|
|
868 | new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned OFF"); |
|
|
869 | } |
|
|
870 | else |
|
|
871 | { |
|
|
872 | CLEAR_FLAG (op, FLAG_FRIENDLY); |
|
|
873 | CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); |
|
|
874 | new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned ON"); |
|
|
875 | } |
|
|
876 | |
|
|
877 | return 1; |
|
|
878 | } |
|
|
879 | |
|
|
880 | /** DM can possess a monster. Basically, this tricks the client into thinking |
|
|
881 | * a given monster, is actually the player it controls. This allows a DM |
|
|
882 | * to inhabit a monster's body, and run around the game with it. |
|
|
883 | * This function is severely broken - it has tons of hardcoded values, |
|
|
884 | */ |
|
|
885 | int |
|
|
886 | command_possess (object *op, char *params) |
|
|
887 | { |
|
|
888 | object *victim, *curinv, *nextinv; |
|
|
889 | player *pl; |
|
|
890 | int i; |
|
|
891 | char buf[MAX_BUF]; |
|
|
892 | |
|
|
893 | victim = NULL; |
|
|
894 | if (params != NULL) |
|
|
895 | { |
|
|
896 | if (sscanf (params, "%d", &i)) |
|
|
897 | victim = find_object (i); |
|
|
898 | else if (sscanf (params, "%s", buf)) |
|
|
899 | victim = find_object_name (buf); |
|
|
900 | } |
|
|
901 | if (victim == NULL) |
|
|
902 | { |
|
|
903 | new_draw_info (NDI_UNIQUE, 0, op, "Patch what object (nr)?"); |
|
|
904 | return 1; |
|
|
905 | } |
|
|
906 | |
|
|
907 | if (victim == op) |
|
|
908 | { |
|
|
909 | new_draw_info (NDI_UNIQUE, 0, op, "As insane as you are, I cannot " "allow you to possess yourself."); |
|
|
910 | return 1; |
|
|
911 | } |
|
|
912 | |
|
|
913 | /* clear out the old inventory */ |
|
|
914 | curinv = op->inv; |
|
|
915 | while (curinv != NULL) |
|
|
916 | { |
|
|
917 | nextinv = curinv->below; |
|
|
918 | esrv_del_item (op->contr, curinv->count); |
|
|
919 | curinv = nextinv; |
|
|
920 | } |
|
|
921 | |
|
|
922 | /* make the switch */ |
|
|
923 | pl = op->contr; |
|
|
924 | victim->contr = pl; |
|
|
925 | pl->ob = victim; |
|
|
926 | victim->type = PLAYER; |
|
|
927 | SET_FLAG (victim, FLAG_WIZ); |
|
|
928 | |
|
|
929 | /* send the inventory to the client */ |
|
|
930 | curinv = victim->inv; |
|
|
931 | while (curinv != NULL) |
|
|
932 | { |
|
|
933 | nextinv = curinv->below; |
|
|
934 | esrv_send_item (victim, curinv); |
|
|
935 | curinv = nextinv; |
|
|
936 | } |
|
|
937 | /* basic patchup */ |
|
|
938 | /* The use of hard coded values is terrible. Note |
|
|
939 | * that really, to be fair, this shouldn't get changed at |
|
|
940 | * all - if you are possessing a kobold, you should have the |
|
|
941 | * same limitations. As it is, as more body locations are added, |
|
|
942 | * this will give this player more locations than perhaps |
|
|
943 | * they should be allowed. |
|
|
944 | */ |
|
|
945 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
946 | if (i == 1 || i == 6 || i == 8 || i == 9) |
|
|
947 | victim->body_info[i] = 2; |
|
|
948 | else |
|
|
949 | victim->body_info[i] = 1; |
|
|
950 | |
|
|
951 | esrv_new_player (pl, 80); /* just pick a wieght, we don't care */ |
|
|
952 | esrv_send_inventory (victim, victim); |
|
|
953 | |
|
|
954 | victim->update_stats (); |
|
|
955 | |
|
|
956 | do_some_living (victim); |
|
|
957 | return 1; |
731 | return 1; |
958 | } |
732 | } |
959 | |
733 | |
960 | int |
734 | int |
961 | command_patch (object *op, char *params) |
735 | command_patch (object *op, char *params) |
… | |
… | |
976 | return 1; |
750 | return 1; |
977 | } |
751 | } |
978 | |
752 | |
979 | if ((arg2 = strchr (arg, ' '))) |
753 | if ((arg2 = strchr (arg, ' '))) |
980 | arg2++; |
754 | arg2++; |
981 | if (settings.real_wiz == FALSE) |
755 | |
982 | SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */ |
|
|
983 | if (set_variable (tmp, arg) == -1) |
756 | if (set_variable (tmp, arg) == -1) |
984 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); |
757 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); |
985 | else |
758 | else |
986 | { |
|
|
987 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); |
759 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); |
988 | } |
|
|
989 | |
760 | |
990 | return 1; |
761 | return 1; |
991 | } |
762 | } |
992 | |
763 | |
993 | int |
764 | int |
… | |
… | |
1042 | |
813 | |
1043 | if (from != STACK_FROM_STACK) |
814 | if (from != STACK_FROM_STACK) |
1044 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
815 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
1045 | dm_stack_pop (op->contr); |
816 | dm_stack_pop (op->contr); |
1046 | |
817 | |
1047 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
|
|
1048 | { |
|
|
1049 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
|
|
1050 | tmp->remove (); |
|
|
1051 | } |
|
|
1052 | |
|
|
1053 | if (tmp->head) |
818 | if (tmp->head) |
1054 | tmp = tmp->head; |
819 | tmp = tmp->head; |
1055 | |
820 | |
1056 | tmp->destroy (); |
821 | tmp->destroy (); |
1057 | return 1; |
822 | return 1; |
… | |
… | |
1062 | */ |
827 | */ |
1063 | int |
828 | int |
1064 | command_addexp (object *op, char *params) |
829 | command_addexp (object *op, char *params) |
1065 | { |
830 | { |
1066 | char buf[MAX_BUF], skill[MAX_BUF]; |
831 | char buf[MAX_BUF], skill[MAX_BUF]; |
1067 | int i, q; |
832 | int q; |
|
|
833 | long long i; // use sint64 and finally provide format specifiers for sint64 etc. via configure |
1068 | object *skillob = NULL; |
834 | object *skillob = NULL; |
1069 | |
835 | |
1070 | skill[0] = '\0'; |
836 | skill[0] = '\0'; |
1071 | if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %d %s", buf, &i, skill)) < 2)) |
837 | if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %lld %s", buf, &i, skill)) < 2)) |
1072 | { |
838 | { |
1073 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); |
839 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); |
1074 | return 1; |
840 | return 1; |
1075 | } |
841 | } |
1076 | |
842 | |
… | |
… | |
1093 | } |
859 | } |
1094 | |
860 | |
1095 | pl->ob->stats.exp += i; |
861 | pl->ob->stats.exp += i; |
1096 | calc_perm_exp (pl->ob); |
862 | calc_perm_exp (pl->ob); |
1097 | player_lvl_adj (pl->ob, NULL); |
863 | player_lvl_adj (pl->ob, NULL); |
1098 | |
|
|
1099 | if (settings.real_wiz == FALSE) |
|
|
1100 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1101 | |
864 | |
1102 | return 1; |
865 | return 1; |
1103 | } |
866 | } |
1104 | |
867 | |
1105 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
868 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
… | |
… | |
1154 | int |
917 | int |
1155 | command_abil (object *op, char *params) |
918 | command_abil (object *op, char *params) |
1156 | { |
919 | { |
1157 | char thing[20], thing2[20]; |
920 | char thing[20], thing2[20]; |
1158 | int iii; |
921 | int iii; |
1159 | player *pl; |
|
|
1160 | char buf[MAX_BUF]; |
922 | char buf[MAX_BUF]; |
1161 | |
923 | |
1162 | iii = 0; |
924 | iii = 0; |
1163 | thing[0] = '\0'; |
925 | thing[0] = '\0'; |
1164 | thing2[0] = '\0'; |
926 | thing2[0] = '\0'; |
… | |
… | |
1182 | |
944 | |
1183 | for_all_players (pl) |
945 | for_all_players (pl) |
1184 | { |
946 | { |
1185 | if (!strcmp (pl->ob->name, thing)) |
947 | if (!strcmp (pl->ob->name, thing)) |
1186 | { |
948 | { |
1187 | if (settings.real_wiz == FALSE) |
|
|
1188 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1189 | if (!strcmp ("str", thing2)) |
|
|
1190 | pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; |
949 | if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; |
1191 | if (!strcmp ("dex", thing2)) |
|
|
1192 | pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; |
950 | if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; |
1193 | if (!strcmp ("con", thing2)) |
|
|
1194 | pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; |
951 | if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; |
1195 | if (!strcmp ("wis", thing2)) |
|
|
1196 | pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; |
952 | if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; |
1197 | if (!strcmp ("cha", thing2)) |
|
|
1198 | pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; |
953 | if (!strcmp ("cha", thing2)) pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; |
1199 | if (!strcmp ("int", thing2)) |
|
|
1200 | pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
954 | if (!strcmp ("int", thing2)) pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
1201 | if (!strcmp ("pow", thing2)) |
|
|
1202 | pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
955 | if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
|
|
956 | |
1203 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
957 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1204 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
958 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1205 | pl->ob->update_stats (); |
959 | pl->ob->update_stats (); |
1206 | return 1; |
960 | return 1; |
1207 | } |
961 | } |
… | |
… | |
1210 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
964 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1211 | return 1; |
965 | return 1; |
1212 | } |
966 | } |
1213 | |
967 | |
1214 | int |
968 | int |
1215 | command_reset (object *op, char *params) |
|
|
1216 | { |
|
|
1217 | maptile *m; |
|
|
1218 | object *dummy = NULL, *tmp = NULL; |
|
|
1219 | |
|
|
1220 | if (params == NULL) |
|
|
1221 | { |
|
|
1222 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
|
|
1223 | return 1; |
|
|
1224 | } |
|
|
1225 | |
|
|
1226 | if (strcmp (params, ".") == 0) |
|
|
1227 | params = op->map->path; |
|
|
1228 | |
|
|
1229 | m = has_been_loaded (params); |
|
|
1230 | if (m == NULL) |
|
|
1231 | { |
|
|
1232 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
|
|
1233 | return 1; |
|
|
1234 | } |
|
|
1235 | |
|
|
1236 | if (m->in_memory != MAP_SWAPPED) |
|
|
1237 | { |
|
|
1238 | if (m->in_memory != MAP_IN_MEMORY) |
|
|
1239 | { |
|
|
1240 | LOG (llevError, "Tried to swap out map which was not in memory.\n"); |
|
|
1241 | return 0; |
|
|
1242 | } |
|
|
1243 | |
|
|
1244 | /* |
|
|
1245 | * Only attempt to remove the player that is doing the reset, and not other |
|
|
1246 | * players or wiz's. |
|
|
1247 | */ |
|
|
1248 | if (op->map == m) |
|
|
1249 | { |
|
|
1250 | dummy = object::create (); |
|
|
1251 | dummy->map = NULL; |
|
|
1252 | EXIT_X (dummy) = op->x; |
|
|
1253 | EXIT_Y (dummy) = op->y; |
|
|
1254 | EXIT_PATH (dummy) = op->map->path; |
|
|
1255 | op->remove (); |
|
|
1256 | op->map = NULL; |
|
|
1257 | tmp = op; |
|
|
1258 | } |
|
|
1259 | swap_map (m); |
|
|
1260 | } |
|
|
1261 | |
|
|
1262 | if (m->in_memory == MAP_SWAPPED) |
|
|
1263 | { |
|
|
1264 | LOG (llevDebug, "Resetting map %s.\n", m->path); |
|
|
1265 | |
|
|
1266 | /* setting this effectively causes an immediate reload */ |
|
|
1267 | m->reset_time = 1; |
|
|
1268 | flush_old_maps (); |
|
|
1269 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
1270 | |
|
|
1271 | if (tmp) |
|
|
1272 | { |
|
|
1273 | enter_exit (tmp, dummy); |
|
|
1274 | dummy->destroy (); |
|
|
1275 | } |
|
|
1276 | |
|
|
1277 | return 1; |
|
|
1278 | } |
|
|
1279 | else |
|
|
1280 | { |
|
|
1281 | player *pl; |
|
|
1282 | int playercount = 0; |
|
|
1283 | |
|
|
1284 | /* Need to re-insert player if swap failed for some reason */ |
|
|
1285 | if (tmp) |
|
|
1286 | { |
|
|
1287 | insert_ob_in_map (op, m, NULL, 0); |
|
|
1288 | dummy->destroy (); |
|
|
1289 | } |
|
|
1290 | |
|
|
1291 | new_draw_info (NDI_UNIQUE, 0, op, "Reset failed, couldn't swap map, the following players are on it:"); |
|
|
1292 | |
|
|
1293 | for_all_players (pl) |
|
|
1294 | if (pl->ob->map == m && pl->ob != op) |
|
|
1295 | { |
|
|
1296 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s", &pl->ob->name); |
|
|
1297 | playercount++; |
|
|
1298 | } |
|
|
1299 | |
|
|
1300 | if (!playercount) |
|
|
1301 | new_draw_info (NDI_UNIQUE, 0, op, "hmm, I don't see any other players on this map, something else is the problem."); |
|
|
1302 | return 1; |
|
|
1303 | } |
|
|
1304 | } |
|
|
1305 | |
|
|
1306 | int |
|
|
1307 | command_nowiz (object *op, char *params) |
969 | command_nowiz (object *op, char *params) |
1308 | { /* 'noadm' is alias */ |
970 | { /* 'nodm' is alias */ |
1309 | CLEAR_FLAG (op, FLAG_WIZ); |
971 | CLEAR_FLAG (op, FLAG_WIZ); |
1310 | CLEAR_FLAG (op, FLAG_WIZPASS); |
972 | CLEAR_FLAG (op, FLAG_WIZPASS); |
1311 | CLEAR_FLAG (op, FLAG_WIZCAST); |
973 | CLEAR_FLAG (op, FLAG_WIZCAST); |
1312 | |
974 | |
1313 | if (settings.real_wiz == TRUE) |
|
|
1314 | CLEAR_FLAG (op, FLAG_WAS_WIZ); |
|
|
1315 | if (op->contr->hidden) |
975 | if (op->contr->hidden) |
1316 | { |
976 | { |
1317 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
977 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
1318 | op->map->players++; |
978 | op->map->players++; |
1319 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
979 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
… | |
… | |
1381 | } |
1041 | } |
1382 | |
1042 | |
1383 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1043 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1384 | { |
1044 | { |
1385 | SET_FLAG (op, FLAG_WIZ); |
1045 | SET_FLAG (op, FLAG_WIZ); |
1386 | SET_FLAG (op, FLAG_WAS_WIZ); |
|
|
1387 | SET_FLAG (op, FLAG_WIZPASS); |
1046 | SET_FLAG (op, FLAG_WIZPASS); |
1388 | SET_FLAG (op, FLAG_WIZCAST); |
1047 | SET_FLAG (op, FLAG_WIZCAST); |
|
|
1048 | SET_FLAG (op, FLAG_WIZLOOK); |
|
|
1049 | |
1389 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1050 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1390 | /* |
|
|
1391 | * Remove setting flying here - that won't work, because next |
|
|
1392 | * fix_player() is called that will get cleared - proper solution |
|
|
1393 | * is probably something like a wiz_force which gives that and any |
|
|
1394 | * other desired abilities. |
|
|
1395 | */ |
|
|
1396 | clear_los (op); |
|
|
1397 | op->contr->write_buf[0] = '\0'; |
1051 | op->contr->write_buf[0] = '\0'; |
1398 | |
1052 | |
1399 | if (!silent) |
1053 | if (!silent) |
1400 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1054 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1401 | |
1055 | |
… | |
… | |
1428 | command_invisible (object *op, char *params) |
1082 | command_invisible (object *op, char *params) |
1429 | { |
1083 | { |
1430 | if (op) |
1084 | if (op) |
1431 | { |
1085 | { |
1432 | op->invisible += 100; |
1086 | op->invisible += 100; |
1433 | update_object (op, UP_OBJ_FACE); |
1087 | update_object (op, UP_OBJ_CHANGE); |
1434 | new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); |
1088 | new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); |
1435 | } |
1089 | } |
1436 | |
1090 | |
1437 | return 0; |
1091 | return 0; |
1438 | } |
1092 | } |
… | |
… | |
1450 | * name than other "spell_xxx" archetypes and would always conflict. |
1104 | * name than other "spell_xxx" archetypes and would always conflict. |
1451 | */ |
1105 | */ |
1452 | static object * |
1106 | static object * |
1453 | get_spell_by_name (object *op, const char *spell_name) |
1107 | get_spell_by_name (object *op, const char *spell_name) |
1454 | { |
1108 | { |
1455 | archetype *ar; |
1109 | archetype *at; |
1456 | archetype *found; |
1110 | archetype *found; |
1457 | int conflict_found; |
1111 | int conflict_found; |
1458 | size_t spell_name_length; |
1112 | size_t spell_name_length; |
1459 | |
1113 | |
1460 | /* First check for full name matches. */ |
1114 | /* First check for full name matches. */ |
1461 | conflict_found = 0; |
1115 | conflict_found = 0; |
1462 | found = NULL; |
1116 | found = NULL; |
1463 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1117 | for_all_archetypes (at) |
1464 | { |
1118 | { |
1465 | if (ar->clone.type != SPELL) |
1119 | if (at->type != SPELL) |
1466 | continue; |
1120 | continue; |
1467 | |
1121 | |
1468 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1122 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1469 | continue; |
1123 | continue; |
1470 | |
1124 | |
1471 | if (strcmp (ar->clone.name, spell_name) != 0) |
1125 | if (strcmp (at->object::name, spell_name) != 0) |
1472 | continue; |
1126 | continue; |
1473 | |
1127 | |
1474 | if (found != NULL) |
1128 | if (found != NULL) |
1475 | { |
1129 | { |
1476 | if (!conflict_found) |
1130 | if (!conflict_found) |
1477 | { |
1131 | { |
1478 | conflict_found = 1; |
1132 | conflict_found = 1; |
1479 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1133 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1480 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); |
1134 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1481 | } |
1135 | } |
|
|
1136 | |
1482 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); |
1137 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1483 | continue; |
1138 | continue; |
1484 | } |
1139 | } |
1485 | |
1140 | |
1486 | found = ar; |
1141 | found = at; |
1487 | } |
1142 | } |
1488 | |
1143 | |
1489 | /* No match if more more than one archetype matches. */ |
1144 | /* No match if more more than one archetype matches. */ |
1490 | if (conflict_found) |
1145 | if (conflict_found) |
1491 | return NULL; |
1146 | return NULL; |
… | |
… | |
1496 | |
1151 | |
1497 | /* No full match found: now check for partial matches. */ |
1152 | /* No full match found: now check for partial matches. */ |
1498 | spell_name_length = strlen (spell_name); |
1153 | spell_name_length = strlen (spell_name); |
1499 | conflict_found = 0; |
1154 | conflict_found = 0; |
1500 | found = NULL; |
1155 | found = NULL; |
1501 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1156 | for_all_archetypes (at) |
1502 | { |
1157 | { |
1503 | if (ar->clone.type != SPELL) |
1158 | if (at->type != SPELL) |
1504 | continue; |
1159 | continue; |
1505 | |
1160 | |
1506 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1161 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1507 | continue; |
1162 | continue; |
1508 | |
1163 | |
1509 | if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) |
1164 | if (strncmp (at->object::name, spell_name, spell_name_length) != 0) |
1510 | continue; |
1165 | continue; |
1511 | |
1166 | |
1512 | if (found != NULL) |
1167 | if (found != NULL) |
1513 | { |
1168 | { |
1514 | if (!conflict_found) |
1169 | if (!conflict_found) |
1515 | { |
1170 | { |
1516 | conflict_found = 1; |
1171 | conflict_found = 1; |
1517 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1172 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1518 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); |
1173 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); |
1519 | } |
1174 | } |
1520 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); |
1175 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); |
1521 | continue; |
1176 | continue; |
1522 | } |
1177 | } |
1523 | |
1178 | |
1524 | found = ar; |
1179 | found = at; |
1525 | } |
1180 | } |
1526 | |
1181 | |
1527 | /* No match if more more than one archetype matches. */ |
1182 | /* No match if more more than one archetype matches. */ |
1528 | if (conflict_found) |
1183 | if (conflict_found) |
1529 | return NULL; |
1184 | return NULL; |
… | |
… | |
1594 | new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); |
1249 | new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); |
1595 | return 0; |
1250 | return 0; |
1596 | } |
1251 | } |
1597 | |
1252 | |
1598 | do_forget_spell (op, spell->name); |
1253 | do_forget_spell (op, spell->name); |
1599 | return 1; |
|
|
1600 | } |
|
|
1601 | |
|
|
1602 | /** |
|
|
1603 | * Lists all plugins currently loaded with their IDs and full names. |
|
|
1604 | */ |
|
|
1605 | int |
|
|
1606 | command_listplugins (object *op, char *params) |
|
|
1607 | { |
|
|
1608 | plugins_display_list (op); |
|
|
1609 | return 1; |
|
|
1610 | } |
|
|
1611 | |
|
|
1612 | /** |
|
|
1613 | * Loads the given plugin. The DM specifies the name of the library to load (no |
|
|
1614 | * pathname is needed). Do not ever attempt to load the same plugin more than |
|
|
1615 | * once at a time, or bad things could happen. |
|
|
1616 | */ |
|
|
1617 | int |
|
|
1618 | command_loadplugin (object *op, char *params) |
|
|
1619 | { |
|
|
1620 | char buf[MAX_BUF]; |
|
|
1621 | |
|
|
1622 | if (params == NULL) |
|
|
1623 | { |
|
|
1624 | new_draw_info (NDI_UNIQUE, 0, op, "Load which plugin?"); |
|
|
1625 | return 1; |
|
|
1626 | } |
|
|
1627 | |
|
|
1628 | strcpy (buf, LIBDIR); |
|
|
1629 | strcat (buf, "/plugins/"); |
|
|
1630 | strcat (buf, params); |
|
|
1631 | LOG (llevDebug, "Requested plugin file is %s\n", buf); |
|
|
1632 | if (plugins_init_plugin (buf) == 0) |
|
|
1633 | new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully loaded."); |
|
|
1634 | else |
|
|
1635 | new_draw_info (NDI_UNIQUE, 0, op, "Could not load plugin."); |
|
|
1636 | return 1; |
|
|
1637 | } |
|
|
1638 | |
|
|
1639 | /** |
|
|
1640 | * Unloads the given plugin. The DM specified the ID of the library to unload. |
|
|
1641 | * Note that some things may behave strangely if the correct plugins are not |
|
|
1642 | * loaded. |
|
|
1643 | */ |
|
|
1644 | int |
|
|
1645 | command_unloadplugin (object *op, char *params) |
|
|
1646 | { |
|
|
1647 | if (params == NULL) |
|
|
1648 | { |
|
|
1649 | new_draw_info (NDI_UNIQUE, 0, op, "Remove which plugin?"); |
|
|
1650 | return 1; |
|
|
1651 | } |
|
|
1652 | |
|
|
1653 | if (plugins_remove_plugin (params) == 0) |
|
|
1654 | new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully removed."); |
|
|
1655 | else |
|
|
1656 | new_draw_info (NDI_UNIQUE, 0, op, "Could not remove plugin."); |
|
|
1657 | return 1; |
1254 | return 1; |
1658 | } |
1255 | } |
1659 | |
1256 | |
1660 | /** |
1257 | /** |
1661 | * A players wants to become DM and hide. |
1258 | * A players wants to become DM and hide. |
… | |
… | |
1982 | return 0; |
1579 | return 0; |
1983 | } |
1580 | } |
1984 | |
1581 | |
1985 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1582 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1986 | right->remove (); |
1583 | right->remove (); |
|
|
1584 | |
1987 | inserted = insert_ob_in_ob (right, left); |
1585 | insert_ob_in_ob (right, left); |
1988 | if (left->type == PLAYER) |
|
|
1989 | if (inserted == right) |
|
|
1990 | esrv_send_item (left, right); |
|
|
1991 | else |
|
|
1992 | esrv_update_item (UPD_WEIGHT | UPD_NAME | UPD_NROF, left, inserted); |
|
|
1993 | |
1586 | |
1994 | new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); |
1587 | new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); |
1995 | |
1588 | |
1996 | return 0; |
1589 | return 0; |
1997 | |
1590 | |