Skip to content

Commit dfedebb

Browse files
committed
* FEATURE: spell name instead of words
1 parent 720e408 commit dfedebb

File tree

10 files changed

+67
-4
lines changed

10 files changed

+67
-4
lines changed

config.lua.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ allowChangeOutfit = true
426426
freePremium = false
427427
kickIdlePlayerAfterMinutes = 15
428428
maxMessageBuffer = 4
429-
emoteSpells = false
430429
allowWalkthrough = true
431430
coinPacketSize = 25
432431
coinImagesURL = "http://127.0.0.1/images/store/"
@@ -465,6 +464,10 @@ combatChainSkillFormulaDistance = 0.9
465464
combatChainSkillFormulaMissile = 0.9
466465
combatChainSkillFormulaWandsAndRods = 1.0
467466

467+
-- Spells
468+
emoteSpells = false
469+
spellNameInsteadOfWords = false
470+
468471
-- Global server Save
469472
-- NOTE: globalServerSaveNotifyDuration in minutes
470473
globalServerSaveNotifyMessage = true

data/libs/systems/features.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Features = {
22
AutoLoot = "autoloot",
33
ChainSystem = "chainSystem",
44
EmoteSpells = "emoteSpells",
5+
SpellNameInsteadOfWords = "spellNameInsteadOfWords",
56
}
67

78
local function validateFeature(feature)

data/scripts/talkactions/player/emote_spell.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function emoteSpell.onSay(player, words, param)
1313

1414
if not table.contains(validValues, param) then
1515
local validValuesStr = table.concat(validValues, "/")
16-
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Invalid param specified. Usage: !emote [" .. validValuesStr .. "]")
16+
player:sendTextMessage(MESSAGE_FAILURE, "Invalid param specified. Usage: !emote [" .. validValuesStr .. "]")
1717
return true
1818
end
1919

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
local featrue = TalkAction("!spellwords")
2+
3+
local validValues = {
4+
"on",
5+
"off",
6+
}
7+
8+
function featrue.onSay(player, words, param)
9+
if not configManager.getBoolean(configKeys.EMOTE_SPELLS) then
10+
player:sendTextMessage(MESSAGE_FAILURE, "Spell name instead of words have been disabled by the administrator.")
11+
return true
12+
end
13+
14+
if not table.contains(validValues, param) then
15+
local validValuesStr = table.concat(validValues, "/")
16+
player:sendTextMessage(MESSAGE_FAILURE, "Invalid param specified. Usage: !spellwords [" .. validValuesStr .. "]")
17+
return true
18+
end
19+
20+
if param == "on" then
21+
player:setFeature(Features.SpellNameInsteadOfWords, 1)
22+
player:sendTextMessage(MESSAGE_LOOK, "You have activated spell name instead of words.")
23+
elseif param == "off" then
24+
player:setFeature(Features.SpellNameInsteadOfWords, 0)
25+
player:sendTextMessage(MESSAGE_LOOK, "You have deactivated spell name instead of words.")
26+
end
27+
return true
28+
end
29+
30+
featrue:separator(" ")
31+
featrue:groupType("normal")
32+
featrue:register()

markdowns/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
- New protocol 14.05 assets. ([Tryller](https://github.com/jprzimba))
1010
- Optimized the `onPlayerSellAllLoot` code to prevent prolonged freezes. ([Tryller](https://github.com/jprzimba))
1111
- Add new configurable featurees in `config.lua`: `chainSystemVipOnly`, `fieldOwnershipDuration`, `bedsOnlyPremium`, `loginProtectionPeriod`, `chainSystemModifyMagic`. ([Tryller](https://github.com/jprzimba))
12-
- Added a new command for players: `!randomoutfit`. ([Tryller](https://github.com/jprzimba))
12+
- Added a new commands for players: `!randomoutfit`, `!spellwords`. ([Tryller](https://github.com/jprzimba))
1313
- Moved emote spells to `kv` instead of `storage`. ([Tryller](https://github.com/jprzimba))
1414

1515
## Added files
1616

1717
- Add all files in data/migrations
1818
- data/scripts/talkactions/player/randomoutfit.lua
19+
- data/scripts/talkactions/player/spell_name_instead_words.lua
1920
- data/scripts/creaturescripts/player/swimming.lua
2021
- data-global/scripts/creaturescripts/customs/water_houses.lua
2122

src/config/config_enums.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,5 @@ enum ConfigKey_t : uint16_t {
350350
FIELD_OWNERSHIP,
351351
BEDS_ONLY_PREMIUM,
352352
LOGIN_PROTECTION,
353+
SPELL_NAME_INSTEAD_WORDS,
353354
};

src/config/configmanager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ bool ConfigManager::load() {
171171
loadBoolConfig(L, HALF_LOSS_MAGIC, "halfLossMagicLevel", true);
172172
loadBoolConfig(L, CHAIN_SYSTEM_VIP_ONLY, "chainSystemVipOnly", false);
173173
loadBoolConfig(L, BEDS_ONLY_PREMIUM, "bedsOnlyPremium", true);
174+
loadBoolConfig(L, SPELL_NAME_INSTEAD_WORDS, "spellNameInsteadOfWords", false);
174175

175176
loadFloatConfig(L, BESTIARY_RATE_CHARM_SHOP_PRICE, "bestiaryRateCharmShopPrice", 1.0);
176177
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_AXE, "combatChainSkillFormulaAxe", 0.9);

src/creatures/combat/spells.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ TalkActionResult_t Spells::playerSaySpell(const std::shared_ptr<Player> &player,
9999
}
100100

101101
if (instantSpell->playerCastInstant(player, param)) {
102-
words = instantSpell->getWords();
102+
if (!player->checkSpellNameInsteadOfWords()) {
103+
words = instantSpell->getWords();
104+
}
105+
else {
106+
words = instantSpell->getName();
107+
}
103108

104109
if (instantSpell->getHasParam() && !param.empty()) {
105110
words += " \"" + param + "\"";

src/creatures/players/player.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5020,6 +5020,24 @@ bool Player::checkEmoteSpells() const {
50205020
return false;
50215021
}
50225022

5023+
bool Player::checkSpellNameInsteadOfWords() const {
5024+
if (!g_configManager().getBoolean(SPELL_NAME_INSTEAD_WORDS)) {
5025+
return false;
5026+
}
5027+
5028+
auto featureKV = kv()->scoped("features")->get("spellNameInsteadOfWords");
5029+
if (featureKV.has_value()) {
5030+
auto value = featureKV->getNumber();
5031+
if (value == 1) {
5032+
return true;
5033+
} else if (value == 0) {
5034+
return false;
5035+
}
5036+
}
5037+
5038+
return false;
5039+
}
5040+
50235041
QuickLootFilter_t Player::getQuickLootFilter() const {
50245042
return quickLootFilter;
50255043
}

src/creatures/players/player.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
12121212
bool checkAutoLoot(bool isBoss) const;
12131213
bool checkChainSystem() const;
12141214
bool checkEmoteSpells() const;
1215+
bool checkSpellNameInsteadOfWords() const;
12151216

12161217
QuickLootFilter_t getQuickLootFilter() const;
12171218

0 commit comments

Comments
 (0)