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 | #ifndef __CEXTRACT__ |
|
|
26 | # include <sproto.h> |
26 | #include <sproto.h> |
27 | #endif |
|
|
28 | #include <spells.h> |
27 | #include <spells.h> |
29 | #include <treasure.h> |
28 | #include <treasure.h> |
30 | #include <skills.h> |
29 | #include <skills.h> |
31 | |
30 | |
32 | /** Defines for DM item stack **/ |
31 | /** Defines for DM item stack **/ |
… | |
… | |
87 | op->contr->hidden = 0; |
86 | op->contr->hidden = 0; |
88 | op->invisible = 1; |
87 | op->invisible = 1; |
89 | 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"); |
90 | op->map->players++; |
89 | op->map->players++; |
91 | 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 | |
92 | if (!silent_dm) |
92 | if (!silent_dm) |
93 | { |
|
|
94 | 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!"); |
95 | } |
|
|
96 | } |
94 | } |
97 | else |
95 | else |
98 | { |
96 | { |
99 | op->contr->hidden = 1; |
97 | op->contr->hidden = 1; |
100 | 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."); |
101 | op->map->players--; |
99 | op->map->players--; |
|
|
100 | |
102 | if (!silent_dm) |
101 | if (!silent_dm) |
103 | { |
|
|
104 | 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.."); |
105 | } |
103 | |
106 | 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); |
107 | 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); |
108 | } |
106 | } |
109 | } |
107 | } |
110 | |
108 | |
… | |
… | |
174 | |
172 | |
175 | become_follower (ob, god); |
173 | become_follower (ob, god); |
176 | return 1; |
174 | return 1; |
177 | } |
175 | } |
178 | |
176 | |
179 | /** |
177 | // 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 |
178 | int |
230 | command_kick (object *op, char *params) |
179 | command_kick (object *op, char *params) |
231 | { |
180 | { |
232 | for_all_players (pl) |
181 | for_all_players (pl) |
233 | 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))) |
… | |
… | |
244 | } |
193 | } |
245 | |
194 | |
246 | return 1; |
195 | return 1; |
247 | } |
196 | } |
248 | |
197 | |
|
|
198 | //TODO |
|
|
199 | #if 0 |
249 | int |
200 | int |
250 | command_save_overlay (object *op, char *params) |
201 | command_save_overlay (object *op, char *params) |
251 | { |
202 | { |
252 | if (!op) |
203 | if (!op) |
253 | return 0; |
204 | return 0; |
… | |
… | |
264 | |
215 | |
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 | |
220 | #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 | |
221 | |
284 | int |
222 | int |
285 | command_freeze (object *op, char *params) |
223 | command_freeze (object *op, char *params) |
286 | { |
224 | { |
287 | int ticks; |
225 | int ticks; |
… | |
… | |
323 | object *dummy; |
261 | object *dummy; |
324 | player *pl; |
262 | player *pl; |
325 | |
263 | |
326 | if (!op) |
264 | if (!op) |
327 | return 0; |
265 | return 0; |
|
|
266 | |
328 | if (params == NULL) |
267 | if (params == NULL) |
329 | { |
268 | { |
330 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
269 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
331 | return 1; |
270 | return 1; |
332 | } |
271 | } |
|
|
272 | |
333 | pl = get_other_player_from_name (op, params); |
273 | pl = get_other_player_from_name (op, params); |
334 | if (!pl) |
274 | if (!pl) |
335 | return 1; |
275 | return 1; |
|
|
276 | |
336 | dummy = get_jail_exit (pl->ob); |
277 | dummy = get_jail_exit (pl->ob); |
337 | if (!dummy) |
278 | if (!dummy) |
338 | { |
279 | { |
339 | /* we have nowhere to send the prisoner.... */ |
280 | /* 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"); |
281 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
341 | return 0; |
282 | return 0; |
342 | } |
283 | } |
343 | enter_exit (pl->ob, dummy); |
284 | |
|
|
285 | pl->ob->enter_exit (dummy); |
344 | dummy->destroy (); |
286 | dummy->destroy (); |
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; |
… | |
… | |
377 | |
319 | |
378 | dummy = object::create (); |
320 | dummy = object::create (); |
379 | EXIT_PATH (dummy) = op->map->path; |
321 | EXIT_PATH (dummy) = op->map->path; |
380 | EXIT_X (dummy) = op->x + freearr_x[i]; |
322 | EXIT_X (dummy) = op->x + freearr_x[i]; |
381 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
323 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
382 | enter_exit (pl->ob, dummy); |
324 | pl->ob->enter_exit (dummy); |
383 | dummy->destroy (); |
325 | dummy->destroy (); |
384 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
326 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
385 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
327 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
386 | |
328 | |
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; |
329 | return 1; |
432 | } |
330 | } |
433 | |
331 | |
434 | /** |
332 | /** |
435 | * This function is a real mess, because we're stucking getting |
333 | * This function is a real mess, because we're stucking getting |
… | |
… | |
529 | at_spell = archetype::find (cp); |
427 | at_spell = archetype::find (cp); |
530 | if (!at_spell || at_spell->clone.type != SPELL) |
428 | if (!at_spell || at_spell->clone.type != SPELL) |
531 | at_spell = find_archetype_by_object_name (cp); |
429 | at_spell = find_archetype_by_object_name (cp); |
532 | if (!at_spell || at_spell->clone.type != SPELL) |
430 | if (!at_spell || at_spell->clone.type != SPELL) |
533 | { |
431 | { |
534 | strcpy (spell_name, cp); |
432 | assign (spell_name, cp); |
535 | fsp = strchr (spell_name, ' '); |
433 | fsp = strchr (spell_name, ' '); |
536 | if (fsp) |
434 | if (fsp) |
537 | { |
435 | { |
538 | *fsp = 0; |
436 | *fsp = 0; |
539 | fsp++; |
437 | fsp++; |
… | |
… | |
556 | 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->clone.type); |
557 | else |
455 | else |
558 | { |
456 | { |
559 | art = find_artifactlist (at->clone.type)->items; |
457 | art = find_artifactlist (at->clone.type)->items; |
560 | |
458 | |
561 | do |
459 | while (art) |
562 | { |
460 | { |
563 | if (!strcmp (art->item->name, cp)) |
461 | if (!strcmp (art->item->name, cp)) |
564 | break; |
462 | break; |
|
|
463 | |
565 | art = art->next; |
464 | art = art->next; |
566 | } |
465 | } |
567 | while (art != NULL); |
|
|
568 | |
466 | |
569 | if (!art) |
467 | if (!art) |
570 | 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->clone.type, cp); |
571 | } |
469 | } |
572 | |
470 | |
… | |
… | |
585 | * 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, |
586 | * just create one object, do all the processing, and then determine |
484 | * 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. |
485 | * if that one object should be inserted or if we need to make copies. |
588 | */ |
486 | */ |
589 | tmp = arch_to_object (at); |
487 | tmp = arch_to_object (at); |
590 | |
|
|
591 | if (settings.real_wiz == FALSE) |
|
|
592 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
|
|
593 | |
488 | |
594 | if (set_magic) |
489 | if (set_magic) |
595 | set_abs_magic (tmp, magic); |
490 | set_abs_magic (tmp, magic); |
596 | |
491 | |
597 | if (art) |
492 | if (art) |
… | |
… | |
722 | { |
617 | { |
723 | head = dup; |
618 | head = dup; |
724 | tmp->copy_to (dup); |
619 | tmp->copy_to (dup); |
725 | } |
620 | } |
726 | |
621 | |
727 | if (settings.real_wiz == FALSE) |
|
|
728 | SET_FLAG (dup, FLAG_WAS_WIZ); |
|
|
729 | |
|
|
730 | dup->x = op->x + dup->arch->clone.x; |
622 | dup->x = op->x + dup->arch->clone.x; |
731 | dup->y = op->y + dup->arch->clone.y; |
623 | dup->y = op->y + dup->arch->clone.y; |
732 | dup->map = op->map; |
624 | dup->map = op->map; |
733 | |
625 | |
734 | if (head != dup) |
626 | if (head != dup) |
… | |
… | |
852 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
744 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
853 | |
745 | |
854 | return 1; |
746 | return 1; |
855 | } |
747 | } |
856 | |
748 | |
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; |
|
|
958 | } |
|
|
959 | |
|
|
960 | int |
749 | int |
961 | command_patch (object *op, char *params) |
750 | command_patch (object *op, char *params) |
962 | { |
751 | { |
963 | char *arg, *arg2; |
752 | char *arg, *arg2; |
964 | object *tmp; |
753 | object *tmp; |
… | |
… | |
976 | return 1; |
765 | return 1; |
977 | } |
766 | } |
978 | |
767 | |
979 | if ((arg2 = strchr (arg, ' '))) |
768 | if ((arg2 = strchr (arg, ' '))) |
980 | arg2++; |
769 | arg2++; |
981 | if (settings.real_wiz == FALSE) |
770 | |
982 | SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */ |
|
|
983 | if (set_variable (tmp, arg) == -1) |
771 | if (set_variable (tmp, arg) == -1) |
984 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); |
772 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); |
985 | else |
773 | else |
986 | { |
|
|
987 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); |
774 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); |
988 | } |
|
|
989 | |
775 | |
990 | return 1; |
776 | return 1; |
991 | } |
777 | } |
992 | |
778 | |
993 | int |
779 | int |
… | |
… | |
1041 | } |
827 | } |
1042 | |
828 | |
1043 | if (from != STACK_FROM_STACK) |
829 | if (from != STACK_FROM_STACK) |
1044 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
830 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
1045 | dm_stack_pop (op->contr); |
831 | dm_stack_pop (op->contr); |
1046 | |
|
|
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 | |
832 | |
1053 | if (tmp->head) |
833 | if (tmp->head) |
1054 | tmp = tmp->head; |
834 | tmp = tmp->head; |
1055 | |
835 | |
1056 | tmp->destroy (); |
836 | tmp->destroy (); |
… | |
… | |
1093 | } |
873 | } |
1094 | |
874 | |
1095 | pl->ob->stats.exp += i; |
875 | pl->ob->stats.exp += i; |
1096 | calc_perm_exp (pl->ob); |
876 | calc_perm_exp (pl->ob); |
1097 | player_lvl_adj (pl->ob, NULL); |
877 | player_lvl_adj (pl->ob, NULL); |
1098 | |
|
|
1099 | if (settings.real_wiz == FALSE) |
|
|
1100 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1101 | |
878 | |
1102 | return 1; |
879 | return 1; |
1103 | } |
880 | } |
1104 | |
881 | |
1105 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
882 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
… | |
… | |
1154 | int |
931 | int |
1155 | command_abil (object *op, char *params) |
932 | command_abil (object *op, char *params) |
1156 | { |
933 | { |
1157 | char thing[20], thing2[20]; |
934 | char thing[20], thing2[20]; |
1158 | int iii; |
935 | int iii; |
1159 | player *pl; |
|
|
1160 | char buf[MAX_BUF]; |
936 | char buf[MAX_BUF]; |
1161 | |
937 | |
1162 | iii = 0; |
938 | iii = 0; |
1163 | thing[0] = '\0'; |
939 | thing[0] = '\0'; |
1164 | thing2[0] = '\0'; |
940 | thing2[0] = '\0'; |
… | |
… | |
1182 | |
958 | |
1183 | for_all_players (pl) |
959 | for_all_players (pl) |
1184 | { |
960 | { |
1185 | if (!strcmp (pl->ob->name, thing)) |
961 | if (!strcmp (pl->ob->name, thing)) |
1186 | { |
962 | { |
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; |
963 | 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; |
964 | 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; |
965 | 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; |
966 | 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; |
967 | 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; |
968 | 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; |
969 | if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
|
|
970 | |
1203 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
971 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1204 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
972 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1205 | pl->ob->update_stats (); |
973 | pl->ob->update_stats (); |
1206 | return 1; |
974 | return 1; |
1207 | } |
975 | } |
… | |
… | |
1210 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
978 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1211 | return 1; |
979 | return 1; |
1212 | } |
980 | } |
1213 | |
981 | |
1214 | int |
982 | 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) |
983 | command_nowiz (object *op, char *params) |
1308 | { /* 'noadm' is alias */ |
984 | { /* 'nodm' is alias */ |
1309 | CLEAR_FLAG (op, FLAG_WIZ); |
985 | CLEAR_FLAG (op, FLAG_WIZ); |
1310 | CLEAR_FLAG (op, FLAG_WIZPASS); |
986 | CLEAR_FLAG (op, FLAG_WIZPASS); |
1311 | CLEAR_FLAG (op, FLAG_WIZCAST); |
987 | CLEAR_FLAG (op, FLAG_WIZCAST); |
1312 | |
988 | |
1313 | if (settings.real_wiz == TRUE) |
|
|
1314 | CLEAR_FLAG (op, FLAG_WAS_WIZ); |
|
|
1315 | if (op->contr->hidden) |
989 | if (op->contr->hidden) |
1316 | { |
990 | { |
1317 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
991 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
1318 | op->map->players++; |
992 | op->map->players++; |
1319 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
993 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); |
… | |
… | |
1381 | } |
1055 | } |
1382 | |
1056 | |
1383 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1057 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1384 | { |
1058 | { |
1385 | SET_FLAG (op, FLAG_WIZ); |
1059 | SET_FLAG (op, FLAG_WIZ); |
1386 | SET_FLAG (op, FLAG_WAS_WIZ); |
|
|
1387 | SET_FLAG (op, FLAG_WIZPASS); |
1060 | SET_FLAG (op, FLAG_WIZPASS); |
1388 | SET_FLAG (op, FLAG_WIZCAST); |
1061 | SET_FLAG (op, FLAG_WIZCAST); |
|
|
1062 | |
1389 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1063 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1390 | /* |
1064 | /* |
1391 | * Remove setting flying here - that won't work, because next |
1065 | * Remove setting flying here - that won't work, because next |
1392 | * fix_player() is called that will get cleared - proper solution |
1066 | * fix_player() is called that will get cleared - proper solution |
1393 | * is probably something like a wiz_force which gives that and any |
1067 | * is probably something like a wiz_force which gives that and any |
… | |
… | |
1428 | command_invisible (object *op, char *params) |
1102 | command_invisible (object *op, char *params) |
1429 | { |
1103 | { |
1430 | if (op) |
1104 | if (op) |
1431 | { |
1105 | { |
1432 | op->invisible += 100; |
1106 | op->invisible += 100; |
1433 | update_object (op, UP_OBJ_FACE); |
1107 | update_object (op, UP_OBJ_CHANGE); |
1434 | new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); |
1108 | new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); |
1435 | } |
1109 | } |
1436 | |
1110 | |
1437 | return 0; |
1111 | return 0; |
1438 | } |
1112 | } |