ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/pets.C
(Generate patch)

Comparing deliantra/server/server/pets.C (file contents):
Revision 1.31 by root, Sun May 6 04:49:37 2007 UTC vs.
Revision 1.38 by root, Sun Jul 1 05:00:20 2007 UTC

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 (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * 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
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your 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 GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 22 */
24 23
25#include <global.h> 24#include <global.h>
26#include <sproto.h> 25#include <sproto.h>
27 26
293int 292int
294follow_owner (object *ob, object *owner) 293follow_owner (object *ob, object *owner)
295{ 294{
296 if (owner->flag [FLAG_REMOVED]) 295 if (owner->flag [FLAG_REMOVED])
297 return 0; // do nothing if the owner is removed 296 return 0; // do nothing if the owner is removed
298 else if (owner->map->in_memory != MAP_IN_MEMORY) 297 else if (!owner->map || owner->map->in_memory != MAP_IN_MEMORY)
299 LOG (llevError, "Owner of the pet not on a map in memory!?\n"); 298 LOG (llevError, "owner '%s' of the pet '%s' not on a map in memory!?\n", &owner->name, &ob->name);
300 else 299 else
301 { 300 {
302 int dir = find_free_spot (ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); 301 int dir = find_free_spot (ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE);
303 302
304 if (dir >= 0) 303 if (dir >= 0)
437 * is_golem is to note that this is a golem spell. 436 * is_golem is to note that this is a golem spell.
438 */ 437 */
439object * 438object *
440fix_summon_pet (archetype *at, object *op, int dir, int is_golem) 439fix_summon_pet (archetype *at, object *op, int dir, int is_golem)
441{ 440{
442 archetype *atmp;
443 object *tmp = NULL, *prev = NULL, *head = NULL; 441 object *tmp = NULL, *prev = NULL, *head = NULL;
444 442
445 for (atmp = at; atmp; atmp = atmp->more) 443 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more)
446 { 444 {
447 tmp = arch_to_object (atmp); 445 tmp = arch_to_object (atmp);
448 446
449 if (atmp == at) 447 if (atmp == at)
450 { 448 {
451 if (!is_golem) 449 if (!is_golem)
452 SET_FLAG (tmp, FLAG_MONSTER); 450 SET_FLAG (tmp, FLAG_MONSTER);
453 451
454 tmp->set_owner (op); 452 tmp->set_owner (op);
453
455 if (op->type == PLAYER) 454 if (op->type == PLAYER)
456 { 455 {
457 tmp->stats.exp = 0; 456 tmp->stats.exp = 0;
458 add_friendly_object (tmp); 457 add_friendly_object (tmp);
459 if (is_golem) 458 if (is_golem)
487 } 486 }
488 487
489 if (!head) 488 if (!head)
490 head = tmp; 489 head = tmp;
491 490
492 tmp->x = op->x + freearr_x[dir] + tmp->arch->clone.x; 491 tmp->x = op->x + freearr_x[dir] + tmp->arch->x;
493 tmp->y = op->y + freearr_y[dir] + tmp->arch->clone.y; 492 tmp->y = op->y + freearr_y[dir] + tmp->arch->y;
494 tmp->map = op->map; 493 tmp->map = op->map;
495 494
496 if (tmp->invisible) 495 if (tmp->invisible)
497 tmp->invisible = 0; 496 tmp->invisible = 0;
498 497
677 LOG (llevError, "Spell %s lacks other_arch\n", &spob->name); 676 LOG (llevError, "Spell %s lacks other_arch\n", &spob->name);
678 return 0; 677 return 0;
679 } 678 }
680 679
681 if (!dir) 680 if (!dir)
682 dir = find_free_spot (&at->clone, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1); 681 dir = find_free_spot (at, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1);
683 682
684 if (dir < 0 || ob_blocked (&at->clone, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) 683 if (dir < 0 || ob_blocked (at, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir]))
685 { 684 {
686 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 685 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
687 return 0; 686 return 0;
688 } 687 }
689 688
898 if (level < tr->magic) 897 if (level < tr->magic)
899 break; 898 break;
900 899
901 lasttr = tr; 900 lasttr = tr;
902 901
903 if (tr->item->name == sparam) 902 if (tr->item->archname == sparam)
904 break; 903 break;
905 } 904 }
906 905
907 if (!lasttr) 906 if (!lasttr)
908 { 907 {
983 return 0; 982 return 0;
984 } 983 }
985 984
986 for (i = 1; i <= nrof; i++) 985 for (i = 1; i <= nrof; i++)
987 { 986 {
988 archetype *atmp;
989 object *prev = NULL, *head = NULL, *tmp; 987 object *prev = NULL, *head = NULL, *tmp;
990 988
991 if (dir) 989 if (dir)
992 { 990 {
993 ndir = dir; 991 ndir = dir;
994 dir = absdir (dir + 1); 992 dir = absdir (dir + 1);
995 } 993 }
996 else 994 else
997 ndir = find_free_spot (&summon_arch->clone, op->map, op->x, op->y, 1, SIZEOFFREE); 995 ndir = find_free_spot (summon_arch, op->map, op->x, op->y, 1, SIZEOFFREE);
998 996
999 if (ndir > 0) 997 if (ndir > 0)
1000 { 998 {
1001 x = freearr_x[ndir]; 999 x = freearr_x[ndir];
1002 y = freearr_y[ndir]; 1000 y = freearr_y[ndir];
1003 } 1001 }
1004 1002
1005 if (ndir < 0 || ob_blocked (&summon_arch->clone, op->map, op->x + x, op->y + y)) 1003 if (ndir < 0 || ob_blocked (summon_arch, op->map, op->x + x, op->y + y))
1006 { 1004 {
1007 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1005 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1008 if (nrof > 1) 1006 if (nrof > 1)
1009 new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting."); 1007 new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting.");
1010 1008
1011 return nrof > 1; 1009 return nrof > 1;
1012 } 1010 }
1013 1011
1014 for (atmp = summon_arch; atmp != NULL; atmp = atmp->more) 1012 for (archetype *atmp = summon_arch; atmp != NULL; atmp = (archetype *)atmp->more)
1015 { 1013 {
1016 tmp = arch_to_object (atmp); 1014 tmp = arch_to_object (atmp);
1017 if (atmp == summon_arch) 1015 if (atmp == summon_arch)
1018 { 1016 {
1019 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1017 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1052 tmp->head = head; 1050 tmp->head = head;
1053 prev->more = tmp; 1051 prev->more = tmp;
1054 } 1052 }
1055 1053
1056 prev = tmp; 1054 prev = tmp;
1057 tmp->x = op->x + x + tmp->arch->clone.x; 1055 tmp->x = op->x + x + tmp->arch->x;
1058 tmp->y = op->y + y + tmp->arch->clone.y; 1056 tmp->y = op->y + y + tmp->arch->y;
1059 tmp->map = op->map; 1057 tmp->map = op->map;
1060 } 1058 }
1061 1059
1062 head->direction = freedir[ndir]; 1060 head->direction = freedir[ndir];
1063 head->stats.exp = 0; 1061 head->stats.exp = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines