Skip to content

Commit

Permalink
Merge branch 'main' into feat-show-loots-in-bestiary
Browse files Browse the repository at this point in the history
  • Loading branch information
lamonato29 authored Mar 6, 2024
2 parents de5721e + 6721bc6 commit cd6ad99
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 32 deletions.
3 changes: 3 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ maxDamageReflection = 200
toggleChainSystem = true
combatChainDelay = 50
combatChainTargets = 5
combatChainSkillFormulaAxe = 0.9
combatChainSkillFormulaClub = 0.7
combatChainSkillFormulaSword = 1.1

-- Global server Save
-- NOTE: globalServerSaveNotifyDuration in minutes
Expand Down
21 changes: 0 additions & 21 deletions data-otservbr-global/scripts/actions/other/voodoo_doll.lua

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local explosivePresent = Action()
function explosivePresent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:say("KABOOOOOOOOOOM!", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_FIREAREA)
player:addAchievement("Joke's on You")
item:remove()
return true
end
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/actions/items/foods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ local foods = {
local food = Action()

function food.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemFood = setting[item.itemid]
local itemFood = foods[item.itemid]
if not itemFood then
return false
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function voodooDoll.onUse(player, item, fromPosition, target, toPosition, isHotk
local text = ""
if math.random(100) <= 5 then
text = "You concentrate on your victim and hit the needle in the doll."
player:addAchievement("Dark Voodoo Priest")
toPosition:sendMagicEffect(CONST_ME_DRAWBLOOD, player)
else
text = "You concentrate on your victim, hit the needle in the doll.......but nothing happens."
Expand Down
3 changes: 3 additions & 0 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ enum ConfigKey_t : uint16_t {
CLEAN_PROTECTION_ZONES,
COMBAT_CHAIN_DELAY,
COMBAT_CHAIN_TARGETS,
COMBAT_CHAIN_SKILL_FORMULA_AXE,
COMBAT_CHAIN_SKILL_FORMULA_CLUB,
COMBAT_CHAIN_SKILL_FORMULA_SWORD,
COMPRESSION_LEVEL,
CONVERT_UNSAFE_SCRIPTS,
CORE_DIRECTORY,
Expand Down
3 changes: 3 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ bool ConfigManager::load() {
loadIntConfig(L, CHECK_EXPIRED_MARKET_OFFERS_EACH_MINUTES, "checkExpiredMarketOffersEachMinutes", 60);
loadIntConfig(L, COMBAT_CHAIN_DELAY, "combatChainDelay", 50);
loadIntConfig(L, COMBAT_CHAIN_TARGETS, "combatChainTargets", 5);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_AXE, "combatChainSkillFormulaAxe", 0.9);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_CLUB, "combatChainSkillFormulaClub", 0.7);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_SWORD, "combatChainSkillFormulaSword", 1.1);
loadIntConfig(L, COMPRESSION_LEVEL, "packetCompressionLevel", 6);
loadIntConfig(L, CRITICALCHANCE, "criticalChance", 10);
loadIntConfig(L, DAY_KILLS_TO_RED, "dayKillsToRedSkull", 3);
Expand Down
12 changes: 7 additions & 5 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,10 @@ void Combat::setupChain(const std::shared_ptr<Weapon> &weapon) {
return;
}

if (weapon->isChainDisabled()) {
return;
}

const auto &weaponType = weapon->getWeaponType();
if (weaponType == WEAPON_NONE || weaponType == WEAPON_SHIELD || weaponType == WEAPON_AMMO || weaponType == WEAPON_DISTANCE) {
return;
Expand Down Expand Up @@ -980,15 +984,13 @@ void Combat::setupChain(const std::shared_ptr<Weapon> &weapon) {

switch (weaponType) {
case WEAPON_SWORD:
setCommonValues(1.1, MELEE_ATK_SWORD, CONST_ME_SLASH);
setCommonValues(g_configManager().getFloat(COMBAT_CHAIN_SKILL_FORMULA_SWORD, __FUNCTION__), MELEE_ATK_SWORD, CONST_ME_SLASH);
break;

case WEAPON_CLUB:
setCommonValues(0.7, MELEE_ATK_CLUB, CONST_ME_BLACK_BLOOD);
setCommonValues(g_configManager().getFloat(COMBAT_CHAIN_SKILL_FORMULA_CLUB, __FUNCTION__), MELEE_ATK_CLUB, CONST_ME_BLACK_BLOOD);
break;

case WEAPON_AXE:
setCommonValues(0.9, MELEE_ATK_AXE, CONST_ANI_WHIRLWINDAXE);
setCommonValues(g_configManager().getFloat(COMBAT_CHAIN_SKILL_FORMULA_AXE, __FUNCTION__), MELEE_ATK_AXE, CONST_ANI_WHIRLWINDAXE);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5691,7 +5691,7 @@ void Game::playerChangeOutfit(uint32_t playerId, Outfit_t outfit, uint8_t isMoun
return;
}

if (playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
if (!g_configManager().getBoolean(TOGGLE_MOUNT_IN_PZ, __FUNCTION__) && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
outfit.lookMount = 0;
}

Expand Down
11 changes: 8 additions & 3 deletions src/items/functions/item/item_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,9 +1165,14 @@ void ItemParse::createAndRegisterScript(ItemType &itemType, pugi::xml_node attri
g_logger().warn("[{}] - wandtype '{}' does not exist", __FUNCTION__, elementName);
}
} else if (stringKey == "chain" && weapon) {
auto value = subValueAttribute.as_double();
weapon->setChainSkillValue(value);
g_logger().trace("Found chain skill value '{}' for weapon: {}", value, itemType.name);
if (auto value = subValueAttribute.as_double()) {
weapon->setChainSkillValue(value);
g_logger().trace("Found chain skill value '{}' for weapon: {}", value, itemType.name);
}
if (subValueAttribute.as_bool() == false) {
weapon->setDisabledChain();
g_logger().warn("Chain disabled for weapon: {}", itemType.name);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/items/weapons/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void Weapon::internalUseWeapon(std::shared_ptr<Player> player, std::shared_ptr<I
damage.secondary.value = (getElementDamage(player, target, item) * damageModifier / 100) * damagePercent / 100;
}

if (params.chainCallback) {
if (g_configManager().getBoolean(TOGGLE_CHAIN_SYSTEM, __FUNCTION__) && params.chainCallback) {
m_combat->doCombatChain(player, target, params.aggressive);
} else {
Combat::doCombatHealth(player, target, damage, params);
Expand Down
9 changes: 9 additions & 0 deletions src/items/weapons/weapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ class Weapon : public Script {
return m_chainSkillValue;
}

void setDisabledChain() {
m_isDisabledChain = true;
}

bool isChainDisabled() const {
return m_isDisabledChain;
}

const WeaponType_t getWeaponType() const {
return weaponType;
}
Expand Down Expand Up @@ -243,6 +251,7 @@ class Weapon : public Script {
bool enabled = true;
bool premium = false;
bool wieldUnproperly = false;
bool m_isDisabledChain = false;
std::string vocationString = "";

void onUsedWeapon(std::shared_ptr<Player> player, std::shared_ptr<Item> item, std::shared_ptr<Tile> destTile) const;
Expand Down

0 comments on commit cd6ad99

Please sign in to comment.