diff --git a/conf/attriboost.conf.dist b/conf/attriboost.conf.dist index 3fff86a..c575aec 100644 --- a/conf/attriboost.conf.dist +++ b/conf/attriboost.conf.dist @@ -44,3 +44,4 @@ Attriboost.Max.Strength = 100 Attriboost.Max.Agility = 100 Attriboost.Max.Intellect = 100 Attriboost.Max.Spirit = 100 +Attriboost.Max.SpellPower = 100 diff --git a/data/sql/db-characters/updates/zupdate_attriboost_2024_01_19.sql b/data/sql/db-characters/updates/zupdate_attriboost_2024_01_19.sql new file mode 100644 index 0000000..1b6f7de --- /dev/null +++ b/data/sql/db-characters/updates/zupdate_attriboost_2024_01_19.sql @@ -0,0 +1,3 @@ +ALTER TABLE `attriboost_attributes` +ADD COLUMN `spellpower` int unsigned DEFAULT 0 +AFTER `spirit`; \ No newline at end of file diff --git a/src/Attriboost.cpp b/src/Attriboost.cpp index bae82f4..ea68681 100644 --- a/src/Attriboost.cpp +++ b/src/Attriboost.cpp @@ -172,6 +172,9 @@ std::string AttriboostPlayerScript::GetAttributeName(uint32 attribute) case ATTR_SPELL_SPIRIT: return "Spirit"; + + case ATTR_SPELL_SPELL_POWER: + return "Spell Power"; } return std::string(); @@ -193,6 +196,7 @@ Attriboosts* GetAttriboosts(Player* player) attriboosts.Agility = 0; attriboosts.Intellect = 0; attriboosts.Spirit = 0; + attriboosts.SpellPower = 0; attriboosts.Settings = ATTR_SETTING_PROMPT; @@ -237,8 +241,9 @@ void LoadAttriboosts() attriboosts.Agility = fields[4].Get(); attriboosts.Intellect = fields[5].Get(); attriboosts.Spirit = fields[6].Get(); + attriboosts.SpellPower = fields[7].Get(); - attriboosts.Settings = fields[7].Get(); + attriboosts.Settings = fields[8].Get(); attriboostsMap.emplace(guid, attriboosts); @@ -274,8 +279,9 @@ Attriboosts* LoadAttriboostsForPlayer(Player* player) newAttributes.Agility = fields[4].Get(); newAttributes.Intellect = fields[5].Get(); newAttributes.Spirit = fields[6].Get(); + newAttributes.SpellPower = fields[7].Get(); - newAttributes.Settings = fields[7].Get(); + newAttributes.Settings = fields[8].Get(); auto attributes = attriboostsMap.find(guid); @@ -304,13 +310,14 @@ void SaveAttriboosts() auto agility = it->second.Agility; auto intellect = it->second.Intellect; auto spirit = it->second.Spirit; + auto spellPower = it->second.SpellPower; auto settings = it->second.Settings; - CharacterDatabase.Execute("INSERT INTO `attriboost_attributes` (guid, unallocated, stamina, strength, agility, intellect, spirit, settings) VALUES ({}, {}, {}, {}, {}, {}, {}, {}) ON DUPLICATE KEY UPDATE unallocated={}, stamina={}, strength={}, agility={}, intellect={}, spirit={}, settings={}", + CharacterDatabase.Execute("INSERT INTO `attriboost_attributes` (guid, unallocated, stamina, strength, agility, intellect, spirit, spellpower, settings) VALUES ({}, {}, {}, {}, {}, {}, {}, {}, {}) ON DUPLICATE KEY UPDATE unallocated={}, stamina={}, strength={}, agility={}, intellect={}, spirit={}, spellpower={}, settings={}", guid, - unallocated, stamina, strength, agility, intellect, spirit, settings, - unallocated, stamina, strength, agility, intellect, spirit, settings); + unallocated, stamina, strength, agility, intellect, spirit, spellPower, settings, + unallocated, stamina, strength, agility, intellect, spirit, spellPower, settings); } } @@ -331,13 +338,14 @@ void SaveAttriboostsForPlayer(Player* player) auto agility = attributes->Agility; auto intellect = attributes->Intellect; auto spirit = attributes->Spirit; + auto spellPower = attributes->SpellPower; auto settings = attributes->Settings; - CharacterDatabase.Execute("INSERT INTO `attriboost_attributes` (guid, unallocated, stamina, strength, agility, intellect, spirit, settings) VALUES ({}, {}, {}, {}, {}, {}, {}, {}) ON DUPLICATE KEY UPDATE unallocated={}, stamina={}, strength={}, agility={}, intellect={}, spirit={}, settings={}", + CharacterDatabase.Execute("INSERT INTO `attriboost_attributes` (guid, unallocated, stamina, strength, agility, intellect, spirit, spellpower, settings) VALUES ({}, {}, {}, {}, {}, {}, {}, {}, {}) ON DUPLICATE KEY UPDATE unallocated={}, stamina={}, strength={}, agility={}, intellect={}, spirit={}, spellpower={}, settings={}", guid, - unallocated, stamina, strength, agility, intellect, spirit, settings, - unallocated, stamina, strength, agility, intellect, spirit, settings); + unallocated, stamina, strength, agility, intellect, spirit, spellPower, settings, + unallocated, stamina, strength, agility, intellect, spirit, spellPower, settings); } void ApplyAttributes(Player* player, Attriboosts* attributes) @@ -430,6 +438,23 @@ void ApplyAttributes(Player* player, Attriboosts* attributes) player->RemoveAura(ATTR_SPELL_SPIRIT); } } + + if (attributes->SpellPower > 0) + { + auto spellPower = player->GetAura(ATTR_SPELL_SPELL_POWER); + if (!spellPower) + { + spellPower = player->AddAura(ATTR_SPELL_SPELL_POWER, player); + } + spellPower->SetStackAmount(attributes->SpellPower); + } + else + { + if (player->GetAura(ATTR_SPELL_SPELL_POWER)) + { + player->RemoveAura(ATTR_SPELL_SPELL_POWER); + } + } } void DisableAttributes(Player* player) @@ -525,6 +550,17 @@ bool TryAddAttribute(Attriboosts* attributes, uint32 attribute) alreadyMaxValue = true; } } + else if (attribute == ATTR_SPELL_SPELL_POWER) + { + if (!IsAttributeAtMax(attribute, attributes->SpellPower)) + { + attributes->SpellPower += 1; + } + else + { + alreadyMaxValue = true; + } + } if (alreadyMaxValue) { @@ -545,6 +581,7 @@ void ResetAttributes(Attriboosts* attributes) attributes->Agility = 0; attributes->Intellect = 0; attributes->Spirit = 0; + attributes->SpellPower = 0; } bool HasAttributesToSpend(Player* player) @@ -592,6 +629,9 @@ bool IsAttributeAtMax(uint32 attribute, uint32 value) case ATTR_SPELL_SPIRIT: return value >= sConfigMgr->GetOption("Attriboost.Max.Spirit", 100); + + case ATTR_SPELL_SPELL_POWER: + return value >= sConfigMgr->GetOption("Attriboost.Max.SpellPower", 100); } return true; @@ -610,7 +650,7 @@ uint32 GetAttributesToSpend(Player* player) uint32 GetTotalAttributes(Attriboosts* attributes) { - return attributes->Stamina + attributes->Strength + attributes->Agility + attributes->Intellect + attributes->Spirit; + return attributes->Stamina + attributes->Strength + attributes->Agility + attributes->Intellect + attributes->Spirit + attributes->SpellPower; } uint32 GetTotalAttributes(Player* player) @@ -727,6 +767,11 @@ bool AttriboostCreatureScript::OnGossipHello(Player* player, Creature* creature) attributes->Spirit, IsAttributeAtMax(ATTR_SPELL_SPIRIT, attributes->Spirit) ? "|cffFF0000(MAXED)|r" : ""); + std::string optSpellPower = Acore::StringFormatFmt("|TInterface\\MINIMAP\\UI-Minimap-ZoomInButton-Up:16|t {}Spell Power ({}) {}", + IsAttributeAtMax(ATTR_SPELL_SPELL_POWER, attributes->SpellPower) ? "|cff777777" : "|cff000000", + attributes->SpellPower, + IsAttributeAtMax(ATTR_SPELL_SPELL_POWER, attributes->SpellPower) ? "|cffFF0000(MAXED)|r" : ""); + if (HasSetting(player, ATTR_SETTING_PROMPT)) { AddGossipItemFor(player, GOSSIP_ICON_DOT, optStamina, GOSSIP_SENDER_MAIN, ATTR_SPELL_STAMINA, "Are you sure you want to spend your points in stamina?", 0, false); @@ -734,6 +779,7 @@ bool AttriboostCreatureScript::OnGossipHello(Player* player, Creature* creature) AddGossipItemFor(player, GOSSIP_ICON_DOT, optAgility, GOSSIP_SENDER_MAIN, ATTR_SPELL_AGILITY, "Are you sure you want to spend your points in agility?", 0, false); AddGossipItemFor(player, GOSSIP_ICON_DOT, optIntellect, GOSSIP_SENDER_MAIN, ATTR_SPELL_INTELLECT, "Are you sure you want to spend your points in intellect?", 0, false); AddGossipItemFor(player, GOSSIP_ICON_DOT, optSpirit, GOSSIP_SENDER_MAIN, ATTR_SPELL_SPIRIT, "Are you sure you want to spend your points in spirit?", 0, false); + AddGossipItemFor(player, GOSSIP_ICON_DOT, optSpellPower, GOSSIP_SENDER_MAIN, ATTR_SPELL_SPELL_POWER, "Are you sure you want to spel your points in spell power?", 0, false); } else { @@ -742,6 +788,7 @@ bool AttriboostCreatureScript::OnGossipHello(Player* player, Creature* creature) AddGossipItemFor(player, GOSSIP_ICON_DOT, optAgility, GOSSIP_SENDER_MAIN, ATTR_SPELL_AGILITY); AddGossipItemFor(player, GOSSIP_ICON_DOT, optIntellect, GOSSIP_SENDER_MAIN, ATTR_SPELL_INTELLECT); AddGossipItemFor(player, GOSSIP_ICON_DOT, optSpirit, GOSSIP_SENDER_MAIN, ATTR_SPELL_SPIRIT); + AddGossipItemFor(player, GOSSIP_ICON_DOT, optSpellPower, GOSSIP_SENDER_MAIN, ATTR_SPELL_SPELL_POWER); } } diff --git a/src/Attriboost.h b/src/Attriboost.h index 59c71e9..c31b8d3 100644 --- a/src/Attriboost.h +++ b/src/Attriboost.h @@ -22,7 +22,8 @@ enum AttriboostConstants ATTR_SPELL_AGILITY = 7471, ATTR_SPELL_INTELLECT = 7468, ATTR_SPELL_STRENGTH = 7464, - ATTR_SPELL_SPIRIT = 7474 + ATTR_SPELL_SPIRIT = 7474, + ATTR_SPELL_SPELL_POWER = 9392 }; struct Attriboosts @@ -34,6 +35,7 @@ struct Attriboosts uint32 Agility; uint32 Intellect; uint32 Spirit; + uint32 SpellPower; uint32 Settings; };