Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: status.c
- ===================================================================
- --- status.c (revision 15734)
- +++ status.c (working copy)
- @@ -48,10 +48,9 @@
- };
- static int max_weight_base[CLASS_COUNT];
- -static int hp_coefficient[CLASS_COUNT];
- -static int hp_coefficient2[CLASS_COUNT];
- -static int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1];
- -static int sp_coefficient[CLASS_COUNT];
- +static unsigned int hp_table[CLASS_COUNT][MAX_LEVEL];
- +static unsigned int sp_table[CLASS_COUNT][MAX_LEVEL];
- +static unsigned int max_level[CLASS_COUNT];
- static int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89]
- // bonus values and upgrade chances for refining equipment
- @@ -2022,39 +2021,12 @@
- return 1;
- }
- -/// Helper function for status_base_pc_maxhp(), used to pre-calculate the hp_sigma_val[] array
- -static void status_calc_sigma(void)
- -{
- - int i,j;
- -
- - for(i = 0; i < CLASS_COUNT; i++)
- - {
- - unsigned int k = 0;
- - hp_sigma_val[i][0] = hp_sigma_val[i][1] = 0;
- - for(j = 2; j <= MAX_LEVEL; j++)
- - {
- - k += (hp_coefficient[i]*j + 50) / 100;
- - hp_sigma_val[i][j] = k;
- - if (k >= INT_MAX)
- - break; //Overflow protection. [Skotlex]
- - }
- - for(; j <= MAX_LEVEL; j++)
- - hp_sigma_val[i][j] = INT_MAX;
- - }
- -}
- -
- -/// Calculates base MaxHP value according to class and base level
- -/// The recursive equation used to calculate level bonus is (using integer operations)
- -/// f(0) = 35 | f(x+1) = f(x) + A + (x + B)*C/D
- -/// which reduces to something close to
- -/// f(x) = 35 + x*(A + B*C/D) + sum(i=2..x){ i*C/D }
- +//Calculate maxHP from tables
- static unsigned int status_base_pc_maxhp(struct map_session_data* sd, struct status_data* status)
- {
- - unsigned int val = pc_class2idx(sd->status.class_);
- - val = 35 + sd->status.base_level*hp_coefficient2[val]/100 + hp_sigma_val[val][sd->status.base_level];
- + unsigned int val;
- + val = hp_table[pc_class2idx(sd->status.class_)][sd->status.base_level-1];
- - if((sd->class_&MAPID_UPPERMASK) == MAPID_NINJA || (sd->class_&MAPID_UPPERMASK) == MAPID_GUNSLINGER)
- - val += 100; //Since their HP can't be approximated well enough without this.
- if((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON))
- val *= 3; //Triple max HP for top ranking Taekwons over level 90.
- if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99)
- @@ -2069,11 +2041,11 @@
- return val;
- }
- +//Calculate maxSP from tables
- static unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct status_data *status)
- {
- unsigned int val;
- -
- - val = 10 + sd->status.base_level*sp_coefficient[pc_class2idx(sd->status.class_)]/100;
- + val = sp_table[pc_class2idx(sd->status.class_)][sd->status.base_level-1];
- val += val * status->int_/100;
- if (sd->class_&JOBL_UPPER)
- @@ -10072,7 +10044,7 @@
- /*------------------------------------------
- * DB reading.
- - * job_db1.txt - weight, hp, sp, aspd
- + * job_db1.txt - weight, aspd
- * job_db2.txt - job level stat bonuses
- * size_fix.txt - size adjustment table for weapons
- * refine_db.txt - refining data table
- @@ -10097,7 +10069,7 @@
- }
- #endif
- static bool status_readdb_job1(char* fields[], int columns, int current)
- -{// Job-specific values (weight, HP, SP, ASPD)
- +{// Job-specific values (weight, ASPD)
- int idx, class_;
- unsigned int i;
- @@ -10111,13 +10083,10 @@
- idx = pc_class2idx(class_);
- max_weight_base[idx] = atoi(fields[1]);
- - hp_coefficient[idx] = atoi(fields[2]);
- - hp_coefficient2[idx] = atoi(fields[3]);
- - sp_coefficient[idx] = atoi(fields[4]);
- for(i = 0; i < MAX_WEAPON_TYPE; i++)
- {
- - aspd_base[idx][i] = atoi(fields[i+5]);
- + aspd_base[idx][i] = atoi(fields[i+2]);
- }
- return true;
- }
- @@ -10196,9 +10165,6 @@
- // job_db1.txt
- memset(max_weight_base, 0, sizeof(max_weight_base));
- - memset(hp_coefficient, 0, sizeof(hp_coefficient));
- - memset(hp_coefficient2, 0, sizeof(hp_coefficient2));
- - memset(sp_coefficient, 0, sizeof(sp_coefficient));
- memset(aspd_base, 0, sizeof(aspd_base));
- #if REMODE
- memset(re_job_db, 0, sizeof(re_job_db));
- @@ -10225,7 +10191,7 @@
- // read databases
- //
- - sv_readdb(db_path, "job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1);
- + sv_readdb(db_path, "job_db1.txt", ',', 2+MAX_WEAPON_TYPE, 2+MAX_WEAPON_TYPE, -1, &status_readdb_job1);
- sv_readdb(db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2);
- sv_readdb(db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix);
- #if REMODE
- @@ -10233,6 +10199,145 @@
- #endif
- sv_readdb(db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine);
- + // job_maxhp.txt
- + FILE *fp;
- + char line[1024], path[1024],*p;
- +
- + memset(hp_table,0,sizeof(hp_table));
- + memset(max_level,0,sizeof(max_level));
- + sprintf(path, "%s/"DBPATH"job_maxhp.txt", db_path);
- + fp=fopen(path, "r");
- + if(fp==NULL){
- + ShowError("can't read %s\n", path);
- + return 1;
- + }
- + while(fgets(line, sizeof(line), fp))
- + {
- + int jobs[CLASS_COUNT], job_count, job, job_id;
- + unsigned int ui,maxlv;
- + char *split[3];
- + if(line[0]=='/' && line[1]=='/')
- + continue;
- + if (pc_split_str(line,split,3) < 3)
- + continue;
- +
- + job_count = pc_split_atoi(split[1],jobs,':',CLASS_COUNT);
- + if (job_count < 1)
- + continue;
- + job_id = jobs[0];
- + if (!pcdb_checkid(job_id)) {
- + ShowError("status_readdb: Invalid job ID %d.\n", job_id);
- + continue;
- + }
- + maxlv = atoi(split[0]);
- + if (maxlv > MAX_LEVEL) {
- + ShowWarning("status_readdb: Specified max level %u for job %d is beyond server's limit (%u).\n ", maxlv, job_id, MAX_LEVEL);
- + maxlv = MAX_LEVEL;
- + }
- +
- + job = jobs[0] = pc_class2idx(job_id);
- + max_level[job] = pc_split_atoui(split[2], hp_table[job],',',maxlv)+1;
- + while ((ui = max_level[job]) >= 2 && hp_table[job][ui-2] <= 0)
- + max_level[job]--;
- + if (max_level[job] < maxlv) {
- + ShowWarning("status_readdb: Specified max %u for job %d, but that job's hp table only goes up to level %u.\n", maxlv, job_id, max_level[job]);
- + ShowInfo("Filling the missing values with the last hp entry.\n");
- + ui = (max_level[job] <= 2? 0: max_level[job]-2);
- + for (; ui+2 < maxlv; ui++)
- + hp_table[job][ui] = hp_table[job][ui-1];
- + max_level[job] = maxlv;
- + }
- +
- + for (i = 1; i < job_count; i++) {
- + job_id = jobs[i];
- + if (!pcdb_checkid(job_id)) {
- + ShowError("status_readdb: Invalid job ID %d.\n", job_id);
- + continue;
- + }
- + job = pc_class2idx(job_id);
- + memcpy(hp_table[job], hp_table[jobs[0]], sizeof(hp_table[0]));
- + max_level[job] = maxlv;
- + }
- + }
- + fclose(fp);
- + for (i = 0; i < JOB_MAX; i++) {
- + if (!pcdb_checkid(i)) continue;
- + if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER)
- + continue;
- + j = pc_class2idx(i);
- + if (!max_level[j])
- + ShowWarning("Class %s (%d) does not has a base hp table.\n", job_name(i), i);
- + }
- + ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",path);
- +
- + // job_maxsp.txt
- + memset(sp_table,0,sizeof(sp_table));
- + memset(max_level,0,sizeof(max_level));
- + sprintf(path, "%s/"DBPATH"job_maxsp.txt", db_path);
- + fp=fopen(path, "r");
- + if(fp==NULL){
- + ShowError("can't read %s\n", path);
- + return 1;
- + }
- + while(fgets(line, sizeof(line), fp))
- + {
- + int jobs[CLASS_COUNT], job_count, job, job_id;
- + unsigned int ui,maxlv;
- + char *split[3];
- + if(line[0]=='/' && line[1]=='/')
- + continue;
- + if (pc_split_str(line,split,3) < 3)
- + continue;
- +
- + job_count = pc_split_atoi(split[1],jobs,':',CLASS_COUNT);
- + if (job_count < 1)
- + continue;
- + job_id = jobs[0];
- + if (!pcdb_checkid(job_id)) {
- + ShowError("status_readdb: Invalid job ID %d.\n", job_id);
- + continue;
- + }
- + maxlv = atoi(split[0]);
- + if (maxlv > MAX_LEVEL) {
- + ShowWarning("status_readdb: Specified max level %u for job %d is beyond server's limit (%u).\n ", maxlv, job_id, MAX_LEVEL);
- + maxlv = MAX_LEVEL;
- + }
- +
- + job = jobs[0] = pc_class2idx(job_id);
- + max_level[job] = pc_split_atoui(split[2], sp_table[job],',',maxlv)+1;
- + while ((ui = max_level[job]) >= 2 && sp_table[job][ui-2] <= 0)
- + max_level[job]--;
- + if (max_level[job] < maxlv) {
- + ShowWarning("status_readdb: Specified max %u for job %d, but that job's sp table only goes up to level %u.\n", maxlv, job_id, max_level[job]);
- + ShowInfo("Filling the missing values with the last sp entry.\n");
- + ui = (max_level[job] <= 2? 0: max_level[job]-2);
- + for (; ui+2 < maxlv; ui++)
- + sp_table[job][ui] = sp_table[job][ui-1];
- + max_level[job] = maxlv;
- + }
- +
- + for (i = 1; i < job_count; i++) {
- + job_id = jobs[i];
- + if (!pcdb_checkid(job_id)) {
- + ShowError("status_readdb: Invalid job ID %d.\n", job_id);
- + continue;
- + }
- + job = pc_class2idx(job_id);
- + memcpy(sp_table[job], sp_table[jobs[0]], sizeof(sp_table[0]));
- + max_level[job] = maxlv;
- + }
- + }
- + fclose(fp);
- + for (i = 0; i < JOB_MAX; i++) {
- + if (!pcdb_checkid(i)) continue;
- + if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER)
- + continue;
- + j = pc_class2idx(i);
- + if (!max_level[j])
- + ShowWarning("Class %s (%d) does not has a base sp table.\n", job_name(i), i);
- + }
- + ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",path);
- +
- return 0;
- }
- @@ -10247,7 +10352,6 @@
- initChangeTables();
- initDummyData();
- status_readdb();
- - status_calc_sigma();
- natural_heal_prev_tick = gettick();
- sc_data_ers = ers_new(sizeof(struct status_change_entry));
- add_timer_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement