Renewal Mode DEF calc fixed (can go over 127 now), bugreport:5110

Fixed Logic Issues with r15039 script command set

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15051 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
shennetsind 2011-12-09 23:58:15 +00:00
parent 412bf3f3f8
commit 05cad74427
4 changed files with 76 additions and 17 deletions

View File

@ -94,7 +94,8 @@ max_third_parameter: 120
// Same as max_parameter, but for baby classes.
max_baby_parameter: 80
// Max armor def/mdef
// Max armor def/mdef
// NOTE: This setting have no effect if server is run on Renewal Mode (RRMODE)
// NOTE: does not affects skills and status effects like Mental Strength
// If weapon_defense_type is non-zero, it won't apply to max def.
// If magic_defense_type is non-zero, it won't apply to max mdef.

View File

@ -12777,7 +12777,7 @@ BUILDIN_FUNC(explode)
const char delimiter = script_getstr(st, 4)[0];
int32 id;
size_t len = strlen(str);
int i = 0, j = 0, k = 0;
int i = 0, j = 0;
int start;
@ -12848,7 +12848,7 @@ BUILDIN_FUNC(explode)
BUILDIN_FUNC(implode)
{
struct script_data* data = script_getdata(st, 2);
const char *glue, *name, *temp;
const char *glue = NULL, *name, *temp;
int32 glue_len = 0, array_size, id;
size_t len = 0;
int i, k = 0;
@ -13100,7 +13100,7 @@ BUILDIN_FUNC(sscanf){
// Issue sscanf for each parameter
*buf = 0;
q = format;
while(p = strchr(q, '%')){
while((p = strchr(q, '%'))){
if(p!=q){
strncat(buf, q, (size_t)(p-q));
q = p;
@ -13290,7 +13290,7 @@ BUILDIN_FUNC(replacestr)
break;
}
} else {
if((i + f) > inputlen || input[i + f] != find[f] && TOUPPER(input[i+f]) != TOUPPER(find[f])) {
if(((i + f) > inputlen || input[i + f] != find[f]) && TOUPPER(input[i+f]) != TOUPPER(find[f])) {
StringBuf_Printf(&output, "%c", input[i]);
break;
}
@ -13353,7 +13353,7 @@ BUILDIN_FUNC(countstr)
break;
}
} else {
if((i + f) > inputlen || input[i + f] != find[f] && TOUPPER(input[i+f]) != TOUPPER(find[f])) {
if(((i + f) > inputlen || input[i + f] != find[f]) && TOUPPER(input[i+f]) != TOUPPER(find[f])) {
break;
}
}

View File

@ -2604,15 +2604,22 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->def_rate = 0;
if(sd->def_rate != 100) {
i = status->def * sd->def_rate/100;
#if RRMODE
status->def = cap_value(i, SHRT_MIN, SHRT_MAX);
#else
status->def = cap_value(i, CHAR_MIN, CHAR_MAX);
#endif
}
#if RRMODE == 0
/**
* The following setting does not affect Renewal Mode
**/
if (!battle_config.weapon_defense_type && status->def > battle_config.max_def)
{
status->def2 += battle_config.over_def_bonus*(status->def -battle_config.max_def);
status->def = (unsigned char)battle_config.max_def;
}
#endif
// ----- EQUIPMENT-MDEF CALCULATION -----
// Apply relative modifiers from equipment
@ -2620,15 +2627,22 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->mdef_rate = 0;
if(sd->mdef_rate != 100) {
i = status->mdef * sd->mdef_rate/100;
#if RRMODE
status->mdef = cap_value(i, SHRT_MIN, SHRT_MAX);
#else
status->mdef = cap_value(i, CHAR_MIN, CHAR_MAX);
#endif
}
#if RRMODE == 0
/**
* The following setting does not affect Renewal Mode
**/
if (!battle_config.magic_defense_type && status->mdef > battle_config.max_def)
{
status->mdef2 += battle_config.over_def_bonus*(status->mdef -battle_config.max_def);
status->mdef = (signed char)battle_config.max_def;
}
#endif
// ----- ASPD CALCULATION -----
// Unlike other stats, ASPD rate modifiers from skills/SCs/items/etc are first all added together, then the final modifier is applied
@ -2884,9 +2898,17 @@ static signed short status_calc_hit(struct block_list *,struct status_change *,i
static signed short status_calc_critical(struct block_list *,struct status_change *,int);
static signed short status_calc_flee(struct block_list *,struct status_change *,int);
static signed short status_calc_flee2(struct block_list *,struct status_change *,int);
static signed char status_calc_def(struct block_list *,struct status_change *,int);
#if RRMODE
static short status_calc_def(struct block_list *bl, struct status_change *sc, int);
#else
static signed char status_calc_def(struct block_list *,struct status_change *,int);
#endif
static signed short status_calc_def2(struct block_list *,struct status_change *,int);
static signed char status_calc_mdef(struct block_list *,struct status_change *,int);
#if RRMODE
static short status_calc_mdef(struct block_list *bl, struct status_change *sc, int);
#else
static signed char status_calc_mdef(struct block_list *,struct status_change *,int);
#endif
static signed short status_calc_mdef2(struct block_list *,struct status_change *,int);
static unsigned short status_calc_speed(struct block_list *,struct status_change *,int);
static short status_calc_aspd_rate(struct block_list *,struct status_change *,int);
@ -4039,12 +4061,18 @@ static signed short status_calc_flee2(struct block_list *bl, struct status_chang
return (short)cap_value(flee2,10,SHRT_MAX);
}
static signed char status_calc_def(struct block_list *bl, struct status_change *sc, int def)
#if RRMODE
static short status_calc_def(struct block_list *bl, struct status_change *sc, int def)
#else
static signed char status_calc_def(struct block_list *bl, struct status_change *sc, int def)
#endif
{
if(!sc || !sc->count)
#if RRMODE
return (short)cap_value(def,SHRT_MIN,SHRT_MAX);
#else
return (signed char)cap_value(def,CHAR_MIN,CHAR_MAX);
#endif
if(sc->data[SC_BERSERK])
return 0;
if(sc->data[SC_SKA])
@ -4099,8 +4127,11 @@ static signed char status_calc_def(struct block_list *bl, struct status_change *
def -= def * sc->data[SC_ROCK_CRUSHER]->val2 / 100;
if( sc->data[SC_POWER_OF_GAIA] )
def += def * sc->data[SC_POWER_OF_GAIA]->val2 / 100;
#if RRMODE
return (short)cap_value(def,SHRT_MIN,SHRT_MAX);
#else
return (signed char)cap_value(def,CHAR_MIN,CHAR_MAX);
#endif
}
static signed short status_calc_def2(struct block_list *bl, struct status_change *sc, int def2)
@ -4149,10 +4180,18 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
return (short)cap_value(def2,1,SHRT_MAX);
}
static signed char status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef)
#if RRMODE
static short status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef)
#else
static signed char status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef)
#endif
{
if(!sc || !sc->count)
#if RRMODE
return (short)cap_value(mdef,SHRT_MIN,SHRT_MAX);
#else
return (signed char)cap_value(mdef,CHAR_MIN,CHAR_MAX);
#endif
if(sc->data[SC_BERSERK])
return 0;
@ -4183,7 +4222,11 @@ static signed char status_calc_mdef(struct block_list *bl, struct status_change
if(sc->data[SC_WATER_BARRIER])
mdef += sc->data[SC_WATER_BARRIER]->val2;
#if RRMODE
return (short)cap_value(mdef,SHRT_MIN,SHRT_MAX);
#else
return (signed char)cap_value(mdef,CHAR_MIN,CHAR_MAX);
#endif
}
static signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, int mdef2)
@ -4748,7 +4791,11 @@ signed char status_get_def(struct block_list *bl)
ud = unit_bl2ud(bl);
if (ud && ud->skilltimer != INVALID_TIMER)
def -= def * skill_get_castdef(ud->skillid)/100;
#if RRMODE
return cap_value(def, SHRT_MIN, SHRT_MAX);
#else
return cap_value(def, CHAR_MIN, CHAR_MAX);
#endif
}
unsigned short status_get_speed(struct block_list *bl)

View File

@ -1362,6 +1362,12 @@ struct status_data {
short
hit, flee, cri, flee2,
def2, mdef2,
#if RRMODE
/**
* In RE def and mdef can go over 127 (signed char) limit, so in RE mode we use short
**/
def,mdef,
#endif
aspd_rate;
unsigned char
def_ele, ele_lv,
@ -1372,8 +1378,13 @@ struct status_data {
wlv,
#endif
size, race;
#if RRMODE == 0
/**
* In NON-RE def and mdef are not required to be short, so we keep it signed char (ancient-default)
**/
signed char
def, mdef;
#endif
struct weapon_atk rhw, lhw; //Right Hand/Left Hand Weapon.
};