Compare commits

...

10 commits

Author SHA1 Message Date
Revision
f69bff1cfa
Merge pull request #3 from pangolp/upgrade
chore. Compatibility with the latest version of the emulator
2024-09-17 21:51:09 +02:00
Pagani Walter
4f6693337a delete workflows 2024-09-17 16:48:19 -03:00
Pagani Walter
a48672d966 chore. Compatibility with the latest version of the emulator 2024-09-13 23:54:12 -03:00
Revision
8137419b65 Fix messages 2024-09-13 19:59:23 +02:00
Revision
9e7ef44b09 Workflow
I'm going to handle this on my own. I can't put up with GitHub complaining about resources.
2024-06-26 11:08:47 +02:00
Revision
e2151e6a26 Workflow 2024-06-17 21:56:19 +02:00
Revision
81c8de310e README 2024-01-03 21:09:33 +01:00
Revision
55bb137112 Update README.md 2023-02-01 23:04:01 +01:00
Revision
8d6848ba24 Restructure
Restructured the module based on my progression module in anticipation of it being made public.
2023-01-15 19:59:15 +01:00
Revision
206b5a3a3a getLevel -> GetLevel 2023-01-01 00:40:54 +01:00
13 changed files with 257 additions and 171 deletions

0
.github/.gitkeep vendored Normal file
View file

72
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -1,4 +1,5 @@
# Features # Features
This module will deposit a certain percentage of money obtained from quests and money looted into the guild bank. 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. It will **not** take money from the player, it will just add a bonus to the guild bank.

0
conf/.gitkeep Normal file
View file

View file

@ -1 +0,0 @@
#!/usr/bin/env bash

View file

@ -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

View file

@ -1,6 +0,0 @@
void AddGuildFundsScripts();
void Addmod_guildfundsScripts()
{
AddGuildFundsScripts();
}

View file

@ -1,160 +1,8 @@
#include "Chat.h" #include "mod_guildfunds.h"
#include "Config.h"
#include "Guild.h"
#include "Player.h"
#include "ScriptMgr.h"
bool gfShowInfo; GuildFunds::GuildFunds() : LootScript("GuildFundsLootScript"), PlayerScript("GuildFundsPlayerScript"), WorldScript("GuildFundsWorldScript") {}
uint32 gfLootMultiplier;
uint32 gfQuestMultiplier;
class GuildFundsConfig : WorldScript void Addmod_guildfundsScripts()
{ {
public: new GuildFunds();
GuildFundsConfig() : WorldScript("GuildFundsConfig") {}
void OnAfterConfigLoad(bool /*reload*/) override
{
gfShowInfo = sConfigMgr->GetOption<bool>("GuildFunds.ShowInfo", 1);
gfLootMultiplier = sConfigMgr->GetOption<uint32>("GuildFunds.Looted", 10);
gfQuestMultiplier = sConfigMgr->GetOption<uint32>("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();
} }

28
src/mod_guildfunds.h Normal file
View file

@ -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

View file

@ -0,0 +1,10 @@
#include "Config.h"
#include "mod_guildfunds.h"
void GuildFunds::OnAfterConfigLoad(bool /*reload*/)
{
ShowInfo = sConfigMgr->GetOption<bool>("GuildFunds.ShowInfo", 1);
LootMultiplier = sConfigMgr->GetOption<uint32>("GuildFunds.Looted", 10);
QuestMultiplier = sConfigMgr->GetOption<uint32>("GuildFunds.Quests", 3);
}

View file

@ -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);
}
}
}

View file

@ -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("{} copper was deposited to the guild bank.", copper);
else if (money < GOLD)
info = Acore::StringFormat("{} silver, {} copper was deposited to the guild bank.", silver, copper);
else
info = Acore::StringFormat("{} gold, {} silver, {} copper was deposited to the guild bank.", gold, silver, copper);
ChatHandler(player->GetSession()).SendSysMessage(info);
}