Difference for common/item.c from version 1.37 to 1.38


version 1.37 version 1.38
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_item_c =   * static char *rcsid_item_c =
  *   "$Id: item.c,v 1.37 2003/05/21 07:31:13 mwedel Exp $";   *   "$Id: item.c,v 1.38 2003/09/13 05:01:27 mwedel Exp $";
  */   */
   
 /*  /*
Line 120
 
Line 120
  * wear whatever they want with no worries.  Perhaps having the steep   * wear whatever they want with no worries.  Perhaps having the steep
  * curve is good (maybe even steeper), but allowing players to   * curve is good (maybe even steeper), but allowing players to
  * have 2 * level instead.  Ideally, top level characters should only be   * have 2 * level instead.  Ideally, top level characters should only be
  * able to use 2-3 of the most power items.   * able to use 2-3 of the most powerful items.
  * note that this table is only really used for program generated items -   * note that this table is only really used for program generated items -
  * custom objects can use whatever they want.   * custom objects can use whatever they want.
  */   */
 static int enc_to_item_power[21] = {  static int enc_to_item_power[21] = {
 0, 0, 1, 2, 3, 4,    /* 5 */  0, 0, 1, 2, 3, 4,    /* 5 */
 5, 7, 9, 11, 13,    /* 10 */  5, 7, 9, 11, 13,    /* 10 */
 16, 18, 21, 24, 27, /* 15 */  15, 18, 21, 24, 27, /* 15 */
 30, 35, 40, 45, 50  /* 20 */  30, 35, 40, 45, 50  /* 20 */
 };  };
   
Line 205
 
Line 205
     if(QUERY_FLAG(op,FLAG_SEE_IN_DARK))     enc += 1;      if(QUERY_FLAG(op,FLAG_SEE_IN_DARK))     enc += 1;
     if(QUERY_FLAG(op,FLAG_MAKE_INVIS))     enc += 1;      if(QUERY_FLAG(op,FLAG_MAKE_INVIS))     enc += 1;
   
   #if 0
     if (enc > 20) {      if (enc > 20) {
  LOG(llevDebug,"calc_item_power got %d enchantments for %s\n", enc, op->name?op->name:"(null)");   LOG(llevDebug,"calc_item_power got %d enchantments for %s\n", enc, op->name?op->name:"(null)");
  enc = 20;   enc = 20;
     }      }
   #endif
     /* Items only have a positive power rating */      /* Items only have a positive power rating */
     if (enc < 0) enc = 0;      if (enc < 0) enc = 0;
   
Line 401
 
Line 403
   
     switch(op->type) {      switch(op->type) {
       case SPELLBOOK:        case SPELLBOOK:
  if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {  
      if(!op->title) {  
  safe_strcat(buf," of ", &len, HUGE_BUF);  
  if(op->slaying) safe_strcat(buf,op->slaying, &len, HUGE_BUF);  
  else  
    safe_strcat(buf,spells[op->stats.sp].name, &len, HUGE_BUF);  
  if(op->type != SPELLBOOK) {  
      sprintf(buf2, " (lvl %d)", op->level);  
      safe_strcat(buf, buf2, &len, HUGE_BUF);  
  }  
      }  
  }  
    
  break;  
       case SCROLL:        case SCROLL:
       case WAND:        case WAND:
       case ROD:        case ROD:
  if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {   if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {
      if(!op->title) {       if(!op->title) {
  safe_strcat(buf," of ", &len, HUGE_BUF);   safe_strcat(buf," of ", &len, HUGE_BUF);
  safe_strcat(buf,spells[op->stats.sp].name, &len, HUGE_BUF);       if (op->inv)
    safe_strcat(buf,op->inv->name, &len, HUGE_BUF);
        else
    LOG(llevError,"Spellbook %s lacks inventory\n", op->name);
    }
  if(op->type != SPELLBOOK) {   if(op->type != SPELLBOOK) {
      sprintf(buf2, " (lvl %d)", op->level);       sprintf(buf2, " (lvl %d)", op->level);
      safe_strcat(buf, buf2, &len, HUGE_BUF);       safe_strcat(buf, buf2, &len, HUGE_BUF);
  }   }
      }       }
  }  
  break;   break;
   
       case SKILL:        case SKILL:
Line 508
 
Line 499
     if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED))      if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED))
  safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF);   safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF);
   
   #if 0
       /* item_power will be returned in desribe_item - it shouldn't really
        * be returned in the name.
        */
     if(op->item_power)      if(op->item_power)
  sprintf(buf[use_buf]+strlen(buf[use_buf]), "(item_power %+d)",   sprintf(buf[use_buf]+strlen(buf[use_buf]), "(item_power %+d)",
      op->item_power);       op->item_power);
   
   #endif
   
     if (QUERY_FLAG(op,FLAG_APPLIED)) {      if (QUERY_FLAG(op,FLAG_APPLIED)) {
  switch(op->type) {   switch(op->type) {
    case BOW:     case BOW:
Line 559
 
Line 556
  * If plural is set, we generate the plural name of this.   * If plural is set, we generate the plural name of this.
  */   */
 char *query_base_name(object *op, int plural) {  char *query_base_name(object *op, int plural) {
     static char buf[MAX_BUF];      static char buf[MAX_BUF], buf2[MAX_BUF];
     int len;      int len;
     materialtype_t *mt;      materialtype_t *mt;
   
Line 601
 
Line 598
   
     switch(op->type) {      switch(op->type) {
       case SPELLBOOK:        case SPELLBOOK:
  if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {  
      if(!op->title) {  
  safe_strcat(buf," of ", &len, MAX_BUF);  
  if(op->slaying) safe_strcat(buf,op->slaying, &len, MAX_BUF);  
  else  
    safe_strcat(buf,spells[op->stats.sp].name, &len, MAX_BUF);  
  if(op->type != SPELLBOOK)   
      sprintf(buf+strlen(buf), " (lvl %d)", op->level);  
      }  
  }  
  break;  
   
       case SCROLL:        case SCROLL:
       case WAND:        case WAND:
       case ROD:        case ROD:
  if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {   if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {
      if(!op->title) {       if(!op->title) {
  safe_strcat(buf," of ", &len, MAX_BUF);       safe_strcat(buf," of ", &len, HUGE_BUF);
  safe_strcat(buf,spells[op->stats.sp].name, &len, MAX_BUF);       if (op->inv)
  if(op->type != SPELLBOOK)   safe_strcat(buf,op->inv->name, &len, HUGE_BUF);
      sprintf(buf+strlen(buf), " (lvl %d)", op->level);       else
    LOG(llevError,"Spellbook %s lacks inventory\n", op->name);
    }
    if(op->type != SPELLBOOK) {
        sprintf(buf2, " (lvl %d)", op->level);
        safe_strcat(buf, buf2, &len, HUGE_BUF);
      }       }
  }   }
  break;   break;
   
   
       case SKILL:        case SKILL:
       case AMULET:        case AMULET:
       case RING:        case RING:
Line 727
 
Line 718
  treasure *t;   treasure *t;
  int first = 1;   int first = 1;
  for(t=op->randomitems->items; t != NULL; t=t->next)   for(t=op->randomitems->items; t != NULL; t=t->next)
      if(t->item && (t->item->clone.type == ABILITY)) {       if(t->item && (t->item->clone.type == SPELL)) {
  if(first) {   if(first) {
      first = 0;       first = 0;
      strcat(retbuf,"(Spell abilities:)");       strcat(retbuf,"(Spell abilities:)");
Line 883
 
Line 874
  case SKILL:   case SKILL:
  case RING:   case RING:
  case AMULET:   case AMULET:
        if(op->item_power) {
    sprintf(buf,"(item_power %+d)",op->item_power);
    strcat(retbuf,buf);
        }
      if (op->title)       if (op->title)
  strcat (retbuf, ring_desc(op));   strcat (retbuf, ring_desc(op));
      return retbuf;       return retbuf;
Line 1173
 
Line 1168
   case POWER_CRYSTAL:    case POWER_CRYSTAL:
   case POISON:    case POISON:
   case BOOK:    case BOOK:
    case SKILL_TOOL:
     return 1;      return 1;
   }    }
 /* Try to track down some stuff that may show up here.  Thus, the  /* Try to track down some stuff that may show up here.  Thus, the
Line 1186
 
Line 1182
   
   
 /*   /*
  *  Return the number of the spell that whose name passes the pasesed string  
  *  argument.   Return -1 if no such spell name match is found.  
  */  
 int look_up_spell_name( char * spname ){  
    register int i;  
    for(i=0;i< NROFREALSPELLS;i++){  
       if( strcmp(spname, spells[i].name) == 0) return i;  
    }  
    return -1;  
 }  
   
 /*  
  * Supposed to fix face-values as well here, but later.   * Supposed to fix face-values as well here, but later.
  */   */
   
Line 1214
 
Line 1198
   if (QUERY_FLAG(op,FLAG_CURSED) || QUERY_FLAG(op,FLAG_DAMNED))    if (QUERY_FLAG(op,FLAG_CURSED) || QUERY_FLAG(op,FLAG_DAMNED))
     SET_FLAG(op,FLAG_KNOWN_CURSED);      SET_FLAG(op,FLAG_KNOWN_CURSED);
   
   if (op->type == POTION && op->arch != (archetype *) NULL) {      if (op->type == POTION) {
    if (op->inv) {
        if (op->title) free_string(op->title);
        op->title = add_refcount(op->inv->name);
    } else if (op->arch) {
       free_string(op->name);        free_string(op->name);
       op->name = add_refcount(op->arch->clone.name);        op->name = add_refcount(op->arch->clone.name);
       free_string(op->name_pl);        free_string(op->name_pl);
       op->name_pl = add_refcount(op->arch->clone.name_pl);        op->name_pl = add_refcount(op->arch->clone.name_pl);
   } else if( op->type == SPELLBOOK && op->slaying != NULL){  
        if((op->stats.sp = look_up_spell_name( op->slaying )) <0 ){  
    char buf[256];  
           op->stats.sp = -1;    
           sprintf(buf, "Spell forumla for %s", op->slaying);  
    if(op->name != NULL)   
  free_string(op->name);  
    op->name = add_string(buf);  
        } else {  
          /* clear op->slaying since we no longer need it */  
          free_string(op->slaying);  
          op->slaying=NULL;  
        }         }
   }    }
   
   if (op->map) /* The shop identifies items before they hit the ground */      /* If the object is on a map, make sure we update its face */
     /* I don't think identification will change anything but face */      if (op->map)
     update_object(op,UP_OBJ_FACE);      update_object(op,UP_OBJ_FACE);
   else {    else {
     pl = is_player_inv(op->env);      pl = is_player_inv(op->env);


Legend:
line(s) removed in v.1.37 
line(s) changed
 line(s) added in v.1.38

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