case CR_ACIDDEMONSTRATION:
#ifdef RENEWAL
{// [malufett]
int64 matk=0, atk;
short tdef = status->get_total_def(target);
short tmdef = status->get_total_mdef(target);
int targetVit = min(120, status_get_vit(target));
short totaldef = (tmdef + tdef - ((uint64)(tmdef + tdef) >> 32)) >> 1; // FIXME: What's the >> 32 supposed to do here? tmdef and tdef are both 16-bit...
matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage;
atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag);
md.damage = matk + atk;
if( src->type == BL_MOB ){
totaldef = (tdef + tmdef) >> 1;
md.damage = 7 * targetVit * skill_lv * (atk + matk) / 100;
/*
// Pending [malufett]
if( unknown condition ){
md.damage = 7 * md.damage % 20;
md.damage = 7 * md.damage / 20;
}*/
}else{
float vitfactor = 0.0f, ftemp;
if( (vitfactor=(status_get_vit(target)-120.0f)) > 0)
vitfactor = (vitfactor * (matk + atk) / 10) / status_get_vit(target);
ftemp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10;
md.damage = (int64)(ftemp * 70 * skill_lv / 100);
if (target->type == BL_PC)
md.damage >>= 1;
}
md.damage -= totaldef;
if( tsc && tsc->data[SC_LEXAETERNA] ) {
md.damage <<= 1;
status_change_end(target, SC_LEXAETERNA, INVALID_TIMER);
}
}
#else
// updated the formula based on a Japanese formula found to be exact [Reddozen]
if(tstatus->vit+sstatus->int_) //crash fix
md.damage = (int)(7*tstatus->vit*sstatus->int_*sstatus->int_ / (10*(tstatus->vit+sstatus->int_)));
else
md.damage = 0;
if (tsd) md.damage>>=1;
#endif
// Some monsters have totaldef higher than md.damage in some cases, leading to md.damage < 0
if( md.damage < 0 )
md.damage = 0;
if( md.damage > INT_MAX>>1 )
//Overflow prevention, will anyone whine if I cap it to a few billion?
//Not capped to INT_MAX to give some room for further damage increase.
md.damage = INT_MAX>>1;
break;
In battle_calc_misc_attack (battle.c)