Difference for server/skill_util.c from version 1.27 to 1.28


version 1.27 version 1.28
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_skill_util_c =   * static char *rcsid_skill_util_c =
  *   "$Id: skill_util.c,v 1.27 2002/03/20 06:27:46 mwedel Exp $";   *   "$Id: skill_util.c,v 1.28 2002/07/15 04:57:13 mwedel Exp $";
  */   */
 /*  /*
     CrossFire, A Multiplayer game for X-windows      CrossFire, A Multiplayer game for X-windows
Line 611
 
Line 611
 }  }
   
 /* check_skill_to_fire() -  */  /* check_skill_to_fire() -  */
   
 int check_skill_to_fire(object *who) {  int check_skill_to_fire(object *who) {
   int skillnr=0;    int skillnr=0;
   rangetype shoottype=range_none;    rangetype shoottype=range_none;
   
   if(who->type!=PLAYER) return 1;    if(who->type!=PLAYER) return 1;
   
   switch((shoottype = who->contr->shoottype)) {      shoottype = who->contr->shoottype;
       switch(shoottype) {
   
     case range_bow:      case range_bow:
        skillnr = SK_MISSILE_WEAPON;         skillnr = SK_MISSILE_WEAPON;
        break;         break;
   
     case range_none:      case range_none:
     case range_skill:      case range_skill:
        return 1;         return 1;
        break;         break;
   
     case range_magic:      case range_magic:
         if(spells[who->contr->chosen_spell].cleric)          if(spells[who->contr->chosen_spell].cleric)
             skillnr = SK_PRAYING;              skillnr = SK_PRAYING;
         else          else
             skillnr = SK_SPELL_CASTING;              skillnr = SK_SPELL_CASTING;
         break;          break;
     case range_scroll:  
     case range_rod:   case range_golem:
     case range_horn:   case range_misc:
     case range_wand:  
        skillnr = SK_USE_MAGIC_ITEM;         skillnr = SK_USE_MAGIC_ITEM;
        break;         break;
   
     default:      default:
        LOG(llevError,"Warning: bad call of check_skill_to_fire()\n");         LOG(llevError,"Warning: bad call of check_skill_to_fire()\n");
        return 0;         return 0;
Line 682
 
Line 685
         skill = SK_MELEE_WEAPON;          skill = SK_MELEE_WEAPON;
         shoottype = range_skill;          shoottype = range_skill;
         break;          break;
   
       case BOW:        case BOW:
         skill = SK_MISSILE_WEAPON;          skill = SK_MISSILE_WEAPON;
         shoottype = range_bow;          shoottype = range_bow;
         break;          break;
   
       case POTION:        case POTION:
       case SCROLL:        case SCROLL:
         skill = SK_USE_MAGIC_ITEM; /* not literacy! */          skill = SK_USE_MAGIC_ITEM; /* not literacy! */
         shoottype = range_scroll;       shoottype = range_golem;
  break;   break;
   
       case ROD:        case ROD:
         skill = SK_USE_MAGIC_ITEM;  
         shoottype = range_rod;   
  break;  
       case WAND:                        case WAND:               
         skill = SK_USE_MAGIC_ITEM;  
         shoottype = range_wand;   
         break;  
       case HORN:                        case HORN:               
         skill = SK_USE_MAGIC_ITEM;          skill = SK_USE_MAGIC_ITEM;
         shoottype = range_horn;       shoottype = range_misc;
         break;          break;
   
       default:        default:
         LOG(llevDebug,"Warning: bad call of check_skill_to_apply()\n");          LOG(llevDebug,"Warning: bad call of check_skill_to_apply()\n");
         LOG(llevDebug,"No skill exists for item: %s\n",query_name(item));          LOG(llevDebug,"No skill exists for item: %s\n",query_name(item));
Line 712
 
Line 713
 /* now we alter player status appropriately */  /* now we alter player status appropriately */
    
     if(!QUERY_FLAG(item,FLAG_APPLIED)) {     /* we are trying to unapply */      if(!QUERY_FLAG(item,FLAG_APPLIED)) {     /* we are trying to unapply */
    
         if(who->chosen_skill && who->chosen_skill->stats.sp == skill)          if(who->chosen_skill && who->chosen_skill->stats.sp == skill)
            (void) change_skill(who,-1);             (void) change_skill(who,-1);
         return 0;          return 0;
    
     } else {                               /* we are trying to apply */      } else {                               /* we are trying to apply */
            if(!who->chosen_skill || (who->chosen_skill && who->chosen_skill->stats.sp!=skill))
         if(!who->chosen_skill || (who->chosen_skill  
              && who->chosen_skill->stats.sp!=skill))  
                 if(!change_skill(who,skill)) {                  if(!change_skill(who,skill)) {
                     new_draw_info(NDI_UNIQUE, 0,who,"You can't use that!");                      new_draw_info(NDI_UNIQUE, 0,who,"You can't use that!");
                     CLEAR_FLAG(item,FLAG_APPLIED);                      CLEAR_FLAG(item,FLAG_APPLIED);
                     return 0;                      return 0;
                 }                  }
     }      }
    
     who->contr->shoottype=shoottype;      who->contr->shoottype=shoottype;
     return 1;      return 1;
 }  }
Line 772
 
Line 768
            exp_ob[j] = tmp;             exp_ob[j] = tmp;
            esrv_send_item(pl, tmp);             esrv_send_item(pl, tmp);
            exp_index++;             exp_index++;
        find_skill_exp_name(pl, tmp, pl->contr->last_skill_index);
         }          }
   } else if (exp_index!=nrofexpcat) { /* situation for old save file */    } else if (exp_index!=nrofexpcat) { /* situation for old save file */
      if(exp_index<nrofexpcat)        if(exp_index<nrofexpcat)
Line 1041
 
Line 1038
  * unused skills may have wrong value. This is why we call    * unused skills may have wrong value. This is why we call
  * skill->exp_obj->level instead (the level of the associated experience   * skill->exp_obj->level instead (the level of the associated experience
  * object -- which is always right).   * object -- which is always right).
  * -b.t.   * This function is pretty inefficient - it basically goes through the
    * players inventory 'nrofexpcat' times.  However, this isn't called
    * that often, so I have no great desire to try to make it more
    * efficient - MSW
  */   */
    
 void show_skills(object *op) {  void show_skills(object *op) {
     object *tmp=NULL;      object *tmp=NULL;
     char buf[MAX_BUF], *in;      char buf[MAX_BUF], *in;
     int i,length,is_first;      int i,length,is_first;
       static char *periods="........................................";
   
     length = 31;      length = 31;
     in = "";      in = "";
     if (op)  
     clear_win_info(op);      clear_win_info(op);
     /* sprintf(buf,"Player Skills      Category    /lvl"); */       new_draw_info(NDI_UNIQUE, 0,op,"Player skills by experience category");
     sprintf(buf,"Player skills by experience category");  
     new_draw_info(NDI_UNIQUE, 0,op,buf);  
   
     /* print out skills by category */      /* print out skills by category */
     for (i=0;i<=nrofexpcat;i++) {      for (i=0;i<=nrofexpcat;i++) {
  char Special[100];   char Special[100];
   
  Special[0]='\0';   Special[0]='\0';
  is_first=1;   is_first=1;
  if(i==nrofexpcat) i=EXP_NONE; /* skip to misc exp category */   if(i==nrofexpcat) i=EXP_NONE; /* skip to misc exp category */
   
  for (tmp=op->inv;tmp;tmp=tmp->below) {   for (tmp=op->inv;tmp;tmp=tmp->below) {
      if(tmp->type!=SKILL) continue;       if(tmp->type!=SKILL) continue;
   
        /* Don't want to show info for all skills the player may be
         * able to get by equipping different things.  Doing so would also
         * result in things like spell casting being shown multiple times (one
         * for each talisman
         */
      if(skills[tmp->stats.sp].category==i       if(skills[tmp->stats.sp].category==i
         &&(tmp->invisible||QUERY_FLAG(tmp,FLAG_APPLIED))) {          &&(tmp->invisible||QUERY_FLAG(tmp,FLAG_APPLIED))) {
   
  /* header info */   /* header info */
  if(is_first) {     if(is_first) { 
      is_first=0;       is_first=0;
      new_draw_info(NDI_UNIQUE, 0,op," ");        new_draw_info(NDI_UNIQUE, 0,op," ");
   
      if(tmp->exp_obj) {        if(tmp->exp_obj) {
  object *tmp_exp = tmp->exp_obj;   /* Basically want to fill this out to 40 spaces with periods */
  int k=(length-15-strlen(tmp_exp->name));    sprintf(buf,"%s%s", tmp->exp_obj->name, periods);
  char tmpbuf[40];   buf[40] = 0;
  strcpy(tmpbuf,tmp_exp->name);  
  while(k>0) {k--; strcat(tmpbuf,".");}  
  if (settings.use_permanent_experience) {   if (settings.use_permanent_experience) {
      new_draw_info_format(NDI_UNIQUE,0,op,"%slvl:%3d (xp:%d/%d/%d%%)",       new_draw_info_format(NDI_UNIQUE,0,op,"%slvl:%3d (xp:%d/%d/%d%%)",
  tmpbuf,tmp_exp->level,   buf,tmp->exp_obj->level,
  tmp_exp->stats.exp,   tmp->exp_obj->stats.exp,
  level_exp(tmp_exp->level+1, op->expmul),   level_exp(tmp->exp_obj->level+1, op->expmul),
  clipped_percent(tmp_exp->last_heal,tmp_exp->stats.exp));   clipped_percent(tmp->exp_obj->last_heal,tmp->exp_obj->stats.exp));
  } else {   } else {
      new_draw_info_format(NDI_UNIQUE,0,op,"%slvl:%3d (xp:%d/%d)",       new_draw_info_format(NDI_UNIQUE,0,op,"%slvl:%3d (xp:%d/%d)",
  tmpbuf,tmp_exp->level,   buf,tmp->exp_obj->level,
  tmp_exp->stats.exp,   tmp->exp_obj->stats.exp,
  level_exp(tmp_exp->level+1, op->expmul));   level_exp(tmp->exp_obj->level+1, op->expmul));
  }   }
  if (strcmp(tmp_exp->name,"physique")==0) {   if (strcmp(tmp->exp_obj->name,"physique")==0) {
      sprintf(Special,"You can handle %d weapon improvements.",tmp_exp->level/5+5);       sprintf(Special,"You can handle %d weapon improvements.",tmp->exp_obj->level/5+5);
  }   }
  if (strcmp(tmp_exp->name,"wisdom")==0) {   if (strcmp(tmp->exp_obj->name,"wisdom")==0) {
      char *cp = determine_god(op);       char *cp = determine_god(op);
      sprintf(Special,"You worship %s.", cp?cp:"no god at current time");       sprintf(Special,"You worship %s.", cp?cp:"no god at current time");
  }   }
Line 1100
 
Line 1107
  new_draw_info(NDI_UNIQUE,0,op,"misc.");   new_draw_info(NDI_UNIQUE,0,op,"misc.");
      }       }
  } /* is_first */   } /* is_first */
   
  /* print matched skills */   /* print matched skills */
  if((!op || QUERY_FLAG(op, FLAG_WIZ)))   if((!op || QUERY_FLAG(op, FLAG_WIZ)))
      (void) sprintf(buf,"%s%s %s (%5d)",in,       new_draw_info_format(NDI_UNIQUE,0,op,
    "%s%s %s (%5d)",in,
     QUERY_FLAG(tmp,FLAG_APPLIED)?"*":"-",      QUERY_FLAG(tmp,FLAG_APPLIED)?"*":"-",
     skills[tmp->stats.sp].name,tmp->count);      skills[tmp->stats.sp].name,tmp->count);
  else   else
      (void) sprintf(buf,"%s%s %s",in,       new_draw_info_format(NDI_UNIQUE,0,op,
    "%s%s %s",in,
     QUERY_FLAG(tmp,FLAG_APPLIED)?"*":"-",      QUERY_FLAG(tmp,FLAG_APPLIED)?"*":"-",
     skills[tmp->stats.sp].name);      skills[tmp->stats.sp].name);
  new_draw_info(NDI_UNIQUE,0,op,buf);       } /* if object is skill object */
      }   } /* for this cycle through inventory */
  }  
    /* After we print all the skills for a category, print special information */
  if (Special[0]!='\0') {   if (Special[0]!='\0') {
      new_draw_info(NDI_UNIQUE,0,op,Special);       new_draw_info(NDI_UNIQUE,0,op,Special);
  }   }
     }      } /* for all the exp categories */
   
       /* This isn't really skill related.  However, this seems to be as good as any place
        * to dump this information - after all, we are already showing the number of
        * of allowed weapon enchantments
        */
   
       new_draw_info_format(NDI_UNIQUE,0,op, "Your equipped item power is %d out of %d\n",
    op->contr->item_power, op->level);
 }  }
   
 /* use_skill() - similar to invoke command, it executes the skill in the   /* use_skill() - similar to invoke command, it executes the skill in the


Legend:
line(s) removed in v.1.27 
line(s) changed
 line(s) added in v.1.28

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