From 206b5a3a3ab182e279c8570e28b864c7f587a222 Mon Sep 17 00:00:00 2001 From: Revision Date: Sun, 1 Jan 2023 00:40:54 +0100 Subject: [PATCH 1/9] getLevel -> GetLevel --- src/mod_guildfunds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod_guildfunds.cpp b/src/mod_guildfunds.cpp index a7cae0e..1c38409 100644 --- a/src/mod_guildfunds.cpp +++ b/src/mod_guildfunds.cpp @@ -115,7 +115,7 @@ public: if (gfQuestMultiplier < 1) return; - uint32 playerLevel = player->getLevel(); + uint32 playerLevel = player->GetLevel(); if (quest->GetRewOrReqMoney(playerLevel) < 1) return; From 8d6848ba2446ed1f4db740e95384ac167a806536 Mon Sep 17 00:00:00 2001 From: Revision Date: Sun, 15 Jan 2023 19:59:15 +0100 Subject: [PATCH 2/9] Restructure Restructured the module based on my progression module in anticipation of it being made public. --- src/loader.cpp | 6 -- src/mod_guildfunds.cpp | 160 +--------------------------------- src/mod_guildfunds.h | 28 ++++++ src/mod_guildfunds_config.cpp | 10 +++ src/mod_guildfunds_loot.cpp | 62 +++++++++++++ src/mod_guildfunds_player.cpp | 47 ++++++++++ 6 files changed, 151 insertions(+), 162 deletions(-) delete mode 100644 src/loader.cpp create mode 100644 src/mod_guildfunds.h create mode 100644 src/mod_guildfunds_config.cpp create mode 100644 src/mod_guildfunds_loot.cpp create mode 100644 src/mod_guildfunds_player.cpp diff --git a/src/loader.cpp b/src/loader.cpp deleted file mode 100644 index 2682ffe..0000000 --- a/src/loader.cpp +++ /dev/null @@ -1,6 +0,0 @@ -void AddGuildFundsScripts(); - -void Addmod_guildfundsScripts() -{ - AddGuildFundsScripts(); -} diff --git a/src/mod_guildfunds.cpp b/src/mod_guildfunds.cpp index 1c38409..f602367 100644 --- a/src/mod_guildfunds.cpp +++ b/src/mod_guildfunds.cpp @@ -1,160 +1,8 @@ -#include "Chat.h" -#include "Config.h" -#include "Guild.h" -#include "Player.h" -#include "ScriptMgr.h" +#include "mod_guildfunds.h" -bool gfShowInfo; -uint32 gfLootMultiplier; -uint32 gfQuestMultiplier; +GuildFunds::GuildFunds() : LootScript("GuildFundsLootScript"), PlayerScript("GuildFundsPlayerScript"), WorldScript("GuildFundsWorldScript") {} -class GuildFundsConfig : WorldScript +void Addmod_guildfundsScripts() { -public: - GuildFundsConfig() : WorldScript("GuildFundsConfig") {} - - void OnAfterConfigLoad(bool /*reload*/) override - { - gfShowInfo = sConfigMgr->GetOption("GuildFunds.ShowInfo", 1); - gfLootMultiplier = sConfigMgr->GetOption("GuildFunds.Looted", 10); - gfQuestMultiplier = sConfigMgr->GetOption("GuildFunds.Quests", 3); - } -}; - -class GuildFundsLoot : LootScript -{ -public: - GuildFundsLoot() : LootScript("GuildFundsLoot") {} - - void OnLootMoney(Player* player, uint32 gold) override - { - if (Group* group = player->GetGroup()) - { - uint32 membersInRange = 0; - for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) - { - if (Player* member = groupRef->GetSource()) - { - if (member->IsAtLootRewardDistance(player)) - membersInRange++; - } - } - - if (gfLootMultiplier < 1) - return; - - uint32 money = (gold / membersInRange) * gfLootMultiplier / 100; - - if (money < 1) - return; - - for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) - { - if (Player* member = groupRef->GetSource()) - { - if (member->IsAtLootRewardDistance(player)) - { - if (Guild* guild = member->GetGuild()) - { - guild->HandleMemberDepositMoney(member->GetSession(), money); - member->ModifyMoney(money); - - if (gfShowInfo) - PrintGuildFundsInformation(member, money); - } - } - } - } - } - else - { - if (Guild* guild = player->GetGuild()) - { - uint32 money = gold * gfLootMultiplier / 100; - - if (money < 1 || gfLootMultiplier < 1) - return; - - guild->HandleMemberDepositMoney(player->GetSession(), money); - player->ModifyMoney(money); - - if (gfShowInfo) - PrintGuildFundsInformation(player, money); - } - } - } - -private: - void PrintGuildFundsInformation(Player* player, uint32 money) - { - uint32 gold = money / GOLD; - uint32 silver = (money % GOLD) / SILVER; - uint32 copper = (money % GOLD) % SILVER; - std::string info; - - if (money < SILVER) - info = Acore::StringFormat("%i copper was deposited to the guild bank.", copper); - else if (money < GOLD) - info = Acore::StringFormat("%i silver, %i copper was deposited to the guild bank.", silver, copper); - else - info = Acore::StringFormat("%i gold, %i silver, %i copper was deposited to the guild bank.", gold, silver, copper); - - ChatHandler(player->GetSession()).SendSysMessage(info); - } -}; - -class GuildFundsQuest : public PlayerScript -{ -public: - GuildFundsQuest() : PlayerScript("GuildFundsQuest") {} - - void OnPlayerCompleteQuest(Player* player, Quest const* quest) override - { - if (Guild* guild = player->GetGuild()) - { - if (gfQuestMultiplier < 1) - return; - - uint32 playerLevel = player->GetLevel(); - - if (quest->GetRewOrReqMoney(playerLevel) < 1) - return; - - uint32 money = quest->GetRewOrReqMoney(playerLevel) * gfQuestMultiplier / 100; - - if (money < 1) - return; - - guild->HandleMemberDepositMoney(player->GetSession(), money); - player->ModifyMoney(money); - - if (gfShowInfo) - PrintGuildFundsInformation(player, money); - } - } - -private: - void PrintGuildFundsInformation(Player* player, uint32 money) - { - uint32 gold = money / GOLD; - uint32 silver = (money % GOLD) / SILVER; - uint32 copper = (money % GOLD) % SILVER; - std::string info; - - if (money < SILVER) - info = Acore::StringFormat("%i copper was deposited to the guild bank.", copper); - else if (money < GOLD) - info = Acore::StringFormat("%i silver, %i copper was deposited to the guild bank.", silver, copper); - else - info = Acore::StringFormat("%i gold, %i silver, %i copper was deposited to the guild bank.", gold, silver, copper); - - ChatHandler(player->GetSession()).SendSysMessage(info); - } -}; - -void AddGuildFundsScripts() -{ - new GuildFundsConfig(); - new GuildFundsLoot(); - new GuildFundsQuest(); + new GuildFunds(); } diff --git a/src/mod_guildfunds.h b/src/mod_guildfunds.h new file mode 100644 index 0000000..6f9e72b --- /dev/null +++ b/src/mod_guildfunds.h @@ -0,0 +1,28 @@ +#ifndef MOD_GUILDFUNDS +#define MOD_GUILDFUNDS + +#include "ScriptMgr.h" + +class GuildFunds : public LootScript, PlayerScript, WorldScript +{ +public: + GuildFunds(); + + // LootScript + void OnLootMoney(Player* /*player*/, uint32 /*gold*/) override; + + // PlayerScript + void OnPlayerCompleteQuest(Player* /*player*/, Quest const* /*quest*/) override; + + // WorldScript + void OnAfterConfigLoad(bool /*reload*/) override; + +private: + bool ShowInfo; + uint32 LootMultiplier; + uint32 QuestMultiplier; + + void SendFundsInformation(Player* /*player*/, uint32 /*money*/); +}; + +#endif diff --git a/src/mod_guildfunds_config.cpp b/src/mod_guildfunds_config.cpp new file mode 100644 index 0000000..ce14332 --- /dev/null +++ b/src/mod_guildfunds_config.cpp @@ -0,0 +1,10 @@ +#include "Config.h" + +#include "mod_guildfunds.h" + +void GuildFunds::OnAfterConfigLoad(bool /*reload*/) +{ + ShowInfo = sConfigMgr->GetOption("GuildFunds.ShowInfo", 1); + LootMultiplier = sConfigMgr->GetOption("GuildFunds.Looted", 10); + QuestMultiplier = sConfigMgr->GetOption("GuildFunds.Quests", 3); +} diff --git a/src/mod_guildfunds_loot.cpp b/src/mod_guildfunds_loot.cpp new file mode 100644 index 0000000..c674e48 --- /dev/null +++ b/src/mod_guildfunds_loot.cpp @@ -0,0 +1,62 @@ +#include "Guild.h" +#include "Player.h" + +#include "mod_guildfunds.h" + +void GuildFunds::OnLootMoney(Player* player, uint32 gold) +{ + if (Group* group = player->GetGroup()) + { + uint32 membersInRange = 0; + for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) + { + if (Player* member = groupRef->GetSource()) + { + if (member->IsAtLootRewardDistance(player)) + membersInRange++; + } + } + + if (LootMultiplier < 1) + return; + + uint32 money = (gold / membersInRange) * LootMultiplier / 100; + + if (money < 1) + return; + + for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) + { + if (Player* member = groupRef->GetSource()) + { + if (member->IsAtLootRewardDistance(player)) + { + if (Guild* guild = member->GetGuild()) + { + guild->HandleMemberDepositMoney(member->GetSession(), money); + member->ModifyMoney(money); + + if (ShowInfo) + SendFundsInformation(member, money); + } + } + } + } + } + else + { + if (Guild* guild = player->GetGuild()) + { + uint32 money = gold * LootMultiplier / 100; + + if (money < 1 || LootMultiplier < 1) + return; + + guild->HandleMemberDepositMoney(player->GetSession(), money); + player->ModifyMoney(money); + + if (ShowInfo) + SendFundsInformation(player, money); + } + } +} diff --git a/src/mod_guildfunds_player.cpp b/src/mod_guildfunds_player.cpp new file mode 100644 index 0000000..0931ec3 --- /dev/null +++ b/src/mod_guildfunds_player.cpp @@ -0,0 +1,47 @@ +#include "Chat.h" +#include "Guild.h" +#include "Player.h" + +#include "mod_guildfunds.h" + +void GuildFunds::OnPlayerCompleteQuest(Player* player, Quest const* quest) +{ + if (Guild* guild = player->GetGuild()) + { + if (QuestMultiplier < 1) + return; + + uint32 playerLevel = player->GetLevel(); + + if (quest->GetRewOrReqMoney(playerLevel) < 1) + return; + + uint32 money = quest->GetRewOrReqMoney(playerLevel) * QuestMultiplier / 100; + + if (money < 1) + return; + + guild->HandleMemberDepositMoney(player->GetSession(), money); + player->ModifyMoney(money); + + if (ShowInfo) + SendFundsInformation(player, money); + } +} + +void GuildFunds::SendFundsInformation(Player* player, uint32 money) +{ + uint32 gold = money / GOLD; + uint32 silver = (money % GOLD) / SILVER; + uint32 copper = (money % GOLD) % SILVER; + std::string info; + + if (money < SILVER) + info = Acore::StringFormat("%i copper was deposited to the guild bank.", copper); + else if (money < GOLD) + info = Acore::StringFormat("%i silver, %i copper was deposited to the guild bank.", silver, copper); + else + info = Acore::StringFormat("%i gold, %i silver, %i copper was deposited to the guild bank.", gold, silver, copper); + + ChatHandler(player->GetSession()).SendSysMessage(info); +} From 55bb1371125c79a15edf1f0ca9db1527244d487d Mon Sep 17 00:00:00 2001 From: Revision Date: Wed, 1 Feb 2023 23:04:01 +0100 Subject: [PATCH 3/9] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a5c55ae..ca6e5d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +# Buy Me A Coffee +Want to show me some appreciation? Why not [buy me a coffee](https://www.buymeacoffee.com/noisiver)? + # Features This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank. From 81c8de310e8180d13bb3194de2f1ddb18db742b5 Mon Sep 17 00:00:00 2001 From: Revision Date: Wed, 3 Jan 2024 21:09:33 +0100 Subject: [PATCH 4/9] README --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index ca6e5d1..a5c55ae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -# Buy Me A Coffee -Want to show me some appreciation? Why not [buy me a coffee](https://www.buymeacoffee.com/noisiver)? - # Features This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank. From e2151e6a26e76d2d27b158788df0556809193a3b Mon Sep 17 00:00:00 2001 From: Revision Date: Mon, 17 Jun 2024 21:56:19 +0200 Subject: [PATCH 5/9] Workflow --- .github/workflows/core-build.yml | 13 +++++++++++++ README.md | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 .github/workflows/core-build.yml diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml new file mode 100644 index 0000000..c6227a5 --- /dev/null +++ b/.github/workflows/core-build.yml @@ -0,0 +1,13 @@ +name: core-build +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + build: + uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main + with: + module_repo: ${{ github.event.repository.name }} diff --git a/README.md b/README.md index a5c55ae..a5be59a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![core-build](https://github.com/noisiver/mod-guildfunds/actions/workflows/core-build.yml/badge.svg)](https://github.com/noisiver/mod-guildfunds/actions/workflows/core-build.yml) + # Features This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank. From 9e7ef44b091c057050825a927943533b0370b4f9 Mon Sep 17 00:00:00 2001 From: Revision Date: Wed, 26 Jun 2024 11:08:47 +0200 Subject: [PATCH 6/9] Workflow I'm going to handle this on my own. I can't put up with GitHub complaining about resources. --- .github/workflows/core-build.yml | 13 ------------- README.md | 2 -- 2 files changed, 15 deletions(-) delete mode 100644 .github/workflows/core-build.yml diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml deleted file mode 100644 index c6227a5..0000000 --- a/.github/workflows/core-build.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: core-build -on: - push: - pull_request: - workflow_dispatch: - schedule: - - cron: "0 0 * * *" - -jobs: - build: - uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main - with: - module_repo: ${{ github.event.repository.name }} diff --git a/README.md b/README.md index a5be59a..a5c55ae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![core-build](https://github.com/noisiver/mod-guildfunds/actions/workflows/core-build.yml/badge.svg)](https://github.com/noisiver/mod-guildfunds/actions/workflows/core-build.yml) - # Features This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank. From 8137419b657360d2822fc8ac64367bac5efa353b Mon Sep 17 00:00:00 2001 From: Revision Date: Fri, 13 Sep 2024 19:59:23 +0200 Subject: [PATCH 7/9] Fix messages --- src/mod_guildfunds_player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod_guildfunds_player.cpp b/src/mod_guildfunds_player.cpp index 0931ec3..22e9463 100644 --- a/src/mod_guildfunds_player.cpp +++ b/src/mod_guildfunds_player.cpp @@ -37,11 +37,11 @@ void GuildFunds::SendFundsInformation(Player* player, uint32 money) std::string info; if (money < SILVER) - info = Acore::StringFormat("%i copper was deposited to the guild bank.", copper); + info = Acore::StringFormat("{} copper was deposited to the guild bank.", copper); else if (money < GOLD) - info = Acore::StringFormat("%i silver, %i copper was deposited to the guild bank.", silver, copper); + info = Acore::StringFormat("{} silver, {} copper was deposited to the guild bank.", silver, copper); else - info = Acore::StringFormat("%i gold, %i silver, %i copper was deposited to the guild bank.", gold, silver, copper); + info = Acore::StringFormat("{} gold, {} silver, {} copper was deposited to the guild bank.", gold, silver, copper); ChatHandler(player->GetSession()).SendSysMessage(info); } From a48672d966d13f3a2ac7a8a2598c641722099d99 Mon Sep 17 00:00:00 2001 From: Pagani Walter Date: Fri, 13 Sep 2024 23:54:12 -0300 Subject: [PATCH 8/9] chore. Compatibility with the latest version of the emulator --- .github/ISSUE_TEMPLATE/bug_report.yml | 72 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 33 ++++++++++ .github/workflows/core-build.yml | 12 ++++ README.md | 1 + conf/.gitkeep | 0 conf/conf.sh.dist | 1 - include.sh | 8 --- 7 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/workflows/core-build.yml create mode 100644 conf/.gitkeep delete mode 100644 conf/conf.sh.dist diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..5610d2b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,72 @@ +name: Bug report +description: Create a bug report to help us improve. +title: "Bug: " +body: + - type: textarea + id: current + attributes: + label: Current Behaviour + description: | + Description of the problem or issue here. + Include entries of affected creatures / items / quests / spells etc. + If this is a crash, post the crashlog (upload to https://gist.github.com/) and include the link here. + Never upload files! Use GIST for text and YouTube for videos! + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behaviour + description: | + Tell us what should happen instead. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: Steps to reproduce the problem + description: | + What does someone else need to do to encounter the same bug? + placeholder: | + 1. Step 1 + 2. Step 2 + 3. Step 3 + validations: + required: true + - type: textarea + id: extra + attributes: + label: Extra Notes + description: | + Do you have any extra notes that can help solve the issue that does not fit any other field? + placeholder: | + None + validations: + required: false + - type: textarea + id: commit + attributes: + label: AC rev. hash/commit + description: | + Copy the result of the `.server debug` command (if you need to run it from the client get a prat addon) + validations: + required: true + - type: input + id: os + attributes: + label: Operating system + description: | + The Operating System the Server is running on. + i.e. Windows 11 x64, Debian 10 x64, macOS 12, Ubuntu 20.04 + validations: + required: true + - type: textarea + id: custom + attributes: + label: Custom changes or Modules + description: | + List which custom changes or modules you have applied, i.e. Eluna module, etc. + placeholder: | + None + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..58f79dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,33 @@ +name: Feature request +description: Suggest an idea for this project +title: "Feature: " +body: + - type: markdown + attributes: + value: | + Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above. + An issue that is not properly filled out will be closed. + - type: textarea + id: description + attributes: + label: Describe your feature request or suggestion in detail + description: | + A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe a possible solution to your feature or suggestion in detail + description: | + A clear and concise description of any alternative solutions or features you've considered. + validations: + required: false + - type: textarea + id: additional + attributes: + label: Additional context + description: | + Add any other context or screenshots about the feature request here. + validations: + required: false diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml new file mode 100644 index 0000000..921c9eb --- /dev/null +++ b/.github/workflows/core-build.yml @@ -0,0 +1,12 @@ +name: core-build +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build: + uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main + with: + module_repo: ${{ github.event.repository.name }} diff --git a/README.md b/README.md index a5c55ae..44e46bb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Features + This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank. It will **not** take money from the player, it will just add a bonus to the guild bank. diff --git a/conf/.gitkeep b/conf/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist deleted file mode 100644 index f1f641a..0000000 --- a/conf/conf.sh.dist +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/env bash diff --git a/include.sh b/include.sh index 1c4cfbd..e69de29 100644 --- a/include.sh +++ b/include.sh @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -MOD_GUILDFUNDS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )" - -source $MOD_GUILDFUNDS_ROOT"/conf/conf.sh.dist" - -if [ -f $MOD_GUILDFUNDS_ROOT"/conf/conf.sh" ]; then - source $MOD_GUILDFUNDS_ROOT"/conf/conf.sh" -fi From 4f6693337ad26b521c4d6dd4b4e1ecbb2cee97ac Mon Sep 17 00:00:00 2001 From: Pagani Walter Date: Tue, 17 Sep 2024 16:48:19 -0300 Subject: [PATCH 9/9] delete workflows --- .github/.gitkeep | 0 .github/workflows/core-build.yml | 12 ------------ 2 files changed, 12 deletions(-) create mode 100644 .github/.gitkeep delete mode 100644 .github/workflows/core-build.yml diff --git a/.github/.gitkeep b/.github/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml deleted file mode 100644 index 921c9eb..0000000 --- a/.github/workflows/core-build.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: core-build -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build: - uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main - with: - module_repo: ${{ github.event.repository.name }}