TFS version: 1.4.2
How can I make chance accepts decimal numbers? I am trying to use from 0.1, 0.2, 0.02, 5, 7, 30, etc.. and up to 100 like it is.
I tried to divine chance / 1.0 and then multiply it below * 1.0 but that didn't work.
Excuse my low knowledge of C++
How can I make chance accepts decimal numbers? I am trying to use from 0.1, 0.2, 0.02, 5, 7, 30, etc.. and up to 100 like it is.
I tried to divine chance / 1.0 and then multiply it below * 1.0 but that didn't work.
C++:
if (casterPlayer->getHealth() < casterPlayer->getMaxHealth()) {
uint16_t chance = casterPlayer->getSpecialSkill(SPECIALSKILL_LIFELEECHCHANCE);
uint16_t skill = casterPlayer->getSpecialSkill(SPECIALSKILL_LIFELEECHAMOUNT);
if (chance > 0 && skill > 0 && normal_random(1, 100) <= chance) {
leechCombat.primary.value = std::round(totalDamage * (skill / 100.));
g_game.combatChangeHealth(nullptr, casterPlayer, leechCombat);
casterPlayer->sendMagicEffect(casterPlayer->getPosition(), CONST_ME_MAGIC_RED);
}
}
Last edited: