version 1.6 | | version 1.7 |
---|
| | |
/* | | /* |
* static char *rcsid_pets_c = | | * static char *rcsid_pets_c = |
* "$Id: pets.c,v 1.6 2001/02/23 06:06:35 mwedel Exp $"; | | * "$Id: pets.c,v 1.7 2001/05/23 06:14:41 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
void pet_move(object * ob) | | void pet_move(object * ob) |
{ | | { |
int dir; | | int dir,tag; |
object *ob2, *owner; | | object *ob2, *owner; |
| | |
/* Check to see if player pulled out */ | | /* Check to see if player pulled out */ |
if ((owner = get_owner(ob)) == NULL) { | | if ((owner = get_owner(ob)) == NULL) { |
remove_ob(ob); /* Will be freed when returning */ | | remove_ob(ob); /* Will be freed when returning */ |
| | remove_friendly_object(ob); |
| | free_object(ob); |
LOG(llevMonster, "Pet: no owner, leaving.\n"); | | LOG(llevMonster, "Pet: no owner, leaving.\n"); |
return; | | return; |
} | | } |
| | |
dir = find_dir_2(ob->x - ob->owner->x, ob->y - ob->owner->y); | | dir = find_dir_2(ob->x - ob->owner->x, ob->y - ob->owner->y); |
ob->direction = dir; | | ob->direction = dir; |
| | |
| | tag = ob->count; |
if (!(move_ob(ob, dir,ob))) { | | if (!(move_ob(ob, dir,ob))) { |
object *part; | | object *part; |
| | |
| | /* the failed move_ob above may destroy the pet, so check here */ |
| | if (was_destroyed(ob, tag)) return; |
| | |
for(part = ob; part != NULL; part = part->more) | | for(part = ob; part != NULL; part = part->more) |
{ | | { |
for (ob2 = get_map_ob(part->map, part->x + freearr_x[dir], | | for (ob2 = get_map_ob(part->map, part->x + freearr_x[dir], |
| | |
if (QUERY_FLAG(new_ob,FLAG_ALIVE) && !QUERY_FLAG(ob,FLAG_UNAGGRESSIVE) | | if (QUERY_FLAG(new_ob,FLAG_ALIVE) && !QUERY_FLAG(ob,FLAG_UNAGGRESSIVE) |
&& !QUERY_FLAG(new_ob,FLAG_UNAGGRESSIVE) && | | && !QUERY_FLAG(new_ob,FLAG_UNAGGRESSIVE) && |
!QUERY_FLAG(new_ob,FLAG_FRIENDLY)) { | | !QUERY_FLAG(new_ob,FLAG_FRIENDLY)) { |
| | |
ob->enemy = new_ob; | | ob->enemy = new_ob; |
if(new_ob->enemy == NULL) | | if(new_ob->enemy == NULL) |
new_ob->enemy = ob; | | new_ob->enemy = ob; |