1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT 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 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
8 | it under the terms of the GNU General Public License as published by |
9 | * under the terms of the GNU General Public License as published by the Free |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | (at your option) any later version. |
11 | * 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, but |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | GNU General Public License for more details. |
16 | * 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 along |
18 | along with this program; if not, write to the Free Software |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <sproto.h> |
26 | #include <sproto.h> |
26 | #include <spells.h> |
27 | #include <spells.h> |
27 | #include <treasure.h> |
28 | #include <treasure.h> |
… | |
… | |
85 | op->contr->hidden = 0; |
86 | op->contr->hidden = 0; |
86 | op->invisible = 1; |
87 | op->invisible = 1; |
87 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
88 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
88 | op->map->players++; |
89 | op->map->players++; |
89 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
90 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
|
|
91 | |
90 | if (!silent_dm) |
92 | if (!silent_dm) |
91 | { |
|
|
92 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
93 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
93 | } |
|
|
94 | } |
94 | } |
95 | else |
95 | else |
96 | { |
96 | { |
97 | op->contr->hidden = 1; |
97 | op->contr->hidden = 1; |
98 | new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you."); |
98 | new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you."); |
99 | op->map->players--; |
99 | op->map->players--; |
|
|
100 | |
100 | if (!silent_dm) |
101 | if (!silent_dm) |
101 | { |
|
|
102 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); |
102 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); |
103 | } |
103 | |
104 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name); |
104 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name); |
105 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name); |
105 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name); |
106 | } |
106 | } |
107 | } |
107 | } |
108 | |
108 | |
… | |
… | |
172 | |
172 | |
173 | become_follower (ob, god); |
173 | become_follower (ob, god); |
174 | return 1; |
174 | return 1; |
175 | } |
175 | } |
176 | |
176 | |
177 | /** |
177 | // TODO: Rewrite banish in perl and get rid of the following two functions |
178 | * Add player's IP to ban_file and kick them off the server |
|
|
179 | * I know most people have dynamic IPs but this is more of a short term |
|
|
180 | * solution if they have to get a new IP to play maybe they'll calm down. |
|
|
181 | * This uses the banish_file in the local directory *not* the ban_file |
|
|
182 | * The action is logged with a ! for easy searching. -tm |
|
|
183 | */ |
|
|
184 | int |
|
|
185 | command_banish (object *op, char *params) |
|
|
186 | { |
|
|
187 | player *pl; |
|
|
188 | FILE *banishfile; |
|
|
189 | char buf[MAX_BUF]; |
|
|
190 | time_t now; |
|
|
191 | |
|
|
192 | if (!params) |
|
|
193 | { |
|
|
194 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: banish <player>."); |
|
|
195 | return 1; |
|
|
196 | } |
|
|
197 | |
|
|
198 | pl = get_other_player_from_name (op, params); |
|
|
199 | if (!pl) |
|
|
200 | return 1; |
|
|
201 | |
|
|
202 | sprintf (buf, "%s/%s", settings.localdir, BANISHFILE); |
|
|
203 | |
|
|
204 | if ((banishfile = fopen (buf, "a")) == NULL) |
|
|
205 | { |
|
|
206 | LOG (llevDebug, "Could not find file banish_file.\n"); |
|
|
207 | new_draw_info (NDI_UNIQUE, 0, op, "Could not find banish_file."); |
|
|
208 | return 0; |
|
|
209 | } |
|
|
210 | |
|
|
211 | now = time (NULL); |
|
|
212 | /* |
|
|
213 | * Record this as a comment - then we don't have to worry about changing |
|
|
214 | * the parsing code. |
|
|
215 | */ |
|
|
216 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now)); |
|
|
217 | fprintf (banishfile, "*@%s\n", pl->ns->host); |
|
|
218 | fclose (banishfile); |
|
|
219 | |
|
|
220 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host); |
|
|
221 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name); |
|
|
222 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name); |
|
|
223 | command_kick (op, (char *) &pl->ob->name); |
|
|
224 | return 1; |
|
|
225 | } |
|
|
226 | |
|
|
227 | int |
178 | int |
228 | command_kick (object *op, char *params) |
179 | command_kick (object *op, char *params) |
229 | { |
180 | { |
230 | for_all_players (pl) |
181 | for_all_players (pl) |
231 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
182 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
… | |
… | |
265 | ready_map_name (op->map->path, 0); |
216 | ready_map_name (op->map->path, 0); |
266 | |
217 | |
267 | return 1; |
218 | return 1; |
268 | } |
219 | } |
269 | #endif |
220 | #endif |
270 | |
|
|
271 | int |
|
|
272 | command_shutdown (object *op, char *params) |
|
|
273 | { |
|
|
274 | if (op && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
275 | { |
|
|
276 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
|
|
277 | return 1; |
|
|
278 | } |
|
|
279 | |
|
|
280 | cleanup ("dm initiated shutdown", 0); |
|
|
281 | |
|
|
282 | /* not reached */ |
|
|
283 | return 1; |
|
|
284 | } |
|
|
285 | |
221 | |
286 | int |
222 | int |
287 | command_freeze (object *op, char *params) |
223 | command_freeze (object *op, char *params) |
288 | { |
224 | { |
289 | int ticks; |
225 | int ticks; |
… | |
… | |
388 | pl->ob->enter_exit (dummy); |
324 | pl->ob->enter_exit (dummy); |
389 | dummy->destroy (); |
325 | dummy->destroy (); |
390 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
326 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
391 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
327 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
392 | |
328 | |
393 | return 1; |
|
|
394 | } |
|
|
395 | |
|
|
396 | /** |
|
|
397 | * Teleport next to target player. |
|
|
398 | */ |
|
|
399 | |
|
|
400 | /* mids 01/16/2002 */ |
|
|
401 | int |
|
|
402 | command_teleport (object *op, char *params) |
|
|
403 | { |
|
|
404 | int i; |
|
|
405 | object *dummy; |
|
|
406 | player *pl; |
|
|
407 | |
|
|
408 | if (!op) |
|
|
409 | return 0; |
|
|
410 | |
|
|
411 | if (params == NULL) |
|
|
412 | { |
|
|
413 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: teleport <player>."); |
|
|
414 | return 1; |
|
|
415 | } |
|
|
416 | |
|
|
417 | pl = get_other_player_from_name (op, params); |
|
|
418 | if (!pl) |
|
|
419 | return 1; |
|
|
420 | |
|
|
421 | i = find_free_spot (pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9); |
|
|
422 | if (i == -1) |
|
|
423 | { |
|
|
424 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
|
|
425 | return 1; |
|
|
426 | } |
|
|
427 | |
|
|
428 | dummy = object::create (); |
|
|
429 | EXIT_PATH (dummy) = pl->ob->map->path; |
|
|
430 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
|
|
431 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
|
|
432 | op->enter_exit (dummy); |
|
|
433 | dummy->destroy (); |
|
|
434 | if (!op->contr->hidden) |
|
|
435 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
|
|
436 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
437 | return 1; |
329 | return 1; |
438 | } |
330 | } |
439 | |
331 | |
440 | /** |
332 | /** |
441 | * This function is a real mess, because we're stucking getting |
333 | * This function is a real mess, because we're stucking getting |
… | |
… | |
531 | * we also set up spell_name which is only |
423 | * we also set up spell_name which is only |
532 | * the first word. |
424 | * the first word. |
533 | */ |
425 | */ |
534 | |
426 | |
535 | at_spell = archetype::find (cp); |
427 | at_spell = archetype::find (cp); |
536 | if (!at_spell || at_spell->clone.type != SPELL) |
428 | if (!at_spell || at_spell->type != SPELL) |
537 | at_spell = find_archetype_by_object_name (cp); |
429 | at_spell = find_archetype_by_object_name (cp); |
538 | if (!at_spell || at_spell->clone.type != SPELL) |
430 | if (!at_spell || at_spell->type != SPELL) |
539 | { |
431 | { |
540 | strcpy (spell_name, cp); |
432 | assign (spell_name, cp); |
541 | fsp = strchr (spell_name, ' '); |
433 | fsp = strchr (spell_name, ' '); |
542 | if (fsp) |
434 | if (fsp) |
543 | { |
435 | { |
544 | *fsp = 0; |
436 | *fsp = 0; |
545 | fsp++; |
437 | fsp++; |
546 | at_spell = archetype::find (spell_name); |
438 | at_spell = archetype::find (spell_name); |
547 | |
439 | |
548 | /* Got a spell, update the first string pointer */ |
440 | /* Got a spell, update the first string pointer */ |
549 | if (at_spell && at_spell->clone.type == SPELL) |
441 | if (at_spell && at_spell->type == SPELL) |
550 | bp2 = cp + strlen (spell_name) + 1; |
442 | bp2 = cp + strlen (spell_name) + 1; |
551 | else |
443 | else |
552 | at_spell = NULL; |
444 | at_spell = NULL; |
553 | } |
445 | } |
554 | } |
446 | } |
… | |
… | |
556 | /* OK - we didn't find a spell - presume the 'of' |
448 | /* OK - we didn't find a spell - presume the 'of' |
557 | * in this case means its an artifact. |
449 | * in this case means its an artifact. |
558 | */ |
450 | */ |
559 | if (!at_spell) |
451 | if (!at_spell) |
560 | { |
452 | { |
561 | if (find_artifactlist (at->clone.type) == NULL) |
453 | if (find_artifactlist (at->type) == NULL) |
562 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); |
454 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->type); |
563 | else |
455 | else |
564 | { |
456 | { |
565 | art = find_artifactlist (at->clone.type)->items; |
457 | art = find_artifactlist (at->type)->items; |
566 | |
458 | |
567 | do |
459 | while (art) |
568 | { |
460 | { |
569 | if (!strcmp (art->item->name, cp)) |
461 | if (!strcmp (art->item->name, cp)) |
570 | break; |
462 | break; |
|
|
463 | |
571 | art = art->next; |
464 | art = art->next; |
572 | } |
465 | } |
573 | while (art != NULL); |
|
|
574 | |
466 | |
575 | if (!art) |
467 | if (!art) |
576 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); |
468 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->type, cp); |
577 | } |
469 | } |
578 | |
470 | |
579 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
471 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
580 | } |
472 | } |
581 | } /* if cp */ |
473 | } /* if cp */ |
582 | |
474 | |
583 | if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || |
475 | if ((at->type == ROD || at->type == WAND || at->type == SCROLL || |
584 | at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) |
476 | at->type == HORN || at->type == SPELLBOOK) && !at_spell) |
585 | { |
477 | { |
586 | 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); |
478 | 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); |
587 | return 1; |
479 | return 1; |
588 | } |
480 | } |
589 | |
481 | |
… | |
… | |
591 | * Rather than have two different blocks with a lot of similar code, |
483 | * Rather than have two different blocks with a lot of similar code, |
592 | * just create one object, do all the processing, and then determine |
484 | * just create one object, do all the processing, and then determine |
593 | * if that one object should be inserted or if we need to make copies. |
485 | * if that one object should be inserted or if we need to make copies. |
594 | */ |
486 | */ |
595 | tmp = arch_to_object (at); |
487 | tmp = arch_to_object (at); |
596 | |
|
|
597 | if (settings.real_wiz == FALSE) |
|
|
598 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
|
|
599 | |
488 | |
600 | if (set_magic) |
489 | if (set_magic) |
601 | set_abs_magic (tmp, magic); |
490 | set_abs_magic (tmp, magic); |
602 | |
491 | |
603 | if (art) |
492 | if (art) |
… | |
… | |
683 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
572 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
684 | |
573 | |
685 | bp2 = bp3 + 1; |
574 | bp2 = bp3 + 1; |
686 | } |
575 | } |
687 | |
576 | |
688 | if (at->clone.nrof) |
577 | if (at->nrof) |
689 | { |
578 | { |
690 | if (at_spell) |
579 | if (at_spell) |
691 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
580 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
692 | |
581 | |
693 | tmp->x = op->x; |
582 | tmp->x = op->x; |
… | |
… | |
708 | } |
597 | } |
709 | else |
598 | else |
710 | { |
599 | { |
711 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
600 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
712 | { |
601 | { |
713 | archetype *atmp; |
|
|
714 | object *prev = 0, *head = 0; |
602 | object *prev = 0, *head = 0; |
715 | |
603 | |
716 | for (atmp = at; atmp; atmp = atmp->more) |
604 | for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more) |
717 | { |
605 | { |
718 | object *dup = arch_to_object (atmp); |
606 | object *dup = arch_to_object (atmp); |
719 | |
607 | |
720 | if (at_spell) |
608 | if (at_spell) |
721 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
609 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
… | |
… | |
728 | { |
616 | { |
729 | head = dup; |
617 | head = dup; |
730 | tmp->copy_to (dup); |
618 | tmp->copy_to (dup); |
731 | } |
619 | } |
732 | |
620 | |
733 | if (settings.real_wiz == FALSE) |
|
|
734 | SET_FLAG (dup, FLAG_WAS_WIZ); |
|
|
735 | |
|
|
736 | dup->x = op->x + dup->arch->clone.x; |
621 | dup->x = op->x + dup->arch->x; |
737 | dup->y = op->y + dup->arch->clone.y; |
622 | dup->y = op->y + dup->arch->y; |
738 | dup->map = op->map; |
623 | dup->map = op->map; |
739 | |
624 | |
740 | if (head != dup) |
625 | if (head != dup) |
741 | { |
626 | { |
742 | dup->head = head; |
627 | dup->head = head; |
… | |
… | |
752 | int size_x = 0; |
637 | int size_x = 0; |
753 | int size_y = 0; |
638 | int size_y = 0; |
754 | |
639 | |
755 | while (check) |
640 | while (check) |
756 | { |
641 | { |
757 | size_x = MAX (size_x, check->arch->clone.x); |
642 | size_x = MAX (size_x, check->arch->x); |
758 | size_y = MAX (size_y, check->arch->clone.y); |
643 | size_y = MAX (size_y, check->arch->y); |
759 | check = check->more; |
644 | check = check->more; |
760 | } |
645 | } |
761 | |
646 | |
762 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
647 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
763 | { |
648 | { |
… | |
… | |
789 | /* Wonder if we really want to push all of these, but since |
674 | /* Wonder if we really want to push all of these, but since |
790 | * things like rods have nrof 0, we want to cover those. |
675 | * things like rods have nrof 0, we want to cover those. |
791 | */ |
676 | */ |
792 | dm_stack_push (op->contr, head->count); |
677 | dm_stack_push (op->contr, head->count); |
793 | |
678 | |
794 | if (at->clone.randomitems != NULL && !at_spell) |
679 | if (at->randomitems != NULL && !at_spell) |
795 | create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); |
680 | create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0); |
796 | |
681 | |
797 | esrv_send_item (op, head); |
682 | esrv_send_item (op, head); |
798 | } |
683 | } |
799 | |
684 | |
800 | /* free the one we used to copy */ |
685 | /* free the one we used to copy */ |
… | |
… | |
855 | free (dump); |
740 | free (dump); |
856 | |
741 | |
857 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
742 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
858 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
743 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
859 | |
744 | |
860 | return 1; |
|
|
861 | } |
|
|
862 | |
|
|
863 | /** |
|
|
864 | * When DM is possessing a monster, flip aggression on and off, to allow |
|
|
865 | * better motion. |
|
|
866 | */ |
|
|
867 | int |
|
|
868 | command_mon_aggr (object *op, char *params) |
|
|
869 | { |
|
|
870 | if (op->enemy || !QUERY_FLAG (op, FLAG_UNAGGRESSIVE)) |
|
|
871 | { |
|
|
872 | op->enemy = NULL; |
|
|
873 | SET_FLAG (op, FLAG_UNAGGRESSIVE); |
|
|
874 | new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned OFF"); |
|
|
875 | } |
|
|
876 | else |
|
|
877 | { |
|
|
878 | CLEAR_FLAG (op, FLAG_FRIENDLY); |
|
|
879 | CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); |
|
|
880 | new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned ON"); |
|
|
881 | } |
|
|
882 | |
|
|
883 | return 1; |
|
|
884 | } |
|
|
885 | |
|
|
886 | /** DM can possess a monster. Basically, this tricks the client into thinking |
|
|
887 | * a given monster, is actually the player it controls. This allows a DM |
|
|
888 | * to inhabit a monster's body, and run around the game with it. |
|
|
889 | * This function is severely broken - it has tons of hardcoded values, |
|
|
890 | */ |
|
|
891 | int |
|
|
892 | command_possess (object *op, char *params) |
|
|
893 | { |
|
|
894 | object *victim, *curinv, *nextinv; |
|
|
895 | player *pl; |
|
|
896 | int i; |
|
|
897 | char buf[MAX_BUF]; |
|
|
898 | |
|
|
899 | victim = NULL; |
|
|
900 | if (params != NULL) |
|
|
901 | { |
|
|
902 | if (sscanf (params, "%d", &i)) |
|
|
903 | victim = find_object (i); |
|
|
904 | else if (sscanf (params, "%s", buf)) |
|
|
905 | victim = find_object_name (buf); |
|
|
906 | } |
|
|
907 | if (victim == NULL) |
|
|
908 | { |
|
|
909 | new_draw_info (NDI_UNIQUE, 0, op, "Patch what object (nr)?"); |
|
|
910 | return 1; |
|
|
911 | } |
|
|
912 | |
|
|
913 | if (victim == op) |
|
|
914 | { |
|
|
915 | new_draw_info (NDI_UNIQUE, 0, op, "As insane as you are, I cannot " "allow you to possess yourself."); |
|
|
916 | return 1; |
|
|
917 | } |
|
|
918 | |
|
|
919 | /* clear out the old inventory */ |
|
|
920 | curinv = op->inv; |
|
|
921 | while (curinv != NULL) |
|
|
922 | { |
|
|
923 | nextinv = curinv->below; |
|
|
924 | esrv_del_item (op->contr, curinv->count); |
|
|
925 | curinv = nextinv; |
|
|
926 | } |
|
|
927 | |
|
|
928 | /* make the switch */ |
|
|
929 | pl = op->contr; |
|
|
930 | victim->contr = pl; |
|
|
931 | pl->ob = victim; |
|
|
932 | victim->type = PLAYER; |
|
|
933 | SET_FLAG (victim, FLAG_WIZ); |
|
|
934 | |
|
|
935 | /* send the inventory to the client */ |
|
|
936 | curinv = victim->inv; |
|
|
937 | while (curinv != NULL) |
|
|
938 | { |
|
|
939 | nextinv = curinv->below; |
|
|
940 | esrv_send_item (victim, curinv); |
|
|
941 | curinv = nextinv; |
|
|
942 | } |
|
|
943 | /* basic patchup */ |
|
|
944 | /* The use of hard coded values is terrible. Note |
|
|
945 | * that really, to be fair, this shouldn't get changed at |
|
|
946 | * all - if you are possessing a kobold, you should have the |
|
|
947 | * same limitations. As it is, as more body locations are added, |
|
|
948 | * this will give this player more locations than perhaps |
|
|
949 | * they should be allowed. |
|
|
950 | */ |
|
|
951 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
952 | if (i == 1 || i == 6 || i == 8 || i == 9) |
|
|
953 | victim->body_info[i] = 2; |
|
|
954 | else |
|
|
955 | victim->body_info[i] = 1; |
|
|
956 | |
|
|
957 | esrv_new_player (pl, 80); /* just pick a wieght, we don't care */ |
|
|
958 | esrv_send_inventory (victim, victim); |
|
|
959 | |
|
|
960 | victim->update_stats (); |
|
|
961 | |
|
|
962 | do_some_living (victim); |
|
|
963 | return 1; |
745 | return 1; |
964 | } |
746 | } |
965 | |
747 | |
966 | int |
748 | int |
967 | command_patch (object *op, char *params) |
749 | command_patch (object *op, char *params) |
… | |
… | |
982 | return 1; |
764 | return 1; |
983 | } |
765 | } |
984 | |
766 | |
985 | if ((arg2 = strchr (arg, ' '))) |
767 | if ((arg2 = strchr (arg, ' '))) |
986 | arg2++; |
768 | arg2++; |
987 | if (settings.real_wiz == FALSE) |
769 | |
988 | SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */ |
|
|
989 | if (set_variable (tmp, arg) == -1) |
770 | if (set_variable (tmp, arg) == -1) |
990 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); |
771 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); |
991 | else |
772 | else |
992 | { |
|
|
993 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); |
773 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); |
994 | } |
|
|
995 | |
774 | |
996 | return 1; |
775 | return 1; |
997 | } |
776 | } |
998 | |
777 | |
999 | int |
778 | int |
… | |
… | |
1047 | } |
826 | } |
1048 | |
827 | |
1049 | if (from != STACK_FROM_STACK) |
828 | if (from != STACK_FROM_STACK) |
1050 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
829 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
1051 | dm_stack_pop (op->contr); |
830 | dm_stack_pop (op->contr); |
1052 | |
|
|
1053 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
|
|
1054 | { |
|
|
1055 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
|
|
1056 | tmp->remove (); |
|
|
1057 | } |
|
|
1058 | |
831 | |
1059 | if (tmp->head) |
832 | if (tmp->head) |
1060 | tmp = tmp->head; |
833 | tmp = tmp->head; |
1061 | |
834 | |
1062 | tmp->destroy (); |
835 | tmp->destroy (); |
… | |
… | |
1099 | } |
872 | } |
1100 | |
873 | |
1101 | pl->ob->stats.exp += i; |
874 | pl->ob->stats.exp += i; |
1102 | calc_perm_exp (pl->ob); |
875 | calc_perm_exp (pl->ob); |
1103 | player_lvl_adj (pl->ob, NULL); |
876 | player_lvl_adj (pl->ob, NULL); |
1104 | |
|
|
1105 | if (settings.real_wiz == FALSE) |
|
|
1106 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1107 | |
877 | |
1108 | return 1; |
878 | return 1; |
1109 | } |
879 | } |
1110 | |
880 | |
1111 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
881 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
… | |
… | |
1160 | int |
930 | int |
1161 | command_abil (object *op, char *params) |
931 | command_abil (object *op, char *params) |
1162 | { |
932 | { |
1163 | char thing[20], thing2[20]; |
933 | char thing[20], thing2[20]; |
1164 | int iii; |
934 | int iii; |
1165 | player *pl; |
|
|
1166 | char buf[MAX_BUF]; |
935 | char buf[MAX_BUF]; |
1167 | |
936 | |
1168 | iii = 0; |
937 | iii = 0; |
1169 | thing[0] = '\0'; |
938 | thing[0] = '\0'; |
1170 | thing2[0] = '\0'; |
939 | thing2[0] = '\0'; |
… | |
… | |
1188 | |
957 | |
1189 | for_all_players (pl) |
958 | for_all_players (pl) |
1190 | { |
959 | { |
1191 | if (!strcmp (pl->ob->name, thing)) |
960 | if (!strcmp (pl->ob->name, thing)) |
1192 | { |
961 | { |
1193 | if (settings.real_wiz == FALSE) |
|
|
1194 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1195 | if (!strcmp ("str", thing2)) |
|
|
1196 | pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; |
962 | if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; |
1197 | if (!strcmp ("dex", thing2)) |
|
|
1198 | pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; |
963 | if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; |
1199 | if (!strcmp ("con", thing2)) |
|
|
1200 | pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; |
964 | if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; |
1201 | if (!strcmp ("wis", thing2)) |
|
|
1202 | pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; |
965 | if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; |
1203 | if (!strcmp ("cha", thing2)) |
|
|
1204 | pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; |
966 | if (!strcmp ("cha", thing2)) pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; |
1205 | if (!strcmp ("int", thing2)) |
|
|
1206 | pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
967 | if (!strcmp ("int", thing2)) pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
1207 | if (!strcmp ("pow", thing2)) |
|
|
1208 | pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
968 | if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
|
|
969 | |
1209 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
970 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1210 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
971 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1211 | pl->ob->update_stats (); |
972 | pl->ob->update_stats (); |
1212 | return 1; |
973 | return 1; |
1213 | } |
974 | } |
… | |
… | |
1217 | return 1; |
978 | return 1; |
1218 | } |
979 | } |
1219 | |
980 | |
1220 | int |
981 | int |
1221 | command_nowiz (object *op, char *params) |
982 | command_nowiz (object *op, char *params) |
1222 | { /* 'noadm' is alias */ |
983 | { /* 'nodm' is alias */ |
1223 | CLEAR_FLAG (op, FLAG_WIZ); |
984 | CLEAR_FLAG (op, FLAG_WIZ); |
1224 | CLEAR_FLAG (op, FLAG_WIZPASS); |
985 | CLEAR_FLAG (op, FLAG_WIZPASS); |
1225 | CLEAR_FLAG (op, FLAG_WIZCAST); |
986 | CLEAR_FLAG (op, FLAG_WIZCAST); |
1226 | |
987 | |
1227 | if (settings.real_wiz == TRUE) |
|
|
1228 | CLEAR_FLAG (op, FLAG_WAS_WIZ); |
|
|
1229 | if (op->contr->hidden) |
988 | if (op->contr->hidden) |
1230 | { |
989 | { |
1231 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
990 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
1232 | op->map->players++; |
991 | op->map->players++; |
1233 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
992 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
… | |
… | |
1295 | } |
1054 | } |
1296 | |
1055 | |
1297 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1056 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1298 | { |
1057 | { |
1299 | SET_FLAG (op, FLAG_WIZ); |
1058 | SET_FLAG (op, FLAG_WIZ); |
1300 | SET_FLAG (op, FLAG_WAS_WIZ); |
|
|
1301 | SET_FLAG (op, FLAG_WIZPASS); |
1059 | SET_FLAG (op, FLAG_WIZPASS); |
1302 | SET_FLAG (op, FLAG_WIZCAST); |
1060 | SET_FLAG (op, FLAG_WIZCAST); |
|
|
1061 | |
1303 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1062 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1304 | /* |
1063 | /* |
1305 | * Remove setting flying here - that won't work, because next |
1064 | * Remove setting flying here - that won't work, because next |
1306 | * fix_player() is called that will get cleared - proper solution |
1065 | * fix_player() is called that will get cleared - proper solution |
1307 | * is probably something like a wiz_force which gives that and any |
1066 | * is probably something like a wiz_force which gives that and any |
1308 | * other desired abilities. |
1067 | * other desired abilities. |
1309 | */ |
1068 | */ |
1310 | clear_los (op); |
1069 | clear_los (op->contr); |
1311 | op->contr->write_buf[0] = '\0'; |
1070 | op->contr->write_buf[0] = '\0'; |
1312 | |
1071 | |
1313 | if (!silent) |
1072 | if (!silent) |
1314 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1073 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1315 | |
1074 | |
… | |
… | |
1342 | command_invisible (object *op, char *params) |
1101 | command_invisible (object *op, char *params) |
1343 | { |
1102 | { |
1344 | if (op) |
1103 | if (op) |
1345 | { |
1104 | { |
1346 | op->invisible += 100; |
1105 | op->invisible += 100; |
1347 | update_object (op, UP_OBJ_FACE); |
1106 | update_object (op, UP_OBJ_CHANGE); |
1348 | new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); |
1107 | new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); |
1349 | } |
1108 | } |
1350 | |
1109 | |
1351 | return 0; |
1110 | return 0; |
1352 | } |
1111 | } |
… | |
… | |
1364 | * name than other "spell_xxx" archetypes and would always conflict. |
1123 | * name than other "spell_xxx" archetypes and would always conflict. |
1365 | */ |
1124 | */ |
1366 | static object * |
1125 | static object * |
1367 | get_spell_by_name (object *op, const char *spell_name) |
1126 | get_spell_by_name (object *op, const char *spell_name) |
1368 | { |
1127 | { |
1369 | archetype *ar; |
1128 | archetype *at; |
1370 | archetype *found; |
1129 | archetype *found; |
1371 | int conflict_found; |
1130 | int conflict_found; |
1372 | size_t spell_name_length; |
1131 | size_t spell_name_length; |
1373 | |
1132 | |
1374 | /* First check for full name matches. */ |
1133 | /* First check for full name matches. */ |
1375 | conflict_found = 0; |
1134 | conflict_found = 0; |
1376 | found = NULL; |
1135 | found = NULL; |
1377 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1136 | for_all_archetypes (at) |
1378 | { |
1137 | { |
1379 | if (ar->clone.type != SPELL) |
1138 | if (at->type != SPELL) |
1380 | continue; |
1139 | continue; |
1381 | |
1140 | |
1382 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1141 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1383 | continue; |
1142 | continue; |
1384 | |
1143 | |
1385 | if (strcmp (ar->clone.name, spell_name) != 0) |
1144 | if (strcmp (at->object::name, spell_name) != 0) |
1386 | continue; |
1145 | continue; |
1387 | |
1146 | |
1388 | if (found != NULL) |
1147 | if (found != NULL) |
1389 | { |
1148 | { |
1390 | if (!conflict_found) |
1149 | if (!conflict_found) |
1391 | { |
1150 | { |
1392 | conflict_found = 1; |
1151 | conflict_found = 1; |
1393 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1152 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1394 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1395 | } |
1154 | } |
|
|
1155 | |
1396 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); |
1156 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1397 | continue; |
1157 | continue; |
1398 | } |
1158 | } |
1399 | |
1159 | |
1400 | found = ar; |
1160 | found = at; |
1401 | } |
1161 | } |
1402 | |
1162 | |
1403 | /* No match if more more than one archetype matches. */ |
1163 | /* No match if more more than one archetype matches. */ |
1404 | if (conflict_found) |
1164 | if (conflict_found) |
1405 | return NULL; |
1165 | return NULL; |
… | |
… | |
1410 | |
1170 | |
1411 | /* No full match found: now check for partial matches. */ |
1171 | /* No full match found: now check for partial matches. */ |
1412 | spell_name_length = strlen (spell_name); |
1172 | spell_name_length = strlen (spell_name); |
1413 | conflict_found = 0; |
1173 | conflict_found = 0; |
1414 | found = NULL; |
1174 | found = NULL; |
1415 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1175 | for_all_archetypes (at) |
1416 | { |
1176 | { |
1417 | if (ar->clone.type != SPELL) |
1177 | if (at->type != SPELL) |
1418 | continue; |
1178 | continue; |
1419 | |
1179 | |
1420 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1180 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1421 | continue; |
1181 | continue; |
1422 | |
1182 | |
1423 | if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) |
1183 | if (strncmp (at->object::name, spell_name, spell_name_length) != 0) |
1424 | continue; |
1184 | continue; |
1425 | |
1185 | |
1426 | if (found != NULL) |
1186 | if (found != NULL) |
1427 | { |
1187 | { |
1428 | if (!conflict_found) |
1188 | if (!conflict_found) |
1429 | { |
1189 | { |
1430 | conflict_found = 1; |
1190 | conflict_found = 1; |
1431 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1191 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1432 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); |
1192 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); |
1433 | } |
1193 | } |
1434 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); |
1194 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); |
1435 | continue; |
1195 | continue; |
1436 | } |
1196 | } |
1437 | |
1197 | |
1438 | found = ar; |
1198 | found = at; |
1439 | } |
1199 | } |
1440 | |
1200 | |
1441 | /* No match if more more than one archetype matches. */ |
1201 | /* No match if more more than one archetype matches. */ |
1442 | if (conflict_found) |
1202 | if (conflict_found) |
1443 | return NULL; |
1203 | return NULL; |