Difference for server/pets.c from version 1.8 to 1.9


version 1.8 version 1.9
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_pets_c =   * static char *rcsid_pets_c =
  *    "$Id: pets.c,v 1.8 2001/07/14 04:11:18 mwedel Exp $";   *    "$Id: pets.c,v 1.9 2001/08/21 05:39:30 mwedel Exp $";
  */   */
   
 /*  /*
Line 31
 
Line 31
 #include <sproto.h>  #include <sproto.h>
 #endif  #endif
   
 object *get_pet_enemy(object * pet){  /* given that 'pet' is a friendly object, this function returns a
    * monster the pet should attack, NULL if nothing appropriate is
    * found.  it basically looks for nasty things around the owner
    * of the pet to attack.
    * this is now tilemap aware.
    */
   
   object *get_pet_enemy(object * pet, rv_vector *rv){
   object         *owner, *tmp;    object         *owner, *tmp;
   int             i;      int i,x,y;
       mapstruct *nm;
   
   if ((owner = get_owner(pet)) != NULL) {    if ((owner = get_owner(pet)) != NULL) {
     if ((get_enemy(owner)) == pet) {   /* If the owner has turned on the pet, make the pet
    * unfriendly.
    */
    if ((get_enemy(owner,rv)) == pet) {
       CLEAR_FLAG(pet, FLAG_FRIENDLY);        CLEAR_FLAG(pet, FLAG_FRIENDLY);
       remove_friendly_object(pet);        remove_friendly_object(pet);
       pet->move_type &=~PETMOVE;        pet->move_type &=~PETMOVE;
       return owner;        return owner;
     }      }
   } else { /* No point in keeping it friendly  */      } else {
    /* else the owner is no longer around, so the
    * pet no longer needs to be friendly.
    */
     CLEAR_FLAG(pet, FLAG_FRIENDLY);      CLEAR_FLAG(pet, FLAG_FRIENDLY);
     remove_friendly_object(pet);      remove_friendly_object(pet);
     pet->move_type &=~PETMOVE;      pet->move_type &=~PETMOVE;
     return NULL;      return NULL;
   }    }
   if (owner->map != pet->map)      /* If they are not on the same map, the pet won't be agressive */
       if (!on_same_map(pet,owner))
       return NULL;        return NULL;
   for (i = 0; i < SIZEOFFREE; i++)  
     if (out_of_map(owner->map, owner->x + freearr_x[i],      /* We basically look for anything nasty around the owner that this
                    owner->y + freearr_y[i]))       * pet should go and attack.
        continue;       */
     else      for (i = 0; i < SIZEOFFREE; i++) {
       for (tmp = get_map_ob(owner->map, owner->x + freearr_x[i],   x = owner->x + freearr_x[i];
            owner->y + freearr_y[i]); tmp != NULL; tmp = tmp->above)   y = owner->y + freearr_y[i];
         if (tmp == NULL)   if (out_of_map(owner->map, x, y)) continue;
           continue;  
         else  {          else  {
        nm = get_map_from_coord(owner->map, &x, &y);
        /* Only look on the space if there is something alive there. */
        if (GET_MAP_FLAGS(nm, x,y)&P_IS_ALIVE) {
    for (tmp = get_map_ob(nm, x, y); tmp != NULL; tmp = tmp->above) {
           object *tmp2 = tmp->head == NULL?tmp:tmp->head;            object *tmp2 = tmp->head == NULL?tmp:tmp->head;
           if (QUERY_FLAG(tmp2,FLAG_ALIVE) && !QUERY_FLAG(tmp2,FLAG_FRIENDLY)            if (QUERY_FLAG(tmp2,FLAG_ALIVE) && !QUERY_FLAG(tmp2,FLAG_FRIENDLY)
  && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) &&   && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) &&
                  tmp2 != owner && tmp2->type != PLAYER)                   tmp2 != owner && tmp2->type != PLAYER)
           return tmp2;            return tmp2;
         }   } /* for objects on this space */
        } /* if there is something living on this space */
    } /* this is a valid space on the map */
       } /* for loop of spaces around the owner */
   
       /* Didn't find anything - return NULL */
   return NULL;    return NULL;
 }  }
   


Legend:
line(s) removed in v.1.8 
line(s) changed
 line(s) added in v.1.9

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:39