Forkz
Intermediate OT User
- Joined
- Jun 29, 2020
- Messages
- 528
- Solutions
- 16
- Reaction score
- 129
Based on the cipsoft engine, are these formulas correct?
C++:
int32_t Monster::getDefense()
{
int32_t totalDefense = mType->info.defense;
int32_t defenseSkill = mType->info.skill;
/* fightMode_t attackMode = FIGHTMODE_BALANCED;
if ((followCreature || !attackedCreature) && earliestAttackTime <= OTSYS_TIME()) {
attackMode = FIGHTMODE_DEFENSE;
}
if (attackMode == FIGHTMODE_ATTACK) {
totalDefense -= 4 * totalDefense / 10;
} else if (attackMode == FIGHTMODE_DEFENSE) {
totalDefense += 8 * totalDefense / 10;
} */
if (totalDefense) {
int32_t formula = (5 * (defenseSkill) + 50) * totalDefense;
int32_t randresult = rand() % 100;
totalDefense = formula * ((rand() % 100 + randresult) / 2) / 10000.;
}
return totalDefense;
}
C++:
int32_t Combat::getTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode)
{
return -static_cast<int32_t>(ceil(((5 * attackSkill + 50) * attackValue *
(fightMode == FIGHTMODE_ATTACK ? 1.2 : (fightMode == FIGHTMODE_BALANCED ? 1.0 : 0.6)) *
(rand() % 100 + rand() % 100)) / 2.0 / 10000.0));
}
C++:
int32_t Player::getDefense()
{
int32_t totalDefense = 5;
int32_t defenseSkill = getSkillLevel(SKILL_FIST);
const Item* weapon;
const Item* shield;
getShieldAndWeapon(shield, weapon);
if (weapon) {
totalDefense = weapon->getDefense() + 1;
switch (weapon->getWeaponType()) {
case WEAPON_AXE:
defenseSkill = SKILL_AXE;
break;
case WEAPON_SWORD:
defenseSkill = SKILL_SWORD;
break;
case WEAPON_CLUB:
defenseSkill = SKILL_CLUB;
break;
case WEAPON_DISTANCE:
case WEAPON_AMMO:
defenseSkill = SKILL_DISTANCE;
break;
default:
break;
}
defenseSkill = getSkillLevel(defenseSkill);
}
if (shield) {
totalDefense = shield->getDefense() + 1;
defenseSkill = getSkillLevel(SKILL_SHIELD);
}
fightMode_t attackMode = getFightMode();
if ((followCreature || !attackedCreature) && earliestAttackTime <= OTSYS_TIME()) {
attackMode = FIGHTMODE_DEFENSE;
}
float defenseMultiplier = 1.0f;
switch (attackMode) {
case FIGHTMODE_ATTACK:
defenseMultiplier = 0.6f;
break;
case FIGHTMODE_DEFENSE:
defenseMultiplier = 1.8f;
break;
default:
defenseMultiplier = 1.0f;
break;
}
if (totalDefense) {
int32_t formula = static_cast<int32_t>((5 * (defenseSkill) + 50) * totalDefense * defenseMultiplier);
int32_t randResult = rand() % 100;
totalDefense = formula * ((rand() % 100 + randResult) / 2) / 10000;
}
return totalDefense;
}