mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 05:53:34 +00:00
Merge branch 'DarkflameUniverse:main' into main
This commit is contained in:
commit
84b3386eab
@ -351,6 +351,13 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
|
||||
return;
|
||||
}
|
||||
|
||||
if (team->memberIDs.size() > 3) {
|
||||
// no more teams greater than 4
|
||||
|
||||
Game::logger->Log("ChatPacketHandler", "Someone tried to invite a 5th player to a team");
|
||||
return;
|
||||
}
|
||||
|
||||
SendTeamInvite(other, player);
|
||||
|
||||
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s\n", playerID, invitedPlayer.c_str());
|
||||
|
@ -769,25 +769,32 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
if (team != nullptr && m_Parent->GetComponent<BaseCombatAIComponent>() != nullptr)
|
||||
{
|
||||
LWOOBJID specificOwner = LWOOBJID_EMPTY;
|
||||
auto* scriptedActivityComponent = m_Parent->GetComponent<ScriptedActivityComponent>();
|
||||
uint32_t teamSize = team->members.size();
|
||||
uint32_t lootMatrixId = GetLootMatrixID();
|
||||
|
||||
if (team->lootOption == 0) // Round robin
|
||||
{
|
||||
specificOwner = TeamManager::Instance()->GetNextLootOwner(team);
|
||||
if (scriptedActivityComponent) {
|
||||
lootMatrixId = scriptedActivityComponent->GetLootMatrixForTeamSize(teamSize);
|
||||
}
|
||||
|
||||
for (const auto memberId : team->members)
|
||||
{
|
||||
if (specificOwner != LWOOBJID_EMPTY && memberId != specificOwner) continue;
|
||||
if (team->lootOption == 0) { // Round robin
|
||||
specificOwner = TeamManager::Instance()->GetNextLootOwner(team);
|
||||
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
auto* member = EntityManager::Instance()->GetEntity(specificOwner);
|
||||
|
||||
if (member == nullptr) continue;
|
||||
if (member) LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
}
|
||||
else {
|
||||
for (const auto memberId : team->members) { // Free for all
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
|
||||
LootGenerator::Instance().DropLoot(member, m_Parent, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
||||
if (member == nullptr) continue;
|
||||
|
||||
LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else { // drop loot for non team user
|
||||
LootGenerator::Instance().DropLoot(owner, m_Parent, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "GeneralUtils.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "dConfig.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent)
|
||||
{
|
||||
@ -43,6 +44,31 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent) {
|
||||
// check for LMIs and set the loot LMIs
|
||||
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance()->GetTable<CDActivityRewardsTable>("ActivityRewards");
|
||||
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) {return (entry.LootMatrixIndex == destroyableComponent->GetLootMatrixID()); });
|
||||
|
||||
uint32_t startingLMI = 0;
|
||||
|
||||
if (activityRewards.size() > 0) {
|
||||
startingLMI = activityRewards[0].LootMatrixIndex;
|
||||
}
|
||||
|
||||
if (startingLMI > 0) {
|
||||
// now time for bodge :)
|
||||
|
||||
std::vector<CDActivityRewards> objectTemplateActivities = activityRewardsTable->Query([=](CDActivityRewards entry) {return (activityRewards[0].objectTemplate == entry.objectTemplate); });
|
||||
for (const auto& item : objectTemplateActivities) {
|
||||
if (item.activityRating > 0 && item.activityRating < 5) {
|
||||
m_ActivityLootMatrices.insert({ item.activityRating, item.LootMatrixIndex });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScriptedActivityComponent::~ScriptedActivityComponent()
|
||||
|
@ -328,6 +328,13 @@ public:
|
||||
* @param mapID the map ID to set
|
||||
*/
|
||||
void SetInstanceMapID(uint32_t mapID) { m_ActivityInfo.instanceMapID = mapID; };
|
||||
|
||||
/**
|
||||
* Returns the LMI that this activity points to for a team size
|
||||
* @param teamSize the team size to get the LMI for
|
||||
* @return the LMI that this activity points to for a team size
|
||||
*/
|
||||
uint32_t GetLootMatrixForTeamSize(uint32_t teamSize) { return m_ActivityLootMatrices[teamSize]; }
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -349,6 +356,11 @@ private:
|
||||
* All the activity score for the players in this activity
|
||||
*/
|
||||
std::vector<ActivityPlayer*> m_ActivityPlayers;
|
||||
|
||||
/**
|
||||
* LMIs for team sizes
|
||||
*/
|
||||
std::unordered_map<uint32_t, uint32_t> m_ActivityLootMatrices;
|
||||
};
|
||||
|
||||
#endif // SCRIPTEDACTIVITYCOMPONENT_H
|
||||
|
@ -18,14 +18,24 @@ void MinigameTreasureChestServer::OnUse(Entity *self, Entity *user) {
|
||||
UpdatePlayer(self, user->GetObjectID());
|
||||
|
||||
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
|
||||
uint32_t activityRating = 0;
|
||||
if (team != nullptr) {
|
||||
for (const auto& teamMemberID : team->members) {
|
||||
auto* teamMember = EntityManager::Instance()->GetEntity(teamMemberID);
|
||||
if (teamMember != nullptr)
|
||||
LootGenerator::Instance().DropActivityLoot(teamMember, self, sac->GetActivityID(), CalculateActivityRating(self, teamMemberID));
|
||||
if (teamMember != nullptr) {
|
||||
activityRating = CalculateActivityRating(self, teamMemberID);
|
||||
|
||||
if (self->GetLOT() == frakjawChestId) activityRating = team->members.size();
|
||||
|
||||
LootGenerator::Instance().DropActivityLoot(teamMember, self, sac->GetActivityID(), activityRating);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LootGenerator::Instance().DropActivityLoot(user, self, sac->GetActivityID(), CalculateActivityRating(self, user->GetObjectID()));
|
||||
activityRating = CalculateActivityRating(self, user->GetObjectID());
|
||||
|
||||
if (self->GetLOT() == frakjawChestId) activityRating = 1;
|
||||
|
||||
LootGenerator::Instance().DropActivityLoot(user, self, sac->GetActivityID(), activityRating);
|
||||
}
|
||||
|
||||
sac->PlayerRemove(user->GetObjectID());
|
||||
|
@ -2,7 +2,10 @@
|
||||
#include "ActivityManager.h"
|
||||
|
||||
class MinigameTreasureChestServer : public ActivityManager {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
uint32_t CalculateActivityRating(Entity *self, LWOOBJID playerID) override;
|
||||
private:
|
||||
const uint32_t frakjawChestId = 16486;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user