DarkflameServer/dScripts/VeMissionConsole.cpp
EmosewaMC 7a051afd97 loot source for item drops
Added support for Items to have a loot source attached to them when dropped or rolled.  This fixes the issue where achievements would give the item before it appeared in the achievement window.
2022-04-23 20:35:34 -07:00

26 lines
982 B
C++

#include "VeMissionConsole.h"
#include "InventoryComponent.h"
#include "Character.h"
#include "GameMessages.h"
void VeMissionConsole::OnUse(Entity *self, Entity *user) {
LootGenerator::Instance().DropActivityLoot(user, self, 12551);
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr) {
inventoryComponent->AddItem(12547, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); // Add the panel required for pickup
}
// The flag to set is 101<number>
const auto flagNumber = self->GetVar<std::u16string>(m_NumberVariable);
const auto flag = std::stoi("101" + GeneralUtils::UTF16ToWTF8(flagNumber));
auto* character = user->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(flag, true);
}
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"");
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
}