diff --git a/config.lua.dist b/config.lua.dist index bcc2887d905..31e79ade912 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -64,10 +64,8 @@ gamestoreByModules = true preySystemEnabled = true preyFreeThirdSlot = false preyRerollPricePerLevel = 200 -preySelectListPrice = 1 -preyBonusRerollPrice = 2 -preyBonusPercentMin = 5 -preyBonusPercentMax = 40 +preySelectListPrice = 5 +preyBonusRerollPrice = 1 preyBonusTime = 2 * 60 * 60 preyFreeRerollTime = 20 * 60 * 60 @@ -79,8 +77,8 @@ taskHuntingSystemEnabled = true taskHuntingFreeThirdSlot = false taskHuntingLimitedTasksExhaust = 20 * 60 * 60 taskHuntingRerollPricePerLevel = 200 -taskHuntingSelectListPrice = 1 -taskHuntingBonusRerollPrice = 2 +taskHuntingSelectListPrice = 5 +taskHuntingBonusRerollPrice = 1 taskHuntingFreeRerollTime = 20 * 60 * 60 -- Forge system diff --git a/src/config/config_definitions.hpp b/src/config/config_definitions.hpp index 8e534d5a2b1..f8e88cf62c8 100644 --- a/src/config/config_definitions.hpp +++ b/src/config/config_definitions.hpp @@ -166,8 +166,6 @@ enum integerConfig_t { SAVE_INTERVAL_TIME, PREY_REROLL_PRICE_LEVEL, PREY_SELECTION_LIST_PRICE, - PREY_BONUS_PERCENT_MIN, - PREY_BONUS_PERCENT_MAX, PREY_BONUS_TIME, PREY_BONUS_REROLL_PRICE, PREY_FREE_REROLL_TIME, diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index b90228fc545..ff322b0d67b 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -282,19 +282,17 @@ bool ConfigManager::load() boolean[PREY_ENABLED] = getGlobalBoolean(L, "preySystemEnabled", true); boolean[PREY_FREE_THIRD_SLOT] = getGlobalBoolean(L, "preyFreeThirdSlot", false); integer[PREY_REROLL_PRICE_LEVEL] = getGlobalNumber(L, "preyRerollPricePerLevel", 200); - integer[PREY_SELECTION_LIST_PRICE] = getGlobalNumber(L, "preySelectListPrice", 1); - integer[PREY_BONUS_PERCENT_MIN] = getGlobalNumber(L, "preyBonusPercentMin", 5); - integer[PREY_BONUS_PERCENT_MAX] = getGlobalNumber(L, "preyBonusPercentMax", 40); + integer[PREY_SELECTION_LIST_PRICE] = getGlobalNumber(L, "preySelectListPrice", 5); integer[PREY_BONUS_TIME] = getGlobalNumber(L, "preyBonusTime", 7200); - integer[PREY_BONUS_REROLL_PRICE] = getGlobalNumber(L, "preyBonusRerollPrice", 2); + integer[PREY_BONUS_REROLL_PRICE] = getGlobalNumber(L, "preyBonusRerollPrice", 1); integer[PREY_FREE_REROLL_TIME] = getGlobalNumber(L, "preyFreeRerollTime", 72000); boolean[TASK_HUNTING_ENABLED] = getGlobalBoolean(L, "taskHuntingSystemEnabled", true); boolean[TASK_HUNTING_FREE_THIRD_SLOT] = getGlobalBoolean(L, "taskHuntingFreeThirdSlot", false); integer[TASK_HUNTING_LIMIT_EXHAUST] = getGlobalNumber(L, "taskHuntingLimitedTasksExhaust", 72000); integer[TASK_HUNTING_REROLL_PRICE_LEVEL] = getGlobalNumber(L, "taskHuntingRerollPricePerLevel", 200); - integer[TASK_HUNTING_SELECTION_LIST_PRICE] = getGlobalNumber(L, "taskHuntingSelectListPrice", 1); - integer[TASK_HUNTING_BONUS_REROLL_PRICE] = getGlobalNumber(L, "taskHuntingBonusRerollPrice", 2); + integer[TASK_HUNTING_SELECTION_LIST_PRICE] = getGlobalNumber(L, "taskHuntingSelectListPrice", 5); + integer[TASK_HUNTING_BONUS_REROLL_PRICE] = getGlobalNumber(L, "taskHuntingBonusRerollPrice", 1); integer[TASK_HUNTING_FREE_REROLL_TIME] = getGlobalNumber(L, "taskHuntingFreeRerollTime", 72000); loaded = true; diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 0ce06a91c63..ed486e3dad5 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -494,12 +494,33 @@ void Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatPa { assert(data); CombatDamage damage = *data; - if (caster && caster->getPlayer()) { - Item *item = caster->getPlayer()->getWeapon(); + + Player *attackerPlayer = nullptr; + if (caster) { + attackerPlayer = caster->getPlayer(); + } + + Monster *targetMonster = nullptr; + if (target) { + targetMonster = target->getMonster(); + } + + Monster *attackerMonster = nullptr; + if (caster) { + attackerMonster = caster->getMonster(); + } + + Player *targetPlayer = nullptr; + if (target) { + targetPlayer = target->getPlayer(); + } + + if (caster && attackerPlayer) { + Item *item = attackerPlayer->getWeapon(); damage = applyImbuementElementalDamage(item, damage); - g_events().eventPlayerOnCombat(caster->getPlayer(), target, item, damage); + g_events().eventPlayerOnCombat(attackerPlayer, target, item, damage); - if (target && target->getSkull() != SKULL_BLACK && target->getPlayer()) { + if (targetPlayer && targetPlayer->getSkull() != SKULL_BLACK) { if (damage.primary.type != COMBAT_HEALING) { damage.primary.value /= 2; } @@ -513,6 +534,23 @@ void Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatPa return; } + // Player attacking monster + if (attackerPlayer && targetMonster) { + const PreySlot* slot = attackerPlayer->getPreyWithMonster(targetMonster->getRaceId()); + if (slot && slot->isOccupied() && slot->bonus == PreyBonus_Damage && slot->bonusTimeLeft > 0) { + damage.primary.value += static_cast(std::ceil((damage.primary.value * slot->bonusPercentage) / 100)); + damage.secondary.value += static_cast(std::ceil((damage.primary.value * slot->bonusPercentage) / 100)); + } + } + + // Monster attacking player + if (attackerMonster && targetPlayer) { + const PreySlot* slot = targetPlayer->getPreyWithMonster(attackerMonster->getRaceId()); + if (slot && slot->isOccupied() && slot->bonus == PreyBonus_Defense && slot->bonusTimeLeft > 0) { + damage.primary.value -= static_cast(std::ceil((damage.primary.value * slot->bonusPercentage) / 100)); + } + } + if (g_game().combatChangeHealth(caster, target, damage)) { CombatConditionFunc(caster, target, params, &damage); CombatDispelFunc(caster, target, params, nullptr); diff --git a/src/game/game.cpp b/src/game/game.cpp index 99cb4c72804..16b6a59b81a 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -5766,20 +5766,6 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage attackerMonster = nullptr; } - if (attackerPlayer && targetMonster) { - const PreySlot* slot = attackerPlayer->getPreyWithMonster(targetMonster->getRaceId()); - if (slot && slot->isOccupied() && slot->bonus == PreyBonus_Damage && slot->bonusTimeLeft > 0) { - damage.primary.value += static_cast(std::ceil((damage.primary.value * slot->bonusPercentage) / 100)); - damage.secondary.value += static_cast(std::ceil((damage.secondary.value * slot->bonusPercentage) / 100)); - } - } else if (attackerMonster && targetPlayer) { - const PreySlot* slot = targetPlayer->getPreyWithMonster(attackerMonster->getRaceId()); - if (slot && slot->isOccupied() && slot->bonus == PreyBonus_Defense && slot->bonusTimeLeft > 0) { - damage.primary.value -= static_cast(std::ceil((damage.primary.value * slot->bonusPercentage) / 100)); - damage.secondary.value -= static_cast(std::ceil((damage.secondary.value * slot->bonusPercentage) / 100)); - } - } - TextMessage message; message.position = targetPos; diff --git a/src/io/ioprey.cpp b/src/io/ioprey.cpp index df6f2f8ef4a..7e52f1225fd 100644 --- a/src/io/ioprey.cpp +++ b/src/io/ioprey.cpp @@ -50,20 +50,18 @@ void PreySlot::reloadBonusType() void PreySlot::reloadBonusValue() { - auto minBonusPercent = static_cast(g_configManager().getNumber(PREY_BONUS_PERCENT_MIN)); - auto maxBonusPercent = static_cast(g_configManager().getNumber(PREY_BONUS_PERCENT_MAX)); - auto stagePercent = static_cast(std::floor((maxBonusPercent - minBonusPercent) / 8)); if (bonusRarity >= 9) { bonusRarity = 10; } else { + // Every time you roll it will increase the rarity (star) bonusRarity = static_cast(uniform_random(bonusRarity + 1, 10)); } - - bonusPercentage = stagePercent * bonusRarity; - if (bonusPercentage > maxBonusPercent) { - bonusPercentage = maxBonusPercent; - } else if (bonusPercentage < minBonusPercent) { - bonusPercentage = minBonusPercent; + if (bonus == PreyBonus_Damage) { + bonusPercentage = 2 * bonusRarity + 5; + } else if (bonus == PreyBonus_Defense) { + bonusPercentage = 2 * bonusRarity + 10; + } else { + bonusPercentage = 3 * bonusRarity + 10; } } @@ -275,8 +273,8 @@ void IOPrey::CheckPlayerPreys(Player* player, uint8_t amount) const if (slot->bonusTimeLeft <= amount) { if (slot->option == PreyOption_AutomaticReroll) { if (player->usePreyCards(static_cast(g_configManager().getNumber(PREY_BONUS_REROLL_PRICE)))) { - slot->reloadBonusValue(); slot->reloadBonusType(); + slot->reloadBonusValue(); slot->bonusTimeLeft = static_cast(g_configManager().getNumber(PREY_BONUS_TIME)); player->sendTextMessage(MESSAGE_STATUS, "Your prey bonus type and time has been succesfully reseted."); player->reloadPreySlot(static_cast(slotId)); @@ -355,8 +353,8 @@ void IOPrey::ParsePreyAction(Player* player, } if (slot->bonus == PreyBonus_None) { - slot->reloadBonusValue(); slot->reloadBonusType(); + slot->reloadBonusValue(); } slot->state = PreyDataState_Active; @@ -372,8 +370,8 @@ void IOPrey::ParsePreyAction(Player* player, return; } - slot->reloadBonusValue(); slot->reloadBonusType(); + slot->reloadBonusValue(); slot->bonusTimeLeft = static_cast(g_configManager().getNumber(PREY_BONUS_TIME)); } else if (action == PreyAction_MonsterSelection) { if (slot->isOccupied()) { @@ -388,8 +386,8 @@ void IOPrey::ParsePreyAction(Player* player, } if (slot->bonus == PreyBonus_None) { - slot->reloadBonusValue(); slot->reloadBonusType(); + slot->reloadBonusValue(); } slot->state = PreyDataState_Active; slot->selectedRaceId = slot->raceIdList[index]; diff --git a/src/lua/functions/core/game/config_functions.hpp b/src/lua/functions/core/game/config_functions.hpp index 11ef224a5a9..f318cdf9f06 100644 --- a/src/lua/functions/core/game/config_functions.hpp +++ b/src/lua/functions/core/game/config_functions.hpp @@ -98,8 +98,6 @@ class ConfigFunctions final : LuaScriptInterface { registerEnumIn(L, "configKeys", PREY_ENABLED) registerEnumIn(L, "configKeys", PREY_FREE_THIRD_SLOT) registerEnumIn(L, "configKeys", PREY_REROLL_PRICE_LEVEL) - registerEnumIn(L, "configKeys", PREY_BONUS_PERCENT_MIN) - registerEnumIn(L, "configKeys", PREY_BONUS_PERCENT_MAX) registerEnumIn(L, "configKeys", PREY_BONUS_TIME) registerEnumIn(L, "configKeys", PREY_BONUS_REROLL_PRICE) registerEnumIn(L, "configKeys", PREY_FREE_REROLL_TIME)