From 62995d6e9f31f39e9460416c284357d34a9e78b1 Mon Sep 17 00:00:00 2001 From: sebbesiren <35768829+sebbesiren@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:01:54 +0100 Subject: [PATCH] feat: training weapons for mage and paladin (#1870) Added configure parameters to make the beginning weapon usable for mages and paladins to train. refundBeginningWeaponMana (true): Mana used when using the wand of vortex and snakebite rod is refunded. removeBeginningWeaponAmmunition (false): Arrows, Bolts, and Spears lasts forever. --- config.lua.dist | 4 ++++ src/config/config_definitions.hpp | 2 ++ src/config/configmanager.cpp | 2 ++ src/items/weapons/weapons.cpp | 9 +++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config.lua.dist b/config.lua.dist index 1023fd37d5a..efef42dc91a 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -23,6 +23,8 @@ maintainModeMessage = "" -- Combat settings -- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced" +-- NOTE: removeBeginningWeaponAmmunition: spears, arrows, bolt have endless ammo (allows training for paladins) +-- NOTE: refundManaOnBeginningWeapons: wand of vortex and snakebite refund mana used (allows training for mages) worldType = "pvp" hotkeyAimbotEnabled = true protectionLevel = 7 @@ -31,6 +33,8 @@ removeChargesFromRunes = true removeChargesFromPotions = true removeWeaponAmmunition = true removeWeaponCharges = true +removeBeginningWeaponAmmunition = true +refundBeginningWeaponMana = false timeToDecreaseFrags = 24 * 60 * 60 * 1000 whiteSkullTime = 15 * 60 * 1000 stairJumpExhaustion = 2 * 1000 diff --git a/src/config/config_definitions.hpp b/src/config/config_definitions.hpp index dc7f1caac24..3381e671a98 100644 --- a/src/config/config_definitions.hpp +++ b/src/config/config_definitions.hpp @@ -28,6 +28,8 @@ enum ConfigKey_t : uint16_t { CLASSIC_ATTACK_SPEED, SCRIPTS_CONSOLE_LOGS, REMOVE_WEAPON_AMMO, + REMOVE_BEGINNING_WEAPON_AMMO, + REFUND_BEGINNING_WEAPON_MANA, REMOVE_WEAPON_CHARGES, REMOVE_POTION_CHARGES, GLOBAL_SERVER_SAVE_NOTIFY_MESSAGE, diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index 2931464270a..f7603ba5143 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -102,6 +102,8 @@ bool ConfigManager::load() { loadBoolConfig(L, ALLOW_BLOCK_SPAWN, "allowBlockSpawn", true); loadBoolConfig(L, REMOVE_WEAPON_AMMO, "removeWeaponAmmunition", true); loadBoolConfig(L, REMOVE_WEAPON_CHARGES, "removeWeaponCharges", true); + loadBoolConfig(L, REMOVE_BEGINNING_WEAPON_AMMO, "removeBeginningWeaponAmmunition", true); + loadBoolConfig(L, REFUND_BEGINNING_WEAPON_MANA, "refundBeginningWeaponMana", false); loadBoolConfig(L, REMOVE_POTION_CHARGES, "removeChargesFromPotions", true); loadBoolConfig(L, GLOBAL_SERVER_SAVE_NOTIFY_MESSAGE, "globalServerSaveNotifyMessage", true); loadBoolConfig(L, GLOBAL_SERVER_SAVE_CLEAN_MAP, "globalServerSaveCleanMap", false); diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 0e5d1e949bb..796aea212a6 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -252,6 +252,10 @@ void Weapon::onUsedWeapon(std::shared_ptr player, std::shared_ptr if (manaCost != 0) { player->addManaSpent(manaCost); player->changeMana(-static_cast(manaCost)); + + if (g_configManager().getBoolean(REFUND_BEGINNING_WEAPON_MANA, __FUNCTION__) && (item->getName() == "wand of vortex" || item->getName() == "snakebite rod")) { + player->changeMana(static_cast(manaCost)); + } } uint32_t healthCost = getHealthCost(player); @@ -263,7 +267,8 @@ void Weapon::onUsedWeapon(std::shared_ptr player, std::shared_ptr player->changeSoul(-static_cast(soul)); } - if (breakChance != 0 && uniform_random(1, 100) <= breakChance) { + bool skipRemoveBeginningWeaponAmmo = !g_configManager().getBoolean(REMOVE_BEGINNING_WEAPON_AMMO, __FUNCTION__) && (item->getName() == "arrow" || item->getName() == "bolt" || item->getName() == "spear"); + if (!skipRemoveBeginningWeaponAmmo && breakChance != 0 && uniform_random(1, 100) <= breakChance) { Weapon::decrementItemCount(item); player->updateSupplyTracker(item); return; @@ -271,7 +276,7 @@ void Weapon::onUsedWeapon(std::shared_ptr player, std::shared_ptr switch (action) { case WEAPONACTION_REMOVECOUNT: - if (g_configManager().getBoolean(REMOVE_WEAPON_AMMO, __FUNCTION__)) { + if (!skipRemoveBeginningWeaponAmmo && g_configManager().getBoolean(REMOVE_WEAPON_AMMO, __FUNCTION__)) { Weapon::decrementItemCount(item); player->updateSupplyTracker(item); }