From e171deb58c7ebbc010d0a40b0e2e66651a0d7913 Mon Sep 17 00:00:00 2001 From: smokexyz Date: Sun, 21 May 2017 12:00:05 +0800 Subject: Refine rate correction from kRO. Normal Ores: http://ro.gnjoy.com/news/probability/View.asp?category=4&seq=1941553&curpage=1 Enriched Ores: http://ro.gnjoy.com/news/probability/View.asp?category=4&seq=1941565&curpage=1 Event Normal Ores: http://ro.gnjoy.com/news/probability/View.asp?category=4&seq=1941558&curpage=1 Event Enriched Ores: http://ro.gnjoy.com/news/probability/View.asp?category=4&seq=1941567&curpage=1 --- src/map/script.c | 34 +++++++++++++++++++------ src/map/skill.c | 2 +- src/map/status.c | 77 +++++++++++++++++++++++++++++++++++++------------------- src/map/status.h | 12 +++++++-- 4 files changed, 88 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index 599285e1e..f90df31d8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9338,20 +9338,32 @@ BUILDIN(getequipweaponlv) * 0 : false (max refine level or unequip..) *------------------------------------------*/ BUILDIN(getequippercentrefinery) { - int i = -1,num; + int i = -1, num; struct map_session_data *sd; + int type = 0; + + num = script_getnum(st, 2); + type = (script_hasdata(st, 3)) ? script_getnum(st, 3) : REFINE_CHANCE_TYPE_NORMAL; - num = script_getnum(st,2); sd = script->rid2sd(st); - if( sd == NULL ) + if (sd == NULL) return true; + if (type < REFINE_CHANCE_TYPE_NORMAL || type >= REFINE_CHANCE_TYPE_MAX) { + ShowError("buildin_getequippercentrefinery: Invalid type (%d) provided!\n", type); + script_pushint(st, 0); + return false; + } + + if (num > 0 && num <= ARRAYLENGTH(script->equip)) - i=pc->checkequip(sd,script->equip[num-1]); - if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE) - script_pushint(st,status->get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine)); + i = pc->checkequip(sd, script->equip[num - 1]); + + if (i >= 0 && sd->status.inventory[i].nameid != 0 && sd->status.inventory[i].refine < MAX_REFINE) + script_pushint(st, + status->get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int) sd->status.inventory[i].refine, (enum refine_chance_type) type)); else - script_pushint(st,0); + script_pushint(st, 0); return true; } @@ -23316,7 +23328,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(getequipisidentify,"i"), BUILDIN_DEF(getequiprefinerycnt,"i"), BUILDIN_DEF(getequipweaponlv,"i"), - BUILDIN_DEF(getequippercentrefinery,"i"), + BUILDIN_DEF(getequippercentrefinery,"i?"), BUILDIN_DEF(successrefitem,"i?"), BUILDIN_DEF(failedrefitem,"i"), BUILDIN_DEF(downrefitem,"i?"), @@ -23959,6 +23971,12 @@ void script_hardcoded_constants(void) script->set_constant("BL_CHAR",BL_CHAR,false, false); script->set_constant("BL_ALL",BL_ALL,false, false); + script->constdb_comment("Refine Chance Types"); + script->set_constant("REFINE_CHANCE_TYPE_NORMAL", REFINE_CHANCE_TYPE_NORMAL, false, false); + script->set_constant("REFINE_CHANCE_TYPE_ENRICHED", REFINE_CHANCE_TYPE_ENRICHED, false, false); + script->set_constant("REFINE_CHANCE_TYPE_E_NORMAL", REFINE_CHANCE_TYPE_E_NORMAL, false, false); + script->set_constant("REFINE_CHANCE_TYPE_E_ENRICHED", REFINE_CHANCE_TYPE_E_ENRICHED, false, false); + script->constdb_comment("Player permissions"); script->set_constant("PERM_TRADE", PC_PERM_TRADE, false, false); script->set_constant("PERM_PARTY", PC_PERM_PARTY, false, false); diff --git a/src/map/skill.c b/src/map/skill.c index 714c2aa71..b70ddc055 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -15652,7 +15652,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) return; } - per = status->get_refine_chance(ditem->wlv, (int)item->refine) * 10; + per = status->get_refine_chance(ditem->wlv, (int)item->refine, REFINE_CHANCE_TYPE_NORMAL) * 10; // Aegis leaked formula. [malufett] if (sd->status.class == JOB_MECHANIC_T) diff --git a/src/map/status.c b/src/map/status.c index c3e5a3f40..7982b15eb 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -12860,13 +12860,17 @@ int status_natural_heal_timer(int tid, int64 tick, int id, intptr_t data) * @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) +int status_get_refine_chance(enum refine_type wlv, int refine, enum refine_chance_type type) { Assert_ret((int)wlv >= REFINE_TYPE_ARMOR && wlv < REFINE_TYPE_MAX); - if ( refine < 0 || refine >= MAX_REFINE) - return 0; - return status->dbs->refine_info[wlv].chance[refine]; + if (refine < 0 || refine >= MAX_REFINE) + return 0; + + if (type >= REFINE_CHANCE_TYPE_MAX) + return 0; + + return status->dbs->refine_info[wlv].chance[type][refine]; } int status_get_sc_type(sc_type type) @@ -13191,54 +13195,84 @@ int status_readdb_refine_libconfig_sub(struct config_setting_t *r, const char *n if ((rate=libconfig->setting_get_member(r, "Rates")) != NULL && config_setting_is_group(rate)) { struct config_setting_t *t = NULL; bool duplicate[MAX_REFINE]; - int bonus[MAX_REFINE], rnd_bonus[MAX_REFINE], chance[MAX_REFINE]; - int i; + int bonus[MAX_REFINE], rnd_bonus[MAX_REFINE]; + int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; + int i, j; + memset(&duplicate, 0, sizeof(duplicate)); memset(&bonus, 0, sizeof(bonus)); memset(&rnd_bonus, 0, sizeof(rnd_bonus)); - for (i = 0; i < MAX_REFINE; i++) { - chance[i] = 100; - } + for (i = 0; i < REFINE_CHANCE_TYPE_MAX; i++) + for (j = 0; j < MAX_REFINE; j++) + chance[i][j] = 100; // default value for all rates. + i = 0; + j = 0; while ((t = libconfig->setting_get_elem(rate,i++)) != NULL && config_setting_is_group(t)) { int level = 0, i32; char *rlvl = config_setting_name(t); memset(&lv, 0, sizeof(lv)); - if (!strspn(&rlvl[strlen(rlvl)-1], "0123456789") || (level = atoi(strncpy(lv, rlvl+2, 3))) <= 0) { + + if (!strspn(&rlvl[strlen(rlvl) - 1], "0123456789") || (level = atoi(strncpy(lv, rlvl + 2, 3))) <= 0) { ShowError("status_readdb_refine_libconfig_sub: Invalid refine level format '%s' for entry %s in \"%s\"... skipping.\n", rlvl, name, source); continue; } + if (level <= 0 || level > MAX_REFINE) { ShowError("status_readdb_refine_libconfig_sub: Out of range refine level '%s' for entry %s in \"%s\"... skipping.\n", rlvl, name, source); continue; } + level--; + if (duplicate[level]) { ShowWarning("status_readdb_refine_libconfig_sub: duplicate rate '%s' for entry %s in \"%s\", overwriting previous entry...\n", rlvl, name, source); } else { duplicate[level] = true; } - if (libconfig->setting_lookup_int(t, "Chance", &i32)) - chance[level] = i32; + + if (libconfig->setting_lookup_int(t, "NormalChance", &i32) != 0) + chance[REFINE_CHANCE_TYPE_NORMAL][level] = i32; + else + chance[REFINE_CHANCE_TYPE_NORMAL][level] = 100; + + if (libconfig->setting_lookup_int(t, "EnrichedChance", &i32) != 0) + chance[REFINE_CHANCE_TYPE_ENRICHED][level] = i32; + else + chance[REFINE_CHANCE_TYPE_ENRICHED][level] = level > 10 ? 0 : 100; // enriched ores up to +10 only. + + if (libconfig->setting_lookup_int(t, "EventNormalChance", &i32) != 0) + chance[REFINE_CHANCE_TYPE_E_NORMAL][level] = i32; + else + chance[REFINE_CHANCE_TYPE_E_NORMAL][level] = 100; + + if (libconfig->setting_lookup_int(t, "EventEnrichedChance", &i32) != 0) + chance[REFINE_CHANCE_TYPE_E_ENRICHED][level] = i32; else - chance[level] = 100; - if (libconfig->setting_lookup_int(t, "Bonus", &i32)) + chance[REFINE_CHANCE_TYPE_E_ENRICHED][level] = level > 10 ? 0 : 100; // enriched ores up to +10 only. + + if (libconfig->setting_lookup_int(t, "Bonus", &i32) != 0) bonus[level] += i32; + if (level >= rnd_bonus_lv - 1) rnd_bonus[level] = rnd_bonus_v * (level - rnd_bonus_lv + 2); } for (i = 0; i < MAX_REFINE; i++) { - status->dbs->refine_info[type].chance[i] = chance[i]; + status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_NORMAL][i] = chance[REFINE_CHANCE_TYPE_NORMAL][i]; + status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_NORMAL][i] = chance[REFINE_CHANCE_TYPE_E_NORMAL][i]; + status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_ENRICHED][i]; + status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_E_ENRICHED][i]; status->dbs->refine_info[type].randombonus_max[i] = rnd_bonus[i]; - bonus[i] += bonus_per_level + (i > 0 ? bonus[i-1] : 0); + bonus[i] += bonus_per_level + (i > 0 ? bonus[i - 1] : 0); status->dbs->refine_info[type].bonus[i] = bonus[i]; } } else { ShowWarning("status_readdb_refine_libconfig_sub: Missing refine rates for entry '%s' in \"%s\", skipping.\n", name, source); return 0; } - return type+1; + + return type + 1; } /** @@ -13332,15 +13366,6 @@ int status_readdb(void) for(j = 0; j < MAX_SINGLE_WEAPON_TYPE; j++) status->dbs->atkmods[i][j] = 100; - // refine_db.txt - for(i=0;idbs->refine_info);i++) { - for(j=0;jdbs->refine_info[i].chance[j] = 100; - status->dbs->refine_info[i].bonus[j] = 0; - status->dbs->refine_info[i].randombonus_max[j] = 0; - } - } - // read databases // sv->readdb(map->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, status->readdb_job2); diff --git a/src/map/status.h b/src/map/status.h index 1496429a8..de21fa16c 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -2233,9 +2233,17 @@ struct status_change { #define status_calc_elemental(ed, opt) (status->calc_bl_(&(ed)->bl, SCB_ALL, (opt))) #define status_calc_npc(nd, opt) (status->calc_bl_(&(nd)->bl, SCB_ALL, (opt))) +enum refine_chance_type { + REFINE_CHANCE_TYPE_NORMAL = 0, // Normal Chance + REFINE_CHANCE_TYPE_ENRICHED = 1, // Enriched Ore Chance + REFINE_CHANCE_TYPE_E_NORMAL = 2, // Event Normal Ore Chance + REFINE_CHANCE_TYPE_E_ENRICHED = 3, // Event Enriched Ore Chance + REFINE_CHANCE_TYPE_MAX +}; + // bonus values and upgrade chances for refining equipment struct s_refine_info { - int chance[MAX_REFINE]; // success chance + int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance int bonus[MAX_REFINE]; // cumulative fixed bonus damage int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage }; @@ -2283,7 +2291,7 @@ struct status_interface { int (*init) (bool minimal); void (*final) (void); /* funcs */ - int (*get_refine_chance) (enum refine_type wlv, int refine); + int (*get_refine_chance) (enum refine_type wlv, int refine, enum refine_chance_type type); // for looking up associated data sc_type (*skill2sc) (int skill_id); int (*sc2skill) (sc_type sc); -- cgit v1.2.3-60-g2f50