summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorlordttseven <lordttseven@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-19 14:43:41 +0000
committerlordttseven <lordttseven@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-19 14:43:41 +0000
commita0ac36a5e11af6231b0c3b817d72d01538233b16 (patch)
treec86b2c3a91a2907a00ca6a9b06d40e3453ba83c8 /src/map
parentd439d6d992f76dd547ccd8557e3aa58b11a3ef08 (diff)
downloadhercules-a0ac36a5e11af6231b0c3b817d72d01538233b16.tar.gz
hercules-a0ac36a5e11af6231b0c3b817d72d01538233b16.tar.bz2
hercules-a0ac36a5e11af6231b0c3b817d72d01538233b16.tar.xz
hercules-a0ac36a5e11af6231b0c3b817d72d01538233b16.zip
Refine DB update
* DB courtesy of Kenpachi * added support for different stats per refine level for renewal * cleaned up the corresponding code a little * REMODE now displays the atk values on the client correctly git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15730 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c8
-rw-r--r--src/map/config/Core.h6
-rw-r--r--src/map/pc.h9
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/skill.c2
-rw-r--r--src/map/status.c123
-rw-r--r--src/map/status.h24
7 files changed, 122 insertions, 52 deletions
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ƒ{[ƒiƒXƒe[ƒ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]; // •ŠνATKƒTƒCƒYC³(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ƒ{[ƒiƒX
- *------------------------------------------*/
-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]