Initial build
This commit is contained in:
parent
ff0c5acd2a
commit
f8e7eabde4
8 changed files with 151 additions and 1 deletions
5
.github/README.md
vendored
Normal file
5
.github/README.md
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Guild Funds
|
||||||
|
[](https://github.com/tkn963/mod-guildfunds/actions?query=workflow%3Acore-build+branch%3Amaster+event%3Apush)
|
||||||
|
|
||||||
|
# Features
|
||||||
|
This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank.
|
||||||
12
.github/workflows/core-build.yml
vendored
Normal file
12
.github/workflows/core-build.yml
vendored
Normal file
|
|
@ -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 }}
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
# mod-guildfunds
|
# Features
|
||||||
|
This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank.
|
||||||
|
|
|
||||||
1
conf/conf.sh.dist
Normal file
1
conf/conf.sh.dist
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
13
conf/mod_guildfunds.conf.dist
Normal file
13
conf/mod_guildfunds.conf.dist
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[worldserver]
|
||||||
|
|
||||||
|
##
|
||||||
|
# The amount, in percentage, of money looted to add to the guild bank
|
||||||
|
# Set to 0 to disable
|
||||||
|
GuildFunds.Looted = 10
|
||||||
|
##
|
||||||
|
|
||||||
|
##
|
||||||
|
# The amount, in percentage, of money gained from quests to add to the guild bank
|
||||||
|
# Set to 0 to disable
|
||||||
|
GuildFunds.Quests = 3
|
||||||
|
##
|
||||||
8
include.sh
Normal file
8
include.sh
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/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
|
||||||
6
src/loader.cpp
Normal file
6
src/loader.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
void AddGuildFundsScripts();
|
||||||
|
|
||||||
|
void Addmod_guildfundsScripts()
|
||||||
|
{
|
||||||
|
AddGuildFundsScripts();
|
||||||
|
}
|
||||||
104
src/mod_guildfunds.cpp
Normal file
104
src/mod_guildfunds.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
#include "Chat.h"
|
||||||
|
#include "Config.h"
|
||||||
|
#include "Guild.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "ScriptMgr.h"
|
||||||
|
|
||||||
|
uint32 lootFunds;
|
||||||
|
uint32 questFunds;
|
||||||
|
|
||||||
|
class GuildFundsConfig : WorldScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuildFundsConfig() : WorldScript("GuildFundsConfig") {}
|
||||||
|
|
||||||
|
void OnAfterConfigLoad(bool /*reload*/) override
|
||||||
|
{
|
||||||
|
lootFunds = sConfigMgr->GetOption<uint32>("GuildFunds.Looted", 10);
|
||||||
|
questFunds = sConfigMgr->GetOption<uint32>("GuildFunds.Quests", 3);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuildFundsLoot : LootScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuildFundsLoot() : LootScript("GuildFundsLoot") {}
|
||||||
|
|
||||||
|
void OnLootMoney(Player* player, uint32 gold) override
|
||||||
|
{
|
||||||
|
if (Guild* guild = player->GetGuild())
|
||||||
|
{
|
||||||
|
uint32 money = ((gold / 100) * questFunds);
|
||||||
|
|
||||||
|
if (money < 0 || lootFunds < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
uint32 playerLevel = player->getLevel();
|
||||||
|
uint32 money = ((quest->GetRewOrReqMoney(playerLevel) / 100) * questFunds);
|
||||||
|
|
||||||
|
if (money < 0 || questFunds < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
||||||
|
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();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue