mirror of
https://github.com/araxiaonline/mod-sharedrep.git
synced 2026-06-13 03:12:22 -04:00
Initial prototype of shared rep mod
This commit is contained in:
8
conf/mod_sharedrep.conf.dist
Normal file
8
conf/mod_sharedrep.conf.dist
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
[worldserver]
|
||||
|
||||
ModSharedLoot.Enabled = 1
|
||||
|
||||
Appender.SharedRepLog=2,4,0,sharedrep.log,w
|
||||
Appender.SharedRepConsole=1,4,0,"1 9 3 6 5 8"
|
||||
Logger.sharedrep=5,SharedRepLog SharedRepConsole
|
||||
124
src/SharedRepScript.cpp
Normal file
124
src/SharedRepScript.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "Player.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
|
||||
class SharedRepPlayerScript : public PlayerScript
|
||||
{
|
||||
public:
|
||||
SharedRepPlayerScript() : PlayerScript("SharedRepPlayerScript") { }
|
||||
|
||||
|
||||
void OnLogin(Player* player) override
|
||||
{
|
||||
|
||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the ShareRep module.");
|
||||
|
||||
LOG_INFO("sharedrep", "OnLogin");
|
||||
uint32 accountId = player->GetSession()->GetAccountId();
|
||||
ObjectGuid playerGuid = player->GetGUID();
|
||||
std::string hordeInClause = "(2, 5, 6, 8, 10)";
|
||||
std::string allianceInClause = "(1, 3, 4, 7, 11)";
|
||||
|
||||
uint32 faction_aldor = 932;
|
||||
uint32 faction_scryer = 934;
|
||||
uint32 faction_sporeggar = 970;
|
||||
uint32 faction_theashenverdict = 1119;
|
||||
|
||||
std::string factionClause = hordeInClause;
|
||||
|
||||
|
||||
std::string query = R"(
|
||||
SELECT
|
||||
guid
|
||||
, faction
|
||||
, MAX(standing)
|
||||
FROM acore_characters.character_reputation
|
||||
WHERE standing != 0
|
||||
AND GUID IN (
|
||||
SELECT
|
||||
guid
|
||||
FROM characters
|
||||
WHERE
|
||||
account = {}
|
||||
AND guid != {}
|
||||
AND race IN {}
|
||||
)
|
||||
GROUP BY faction;
|
||||
)";
|
||||
|
||||
QueryResult result = CharacterDatabase.Query(
|
||||
query,
|
||||
accountId,
|
||||
playerGuid.GetRawValue(),
|
||||
factionClause
|
||||
);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_DEBUG("sharedrep",
|
||||
"Failed to query reputation for player " + player->GetName()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
float standingAldor = 0;
|
||||
float standingScryer = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* row = result->Fetch();
|
||||
|
||||
uint32 repGuid = row[0].Get<uint32>();
|
||||
uint32 repFaction = row[1].Get<uint32>();
|
||||
float repStanding = row[2].Get<float>();
|
||||
|
||||
if (repGuid == playerGuid.GetRawValue()) continue;
|
||||
|
||||
if (repFaction == faction_aldor)
|
||||
{
|
||||
standingAldor = repStanding;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repFaction == faction_scryer)
|
||||
{
|
||||
standingScryer = repStanding;
|
||||
continue;
|
||||
}
|
||||
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction);
|
||||
|
||||
if (!factionEntry)
|
||||
{
|
||||
LOG_DEBUG("sharedrep", "Faction not found: " + std::to_string(repFaction));
|
||||
continue;
|
||||
}
|
||||
|
||||
float currentStanding = player->GetReputationMgr().GetReputation(factionEntry);
|
||||
if (repStanding <= currentStanding)
|
||||
{
|
||||
LOG_DEBUG("sharedrep",
|
||||
"Standing not higher for faction(" + std::to_string(repFaction) + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
player->GetReputationMgr().SetOneFactionReputation(factionEntry, float(repStanding), false);
|
||||
player->GetReputationMgr().SendState(player->GetReputationMgr().GetState(factionEntry));
|
||||
LOG_DEBUG("sharedrep",
|
||||
"Faction(" + std::to_string(repFaction) + ") reputation set: "
|
||||
+ std::to_string(repStanding)
|
||||
);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
void AddSharedRepScripts()
|
||||
{
|
||||
new SharedRepPlayerScript();
|
||||
};
|
||||
7
src/SharedRep_loader.cpp
Normal file
7
src/SharedRep_loader.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
void AddSharedRepScripts();
|
||||
|
||||
void Addmod_sharedrepScripts()
|
||||
{
|
||||
AddSharedRepScripts();
|
||||
}
|
||||
Reference in New Issue
Block a user