Difference for server/spell_util.c from version 1.9 to 1.10


version 1.9 version 1.10
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_spell_util_c =   * static char *rcsid_spell_util_c =
  *   "$Id: spell_util.c,v 1.9 2000/04/19 11:46:42 jec Exp $";   *   "$Id: spell_util.c,v 1.10 2000/04/25 04:53:00 cvs Exp $";
  */   */
   
 /*  /*
Line 1286
 
Line 1286
   }    }
 }  }
   
   
 /* updated this to allow more than the golem 'head' to attack */  /* updated this to allow more than the golem 'head' to attack */
   /* op is the golem to be moved. */
   
 void move_golem(object *op) {  void move_golem(object *op) {
   int made_attack=0;    int made_attack=0;
   object *tmp;    object *tmp;
   
   if(QUERY_FLAG(op, FLAG_MONSTER))    if(QUERY_FLAG(op, FLAG_MONSTER))
     return; /* Has already been moved */      return; /* Has already been moved */
   
   if(get_owner(op)==NULL) {    if(get_owner(op)==NULL) {
     LOG(llevDebug,"Golem without owner destructed.\n");      LOG(llevDebug,"Golem without owner destructed.\n");
     remove_ob(op);      remove_ob(op);
     free_object(op);      free_object(op);
     return;      return;
   }    }
       /* It would be nice to have a cleaner way of what message to print
        * when the golem expires than these hard coded entries.
        */
   if(--op->stats.hp<0) {    if(--op->stats.hp<0) {
     char buf[MAX_BUF];      char buf[MAX_BUF];
     if(op->exp_obj && op->exp_obj->stats.Wis) {      if(op->exp_obj && op->exp_obj->stats.Wis) {
       if(op->inv)         if(op->inv)
  sprintf(buf,"Your staff stops slithering around and lies still.");   strcpy(buf,"Your staff stops slithering around and lies still.");
       else        else
  sprintf(buf,"Your %s departed this plane.",op->name);   sprintf(buf,"Your %s departed this plane.",op->name);
     } else if (!strncmp(op->name,"animated ",9)) {      } else if (!strncmp(op->name,"animated ",9)) {
Line 1321
 
Line 1329
   /* Do golem attacks/movement for single & multisq golems.     /* Do golem attacks/movement for single & multisq golems.
    * Assuming here that op is the 'head' object. Pass only op to      * Assuming here that op is the 'head' object. Pass only op to
    * move_ob (makes recursive calls to other parts)      * move_ob (makes recursive calls to other parts)
        * move_ob returns 0 if the creature was not able to move.
    */     */
   if(!move_ob(op,op->direction))      if(move_ob(op,op->direction)) return;
   
     for(tmp=op;tmp;tmp=tmp->more) {       for(tmp=op;tmp;tmp=tmp->more) {
       int x=tmp->x+freearr_x[op->direction],y=tmp->y+freearr_y[op->direction];        int x=tmp->x+freearr_x[op->direction],y=tmp->y+freearr_y[op->direction];
       if(!out_of_map(op->map,x,y)&&!will_hit_self(op,x,y)) {  
         object *victim;          object *victim;
   
    if (out_of_map(op->map,x,y)) continue;
   
         for(victim=get_map_ob(op->map,x,y);victim;victim=victim->above)           for(victim=get_map_ob(op->map,x,y);victim;victim=victim->above)
              if(QUERY_FLAG(victim,FLAG_ALIVE)) break;               if(QUERY_FLAG(victim,FLAG_ALIVE)) break;
   
         if(victim) {   /* We used to call will_hit_self to make sure we don't
    * hit ourselves, but that didn't work, and I don't really
    * know if that was more efficient anyways than this.
    * This at least works.  Note that victim->head can be NULL,
    * but since we are not trying to dereferance that pointer,
    * that isn't a problem.
    */
    if(victim && victim!=op && victim->head!=op) {
   
    /* for golems with race fields, we don't attack     /* for golems with race fields, we don't attack
     * aligned races */      * aligned races */
   
    if(victim->race&&op->race&&strstr(op->race,victim->race)) {     if(victim->race&&op->race&&strstr(op->race,victim->race)) {
      if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner,       if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner,
      "%s avoids damaging %s.",op->name,victim->name);       "%s avoids damaging %s.",op->name,victim->name);
Line 1341
 
Line 1362
      if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner,       if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner,
      "%s avoids damaging you.",op->name);       "%s avoids damaging you.",op->name);
    } else {     } else {
             hit_map(tmp,op->direction,op->attacktype);   /* I think using hit_map here is just wrong -
    * we are not attacking a space - we have a specific
    * creature we are attacking, attack_ob seems more
    * appropriate.
    */
   
    attack_ob(victim,op);
   /* hit_map(tmp,op->direction,op->attacktype);*/
             made_attack=1;              made_attack=1;
    }     }
  }   } /* If victim */
       }  
     }      }
   if(made_attack) update_object(op);    if(made_attack) update_object(op);
 }  }
   
 /* check to see if the monster will hit itself at  
  * location x,y   
  */  
 int will_hit_self(object *head, int x, int y) {  
   object *tmp;  
   
   for(tmp=head;tmp;tmp=tmp->more) {   
     int cx=tmp->arch->clone.x, cy=tmp->arch->clone.y;  
     if((cx+head->x==x)&&(cy+head->y==y)) return 1;   
   }  
   return 0;  
 }  
   
 void control_golem(object *op,int dir) {  void control_golem(object *op,int dir) {
   op->direction=dir;    op->direction=dir;
 }  }


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

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