Skip to content

Commit

Permalink
feat: training weapons for mage and paladin (#1870)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebbesiren authored Dec 4, 2023
1 parent cda6813 commit 62995d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions src/items/weapons/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ void Weapon::onUsedWeapon(std::shared_ptr<Player> player, std::shared_ptr<Item>
if (manaCost != 0) {
player->addManaSpent(manaCost);
player->changeMana(-static_cast<int32_t>(manaCost));

if (g_configManager().getBoolean(REFUND_BEGINNING_WEAPON_MANA, __FUNCTION__) && (item->getName() == "wand of vortex" || item->getName() == "snakebite rod")) {
player->changeMana(static_cast<int32_t>(manaCost));
}
}

uint32_t healthCost = getHealthCost(player);
Expand All @@ -263,15 +267,16 @@ void Weapon::onUsedWeapon(std::shared_ptr<Player> player, std::shared_ptr<Item>
player->changeSoul(-static_cast<int32_t>(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;
}

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);
}
Expand Down

0 comments on commit 62995d6

Please sign in to comment.