1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <sproto.h> |
26 | #include <sproto.h> |
… | |
… | |
436 | |
436 | |
437 | int |
437 | int |
438 | command_summon (object *op, char *params) |
438 | command_summon (object *op, char *params) |
439 | { |
439 | { |
440 | int i; |
440 | int i; |
441 | object *dummy; |
|
|
442 | player *pl; |
441 | player *pl; |
443 | |
442 | |
444 | if (!op) |
443 | if (!op) |
445 | return 0; |
444 | return 0; |
446 | |
445 | |
… | |
… | |
452 | |
451 | |
453 | pl = get_other_player_from_name (op, params); |
452 | pl = get_other_player_from_name (op, params); |
454 | if (!pl) |
453 | if (!pl) |
455 | return 1; |
454 | return 1; |
456 | |
455 | |
457 | i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
456 | maptile *m = op->map; |
|
|
457 | sint16 nx = op->x; |
|
|
458 | sint16 ny = op->y; |
|
|
459 | |
|
|
460 | i = find_free_spot (op, m, nx, ny, 1, SIZEOFFREE1+1); |
458 | if (i == -1) |
461 | if (i == -1) |
459 | { |
462 | { |
460 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
463 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
461 | return 1; |
464 | return 1; |
462 | } |
465 | } |
463 | |
466 | |
464 | pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]); |
467 | nx += freearr_x [i]; |
|
|
468 | ny += freearr_y [i]; |
|
|
469 | |
|
|
470 | if (!xy_normalise (m, nx, ny)) |
|
|
471 | { |
|
|
472 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
|
|
473 | return 1; |
|
|
474 | } |
|
|
475 | |
|
|
476 | pl->ob->player_goto (m->path, nx, ny); |
465 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
477 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
466 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
478 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
467 | |
479 | |
468 | return 1; |
480 | return 1; |
469 | } |
481 | } |
… | |
… | |
486 | int |
498 | int |
487 | command_create (object *op, char *params) |
499 | command_create (object *op, char *params) |
488 | { |
500 | { |
489 | object *tmp = NULL; |
501 | object *tmp = NULL; |
490 | int nrof, i, magic, set_magic = 0, set_nrof = 0, gotquote, gotspace; |
502 | int nrof, i, magic, set_magic = 0, set_nrof = 0, gotquote, gotspace; |
491 | char buf[MAX_BUF], *cp, *bp = buf, *bp2, *bp3, *bp4, *endline; |
503 | char buf[MAX_BUF], *cp, *bp = buf, *bp2, *bp3, *endline; |
492 | archetype *at, *at_spell = NULL; |
504 | archetype *at, *at_spell = NULL; |
493 | artifact *art = NULL; |
505 | artifact *art = NULL; |
494 | |
506 | |
495 | if (!op) |
507 | if (!op) |
496 | return 0; |
508 | return 0; |
… | |
… | |
629 | set_abs_magic (tmp, magic); |
641 | set_abs_magic (tmp, magic); |
630 | |
642 | |
631 | if (art) |
643 | if (art) |
632 | give_artifact_abilities (tmp, art->item); |
644 | give_artifact_abilities (tmp, art->item); |
633 | |
645 | |
634 | if (need_identify (tmp)) |
646 | if (tmp->need_identify ()) |
635 | { |
647 | { |
636 | tmp->set_flag (FLAG_IDENTIFIED); |
648 | tmp->set_flag (FLAG_IDENTIFIED); |
637 | tmp->clr_flag (FLAG_KNOWN_MAGICAL); |
649 | tmp->clr_flag (FLAG_KNOWN_MAGICAL); |
638 | } |
650 | } |
639 | |
651 | |
… | |
… | |
644 | * is we want to find two spaces, but if we got a quote, |
656 | * is we want to find two spaces, but if we got a quote, |
645 | * any spaces there don't count. |
657 | * any spaces there don't count. |
646 | */ |
658 | */ |
647 | while (*bp2 && bp2 <= endline) |
659 | while (*bp2 && bp2 <= endline) |
648 | { |
660 | { |
649 | bp4 = NULL; |
|
|
650 | gotspace = 0; |
661 | gotspace = 0; |
651 | gotquote = 0; |
662 | gotquote = 0; |
652 | |
663 | |
653 | /* find the first quote */ |
664 | /* find the first quote */ |
654 | for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++) |
665 | for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++) |
… | |
… | |
1022 | /**************************************************************************/ |
1033 | /**************************************************************************/ |
1023 | |
1034 | |
1024 | int |
1035 | int |
1025 | command_stats (object *op, char *params) |
1036 | command_stats (object *op, char *params) |
1026 | { |
1037 | { |
1027 | char thing[20]; |
|
|
1028 | char buf[MAX_BUF]; |
1038 | char buf[MAX_BUF]; |
1029 | |
1039 | |
1030 | thing[0] = '\0'; |
1040 | if (params == NULL || params[0] == '\0') |
1031 | if (params == NULL || !sscanf (params, "%s", thing) || thing == NULL) |
|
|
1032 | { |
1041 | { |
1033 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
1042 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
1034 | return 1; |
1043 | return 1; |
1035 | } |
1044 | } |
1036 | |
1045 | |
1037 | for_all_players (pl) |
1046 | for_all_players (pl) |
1038 | if (!strcmp (&pl->ob->name, thing)) |
1047 | if (!strcmp (&pl->ob->name, params)) |
1039 | { |
1048 | { |
1040 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
1049 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
1041 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1050 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1042 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
1051 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
1043 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1052 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
… | |
… | |
1336 | { |
1345 | { |
1337 | new_draw_info (NDI_UNIQUE, 0, op, "Which spell do you want to forget?"); |
1346 | new_draw_info (NDI_UNIQUE, 0, op, "Which spell do you want to forget?"); |
1338 | return 0; |
1347 | return 0; |
1339 | } |
1348 | } |
1340 | |
1349 | |
1341 | spell = lookup_spell_by_name (op, params); |
1350 | spell = op->find_spell (params); |
1342 | if (spell == NULL) |
1351 | if (spell == NULL) |
1343 | { |
1352 | { |
1344 | new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); |
1353 | new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); |
1345 | return 0; |
1354 | return 0; |
1346 | } |
1355 | } |