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.38 by root, Sun Jul 1 05:00:20 2007 UTC vs.
Revision 1.43 by root, Tue Jan 22 16:22:45 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra 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 3 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,
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, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <sproto.h> 25#include <sproto.h>
26 26
31 * this is now tilemap aware. 31 * this is now tilemap aware.
32 */ 32 */
33object * 33object *
34get_pet_enemy (object *pet, rv_vector * rv) 34get_pet_enemy (object *pet, rv_vector * rv)
35{ 35{
36 object *owner, *tmp, *attacker, *tmp3; 36 object *tmp, *attacker, *tmp3;
37 int i; 37 int i;
38 sint16 x, y; 38 sint16 x, y;
39 maptile *nm; 39 maptile *nm;
40 int search_arr[SIZEOFFREE]; 40 int search_arr[SIZEOFFREE];
41 int mflags; 41 int mflags;
42 42
43 attacker = pet->attacked_by; /*pointer to attacking enemy */ 43 attacker = pet->attacked_by; /*pointer to attacking enemy */
44 pet->attacked_by = NULL; /*clear this, since we are dealing with it */ 44 pet->attacked_by = NULL; /*clear this, since we are dealing with it */
45 45
46 if (owner = pet->owner) 46 object *owner = pet->owner;
47 { 47
48 /* If the owner has turned on the pet, make the pet 48 if (!owner)
49 * unfriendly.
50 */
51 if (check_enemy (owner, rv) == pet)
52 {
53 remove_friendly_object (pet);
54 pet->attack_movement &= ~PETMOVE;
55 return owner;
56 }
57 } 49 {
58 else
59 {
60 /* else the owner is no longer around, so the 50 /* the owner is no longer around, so the
61 * pet no longer needs to be friendly. 51 * pet no longer needs to be friendly.
62 */ 52 */
63 remove_friendly_object (pet); 53 remove_friendly_object (pet);
64 pet->attack_movement &= ~PETMOVE; 54 pet->attack_movement &= ~PETMOVE;
65 return 0; 55 return 0;
56 }
57
58 /* If the owner has turned on the pet, make the pet
59 * unfriendly.
60 */
61 if (check_enemy (owner, rv) == pet)
62 {
63 remove_friendly_object (pet);
64 pet->attack_movement &= ~PETMOVE;
65 return owner;
66 } 66 }
67 67
68 /* If they are not on the same map, the pet won't be agressive */ 68 /* If they are not on the same map, the pet won't be agressive */
69 //if (!on_same_map (pet, owner)) 69 //if (!on_same_map (pet, owner))
70 // return 0; 70 // return 0;
575 mflags = get_map_flags (m, &m, x, y, &x, &y); 575 mflags = get_map_flags (m, &m, x, y, &x, &y);
576 576
577 if (mflags & P_OUT_OF_MAP) 577 if (mflags & P_OUT_OF_MAP)
578 continue; 578 continue;
579 579
580 for (victim = GET_MAP_OB (op->map, x, y); victim; victim = victim->above) 580 for (victim = GET_MAP_OB (m, x, y); victim; victim = victim->above)
581 if (QUERY_FLAG (victim, FLAG_ALIVE)) 581 if (QUERY_FLAG (victim, FLAG_ALIVE))
582 break; 582 break;
583 583
584 /* We used to call will_hit_self to make sure we don't 584 /* We used to call will_hit_self to make sure we don't
585 * hit ourselves, but that didn't work, and I don't really 585 * hit ourselves, but that didn't work, and I don't really
678 } 678 }
679 679
680 if (!dir) 680 if (!dir)
681 dir = find_free_spot (at, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1); 681 dir = find_free_spot (at, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1);
682 682
683 if (dir < 0 || ob_blocked (at, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) 683 if (dir < 0 || at->blocked (op->map, op->x + freearr_x[dir], op->y + freearr_y[dir]))
684 { 684 {
685 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.");
686 return 0; 686 return 0;
687 } 687 }
688 688
695 } 695 }
696 696
697 if (op->type == PLAYER) 697 if (op->type == PLAYER)
698 { 698 {
699 tmp->type = GOLEM; 699 tmp->type = GOLEM;
700 tmp->set_owner (op);
701 op->contr->golem = tmp; 700 op->contr->golem = tmp;
702 /* give the player control of the golem */ 701 /* give the player control of the golem */
703 set_spell_skill (op, caster, spob, tmp); 702 set_spell_skill (op, caster, spob, tmp);
704 }
705 else
706 {
707 if (QUERY_FLAG (op, FLAG_FRIENDLY))
708 {
709 object *owner = op->owner;
710
711 if (owner)
712 { /* For now, we transfer ownership */
713 tmp->set_owner (owner);
714 tmp->attack_movement = PETMOVE;
715 add_friendly_object (tmp);
716 }
717 }
718
719 SET_FLAG (tmp, FLAG_MONSTER);
720 } 703 }
721 704
722 /* make the speed positive. */ 705 /* make the speed positive. */
723 tmp->speed = FABS (tmp->speed); 706 tmp->speed = FABS (tmp->speed);
724 707
949 ndir = dir; 932 ndir = dir;
950 933
951 if (!ndir) 934 if (!ndir)
952 ndir = find_free_spot (mon, op->map, op->x, op->y, 1, SIZEOFFREE); 935 ndir = find_free_spot (mon, op->map, op->x, op->y, 1, SIZEOFFREE);
953 936
954 if (ndir < 0 || ob_blocked (mon, op->map, op->x + freearr_x[ndir], op->y + freearr_y[ndir])) 937 if (ndir < 0 || mon->blocked (op->map, op->x + freearr_x[ndir], op->y + freearr_y[ndir]))
955 { 938 {
956 ndir = -1; 939 ndir = -1;
957 if (++tries == 5) 940 if (++tries == 5)
958 { 941 {
959 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 942 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
998 { 981 {
999 x = freearr_x[ndir]; 982 x = freearr_x[ndir];
1000 y = freearr_y[ndir]; 983 y = freearr_y[ndir];
1001 } 984 }
1002 985
1003 if (ndir < 0 || ob_blocked (summon_arch, op->map, op->x + x, op->y + y)) 986 if (ndir < 0 || summon_arch->blocked (op->map, op->x + x, op->y + y))
1004 { 987 {
1005 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 988 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1006 if (nrof > 1) 989 if (nrof > 1)
1007 new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting."); 990 new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting.");
1008 991

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines