--- deliantra/server/common/exp.C 2006/08/13 17:16:00 1.1 +++ deliantra/server/common/exp.C 2006/08/30 16:30:36 1.3 @@ -1,6 +1,6 @@ /* * static char *rcsid_arch_c = - * "$Id: exp.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; + * "$Id: exp.C,v 1.3 2006/08/30 16:30:36 root Exp $"; */ /* @@ -31,53 +31,50 @@ sint64 *levels; -#define TRUE 1 -#define FALSE 0 - float exp_att_mult[NROFATTACKS+2] = { - 0.0, /* AT_PHYSICAL */ - 0.0, /* AT_MAGIC */ - 0.0, /* AT_FIRE */ - 0.0, /* AT_ELECTRICITY */ - 0.0, /* AT_COLD */ - 0.0, /* AT_WATER *//*AT_CONFUSION!*/ - 0.4, /* AT_ACID */ - 1.5, /* AT_DRAIN */ - 0.0, /* AT_WEAPONMAGIC */ - 0.1, /* AT_GHOSTHIT */ - 0.3, /* AT_POISON */ - 0.2, /* AT_DISEASE */ - 0.3, /* AT_PARALYZE */ - 0.0, /* AT_TURN_UNDEAD */ - 0.0, /* AT_FEAR */ - 0.0, /* AT_CANCELLATION */ - 0.0, /* AT_DEPLETE */ - 0.0, /* AT_DEATH */ - 0.0, /* AT_CHAOS */ - 0.0 /* AT_COUNTERSPELL */ + 0.0, /* AT_PHYSICAL */ + 0.0, /* AT_MAGIC */ + 0.0, /* AT_FIRE */ + 0.0, /* AT_ELECTRICITY */ + 0.0, /* AT_COLD */ + 0.0, /* AT_WATER *//*AT_CONFUSION!*/ + 0.4, /* AT_ACID */ + 1.5, /* AT_DRAIN */ + 0.0, /* AT_WEAPONMAGIC */ + 0.1, /* AT_GHOSTHIT */ + 0.3, /* AT_POISON */ + 0.2, /* AT_DISEASE */ + 0.3, /* AT_PARALYZE */ + 0.0, /* AT_TURN_UNDEAD */ + 0.0, /* AT_FEAR */ + 0.0, /* AT_CANCELLATION */ + 0.0, /* AT_DEPLETE */ + 0.0, /* AT_DEATH */ + 0.0, /* AT_CHAOS */ + 0.0 /* AT_COUNTERSPELL */ }; float exp_prot_mult[NROFATTACKS+2] = { - 0.4, /* AT_PHYSICAL */ - 0.5, /* AT_MAGIC */ - 0.1, /* AT_FIRE */ - 0.1, /* AT_ELECTRICITY */ - 0.1, /* AT_COLD */ - 0.1, /* AT_WATER */ - 0.1, /* AT_ACID */ - 0.1, /* AT_DRAIN */ - 0.1, /* AT_WEAPONMAGIC */ - 0.1, /* AT_GHOSTHIT */ - 0.1, /* AT_POISON */ - 0.1, /* AT_DISEASE */ - 0.1, /* AT_PARALYZE */ - 0.1, /* AT_TURN_UNDEAD */ - 0.1, /* AT_FEAR */ - 0.0, /* AT_CANCELLATION */ - 0.0, /* AT_DEPLETE */ - 0.0, /* AT_DEATH */ - 0.0, /* AT_CHAOS */ - 0.0 /* AT_COUNTERSPELL */ + 0.4, /* AT_PHYSICAL */ + 0.5, /* AT_MAGIC */ + 0.1, /* AT_FIRE */ + 0.1, /* AT_ELECTRICITY */ + 0.1, /* AT_COLD */ + 0.1, /* AT_WATER */ + 0.1, /* AT_ACID */ + 0.1, /* AT_DRAIN */ + 0.1, /* AT_WEAPONMAGIC */ + 0.1, /* AT_GHOSTHIT */ + 0.1, /* AT_POISON */ + 0.1, /* AT_DISEASE */ + 0.1, /* AT_PARALYZE */ + 0.1, /* AT_TURN_UNDEAD */ + 0.1, /* AT_FEAR */ + 0.0, /* AT_CANCELLATION */ + 0.0, /* AT_DEPLETE */ + 0.0, /* AT_DEATH */ + 0.0, /* AT_CHAOS */ + 0.0 /* AT_COUNTERSPELL */ }; @@ -89,7 +86,7 @@ * this is only used with one of the dumpflags, * and not anyplace in the code. */ - + int new_exp(const object *ob) { double att_mult, prot_mult, spec_mult; double exp; @@ -99,23 +96,23 @@ att_mult = prot_mult =spec_mult = 1.0; for(i=0;iattacktype&mask) != FALSE)); + att_mult += (exp_att_mult[i] * ((ob->attacktype&mask) != 0)); /* We multiply & then divide to prevent roundoffs on the floats. * the doubling is to take into account the table and resistances * are lower than they once were. */ prot_mult += (exp_prot_mult[i] * 200*ob->resist[i]) / 100.0; } - spec_mult += (0.3*(QUERY_FLAG(ob,FLAG_SEE_INVISIBLE)!= FALSE)) + - (0.5*(QUERY_FLAG(ob,FLAG_SPLITTING)!= FALSE))+ - (0.3*(QUERY_FLAG(ob,FLAG_HITBACK)!= FALSE)) + - (0.1*(QUERY_FLAG(ob,FLAG_REFL_MISSILE)!= FALSE)) + - (0.3*(QUERY_FLAG(ob,FLAG_REFL_SPELL)!= FALSE)) + - (1.0*(QUERY_FLAG(ob,FLAG_NO_MAGIC)!= FALSE)) + - (0.1*(QUERY_FLAG(ob,FLAG_PICK_UP)!= FALSE)) + - (0.1*(QUERY_FLAG(ob,FLAG_USE_SCROLL)!= FALSE)) + - (0.2*(QUERY_FLAG(ob,FLAG_USE_RANGE)!= FALSE)) + - (0.1*(QUERY_FLAG(ob,FLAG_USE_BOW)!= FALSE)); + spec_mult += (0.3*(QUERY_FLAG(ob,FLAG_SEE_INVISIBLE)!= 0)) + + (0.5*(QUERY_FLAG(ob,FLAG_SPLITTING)!= 0))+ + (0.3*(QUERY_FLAG(ob,FLAG_HITBACK)!= 0)) + + (0.1*(QUERY_FLAG(ob,FLAG_REFL_MISSILE)!= 0)) + + (0.3*(QUERY_FLAG(ob,FLAG_REFL_SPELL)!= 0)) + + (1.0*(QUERY_FLAG(ob,FLAG_NO_MAGIC)!= 0)) + + (0.1*(QUERY_FLAG(ob,FLAG_PICK_UP)!= 0)) + + (0.1*(QUERY_FLAG(ob,FLAG_USE_SCROLL)!= 0)) + + (0.2*(QUERY_FLAG(ob,FLAG_USE_RANGE)!= 0)) + + (0.1*(QUERY_FLAG(ob,FLAG_USE_BOW)!= 0)); exp = (ob->stats.maxhp<5) ? 5 : ob->stats.maxhp; exp *= (QUERY_FLAG(ob,FLAG_CAST_SPELL) && has_ability(ob)) @@ -138,9 +135,9 @@ object *tmp; for(tmp=ob->inv;tmp!=NULL;tmp=tmp->below) - if(tmp->type==SPELL||tmp->type==SPELLBOOK) - return TRUE; - return FALSE; + if(tmp->type==SPELL||tmp->type==SPELLBOOK) + return true; + return false; } /* This loads the experience table from the exp_table @@ -163,67 +160,67 @@ return; } while (fgets(buf, MAX_BUF-1, fp) != NULL) { - if (buf[0] == '#') continue; + if (buf[0] == '#') continue; - /* eliminate newline */ - if ((cp=strrchr(buf,'\n'))!=NULL) *cp='\0'; + /* eliminate newline */ + if ((cp=strrchr(buf,'\n'))!=NULL) *cp='\0'; - /* Skip over empty lines */ - if (buf[0] == 0) continue; - cp = buf; - while (isspace(*cp) && *cp!=0) cp++; - if (!strncasecmp(cp, "max_level",9)) { - if (settings.max_level) { - LOG(llevDebug, "Got more than one max_level value from exp_table file?\n"); - free(levels); - } - settings.max_level = atoi(cp+9); - if (!settings.max_level) { - LOG(llevDebug, "Got invalid max_level from exp_table file? %s\n", buf); - } else { - levels = (sint64 *) calloc(settings.max_level +1, sizeof(sint64)); - } - } - while (isdigit(*cp) && *cp!=0) { - if (!settings.max_level) { - LOG(llevError, "max_level is not set in exp_table file. Did you remember to update it?\n"); - exit(1); - } - - tmpexp = atoll(cp); - /* Do some sanity checking - if value is bogus, just exit because - * the table otherwise is probably in an inconsistent state - */ - if (tmpexp <= lastexp) { + /* Skip over empty lines */ + if (buf[0] == 0) continue; + cp = buf; + while (isspace(*cp) && *cp!=0) cp++; + if (!strncasecmp(cp, "max_level",9)) { + if (settings.max_level) { + LOG(llevDebug, "Got more than one max_level value from exp_table file?\n"); + free(levels); + } + settings.max_level = atoi(cp+9); + if (!settings.max_level) { + LOG(llevDebug, "Got invalid max_level from exp_table file? %s\n", buf); + } else { + levels = (sint64 *) calloc(settings.max_level +1, sizeof(sint64)); + } + } + while (isdigit(*cp) && *cp!=0) { + if (!settings.max_level) { + LOG(llevError, "max_level is not set in exp_table file. Did you remember to update it?\n"); + exit(1); + } + + tmpexp = atoll(cp); + /* Do some sanity checking - if value is bogus, just exit because + * the table otherwise is probably in an inconsistent state + */ + if (tmpexp <= lastexp) { #ifndef WIN32 - LOG(llevError,"Experience for level %d is lower than previous level (%lld <= %lld)\n", - lastlevel + 1, tmpexp, lastexp); + LOG(llevError,"Experience for level %d is lower than previous level (%lld <= %lld)\n", + lastlevel + 1, tmpexp, lastexp); #else - LOG(llevError,"Experience for level %d is lower than previous level (%I64d <= %I64d)\n", - lastlevel + 1, tmpexp, lastexp); + LOG(llevError,"Experience for level %d is lower than previous level (%I64d <= %I64d)\n", + lastlevel + 1, tmpexp, lastexp); #endif - exit(1); - } - lastlevel++; - if (lastlevel > settings.max_level) { - LOG(llevError,"Too many levels specified in table (%d > %d)\n", - lastlevel, settings.max_level); - exit(1); - } - levels[lastlevel] = tmpexp; - lastexp = tmpexp; - /* First, skip over the number we just processed. Then skip over - * any spaces, commas, etc. - */ - while (isdigit(*cp) && *cp!=0) cp++; - while (!isdigit(*cp) && *cp!=0) cp++; - } + exit(1); + } + lastlevel++; + if (lastlevel > settings.max_level) { + LOG(llevError,"Too many levels specified in table (%d > %d)\n", + lastlevel, settings.max_level); + exit(1); + } + levels[lastlevel] = tmpexp; + lastexp = tmpexp; + /* First, skip over the number we just processed. Then skip over + * any spaces, commas, etc. + */ + while (isdigit(*cp) && *cp!=0) cp++; + while (!isdigit(*cp) && *cp!=0) cp++; + } } close_and_delete(fp, comp); if (lastlevel != settings.max_level && lastlevel != 0) { - LOG(llevError,"Warning: exp_table does not have %d entries (%d)\n", - settings.max_level, lastlevel); - exit(1); + LOG(llevError,"Warning: exp_table does not have %d entries (%d)\n", + settings.max_level, lastlevel); + exit(1); } } @@ -236,7 +233,7 @@ int i; for (i=1; i<= settings.max_level; i++) { - fprintf(logfile,"%4d %20lld\n", i, levels[i]); + fprintf(logfile,"%4d %20lld\n", i, levels[i]); } exit(0); }