Skip to content

Commit

Permalink
[Bug] forge skill chance bug by changing data type from int to double (
Browse files Browse the repository at this point in the history
  • Loading branch information
murilo09 authored Jan 12, 2023
1 parent 084a914 commit e2d2da1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,12 @@ void Combat::doCombatHealth(Creature* caster, Creature* target, CombatDamage& da
damage.secondary.value += (damage.secondary.value * caster->getPlayer()->getSkillLevel(SKILL_CRITICAL_HIT_DAMAGE ))/100;
}

// fatal hit (onslaught)
if (caster->getPlayer()->getInventoryItem(CONST_SLOT_LEFT) != nullptr) {
double_t fatalChance = caster->getPlayer()->getInventoryItem(CONST_SLOT_LEFT)->getFatalChance();
if (damage.primary.type != COMBAT_HEALING && fatalChance > 0 && uniform_random(1, 100) <= fatalChance) {
// Fatal hit (onslaught)
if (auto playerWeapon = caster->getPlayer()->getInventoryItem(CONST_SLOT_LEFT);
playerWeapon != nullptr && playerWeapon->getTier()) {
double_t fatalChance = playerWeapon->getFatalChance();
double_t randomChance = uniform_random(0, 10000) / 100;
if (damage.primary.type != COMBAT_HEALING && fatalChance > 0 && randomChance < fatalChance) {
damage.fatal = true;
damage.primary.value += static_cast<int32_t>(std::round(damage.primary.value * 0.6));
damage.secondary.value += static_cast<int32_t>(std::round(damage.secondary.value * 0.6));
Expand Down Expand Up @@ -986,11 +988,13 @@ void Combat::doCombatHealth(Creature* caster, const Position& position, const Ar
damage.secondary.value += (damage.secondary.value * caster->getPlayer()->getSkillLevel(SKILL_CRITICAL_HIT_DAMAGE ))/100;
}

// fatal hit (onslaught)
if (caster->getPlayer()->getInventoryItem(CONST_SLOT_LEFT) != nullptr)
// Fatal hit (onslaught)
if (auto playerWeapon = caster->getPlayer()->getInventoryItem(CONST_SLOT_LEFT);
playerWeapon != nullptr && playerWeapon->getTier() > 0)
{
double_t fatalChance = caster->getPlayer()->getInventoryItem(CONST_SLOT_LEFT)->getFatalChance();
if (damage.primary.type != COMBAT_HEALING && fatalChance > 0 && uniform_random(1, 100) <= fatalChance) {
double_t fatalChance = playerWeapon->getFatalChance();
double_t randomChance = uniform_random(0, 10000) / 100;
if (damage.primary.type != COMBAT_HEALING && fatalChance > 0 && randomChance < fatalChance) {
damage.fatal = true;
damage.primary.value += static_cast<int32_t>(std::round(damage.primary.value * 0.6));
damage.secondary.value += static_cast<int32_t>(std::round(damage.secondary.value * 0.6));
Expand Down
3 changes: 2 additions & 1 deletion src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5989,7 +5989,8 @@ void Player::triggerMomentum() {
}

double_t chance = item->getMomentumChance();
if (getZone() != ZONE_PROTECTION && hasCondition(CONDITION_INFIGHT) && ((OTSYS_TIME() / 1000) % 2) == 0 && chance > 0 && uniform_random(1, 100) <= chance) {
double_t randomChance = uniform_random(0, 10000) / 100;
if (getZone() != ZONE_PROTECTION && hasCondition(CONDITION_INFIGHT) && ((OTSYS_TIME() / 1000) % 2) == 0 && chance > 0 && randomChance < chance) {
bool triggered = false;
auto it = conditions.begin();
while (it != conditions.end()) {
Expand Down
8 changes: 5 additions & 3 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5495,9 +5495,11 @@ bool Game::combatBlockHit(CombatDamage& damage, Creature* attacker, Creature* ta

// Skill dodge (ruse)
if (const Player* targetPlayer = target->getPlayer()) {
if (targetPlayer->getInventoryItem(CONST_SLOT_ARMOR) != nullptr) {
double_t chance = targetPlayer->getInventoryItem(CONST_SLOT_ARMOR)->getDodgeChance();
if (chance > 0 && uniform_random(1, 100) <= chance) {
if (auto playerArmor = targetPlayer->getInventoryItem(CONST_SLOT_ARMOR);
playerArmor != nullptr && playerArmor->getTier()) {
double_t chance = playerArmor->getDodgeChance();
double_t randomChance = uniform_random(0, 10000) / 100;
if (chance > 0 && randomChance < chance) {
sendBlockEffect(BLOCK_DODGE, damage.primary.type, target->getPosition());
targetPlayer->sendTextMessage(MESSAGE_ATTENTION, "You dodged an attack. (Ruse)");
return true;
Expand Down

0 comments on commit e2d2da1

Please sign in to comment.