diff options
-rw-r--r-- | db/pre-re/refine_db.txt | 47 | ||||
-rw-r--r-- | db/re/refine_db.txt | 49 | ||||
-rw-r--r-- | src/map/clif.c | 8 | ||||
-rw-r--r-- | src/map/config/Core.h | 6 | ||||
-rw-r--r-- | src/map/pc.h | 9 | ||||
-rw-r--r-- | src/map/script.c | 2 | ||||
-rw-r--r-- | src/map/skill.c | 2 | ||||
-rw-r--r-- | src/map/status.c | 123 | ||||
-rw-r--r-- | src/map/status.h | 24 |
9 files changed, 200 insertions, 70 deletions
diff --git a/db/pre-re/refine_db.txt b/db/pre-re/refine_db.txt index 5fbd6472a..457fd370f 100644 --- a/db/pre-re/refine_db.txt +++ b/db/pre-re/refine_db.txt @@ -1,10 +1,39 @@ -// Database for upgrading items. -// Stats per level for safe upgrade, Stats per level after safe limit, Safe level limit, Lv.1 %, Lv 2 %, Lv.3%, ect... -// Armor defense is done in percentage (ie 70 = .7 def) -// Weapons are whole numbers (ie 3 = 3 atk) +// Pre-renewal Version +// +// Type,Stats per level,Random bonus start level,Random bonus value,Chance+1:Bonus+1,Chance+2:Bonus+2,Chance+3:Bonus+3,... +// +// IMPORTANT: changing the number of upgrade levels requires modifying MAX_REFINE in status.h +// +// For armors, values of 100 add 1 armor defense. +// For weapons, values of 100 add 1 ATK. +// +// Type: +// 0 - Armors +// 1 - Level 1 weapons +// 2 - Level 2 weapons +// 3 - Level 3 weapons +// 4 - Level 4 weapons +// +// Stats per level: +// This value is applied for every upgrade level. +// +// Random bonus start level: +// This value specifies the start point for those levels that give a random bonus value. +// +// Random bonus value: +// A random number between 0 and (Random bonus start level - Upgrade level + 1) * this value is applied for all upgrades past +// Random bonus start level (usually the first unsafe upgrade). This is only applied for weapons, and not displayed client-side. +// +// Chance: +// 100 = 100% - 70, 4,4, 100,100,100,100, 60, 40, 40, 20, 20, 10, 50, 30, 30, 20, 20, 10, 10, 10, 10, 10, // Armor - 2, 3,7, 100,100,100,100,100,100,100, 60, 40, 20, 70, 70, 50, 50, 30, 30, 20, 20, 10, 10, // Lv.1 Weapons - 3, 5,6, 100,100,100,100,100,100, 60, 40, 20, 20, 70, 50, 50, 30, 30, 20, 20, 10, 10, 10, // Lv.2 Weapons - 5, 8,5, 100,100,100,100,100, 60, 50, 20, 20, 20, 50, 50, 30, 30, 20, 20, 10, 10, 10, 10, // Lv.3 Weapons - 7,13,4, 100,100,100,100, 60, 40, 40, 20, 20, 10, 50, 30, 30, 20, 20, 10, 10, 10, 10, 10, // Lv.4 Weapons +// Armors +0,66,0,0,100:0,100:0,100:0,100:0,60:0,40:0,40:0,20:0,20:0,10:0 +// Level 1 weapons +1,200,8,300,100:0,100:0,100:0,100:0,100:0,100:0,100:0,60:0,40:0,20:0 +// Level 2 weapons +2,300,7,500,100:0,100:0,100:0,100:0,100:0,100:0,60:0,40:0,20:0,20:0 +// Level 3 weapons +3,500,6,800,100:0,100:0,100:0,100:0,100:0,60:0,50:0,20:0,20:0,20:0 +// Level 4 weapons +4,700,5,1300,100:0,100:0,100:0,100:0,60:0,40:0,40:0,20:0,20:0,10:0 diff --git a/db/re/refine_db.txt b/db/re/refine_db.txt index 5fbd6472a..f235efc7a 100644 --- a/db/re/refine_db.txt +++ b/db/re/refine_db.txt @@ -1,10 +1,41 @@ -// Database for upgrading items. -// Stats per level for safe upgrade, Stats per level after safe limit, Safe level limit, Lv.1 %, Lv 2 %, Lv.3%, ect... -// Armor defense is done in percentage (ie 70 = .7 def) -// Weapons are whole numbers (ie 3 = 3 atk) +// Renewal Version +// +// Type,Stats per level,Random bonus start level,Random bonus value,Chance+1:Bonus+1,Chance+2:Bonus+2,Chance+3:Bonus+3,... +// +// IMPORTANT: changing the number of upgrade levels requires modifying MAX_REFINE in status.h +// +// For armors, values of 100 add 1 armor defense. +// For weapons, values of 100 add 1 ATK&MATK. +// +// Type: +// 0 - Armors +// 1 - Level 1 weapons +// 2 - Level 2 weapons +// 3 - Level 3 weapons +// 4 - Level 4 weapons +// +// Stats per level: +// This value is applied for every upgrade level. +// +// Random bonus start level: +// This value specifies the start point for those levels that give a random bonus value (usually the first unsafe upgrade). +// +// Random bonus value: +// A random number between 0 and (Random bonus start level - Upgrade level + 1) * this value is applied for all upgrades past +// Random bonus start level. This is only applied for weapons, and not displayed client-side. +// +// Chance: +// 100 = 100% +// +// Note: Chances for +11 and higher are not verified - 10% is a rumor from iRO wiki. +// A note about renewal Armors, there may or may not be another bonus, according to iRO wiki: Every upgrade gives floor[( 3 + current upgrade ) / 4] equipment DEF) - 70, 4,4, 100,100,100,100, 60, 40, 40, 20, 20, 10, 50, 30, 30, 20, 20, 10, 10, 10, 10, 10, // Armor - 2, 3,7, 100,100,100,100,100,100,100, 60, 40, 20, 70, 70, 50, 50, 30, 30, 20, 20, 10, 10, // Lv.1 Weapons - 3, 5,6, 100,100,100,100,100,100, 60, 40, 20, 20, 70, 50, 50, 30, 30, 20, 20, 10, 10, 10, // Lv.2 Weapons - 5, 8,5, 100,100,100,100,100, 60, 50, 20, 20, 20, 50, 50, 30, 30, 20, 20, 10, 10, 10, 10, // Lv.3 Weapons - 7,13,4, 100,100,100,100, 60, 40, 40, 20, 20, 10, 50, 30, 30, 20, 20, 10, 10, 10, 10, 10, // Lv.4 Weapons +0,0,0,0,100:100,100:100,100:100,100:100,60:200,40:200,40:200,20:200,20:300,10:300,10:300,10:300,10:400,10:400,10:400,10:400,10:500,10:500,10:500,10:500 +// Level 1 weapons +1,200,8,300,100:0,100:0,100:0,100:0,100:0,100:0,100:0,60:0,40:0,20:0,10:0,10:0,10:0,10:0,10:0,10:300,10:300,10:300,10:300,10:300 +// Level 2 weapons +2,300,7,500,100:0,100:0,100:0,100:0,100:0,100:0,60:0,40:0,20:0,20:0,10:0,10:0,10:0,10:0,10:0,10:600,10:600,10:600,10:600,10:600 +// Level 3 weapons +3,500,6,800,100:0,100:0,100:0,100:0,100:0,60:0,50:0,20:0,20:0,20:0,10:0,10:0,10:0,10:0,10:0,10:900,10:900,10:900,10:900,10:900 +// Level 4 weapons +4,700,5,1400,100:0,100:0,100:0,100:0,60:0,40:0,40:0,20:0,20:0,10:0,10:0,10:0,10:0,10:0,10:0,10:1200,10:1200,10:1200,10:1200,10:1200 diff --git a/src/map/clif.c b/src/map/clif.c index 7514f87bb..fc215c26a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2766,7 +2766,7 @@ void clif_updatestatus(struct map_session_data *sd,int type) WFIFOL(fd,4)=sd->battle_status.amotion; break; case SP_ATK1: - WFIFOL(fd,4)=sd->battle_status.batk +sd->battle_status.rhw.atk +sd->battle_status.lhw.atk; + WFIFOL(fd,4)=pc_leftside_atk(sd); break; case SP_DEF1: WFIFOL(fd,4)=sd->battle_status.def; @@ -2775,7 +2775,7 @@ void clif_updatestatus(struct map_session_data *sd,int type) WFIFOL(fd,4)=sd->battle_status.mdef; break; case SP_ATK2: - WFIFOL(fd,4)=sd->battle_status.rhw.atk2 + sd->battle_status.lhw.atk2; + WFIFOL(fd,4)=pc_rightside_atk(sd); break; case SP_DEF2: WFIFOL(fd,4)=sd->battle_status.def2; @@ -3124,8 +3124,8 @@ void clif_initialstatus(struct map_session_data *sd) WBUFB(buf,14)=min(sd->status.luk, UINT8_MAX); WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK,1); - WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw.atk; - WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw.atk2; //atk bonus + WBUFW(buf,16) = pc_leftside_atk(sd); + WBUFW(buf,18) = pc_rightside_atk(sd); WBUFW(buf,20) = sd->battle_status.matk_max; WBUFW(buf,22) = sd->battle_status.matk_min; WBUFW(buf,24) = sd->battle_status.def; // def diff --git a/src/map/config/Core.h b/src/map/config/Core.h index cbd7c0aa3..a5db0f1ff 100644 --- a/src/map/config/Core.h +++ b/src/map/config/Core.h @@ -6,12 +6,6 @@ **/ /** - * Max Refine available to your server - * Raising this limit requires edits to /db/refine_db.txt - **/ -#define MAX_REFINE 20 - -/** * Max number of items on @autolootid list **/ #define AUTOLOOTITEM_SIZE 10 diff --git a/src/map/pc.h b/src/map/pc.h index e3d810378..a64c3f48e 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -635,6 +635,15 @@ enum e_pc_permission { || ( (class_) >= JOB_RUNE_KNIGHT && (class_) < JOB_MAX ) \ ) +// clientside atk display macros (values to the left/right of the "+") +#if REMODE +#define pc_leftside_atk(sd) ((sd)->battle_status.batk) +#define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2) +#else +#define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk) +#define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2) +#endif + int pc_class2idx(int class_); int pc_get_group_level(struct map_session_data *sd); int pc_get_group_id(struct map_session_data *sd); diff --git a/src/map/script.c b/src/map/script.c index d2ff334bf..19a041855 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6872,7 +6872,7 @@ BUILDIN_FUNC(getequippercentrefinery) if (num > 0 && num <= ARRAYLENGTH(equip)) i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE) - script_pushint(st,percentrefinery[itemdb_wlv(sd->status.inventory[i].nameid)][(int)sd->status.inventory[i].refine]); + script_pushint(st,status_get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine)); else script_pushint(st,0); diff --git a/src/map/skill.c b/src/map/skill.c index 4ec69ac49..0c1d042d0 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -12480,7 +12480,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) return; } - per = percentrefinery [ditem->wlv][(int)item->refine]; + per = status_get_refine_chance(ditem->wlv, (int)item->refine); per += (((signed int)sd->status.job_level)-50)/2; //Updated per the new kro descriptions. [Skotlex] pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER); diff --git a/src/map/status.c b/src/map/status.c index 0c0eeed0e..e537b800e 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -53,8 +53,14 @@ static int hp_coefficient2[CLASS_COUNT]; static int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; static int sp_coefficient[CLASS_COUNT]; static int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] -static int refinebonus[MAX_REFINE_BONUS][3]; // ΈB{[iXe[u(refine_db.txt) -int percentrefinery[5][MAX_REFINE+1]; // ΈB¬χ¦(refine_db.txt) + +// bonus values and upgrade chances for refining equipment +static struct { + int chance[MAX_REFINE]; // success chance + int bonus[MAX_REFINE]; // cumulative fixed bonus damage + int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage +} refine_info[REFINE_TYPE_MAX]; + static int atkmods[3][MAX_WEAPON_TYPE]; // νATKTCYC³(size_fix.txt) static char job_bonus[CLASS_COUNT][MAX_LEVEL]; #if REMODE @@ -915,17 +921,6 @@ static inline void status_cpy(struct status_data* a, const struct status_data* b memcpy((void*)&a->max_hp, (const void*)&b->max_hp, sizeof(struct status_data)-(sizeof(a->hp)+sizeof(a->sp))); } - -/*========================================== - * ΈB{[iX - *------------------------------------------*/ -int status_getrefinebonus(int lv,int type) -{ - if (lv >= 0 && lv < 5 && type >= 0 && type < 3) - return refinebonus[lv][type]; - return 0; -} - //Sets HP to given value. Flag is the flag passed to status_heal in case //final value is higher than current (use 2 to make a healing effect display //on players) It will always succeed (overrides Berserk block), but it can't kill. @@ -2318,12 +2313,16 @@ int status_calc_pc_(struct map_session_data* sd, bool first) return 1; } + // sanitize the refine level in case someone decreased the value inbetween + if (sd->status.inventory[index].refine > MAX_REFINE) + sd->status.inventory[index].refine = MAX_REFINE; + if(sd->inventory_data[index]->type == IT_WEAPON) { int r,wlv = sd->inventory_data[index]->wlv; struct weapon_data *wd; struct weapon_atk *wa; - if (wlv >= MAX_REFINE_BONUS) - wlv = MAX_REFINE_BONUS - 1; + if (wlv >= REFINE_TYPE_MAX) + wlv = REFINE_TYPE_MAX - 1; if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L) { wd = &sd->left_weapon; // Left-hand weapon wa = &status->lhw; @@ -2332,7 +2331,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first) wa = &status->rhw; } wa->atk += sd->inventory_data[index]->atk; - wa->atk2 = (r=sd->status.inventory[index].refine)*refinebonus[wlv][0]; + if (r = sd->status.inventory[index].refine) + wa->atk2 = refine_info[wlv].bonus[r-1] / 100; #if REMODE /** * in RE matk_max is used as the weapon's matk. @@ -2342,14 +2342,16 @@ int status_calc_pc_(struct map_session_data* sd, bool first) /** * Refine Bonus **/ - status->matk_max += sd->status.inventory[index].refine * refinebonus[wlv][0]; + if (r) + status->matk_max += refine_info[wlv].bonus[r-1] / 100; /** * In RE weapon level is used in several areas, this way we save performance **/ status->wlv = wlv; #endif - if((r-=refinebonus[wlv][2])>0) //Overrefine bonus. - wd->overrefine = r*refinebonus[wlv][1]; + //Overrefine bonus. + if (r) + wd->overrefine = refine_info[wlv].randombonus_max[r-1] / 100; wa->range += sd->inventory_data[index]->range; if(sd->inventory_data[index]->script) { @@ -2375,7 +2377,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first) } } else if(sd->inventory_data[index]->type == IT_ARMOR) { - refinedef += sd->status.inventory[index].refine*refinebonus[0][0]; + int r; + if (r = sd->status.inventory[index].refine) + refinedef += refine_info[REFINE_TYPE_ARMOR].bonus[r-1]; if(sd->inventory_data[index]->script) { if( i == EQI_HAND_L ) //Shield sd->state.lr_flag = 3; @@ -3648,12 +3652,24 @@ void status_calc_bl_(struct block_list* bl, enum scb_flag flag, bool first) clif_updatestatus(sd,SP_ASPD); if(b_status.speed != status->speed) clif_updatestatus(sd,SP_SPEED); - if(b_status.rhw.atk != status->rhw.atk || b_status.lhw.atk != status->lhw.atk || b_status.batk != status->batk) + + if(b_status.batk != status->batk +#if !REMODE + || b_status.rhw.atk != status->rhw.atk || b_status.lhw.atk != status->lhw.atk +#endif + ) clif_updatestatus(sd,SP_ATK1); + if(b_status.def != status->def) clif_updatestatus(sd,SP_DEF1); - if(b_status.rhw.atk2 != status->rhw.atk2 || b_status.lhw.atk2 != status->lhw.atk2) + + if(b_status.rhw.atk2 != status->rhw.atk2 || b_status.lhw.atk2 != status->lhw.atk2 +#if REMODE + || b_status.rhw.atk != status->rhw.atk || b_status.lhw.atk != status->lhw.atk +#endif + ) clif_updatestatus(sd,SP_ATK2); + if(b_status.def2 != status->def2) clif_updatestatus(sd,SP_DEF2); if(b_status.flee2 != status->flee2) @@ -10039,7 +10055,22 @@ static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_ return 0; } -/*========================================== +/** + * Get the chance to upgrade a piece of equipment. + * @param wlv The weapon type of the item to refine (see see enum refine_type) + * @param refine The target refine level + * @return The chance to refine the item, in percent (0~100) + **/ +int status_get_refine_chance(enum refine_type wlv, int refine) +{ + if (wlv < 0 || wlv > REFINE_TYPE_MAX || refine < 0 || refine >= MAX_REFINE) + return 0; + + return refine_info[wlv].chance[refine]; +} + + +/*------------------------------------------ * DB reading. * job_db1.txt - weight, hp, sp, aspd * job_db2.txt - job level stat bonuses @@ -10124,15 +10155,34 @@ static bool status_readdb_sizefix(char* fields[], int columns, int current) static bool status_readdb_refine(char* fields[], int columns, int current) { - int i; + int i, bonus_per_level, random_bonus, random_bonus_start_level; + + current = atoi(fields[0]); - refinebonus[current][0] = atoi(fields[0]); // stats per safe-upgrade - refinebonus[current][1] = atoi(fields[1]); // stats after safe-limit - refinebonus[current][2] = atoi(fields[2]); // safe limit + if (current < 0 || current >= REFINE_TYPE_MAX) + return false; + + bonus_per_level = atoi(fields[1]); + random_bonus_start_level = atoi(fields[2]); + random_bonus = atoi(fields[3]); for(i = 0; i < MAX_REFINE; i++) { - percentrefinery[current][i] = atoi(fields[3+i]); + char* delim; + + if (!(delim = strchr(fields[4+i], ':'))) + return false; + + *delim = '\0'; + + refine_info[current].chance[i] = atoi(fields[4+i]); + + if (i >= random_bonus_start_level - 1) + refine_info[current].randombonus_max[i] = random_bonus * (i - random_bonus_start_level + 2); + + refine_info[current].bonus[i] = bonus_per_level + atoi(delim+1); + if (i > 0) + refine_info[current].bonus[i] += refine_info[current].bonus[i-1]; } return true; } @@ -10162,13 +10212,14 @@ int status_readdb(void) atkmods[i][j]=100; // refine_db.txt - for(i=0;i<ARRAYLENGTH(percentrefinery);i++){ + for(i=0;i<ARRAYLENGTH(refine_info);i++) + { for(j=0;j<MAX_REFINE; j++) - percentrefinery[i][j]=100; // success chance - percentrefinery[i][j]=0; //Slot MAX+1 always has 0% success chance [Skotlex] - refinebonus[i][0]=0; // stats per safe-upgrade - refinebonus[i][1]=0; // stats after safe-limit - refinebonus[i][2]=10; // safe limit + { + refine_info[i].chance[j] = 100; + refine_info[i].bonus[j] = 0; + refine_info[i].randombonus_max[j] = 0; + } } // read databases @@ -10178,9 +10229,9 @@ int status_readdb(void) 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 - sv_readdb(db_path, DBPATH"job_db_extra.txt", ',', 1+RE_JOB_DB_MAX, 1+RE_JOB_DB_MAX, -1, &status_readdb_job_re); + sv_readdb(db_path, DBPATH"job_db_extra.txt", ',', 1+RE_JOB_DB_MAX, 1+RE_JOB_DB_MAX, -1, &status_readdb_job_re); #endif - sv_readdb(db_path, DBPATH"refine_db.txt", ',', 3+MAX_REFINE+1, 3+MAX_REFINE+1, ARRAYLENGTH(percentrefinery), &status_readdb_refine); + sv_readdb(db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); return 0; } diff --git a/src/map/status.h b/src/map/status.h index 200eaf8b8..44487cc59 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -11,8 +11,27 @@ struct homun_data; struct mercenary_data; struct status_change; -#define MAX_REFINE_BONUS 5 +/** + * Max Refine available to your server + * Changing this limit requires edits to refine_db.txt + **/ +#if REMODE +#define MAX_REFINE 20 +#else +#define MAX_REFINE 10 +#endif +enum refine_type { + REFINE_TYPE_ARMOR = 0, + REFINE_TYPE_WEAPON1 = 1, + REFINE_TYPE_WEAPON2 = 2, + REFINE_TYPE_WEAPON3 = 3, + REFINE_TYPE_WEAPON4 = 4, + + REFINE_TYPE_MAX = 5 +}; + +int status_get_refine_chance(enum refine_type wlv, int refine); // Status changes listing. These code are for use by the server. typedef enum sc_type { @@ -1175,8 +1194,6 @@ enum e_joint_break extern int current_equip_item_index; extern int current_equip_card_id; -extern int percentrefinery[5][MAX_REFINE+1]; //The last slot always has a 0% success chance [Skotlex] - //Mode definitions to clear up code reading. [Skotlex] enum e_mode { @@ -1588,7 +1605,6 @@ void status_calc_misc(struct block_list *bl, struct status_data *status, int lev void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen_data *regen); void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, struct status_change *sc); -int status_getrefinebonus(int lv,int type); int status_check_skilluse(struct block_list *src, struct block_list *target, int skill_num, int flag); // [Skotlex] int status_check_visibility(struct block_list *src, struct block_list *target); //[Skotlex] |