mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-27 07:57:21 +00:00
Merge remote-tracking branch 'origin/main' into scripting-lua
This commit is contained in:
commit
1ab1c8eaf5
@ -493,7 +493,7 @@ enum eLootSourceType : int32_t {
|
||||
LOOT_SOURCE_CLAIMCODE,
|
||||
LOOT_SOURCE_CONSUMPTION,
|
||||
LOOT_SOURCE_CRAFTING,
|
||||
LOOT_SOURCE_LEVELREWARD,
|
||||
LOOT_SOURCE_LEVEL_REWARD,
|
||||
LOOT_SOURCE_RELOCATE
|
||||
};
|
||||
|
||||
|
@ -534,7 +534,7 @@ void Character::OnZoneLoad()
|
||||
*/
|
||||
if (HasPermission(PermissionMap::Old)) {
|
||||
if (GetCoins() > 1000000) {
|
||||
SetCoins(1000000, LOOT_SOURCE_NONE);
|
||||
SetCoins(1000000, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1637,7 +1637,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
inv->AddItem(p.second.lot, p.second.count, INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, INVALID, 1);
|
||||
inv->AddItem(p.second.lot, p.second.count, eLootSourceType::LOOT_SOURCE_PICKUP, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2173,3 +2173,15 @@ void Entity::AddToGroup(const std::string& group) {
|
||||
m_Groups.push_back(group);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::RetroactiveVaultSize() {
|
||||
auto inventoryComponent = GetComponent<InventoryComponent>();
|
||||
if (!inventoryComponent) return;
|
||||
|
||||
auto itemsVault = inventoryComponent->GetInventory(eInventoryType::VAULT_ITEMS);
|
||||
auto modelVault = inventoryComponent->GetInventory(eInventoryType::VAULT_MODELS);
|
||||
|
||||
if (itemsVault->GetSize() == modelVault->GetSize()) return;
|
||||
|
||||
modelVault->SetSize(itemsVault->GetSize());
|
||||
}
|
||||
|
@ -220,7 +220,11 @@ public:
|
||||
/*
|
||||
* Utility
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retroactively corrects the model vault size due to incorrect initialization in a previous patch.
|
||||
*
|
||||
*/
|
||||
void RetroactiveVaultSize();
|
||||
bool GetBoolean(const std::u16string& name) const;
|
||||
int32_t GetI32(const std::u16string& name) const;
|
||||
int64_t GetI64(const std::u16string& name) const;
|
||||
|
@ -151,8 +151,8 @@ void Trade::Complete()
|
||||
|
||||
if (inventoryA == nullptr || inventoryB == nullptr || characterA == nullptr || characterB == nullptr || missionsA == nullptr || missionsB == nullptr) return;
|
||||
|
||||
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, LOOT_SOURCE_TRADE);
|
||||
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, LOOT_SOURCE_TRADE);
|
||||
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
|
||||
for (const auto& tradeItem : m_ItemsA)
|
||||
{
|
||||
@ -170,12 +170,12 @@ void Trade::Complete()
|
||||
|
||||
for (const auto& tradeItem : m_ItemsA)
|
||||
{
|
||||
inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount);
|
||||
inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
}
|
||||
|
||||
for (const auto& tradeItem : m_ItemsB)
|
||||
{
|
||||
inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount);
|
||||
inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
}
|
||||
|
||||
TradingManager::Instance()->CancelTrade(m_TradeId);
|
||||
|
@ -291,7 +291,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
xml << "ls=\"0\" lzx=\"-626.5847\" lzy=\"613.3515\" lzz=\"-28.6374\" lzrx=\"0.0\" lzry=\"0.7015\" lzrz=\"0.0\" lzrw=\"0.7126\" ";
|
||||
xml << "stt=\"0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;\"></char>";
|
||||
xml << "<dest hm=\"4\" hc=\"4\" im=\"0\" ic=\"0\" am=\"0\" ac=\"0\" d=\"0\"/>";
|
||||
xml << "<inv><bag><b t=\"0\" m=\"20\"/><b t=\"1\" m=\"240\"/><b t=\"2\" m=\"240\"/><b t=\"3\" m=\"240\"/></bag><items><in t=\"0\">";
|
||||
xml << "<inv><bag><b t=\"0\" m=\"20\"/><b t=\"1\" m=\"40\"/><b t=\"2\" m=\"240\"/><b t=\"3\" m=\"240\"/><b t=\"14\" m=\"40\"/></bag><items><in t=\"0\">";
|
||||
std::string xmlSave1 = xml.str();
|
||||
|
||||
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforshirt) {
|
||||
|
@ -217,11 +217,11 @@ void CharacterComponent::HandleLevelUp()
|
||||
switch (reward->rewardType)
|
||||
{
|
||||
case 0:
|
||||
inventoryComponent->AddItem(reward->value, reward->count);
|
||||
inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LOOT_SOURCE_LEVEL_REWARD);
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
auto* items = inventoryComponent->GetInventory(ITEMS);
|
||||
auto* items = inventoryComponent->GetInventory(eInventoryType::ITEMS);
|
||||
items->SetSize(items->GetSize() + reward->value);
|
||||
}
|
||||
break;
|
||||
|
@ -215,6 +215,8 @@ void DestroyableComponent::SetHealth(int32_t value) {
|
||||
|
||||
void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
|
||||
m_DirtyHealth = true;
|
||||
// Used for playAnim if opted in for.
|
||||
int32_t difference = static_cast<int32_t>(std::abs(m_fMaxHealth - value));
|
||||
m_fMaxHealth = value;
|
||||
|
||||
if (m_iHealth > m_fMaxHealth) {
|
||||
@ -225,23 +227,21 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(value));
|
||||
amount->SetStringValue(std::to_string(difference));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("health");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
|
||||
delete amount;
|
||||
delete type;
|
||||
}
|
||||
else {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetArmor(int32_t value) {
|
||||
m_DirtyHealth = true;
|
||||
@ -287,10 +287,9 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
|
||||
delete amount;
|
||||
delete type;
|
||||
}
|
||||
else {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetImagination(int32_t value) {
|
||||
m_DirtyHealth = true;
|
||||
@ -310,6 +309,8 @@ void DestroyableComponent::SetImagination(int32_t value) {
|
||||
|
||||
void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
|
||||
m_DirtyHealth = true;
|
||||
// Used for playAnim if opted in for.
|
||||
int32_t difference = static_cast<int32_t>(std::abs(m_fMaxImagination - value));
|
||||
m_fMaxImagination = value;
|
||||
|
||||
if (m_iImagination > m_fMaxImagination) {
|
||||
@ -320,23 +321,20 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(value));
|
||||
amount->SetStringValue(std::to_string(difference));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("imagination");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
|
||||
delete amount;
|
||||
delete type;
|
||||
}
|
||||
else {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetDamageToAbsorb(int32_t value)
|
||||
{
|
||||
@ -821,7 +819,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
coinsTotal -= coinsToLoose;
|
||||
|
||||
LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose);
|
||||
character->SetCoins(coinsTotal, LOOT_SOURCE_PICKUP);
|
||||
character->SetCoins(coinsTotal, eLootSourceType::LOOT_SOURCE_PICKUP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,10 +84,13 @@ Inventory* InventoryComponent::GetInventory(const eInventoryType type)
|
||||
case eInventoryType::ITEMS:
|
||||
size = 20u;
|
||||
break;
|
||||
case eInventoryType::VAULT_MODELS:
|
||||
case eInventoryType::VAULT_ITEMS:
|
||||
size = 40u;
|
||||
break;
|
||||
|
||||
case eInventoryType::VENDOR_BUYBACK:
|
||||
size = 27u;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -138,6 +141,7 @@ const EquipmentMap& InventoryComponent::GetEquippedItems() const
|
||||
void InventoryComponent::AddItem(
|
||||
const LOT lot,
|
||||
const uint32_t count,
|
||||
eLootSourceType lootSourceType,
|
||||
eInventoryType inventoryType,
|
||||
const std::vector<LDFBaseData*>& config,
|
||||
const LWOOBJID parent,
|
||||
@ -177,7 +181,7 @@ void InventoryComponent::AddItem(
|
||||
|
||||
if (!config.empty() || bound)
|
||||
{
|
||||
const auto slot = inventory->FindEmptySlot();
|
||||
const auto slot = preferredSlot != -1 && inventory->IsSlotEmpty(preferredSlot) ? preferredSlot : inventory->FindEmptySlot();
|
||||
|
||||
if (slot == -1)
|
||||
{
|
||||
@ -185,8 +189,7 @@ void InventoryComponent::AddItem(
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto* item = new Item(lot, inventory, slot, count, config, parent, showFlyingLoot, isModMoveAndEquip, subKey, bound);
|
||||
auto* item = new Item(lot, inventory, slot, count, config, parent, showFlyingLoot, isModMoveAndEquip, subKey, bound, lootSourceType);
|
||||
|
||||
if (missions != nullptr && !IsTransferInventory(inventoryType))
|
||||
{
|
||||
@ -204,7 +207,7 @@ void InventoryComponent::AddItem(
|
||||
|
||||
auto stack = static_cast<uint32_t>(info.stackSize);
|
||||
|
||||
if (inventoryType == BRICKS)
|
||||
if (inventoryType == eInventoryType::BRICKS)
|
||||
{
|
||||
stack = 999;
|
||||
}
|
||||
@ -221,7 +224,7 @@ void InventoryComponent::AddItem(
|
||||
|
||||
left -= delta;
|
||||
|
||||
existing->SetCount(existing->GetCount() + delta, false, true, showFlyingLoot);
|
||||
existing->SetCount(existing->GetCount() + delta, false, true, showFlyingLoot, lootSourceType);
|
||||
|
||||
if (isModMoveAndEquip)
|
||||
{
|
||||
@ -281,8 +284,7 @@ void InventoryComponent::AddItem(
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* item = new Item(lot, inventory, slot, size, {}, parent, showFlyingLoot, isModMoveAndEquip, subKey);
|
||||
auto* item = new Item(lot, inventory, slot, size, {}, parent, showFlyingLoot, isModMoveAndEquip, subKey, false, lootSourceType);
|
||||
|
||||
isModMoveAndEquip = false;
|
||||
}
|
||||
@ -366,7 +368,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
|
||||
|
||||
left -= delta;
|
||||
|
||||
AddItem(lot, delta, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot);
|
||||
AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot);
|
||||
|
||||
item->SetCount(item->GetCount() - delta, false, false);
|
||||
|
||||
@ -384,7 +386,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
|
||||
|
||||
const auto delta = std::min<uint32_t>(item->GetCount(), count);
|
||||
|
||||
AddItem(lot, delta, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot);
|
||||
AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot);
|
||||
|
||||
item->SetCount(item->GetCount() - delta, false, false);
|
||||
}
|
||||
|
@ -87,10 +87,12 @@ public:
|
||||
* @param sourceType the source of the item, used to determine if the item is dropped or mailed if the inventory is full
|
||||
* @param bound whether this item is bound
|
||||
* @param preferredSlot the preferred slot to store this item
|
||||
* @param lootSourceType The source of the loot. Defaults to none.
|
||||
*/
|
||||
void AddItem(
|
||||
LOT lot,
|
||||
uint32_t count,
|
||||
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE,
|
||||
eInventoryType inventoryType = INVALID,
|
||||
const std::vector<LDFBaseData*>& config = {},
|
||||
LWOOBJID parent = LWOOBJID_EMPTY,
|
||||
|
@ -615,7 +615,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
|
||||
|
||||
GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress());
|
||||
|
||||
inventoryComponent->AddItem(m_Parent->GetLOT(), 1, MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||
inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||
auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
|
||||
|
||||
if (item == nullptr)
|
||||
|
@ -491,7 +491,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
settings.push_back(propertyObjectID);
|
||||
settings.push_back(modelType);
|
||||
|
||||
inventoryComponent->AddItem(6662, 1, HIDDEN, settings, LWOOBJID_EMPTY, false, false, spawnerId, INVALID, 13, false, -1);
|
||||
inventoryComponent->AddItem(6662, 1, eLootSourceType::LOOT_SOURCE_DELETION, eInventoryType::HIDDEN, settings, LWOOBJID_EMPTY, false, false, spawnerId);
|
||||
auto* item = inventoryComponent->FindItemBySubKey(spawnerId);
|
||||
|
||||
if (item == nullptr) {
|
||||
@ -526,7 +526,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(model->GetLOT(), 1, INVALID, {}, LWOOBJID_EMPTY, false);
|
||||
inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_DELETION, INVALID, {}, LWOOBJID_EMPTY, false);
|
||||
|
||||
auto* item = inventoryComponent->FindItemByLot(model->GetLOT());
|
||||
|
||||
|
@ -53,6 +53,11 @@ RacingControlComponent::RacingControlComponent(Entity *parent)
|
||||
m_MainWorld = 1200;
|
||||
break;
|
||||
|
||||
case 1261:
|
||||
m_ActivityID = 60;
|
||||
m_MainWorld = 1260;
|
||||
break;
|
||||
|
||||
case 1303:
|
||||
m_ActivityID = 39;
|
||||
m_MainWorld = 1300;
|
||||
@ -410,10 +415,13 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity *player,
|
||||
// If solo racing is enabled OR if there are 3 players in the race, progress placement tasks.
|
||||
if(m_SoloRacing || m_LoadedPlayers > 2) {
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_FINISH_WITH_PLACEMENT); // Finish in 1st place on a race
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks.
|
||||
if(m_Finished != 1) return;
|
||||
if(data->finished == 1) {
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks.
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_WIN_RACE_IN_WORLD); // Finished first place in specific world.
|
||||
|
||||
}
|
||||
if (data->finished == m_LoadedPlayers) {
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_LAST_PLACE_FINISH); // Finished first place in specific world.
|
||||
}
|
||||
}
|
||||
} else if (id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") {
|
||||
auto *vehicle = EntityManager::Instance()->GetEntity(data->vehicleID);
|
||||
|
@ -28,7 +28,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
||||
|
||||
const auto mapID = m_ActivityInfo.instanceMapID;
|
||||
|
||||
if ((mapID == 1203 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") {
|
||||
if ((mapID == 1203 || mapID == 1261 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") {
|
||||
m_ActivityInfo.minTeamSize = 1;
|
||||
m_ActivityInfo.minTeams = 1;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ void GameMessages::SendGMLevelBroadcast(const LWOOBJID& objectID, uint8_t level)
|
||||
SEND_PACKET_BROADCAST
|
||||
}
|
||||
|
||||
void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey) {
|
||||
void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey, eLootSourceType lootSourceType) {
|
||||
CBITSTREAM
|
||||
CMSGHEADER
|
||||
|
||||
@ -421,9 +421,8 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System
|
||||
bitStream.Write(item->GetInfo().isBOE);
|
||||
bitStream.Write(item->GetInfo().isBOP);
|
||||
|
||||
bitStream.Write0(); // Loot source
|
||||
//if (invType != LOOTTYPE_NONE) bitStream.Write(invType);
|
||||
|
||||
bitStream.Write(lootSourceType != eLootSourceType::LOOT_SOURCE_NONE); // Loot source
|
||||
if (lootSourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(lootSourceType);
|
||||
LWONameValue extraInfo;
|
||||
|
||||
auto config = item->GetConfig();
|
||||
@ -451,8 +450,8 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System
|
||||
auto* inventory = item->GetInventory();
|
||||
const auto inventoryType = inventory->GetType();
|
||||
|
||||
bitStream.Write(inventoryType != INVENTORY_DEFAULT);
|
||||
if (inventoryType != INVENTORY_DEFAULT) bitStream.Write(inventoryType);
|
||||
bitStream.Write(inventoryType != eInventoryType::ITEMS);
|
||||
if (inventoryType != eInventoryType::ITEMS) bitStream.Write(inventoryType);
|
||||
|
||||
bitStream.Write(itemCount != 1);
|
||||
if (itemCount != 1) bitStream.Write(itemCount);
|
||||
@ -566,8 +565,8 @@ void GameMessages::SendModifyLEGOScore(Entity* entity, const SystemAddress& sysA
|
||||
bitStream.Write((uint16_t)GAME_MSG_MODIFY_LEGO_SCORE);
|
||||
bitStream.Write(score);
|
||||
|
||||
bitStream.Write(sourceType != LOOT_SOURCE_NONE);
|
||||
if (sourceType != LOOT_SOURCE_NONE) bitStream.Write(sourceType);
|
||||
bitStream.Write(sourceType != eLootSourceType::LOOT_SOURCE_NONE);
|
||||
if (sourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(sourceType);
|
||||
|
||||
SEND_PACKET
|
||||
}
|
||||
@ -4700,7 +4699,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
|
||||
|
||||
inv->RemoveItem(tokenId, altCurrencyCost);
|
||||
|
||||
inv->AddItem(item, count);
|
||||
inv->AddItem(item, count, eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4725,8 +4724,8 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
|
||||
inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost);
|
||||
}
|
||||
|
||||
character->SetCoins(character->GetCoins() - (coinCost), LOOT_SOURCE_VENDOR);
|
||||
inv->AddItem(item, count);
|
||||
character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
inv->AddItem(item, count, eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
}
|
||||
|
||||
GameMessages::SendVendorTransactionResult(entity, sysAddr);
|
||||
@ -4769,12 +4768,12 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
|
||||
if (Inventory::IsValidItem(itemComp.currencyLOT))
|
||||
{
|
||||
const auto altCurrency = (itemComp.altCurrencyCost * sellScalar) * count;
|
||||
inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency)); // Return alt currencies like faction tokens.
|
||||
inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eLootSourceType::LOOT_SOURCE_VENDOR); // Return alt currencies like faction tokens.
|
||||
}
|
||||
|
||||
//inv->RemoveItem(count, -1, iObjID);
|
||||
inv->MoveItemToInventory(item, VENDOR_BUYBACK, count, true, false, true);
|
||||
character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count)), LOOT_SOURCE_VENDOR);
|
||||
inv->MoveItemToInventory(item, eInventoryType::VENDOR_BUYBACK, count, true, false, true);
|
||||
character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count)), eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
|
||||
GameMessages::SendVendorTransactionResult(entity, sysAddr);
|
||||
}
|
||||
@ -4836,7 +4835,7 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
//inv->RemoveItem(count, -1, iObjID);
|
||||
inv->MoveItemToInventory(item, Inventory::FindInventoryTypeForLot(item->GetLot()), count, true, false);
|
||||
character->SetCoins(character->GetCoins() - cost, LOOT_SOURCE_VENDOR);
|
||||
character->SetCoins(character->GetCoins() - cost, eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
|
||||
GameMessages::SendVendorTransactionResult(entity, sysAddr);
|
||||
}
|
||||
@ -5103,7 +5102,7 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E
|
||||
|
||||
item->Disassemble(TEMP_MODELS);
|
||||
|
||||
item->SetCount(item->GetCount() - 1, false, false);
|
||||
item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::LOOT_SOURCE_QUICKBUILD);
|
||||
}
|
||||
|
||||
void GameMessages::HandleSetFlag(RakNet::BitStream* inStream, Entity* entity) {
|
||||
@ -5269,7 +5268,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
if (entity->CanPickupCoins(currency)) {
|
||||
ch->SetCoins(ch->GetCoins() + currency, LOOT_SOURCE_PICKUP);
|
||||
ch->SetCoins(ch->GetCoins() + currency, eLootSourceType::LOOT_SOURCE_PICKUP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5433,6 +5432,8 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
|
||||
return;
|
||||
}
|
||||
|
||||
iStackCount = std::min<uint32_t>(item->GetCount(), iStackCount);
|
||||
|
||||
if (bConfirmed) {
|
||||
for (auto i = 0; i < iStackCount; ++i) {
|
||||
if (eInvType == eInventoryType::MODELS)
|
||||
@ -5482,8 +5483,8 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity
|
||||
}
|
||||
|
||||
void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
int inventoryTypeA;
|
||||
int inventoryTypeB;
|
||||
eInventoryType inventoryTypeA;
|
||||
eInventoryType inventoryTypeB;
|
||||
LWOOBJID objectID;
|
||||
bool showFlyingLoot = true;
|
||||
bool stackCountIsDefault = false;
|
||||
@ -5500,7 +5501,7 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre
|
||||
inStream->Read(templateIDIsDefault);
|
||||
if (templateIDIsDefault) inStream->Read(templateID);
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(COMPONENT_TYPE_INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
auto* item = inv->FindItemById(objectID);
|
||||
@ -5521,7 +5522,7 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre
|
||||
}
|
||||
}
|
||||
|
||||
inv->MoveItemToInventory(item, static_cast<eInventoryType>(inventoryTypeB), stackCount, showFlyingLoot, false);
|
||||
inv->MoveItemToInventory(item, inventoryTypeB, stackCount, showFlyingLoot);
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
}
|
||||
|
||||
@ -5588,11 +5589,11 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
if (count == 3)
|
||||
{
|
||||
inv->AddItem(6416, 1, MODELS, config);
|
||||
inv->AddItem(6416, 1, eLootSourceType::LOOT_SOURCE_QUICKBUILD, eInventoryType::MODELS, config);
|
||||
}
|
||||
else if (count == 7)
|
||||
{
|
||||
inv->AddItem(8092, 1, MODELS, config);
|
||||
inv->AddItem(8092, 1, eLootSourceType::LOOT_SOURCE_QUICKBUILD, eInventoryType::MODELS, config);
|
||||
}
|
||||
|
||||
auto* missionComponent = character->GetComponent<MissionComponent>();
|
||||
@ -5622,7 +5623,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
for (auto* item : items)
|
||||
{
|
||||
inv->MoveItemToInventory(item, MODELS, item->GetCount(), false);
|
||||
inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5737,7 +5738,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
|
||||
|
||||
for (auto* item : items)
|
||||
{
|
||||
inv->MoveItemToInventory(item, MODELS, item->GetCount(), false, false);
|
||||
inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5763,7 +5764,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E
|
||||
return;
|
||||
}
|
||||
|
||||
inv->MoveItemToInventory(item, MODELS, 1, false, true);
|
||||
inv->MoveItemToInventory(item, eInventoryType::MODELS, 1, false, true);
|
||||
}
|
||||
|
||||
void GameMessages::HandlePickupItem(RakNet::BitStream* inStream, Entity* entity) {
|
||||
|
@ -61,7 +61,7 @@ namespace GameMessages {
|
||||
void SendGMLevelBroadcast(const LWOOBJID& objectID, uint8_t level);
|
||||
void SendChatModeUpdate(const LWOOBJID& objectID, uint8_t level);
|
||||
|
||||
void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY);
|
||||
void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void SendNotifyClientFlagChange(const LWOOBJID& objectID, int iFlagID, bool bFlag, const SystemAddress& sysAddr);
|
||||
void SendChangeObjectWorldState(const LWOOBJID& objectID, int state, const SystemAddress& sysAddr);
|
||||
|
||||
|
@ -90,17 +90,17 @@ int32_t Inventory::FindEmptySlot()
|
||||
{
|
||||
if (free <= 6) // Up from 1
|
||||
{
|
||||
if (type != ITEMS && type != VAULT_ITEMS)
|
||||
if (type != ITEMS && type != VAULT_ITEMS && type != eInventoryType::VAULT_MODELS)
|
||||
{
|
||||
uint32_t newSize = size;
|
||||
|
||||
if (type == MODELS || type == VAULT_MODELS)
|
||||
if (type == MODELS)
|
||||
{
|
||||
newSize = 240;
|
||||
}
|
||||
else
|
||||
else if (type == eInventoryType::VENDOR_BUYBACK)
|
||||
{
|
||||
newSize += 20;
|
||||
newSize += 9u;
|
||||
}
|
||||
|
||||
if (newSize > GetSize())
|
||||
|
@ -14,7 +14,7 @@
|
||||
class Inventory;
|
||||
|
||||
|
||||
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey)
|
||||
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType)
|
||||
{
|
||||
if (!Inventory::IsValidItem(lot))
|
||||
{
|
||||
@ -46,7 +46,8 @@ Item::Item(
|
||||
bool showFlyingLoot,
|
||||
bool isModMoveAndEquip,
|
||||
LWOOBJID subKey,
|
||||
bool bound)
|
||||
bool bound,
|
||||
eLootSourceType lootSourceType)
|
||||
{
|
||||
if (!Inventory::IsValidItem(lot))
|
||||
{
|
||||
@ -80,8 +81,7 @@ Item::Item(
|
||||
inventory->AddManagedItem(this);
|
||||
|
||||
auto* entity = inventory->GetComponent()->GetParent();
|
||||
|
||||
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey);
|
||||
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey, lootSourceType);
|
||||
|
||||
if (isModMoveAndEquip)
|
||||
{
|
||||
@ -148,7 +148,7 @@ PreconditionExpression* Item::GetPreconditionExpression() const
|
||||
return preconditions;
|
||||
}
|
||||
|
||||
void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot)
|
||||
void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot, eLootSourceType lootSourceType)
|
||||
{
|
||||
if (value == count)
|
||||
{
|
||||
@ -176,7 +176,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
|
||||
|
||||
if (value > count)
|
||||
{
|
||||
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta);
|
||||
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -340,7 +340,7 @@ bool Item::UseNonEquip()
|
||||
return false;
|
||||
}
|
||||
|
||||
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result);
|
||||
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||
}
|
||||
|
||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||
@ -374,7 +374,7 @@ void Item::Disassemble(const eInventoryType inventoryType)
|
||||
|
||||
for (const auto mod : modArray)
|
||||
{
|
||||
inventory->GetComponent()->AddItem(mod, 1, inventoryType);
|
||||
inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::LOOT_SOURCE_DELETION, inventoryType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,7 +472,7 @@ void Item::DisassembleModel()
|
||||
continue;
|
||||
}
|
||||
|
||||
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1);
|
||||
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::LOOT_SOURCE_DELETION);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,8 @@ public:
|
||||
bool bound,
|
||||
const std::vector<LDFBaseData*>& config,
|
||||
LWOOBJID parent,
|
||||
LWOOBJID subKey
|
||||
LWOOBJID subKey,
|
||||
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE
|
||||
);
|
||||
|
||||
/**
|
||||
@ -62,7 +63,8 @@ public:
|
||||
bool showFlyingLoot = true,
|
||||
bool isModMoveAndEquip = false,
|
||||
LWOOBJID subKey = LWOOBJID_EMPTY,
|
||||
bool bound = false
|
||||
bool bound = false,
|
||||
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE
|
||||
);
|
||||
|
||||
~Item();
|
||||
@ -86,7 +88,7 @@ public:
|
||||
* @param disassemble if items were removed, this returns all the sub parts of the item individually if it had assembly part lots
|
||||
* @param showFlyingLoot shows flying loot to the client, if not silent
|
||||
*/
|
||||
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true);
|
||||
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
|
||||
/**
|
||||
* Returns the number of items this item represents (e.g. for stacks)
|
||||
|
@ -430,7 +430,7 @@ void Mission::YieldRewards() {
|
||||
|
||||
int32_t coinsToSend = 0;
|
||||
if (info->LegoScore > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT;
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
if(characterComponent->GetLevel() >= dZoneManager::Instance()->GetMaxLevel()) {
|
||||
// Since the character is at the level cap we reward them with coins instead of UScore.
|
||||
coinsToSend += info->LegoScore * dZoneManager::Instance()->GetLevelCapCurrencyConversion();
|
||||
@ -463,11 +463,11 @@ void Mission::YieldRewards() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(pair.first, count);
|
||||
inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT);
|
||||
}
|
||||
|
||||
if (info->reward_currency_repeatable > 0 || coinsToSend > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT;
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency_repeatable + coinsToSend, lootSource);
|
||||
}
|
||||
|
||||
@ -496,11 +496,11 @@ void Mission::YieldRewards() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(pair.first, count);
|
||||
inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT);
|
||||
}
|
||||
|
||||
if (info->reward_currency > 0 || coinsToSend > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT;
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency + coinsToSend, lootSource);
|
||||
}
|
||||
|
||||
@ -511,9 +511,11 @@ void Mission::YieldRewards() {
|
||||
}
|
||||
|
||||
if (info->reward_bankinventory > 0) {
|
||||
auto* inventory = inventoryComponent->GetInventory(VAULT_ITEMS);
|
||||
auto* inventory = inventoryComponent->GetInventory(eInventoryType::VAULT_ITEMS);
|
||||
auto modelInventory = inventoryComponent->GetInventory(eInventoryType::VAULT_MODELS);
|
||||
|
||||
inventory->SetSize(inventory->GetSize() + info->reward_bankinventory);
|
||||
modelInventory->SetSize(modelInventory->GetSize() + info->reward_bankinventory);
|
||||
}
|
||||
|
||||
if (info->reward_reputation > 0) {
|
||||
@ -526,11 +528,11 @@ void Mission::YieldRewards() {
|
||||
}
|
||||
|
||||
if (info->reward_maxhealth > 0) {
|
||||
destroyableComponent->SetMaxHealth(destroyableComponent->GetMaxHealth() + static_cast<float>(info->reward_maxhealth));
|
||||
destroyableComponent->SetMaxHealth(destroyableComponent->GetMaxHealth() + static_cast<float>(info->reward_maxhealth), true);
|
||||
}
|
||||
|
||||
if (info->reward_maximagination > 0) {
|
||||
destroyableComponent->SetMaxImagination(destroyableComponent->GetMaxImagination() + static_cast<float>(info->reward_maximagination));
|
||||
destroyableComponent->SetMaxImagination(destroyableComponent->GetMaxImagination() + static_cast<float>(info->reward_maximagination), true);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
|
@ -183,8 +183,14 @@ bool MissionTask::InParameters(const uint32_t value) const
|
||||
|
||||
bool MissionTask::IsComplete() const
|
||||
{
|
||||
// Mission 668 has task uid 984 which is a bit mask. Its completion value is 3.
|
||||
if (info->uid == 984) {
|
||||
return progress >= 3;
|
||||
}
|
||||
else {
|
||||
return progress >= info->targetValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MissionTask::Complete()
|
||||
@ -423,12 +429,23 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
|
||||
|
||||
if (parameters[0] != associate) break;
|
||||
|
||||
if (associate == 1 || associate == 15 || associate == 2 || associate == 3)
|
||||
if (associate == 1 || associate == 2 || associate == 3)
|
||||
{
|
||||
if (value > info->targetValue) break;
|
||||
|
||||
AddProgress(info->targetValue);
|
||||
}
|
||||
// task 15 is a bit mask!
|
||||
else if (associate == 15) {
|
||||
if (!InAllTargets(value)) break;
|
||||
|
||||
auto tempProgress = GetProgress();
|
||||
// If we won at Nimbus Station, set bit 0
|
||||
if (value == 1203) SetProgress(tempProgress |= 1 << 0);
|
||||
// If we won at Gnarled Forest, set bit 1
|
||||
else if (value == 1303) SetProgress(tempProgress |= 1 << 1);
|
||||
// If both bits are set, then the client sees the mission as complete.
|
||||
}
|
||||
else if (associate == 10)
|
||||
{
|
||||
// If the player did not crash during the race, progress this task by count.
|
||||
|
@ -268,15 +268,15 @@ std::unordered_map<LOT, int32_t> LootGenerator::RollLootMatrix(uint32_t matrixIn
|
||||
return drops;
|
||||
}
|
||||
|
||||
void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex) {
|
||||
void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType) {
|
||||
player = player->GetOwner(); // If the owner is overwritten, we collect that here
|
||||
|
||||
std::unordered_map<LOT, int32_t> result = RollLootMatrix(player, matrixIndex);
|
||||
|
||||
GiveLoot(player, result);
|
||||
GiveLoot(player, result, lootSourceType);
|
||||
}
|
||||
|
||||
void LootGenerator::GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result) {
|
||||
void LootGenerator::GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result, eLootSourceType lootSourceType) {
|
||||
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
@ -285,7 +285,7 @@ void LootGenerator::GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& r
|
||||
return;
|
||||
|
||||
for (const auto& pair : result) {
|
||||
inventoryComponent->AddItem(pair.first, pair.second);
|
||||
inventoryComponent->AddItem(pair.first, pair.second, lootSourceType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,13 +314,13 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac
|
||||
maxCoins = currencyTable[0].maxvalue;
|
||||
}
|
||||
|
||||
GiveLoot(player, selectedReward->LootMatrixIndex);
|
||||
GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
|
||||
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
||||
|
||||
auto* character = player->GetCharacter();
|
||||
|
||||
character->SetCoins(character->GetCoins() + coins, LOOT_SOURCE_ACTIVITY);
|
||||
character->SetCoins(character->GetCoins() + coins, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
}
|
||||
|
||||
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
|
||||
|
@ -47,8 +47,8 @@ class LootGenerator : public Singleton<LootGenerator> {
|
||||
|
||||
std::unordered_map<LOT, int32_t> RollLootMatrix(Entity* player, uint32_t matrixIndex);
|
||||
std::unordered_map<LOT, int32_t> RollLootMatrix(uint32_t matrixIndex);
|
||||
void GiveLoot(Entity* player, uint32_t matrixIndex);
|
||||
void GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result);
|
||||
void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating = 0);
|
||||
void DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins);
|
||||
void DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins);
|
||||
|
@ -262,7 +262,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
|
||||
}
|
||||
|
||||
Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success);
|
||||
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, LOOT_SOURCE_MAIL);
|
||||
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::LOOT_SOURCE_MAIL);
|
||||
|
||||
Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i\n", itemID, attachmentCount, itemLOT);
|
||||
|
||||
@ -363,7 +363,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres
|
||||
auto inv = static_cast<InventoryComponent*>(player->GetComponent(COMPONENT_TYPE_INVENTORY));
|
||||
if (!inv) return;
|
||||
|
||||
inv->AddItem(attachmentLOT, attachmentCount);
|
||||
inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::LOOT_SOURCE_MAIL);
|
||||
|
||||
Mail::SendAttachmentRemoveConfirm(sysAddr, mailID);
|
||||
|
||||
|
@ -872,7 +872,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
InventoryComponent * inventory = static_cast<InventoryComponent*>(entity->GetComponent(COMPONENT_TYPE_INVENTORY));
|
||||
|
||||
inventory->AddItem(itemLOT, 1);
|
||||
inventory->AddItem(itemLOT, 1, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
} else if(args.size() == 2) {
|
||||
uint32_t itemLOT;
|
||||
|
||||
@ -892,7 +892,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(COMPONENT_TYPE_INVENTORY));
|
||||
|
||||
inventory->AddItem(itemLOT, count);
|
||||
inventory->AddItem(itemLOT, count, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
}
|
||||
else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem <lot>");
|
||||
@ -1371,7 +1371,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
CharacterComponent* character = entity->GetComponent<CharacterComponent>();
|
||||
if (character) character->SetUScore(character->GetUScore() + uscore);
|
||||
// LOOT_SOURCE_MODERATION should work but it doesn't. Relog to see uscore changes
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, LOOT_SOURCE_MODERATION);
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
}
|
||||
|
||||
if (chatCommand == "pos" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
@ -1415,7 +1415,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
ch->SetCoins(ch->GetCoins() + money, LOOT_SOURCE_MODERATION);
|
||||
ch->SetCoins(ch->GetCoins() + money, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
}
|
||||
|
||||
if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
@ -1428,7 +1428,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
ch->SetCoins(money, LOOT_SOURCE_MODERATION);
|
||||
ch->SetCoins(money, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
}
|
||||
|
||||
// Allow for this on even while not a GM, as it sometimes toggles incorrrectly.
|
||||
@ -1704,7 +1704,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
std::vector<LDFBaseData*> data {};
|
||||
data.push_back(new LDFData<int32_t>(u"reforgedLOT", reforgedItem));
|
||||
|
||||
inventoryComponent->AddItem(baseItem, 1, INVALID, data);
|
||||
inventoryComponent->AddItem(baseItem, 1, eLootSourceType::LOOT_SOURCE_MODERATION, eInventoryType::INVALID, data);
|
||||
}
|
||||
|
||||
if (chatCommand == "crash" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR)
|
||||
@ -2009,54 +2009,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
bool SlashCommandHandler::CheckIfAccessibleZone(const unsigned int zoneID) {
|
||||
switch (zoneID) {
|
||||
case 98:
|
||||
case 1000:
|
||||
case 1001:
|
||||
|
||||
case 1100:
|
||||
case 1101:
|
||||
case 1150:
|
||||
case 1151:
|
||||
case 1152:
|
||||
|
||||
case 1200:
|
||||
case 1201:
|
||||
|
||||
case 1250:
|
||||
case 1251:
|
||||
case 1260:
|
||||
|
||||
case 1300:
|
||||
case 1350:
|
||||
case 1351:
|
||||
|
||||
case 1400:
|
||||
case 1401:
|
||||
case 1450:
|
||||
case 1451:
|
||||
|
||||
case 1600:
|
||||
case 1601:
|
||||
case 1602:
|
||||
case 1603:
|
||||
case 1604:
|
||||
|
||||
case 1700:
|
||||
case 1800:
|
||||
case 1900:
|
||||
case 2000:
|
||||
|
||||
case 58004:
|
||||
case 58005:
|
||||
case 58006:
|
||||
return true;
|
||||
|
||||
default:
|
||||
//We're gonna go ahead and presume we've got the db loaded already:
|
||||
CDZoneTableTable * zoneTable = CDClientManager::Instance()->GetTable<CDZoneTableTable>("ZoneTable");
|
||||
const CDZoneTable* zone = zoneTable->Query(zoneID);
|
||||
if (zone != nullptr) {
|
||||
std::string zonePath = "./res/maps/" + zone->zoneName;
|
||||
std::transform(zonePath.begin(), zonePath.end(), zonePath.begin(), ::tolower);
|
||||
std::ifstream f(zonePath.c_str());
|
||||
return f.good();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SlashCommandHandler::SendAnnouncement(const std::string& title, const std::string& message) {
|
||||
|
@ -7,10 +7,16 @@
|
||||
class AgFans : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self);
|
||||
void OnDie(Entity* self, Entity* killer);
|
||||
void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3);
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnDie(Entity* self, Entity* killer) override;
|
||||
void OnFireEventServerSide(
|
||||
Entity *self,
|
||||
Entity *sender,
|
||||
std::string args,
|
||||
int32_t param1,
|
||||
int32_t param2,
|
||||
int32_t param3
|
||||
) override;
|
||||
private:
|
||||
void ToggleFX(Entity* self, bool hit);
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user)
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(12323, 1);
|
||||
inventoryComponent->AddItem(12323, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
}
|
||||
|
||||
void AmDropshipComputer::OnDie(Entity* self, Entity* killer)
|
||||
|
@ -274,6 +274,10 @@
|
||||
#include "AgSurvivalMech.h"
|
||||
#include "AgSurvivalSpiderling.h"
|
||||
|
||||
// Frostburgh Scripts
|
||||
#include "RockHydrantBroken.h"
|
||||
#include "WhFans.h"
|
||||
|
||||
//Big bad global bc this is a namespace and not a class:
|
||||
InvalidScript* invalidToReturn = new InvalidScript();
|
||||
std::map<std::string, CppScripts::Script*> m_Scripts;
|
||||
@ -795,6 +799,12 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
else if (scriptName == "scripts\\EquipmentScripts\\BuccaneerValiantShip.lua")
|
||||
script = new BuccaneerValiantShip();
|
||||
|
||||
// FB
|
||||
else if (scriptName == "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua")
|
||||
script = new RockHydrantBroken();
|
||||
else if (scriptName == "scripts\\ai\\NS\\L_NS_WH_FANS.lua")
|
||||
script = new WhFans();
|
||||
|
||||
//Ignore these scripts:
|
||||
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
||||
script = invalidToReturn;
|
||||
|
@ -10,8 +10,6 @@ void HydrantBroken::OnStartup(Entity* self)
|
||||
|
||||
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
|
||||
|
||||
Game::logger->Log("HydrantBroken", "Broken Hydrant spawned (%s)\n", hydrant.c_str());
|
||||
|
||||
for (auto* bouncer : bouncers)
|
||||
{
|
||||
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
|
||||
|
@ -9,14 +9,12 @@ void HydrantSmashable::OnDie(Entity* self, Entity* killer)
|
||||
LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
|
||||
|
||||
EntityInfo info {};
|
||||
info.lot = 7328;
|
||||
info.lot = HYDRANT_BROKEN;
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.settings = {data};
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
|
||||
Game::logger->Log("HydrantBroken", "Hydrant spawned (%s)\n", data->GetString().c_str());
|
||||
|
||||
auto* hydrant = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(hydrant);
|
||||
|
@ -5,4 +5,6 @@ class HydrantSmashable : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnDie(Entity* self, Entity* killer) override;
|
||||
private:
|
||||
LOT HYDRANT_BROKEN = 7328;
|
||||
};
|
@ -11,7 +11,7 @@ void NPCAddRemoveItem::OnMissionDialogueOK(Entity *self, Entity *target, int mis
|
||||
for (const auto& itemSetting : missionSetting.second) {
|
||||
for (const auto& lot : itemSetting.items) {
|
||||
if (itemSetting.add && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE)) {
|
||||
inventory->AddItem(lot, 1);
|
||||
inventory->AddItem(lot, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
} else if (itemSetting.remove && (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE)) {
|
||||
inventory->RemoveItem(lot, 1);
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ void NjColeNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID,
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(16644, 1);
|
||||
inventoryComponent->AddItem(16644, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ void NjScrollChestServer::OnUse(Entity *self, Entity *user) {
|
||||
playerInventory->RemoveItem(keyLOT, 1);
|
||||
|
||||
// Reward the player with the item set
|
||||
playerInventory->AddItem(rewardItemLOT, 1);
|
||||
playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss
|
||||
{
|
||||
if (inventoryComponent->GetLotCount(14378) == 0)
|
||||
{
|
||||
inventoryComponent->AddItem(14378, 1);
|
||||
inventoryComponent->AddItem(14378, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
}
|
||||
}
|
||||
else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE)
|
||||
|
@ -9,7 +9,7 @@ void NpcPirateServer::OnMissionDialogueOK(Entity *self, Entity *target, int miss
|
||||
// Add or remove the lucky shovel based on whether the mission was completed or started
|
||||
if ((missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE)
|
||||
&& luckyShovel == nullptr) {
|
||||
inventory->AddItem(14591, 1);
|
||||
inventory->AddItem(14591, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
} else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) {
|
||||
inventory->RemoveItem(14591, 1);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio
|
||||
// For the daily we add the maelstrom vacuum if the player doesn't have it yet
|
||||
if (missionID == 1883 && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE)
|
||||
&& maelstromVacuum == nullptr) {
|
||||
inventory->AddItem(maelstromVacuumLot, 1);
|
||||
inventory->AddItem(maelstromVacuumLot, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
} else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) {
|
||||
inventory->RemoveItem(maelstromVacuumLot, 1);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void NsConcertInstrument::EquipInstruments(Entity *self, Entity *player) {
|
||||
// Equip the left hand instrument
|
||||
const auto leftInstrumentLot = instrumentLotLeft.find(GetInstrumentLot(self))->second;
|
||||
if (leftInstrumentLot != LOT_NULL) {
|
||||
inventory->AddItem(leftInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false);
|
||||
inventory->AddItem(leftInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
auto* leftInstrument = inventory->FindItemByLot(leftInstrumentLot, TEMP_ITEMS);
|
||||
leftInstrument->Equip();
|
||||
}
|
||||
@ -203,7 +203,7 @@ void NsConcertInstrument::EquipInstruments(Entity *self, Entity *player) {
|
||||
// Equip the right hand instrument
|
||||
const auto rightInstrumentLot = instrumentLotRight.find(GetInstrumentLot(self))->second;
|
||||
if (rightInstrumentLot != LOT_NULL) {
|
||||
inventory->AddItem(rightInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false);
|
||||
inventory->AddItem(rightInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
auto* rightInstrument = inventory->FindItemByLot(rightInstrumentLot, TEMP_ITEMS);
|
||||
rightInstrument->Equip();
|
||||
}
|
||||
|
@ -48,23 +48,28 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user)
|
||||
GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, useSound);
|
||||
}
|
||||
|
||||
// Player must be in faction to interact with this entity.
|
||||
LOT tokenLOT = 0;
|
||||
|
||||
if (character->GetPlayerFlag(46))
|
||||
{
|
||||
inventoryComponent->AddItem(8321, 5);
|
||||
tokenLOT = 8321;
|
||||
}
|
||||
else if (character->GetPlayerFlag(47))
|
||||
{
|
||||
inventoryComponent->AddItem(8318, 5);
|
||||
tokenLOT = 8318;
|
||||
}
|
||||
else if (character->GetPlayerFlag(48))
|
||||
{
|
||||
inventoryComponent->AddItem(8320, 5);
|
||||
tokenLOT = 8320;
|
||||
}
|
||||
else if (character->GetPlayerFlag(49))
|
||||
{
|
||||
inventoryComponent->AddItem(8319, 5);
|
||||
tokenLOT = 8319;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(tokenLOT, 5, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
|
||||
missionComponent->ForceProgressTaskType(863, 1, 1, false);
|
||||
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
|
||||
|
@ -29,7 +29,7 @@ void NtDukeServer::OnMissionDialogueOK(Entity *self, Entity *target, int mission
|
||||
auto lotCount = inventoryComponent->GetLotCount(m_SwordLot);
|
||||
|
||||
if ((state == MissionState::MISSION_STATE_AVAILABLE || state == MissionState::MISSION_STATE_ACTIVE) && lotCount < 1) {
|
||||
inventoryComponent->AddItem(m_SwordLot, 1);
|
||||
inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
} else if (state == MissionState::MISSION_STATE_READY_TO_COMPLETE) {
|
||||
inventoryComponent->RemoveItem(m_SwordLot, lotCount);
|
||||
}
|
||||
|
45
dScripts/RockHydrantBroken.cpp
Normal file
45
dScripts/RockHydrantBroken.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "RockHydrantBroken.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
void RockHydrantBroken::OnStartup(Entity* self)
|
||||
{
|
||||
self->AddTimer("playEffect", 1);
|
||||
|
||||
const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
|
||||
|
||||
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
|
||||
|
||||
for (auto* bouncer : bouncers)
|
||||
{
|
||||
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
|
||||
|
||||
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
self->AddTimer("KillBroken", 10);
|
||||
}
|
||||
|
||||
void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName)
|
||||
{
|
||||
if (timerName == "KillBroken")
|
||||
{
|
||||
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
|
||||
|
||||
if (bouncer != nullptr)
|
||||
{
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
self->Kill();
|
||||
}
|
||||
else if (timerName == "playEffect")
|
||||
{
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 4737, u"water", "water", LWOOBJID_EMPTY, 1, 1, true);
|
||||
}
|
||||
}
|
10
dScripts/RockHydrantBroken.h
Normal file
10
dScripts/RockHydrantBroken.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class RockHydrantBroken : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
||||
|
@ -1,24 +1,21 @@
|
||||
#include "RockHydrantSmashable.h"
|
||||
#include "EntityManager.h"
|
||||
#include "SimplePhysicsComponent.h"
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) {
|
||||
SimplePhysicsComponent* physics = self->GetComponent<SimplePhysicsComponent>();
|
||||
NiPoint3 pos = physics->GetPosition();
|
||||
void RockHydrantSmashable::OnDie(Entity* self, Entity* killer)
|
||||
{
|
||||
const auto hydrantName = self->GetVar<std::u16string>(u"hydrant");
|
||||
|
||||
EntityInfo info;
|
||||
info.lot = 12293;
|
||||
info.pos = pos;
|
||||
info.spawner = nullptr;
|
||||
LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
|
||||
|
||||
EntityInfo info {};
|
||||
info.lot = ROCK_HYDRANT_BROKEN;
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.settings = {data};
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
info.spawnerNodeID = 0;
|
||||
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
if (newEntity) {
|
||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||
}
|
||||
auto* hydrant = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(hydrant);
|
||||
}
|
@ -5,5 +5,7 @@ class RockHydrantSmashable : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnDie(Entity* self, Entity* killer);
|
||||
private:
|
||||
LOT ROCK_HYDRANT_BROKEN = 12293;
|
||||
};
|
||||
|
||||
|
@ -574,7 +574,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) {
|
||||
auto* inventory = player->GetComponent<InventoryComponent>();
|
||||
if (inventory != nullptr) {
|
||||
for (const auto rewardLot : self->GetVar<std::vector<LOT>>(RewardsVariable)) {
|
||||
inventory->AddItem(rewardLot, 1, eInventoryType::MODELS);
|
||||
inventory->AddItem(rewardLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,15 +21,17 @@ void TokenConsoleServer::OnUse(Entity* self, Entity* user) {
|
||||
//figure out which faction the player belongs to:
|
||||
auto character = user->GetCharacter();
|
||||
if (!character) return;
|
||||
|
||||
// At this point the player has to be in a faction.
|
||||
LOT tokenLOT = 0;
|
||||
if (character->GetPlayerFlag(ePlayerFlags::VENTURE_FACTION)) //venture
|
||||
inv->AddItem(8321, tokensToGive);
|
||||
tokenLOT = 8321;
|
||||
else if (character->GetPlayerFlag(ePlayerFlags::ASSEMBLY_FACTION)) //assembly
|
||||
inv->AddItem(8318, tokensToGive);
|
||||
tokenLOT = 8318;
|
||||
else if (character->GetPlayerFlag(ePlayerFlags::PARADOX_FACTION)) //paradox
|
||||
inv->AddItem(8320, tokensToGive);
|
||||
tokenLOT = 8320;
|
||||
else if (character->GetPlayerFlag(ePlayerFlags::SENTINEL_FACTION)) //sentinel
|
||||
inv->AddItem(8319, tokensToGive);
|
||||
tokenLOT = 8319;
|
||||
inv->AddItem(tokenLOT, tokensToGive, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
}
|
||||
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
||||
|
@ -10,7 +10,7 @@ void VeBricksampleServer::OnUse(Entity *self, Entity *user) {
|
||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
||||
|
||||
if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) {
|
||||
inventoryComponent->AddItem(loot, 1);
|
||||
inventoryComponent->AddItem(loot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
|
||||
for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) {
|
||||
GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup");
|
||||
|
@ -8,7 +8,7 @@ void VeMissionConsole::OnUse(Entity *self, Entity *user) {
|
||||
|
||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
||||
if (inventoryComponent != nullptr) {
|
||||
inventoryComponent->AddItem(12547, 1); // Add the panel required for pickup
|
||||
inventoryComponent->AddItem(12547, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); // Add the panel required for pickup
|
||||
}
|
||||
|
||||
// The flag to set is 101<number>
|
||||
|
69
dScripts/WhFans.cpp
Normal file
69
dScripts/WhFans.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "WhFans.h"
|
||||
|
||||
#include "RenderComponent.h"
|
||||
|
||||
void WhFans::OnStartup(Entity* self) {
|
||||
self->SetVar<bool>(u"alive", true);
|
||||
self->SetVar<bool>(u"on", false);
|
||||
|
||||
ToggleFX(self, false);
|
||||
}
|
||||
|
||||
void WhFans::ToggleFX(Entity* self, bool hit) {
|
||||
std::string fanGroup;
|
||||
const auto& groups = self->GetGroups();
|
||||
if (!groups.empty()) {
|
||||
fanGroup = groups[0];
|
||||
} else {
|
||||
fanGroup = "";
|
||||
}
|
||||
|
||||
std::vector<Entity*> fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup);
|
||||
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
|
||||
if (renderComponent == nullptr) return;
|
||||
|
||||
if (fanVolumes.size() == 0 || !self->GetVar<bool>(u"alive")) return;
|
||||
|
||||
if (self->GetVar<bool>(u"on")) {
|
||||
GameMessages::SendPlayAnimation(self, u"fan-off");
|
||||
|
||||
renderComponent->StopEffect("fanOn");
|
||||
self->SetVar<bool>(u"on", false);
|
||||
|
||||
for (Entity* volume : fanVolumes) {
|
||||
auto volumePhys = volume->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(false);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
}
|
||||
}
|
||||
else if (!self->GetVar<bool>(u"on") && self->GetVar<bool>(u"alive")) {
|
||||
GameMessages::SendPlayAnimation(self, u"fan-on");
|
||||
|
||||
self->SetVar<bool>(u"on", true);
|
||||
|
||||
for (Entity* volume : fanVolumes) {
|
||||
auto volumePhys = volume->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(true);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WhFans::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) {
|
||||
if (args.length() == 0 || !self->GetVar<bool>(u"alive")) return;
|
||||
|
||||
if ((args == "turnOn" && self->GetVar<bool>(u"on")) || (args == "turnOff" && !self->GetVar<bool>(u"on"))) return;
|
||||
ToggleFX(self, false);
|
||||
}
|
||||
|
||||
void WhFans::OnDie(Entity* self, Entity* killer) {
|
||||
if (self->GetVar<bool>(u"on")) {
|
||||
ToggleFX(self, true);
|
||||
}
|
||||
self->SetVar<bool>(u"alive", false);
|
||||
}
|
23
dScripts/WhFans.h
Normal file
23
dScripts/WhFans.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
#include "GameMessages.h"
|
||||
#include "EntityManager.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
|
||||
class WhFans : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnDie(Entity* self, Entity* killer) override;
|
||||
void OnFireEventServerSide(
|
||||
Entity *self,
|
||||
Entity *sender,
|
||||
std::string args,
|
||||
int32_t param1,
|
||||
int32_t param2,
|
||||
int32_t param3
|
||||
) override;
|
||||
private:
|
||||
void ToggleFX(Entity* self, bool hit);
|
||||
};
|
||||
|
@ -976,6 +976,8 @@ void HandlePacket(Packet* packet) {
|
||||
|
||||
c->SetRetroactiveFlags();
|
||||
|
||||
player->RetroactiveVaultSize();
|
||||
|
||||
player->GetCharacter()->SetTargetScene("");
|
||||
|
||||
// Fix the destroyable component
|
||||
|
@ -1,6 +1,6 @@
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
UPDATE ComponentsRegistry SET component_id = 1901 WHERE id = 12916;
|
||||
UPDATE ComponentsRegistry SET component_id = 1901 WHERE id = 12916 AND component_type = 39;
|
||||
INSERT INTO ActivityRewards (objectTemplate, ActivityRewardIndex, activityRating, LootMatrixIndex, CurrencyIndex, ChallengeRating, description) VALUES (1901, 166, -1, 598, 1, 4, 'NT Foot Race');
|
||||
|
||||
COMMIT;
|
||||
|
3
migrations/cdserver/4_nt_footrace_parrot.sql
Normal file
3
migrations/cdserver/4_nt_footrace_parrot.sql
Normal file
@ -0,0 +1,3 @@
|
||||
UPDATE ComponentsRegistry SET component_id = 12702 WHERE id = 12916 AND component_type = 2;
|
||||
UPDATE ComponentsRegistry SET component_id = 6280 WHERE id = 12916 AND component_type = 3;
|
||||
UPDATE ComponentsRegistry SET component_id = 1791 WHERE id = 12916 AND component_type = 7;
|
Loading…
Reference in New Issue
Block a user