mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-11-30 13:18:17 +00:00
Merge remote-tracking branch 'origin/main' into scripting-lua
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "Component.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "BuffComponent.h"
|
||||
@@ -456,9 +457,10 @@ void Entity::Initialize()
|
||||
else comp = new InventoryComponent(this);
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_INVENTORY, comp));
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ROCKET_LAUNCH_LUP) > 0) {
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_ROCKET_LAUNCH_LUP, nullptr));
|
||||
// if this component exists, then we initialize it. it's value is always 0
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ROCKET_LAUNCH_LUP, -1) != -1) {
|
||||
auto comp = new RocketLaunchLupComponent(this);
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_ROCKET_LAUNCH_LUP, comp));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,13 +497,6 @@ void Entity::Initialize()
|
||||
std::string customScriptServer;
|
||||
bool hasCustomServerScript = false;
|
||||
|
||||
// Custom script for the LUP teleporter
|
||||
if (m_TemplateID == 14333)
|
||||
{
|
||||
hasCustomServerScript = true;
|
||||
customScriptServer = "scripts\\02_server\\DLU\\L_SB_LUP_TELEPORT.lua";
|
||||
}
|
||||
|
||||
const auto customScriptServerName = GetVarAsString(u"custom_script_server");
|
||||
const auto customScriptClientName = GetVarAsString(u"custom_script_client");
|
||||
|
||||
|
||||
@@ -24,12 +24,13 @@ EntityManager* EntityManager::m_Address = nullptr;
|
||||
std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {
|
||||
// Small zones
|
||||
1000,
|
||||
|
||||
|
||||
// Racing zones
|
||||
1203,
|
||||
1261,
|
||||
1303,
|
||||
1403,
|
||||
|
||||
|
||||
// Property zones
|
||||
1150,
|
||||
1151,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "PossessorComponent.h"
|
||||
#include "VehiclePhysicsComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Item.h"
|
||||
|
||||
CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) {
|
||||
m_Character = character;
|
||||
@@ -448,6 +449,56 @@ void CharacterComponent::SetLastRocketConfig(std::u16string config) {
|
||||
m_LastRocketConfig = config;
|
||||
}
|
||||
|
||||
Item* CharacterComponent::GetRocket(Entity* player) {
|
||||
Item* rocket = nullptr;
|
||||
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
|
||||
if (!inventoryComponent) return rocket;
|
||||
|
||||
// Select the rocket
|
||||
if (!rocket){
|
||||
rocket = inventoryComponent->FindItemById(GetLastRocketItemID());
|
||||
}
|
||||
|
||||
if (!rocket) {
|
||||
rocket = inventoryComponent->FindItemByLot(6416);
|
||||
}
|
||||
|
||||
if (!rocket) {
|
||||
Game::logger->Log("CharacterComponent", "Unable to find rocket to equip!\n");
|
||||
return rocket;
|
||||
}
|
||||
return rocket;
|
||||
}
|
||||
|
||||
Item* CharacterComponent::RocketEquip(Entity* player) {
|
||||
Item* rocket = GetRocket(player);
|
||||
if (!rocket) return rocket;
|
||||
|
||||
// build and define the rocket config
|
||||
for (LDFBaseData* data : rocket->GetConfig()) {
|
||||
if (data->GetKey() == u"assemblyPartLOTs") {
|
||||
std::string newRocketStr = data->GetValueAsString() + ";";
|
||||
GeneralUtils::ReplaceInString(newRocketStr, "+", ";");
|
||||
SetLastRocketConfig(GeneralUtils::ASCIIToUTF16(newRocketStr));
|
||||
}
|
||||
}
|
||||
|
||||
// Store the last used rocket item's ID
|
||||
SetLastRocketItemID(rocket->GetId());
|
||||
// carry the rocket
|
||||
rocket->Equip(true);
|
||||
return rocket;
|
||||
}
|
||||
|
||||
void CharacterComponent::RocketUnEquip(Entity* player) {
|
||||
Item* rocket = GetRocket(player);
|
||||
if (!rocket) return;
|
||||
// We don't want to carry it anymore
|
||||
rocket->UnEquip();
|
||||
}
|
||||
|
||||
void CharacterComponent::TrackMissionCompletion(bool isAchievement) {
|
||||
UpdatePlayerStatistic(MissionsCompleted);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "RakNetTypes.h"
|
||||
#include "Character.h"
|
||||
#include "Component.h"
|
||||
#include "Item.h"
|
||||
#include <string>
|
||||
#include "CDMissionsTable.h"
|
||||
#include "tinyxml2.h"
|
||||
@@ -74,6 +75,26 @@ public:
|
||||
*/
|
||||
void SetLastRocketConfig(std::u16string config);
|
||||
|
||||
/**
|
||||
* Find a player's rocket
|
||||
* @param player the entity that triggered the event
|
||||
* @return rocket
|
||||
*/
|
||||
Item* GetRocket(Entity* player);
|
||||
|
||||
/**
|
||||
* Equip a player's rocket
|
||||
* @param player the entity that triggered the event
|
||||
* @return rocket
|
||||
*/
|
||||
Item* RocketEquip(Entity* player);
|
||||
|
||||
/**
|
||||
* Find a player's rocket and unequip it
|
||||
* @param player the entity that triggered the event
|
||||
*/
|
||||
void RocketUnEquip(Entity* player);
|
||||
|
||||
/**
|
||||
* Gets the current level of the entity
|
||||
* @return the current level of the entity
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -794,10 +794,29 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b
|
||||
|
||||
outBitStream->Write(item.slot != 0);
|
||||
if (item.slot != 0) outBitStream->Write<uint16_t>(item.slot);
|
||||
|
||||
|
||||
outBitStream->Write0();
|
||||
|
||||
outBitStream->Write0(); //TODO: This is supposed to be true and write the assemblyPartLOTs when they're present.
|
||||
|
||||
bool flag = !item.config.empty();
|
||||
outBitStream->Write(flag);
|
||||
if (flag) {
|
||||
RakNet::BitStream ldfStream;
|
||||
ldfStream.Write<int32_t>(item.config.size()); // Key count
|
||||
for (LDFBaseData* data : item.config) {
|
||||
if (data->GetKey() == u"assemblyPartLOTs") {
|
||||
std::string newRocketStr = data->GetValueAsString() + ";";
|
||||
GeneralUtils::ReplaceInString(newRocketStr, "+", ";");
|
||||
LDFData<std::u16string>* ldf_data = new LDFData<std::u16string>(u"assemblyPartLOTs", GeneralUtils::ASCIIToUTF16(newRocketStr));
|
||||
ldf_data->WriteToPacket(&ldfStream);
|
||||
delete ldf_data;
|
||||
} else {
|
||||
data->WriteToPacket(&ldfStream);
|
||||
}
|
||||
}
|
||||
outBitStream->Write(ldfStream.GetNumberOfBytesUsed() + 1);
|
||||
outBitStream->Write<uint8_t>(0); // Don't compress
|
||||
outBitStream->Write(ldfStream);
|
||||
}
|
||||
|
||||
outBitStream->Write1();
|
||||
}
|
||||
@@ -1043,7 +1062,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks)
|
||||
|
||||
GenerateProxies(item);
|
||||
|
||||
UpdateSlot(item->GetInfo().equipLocation, { item->GetId(), item->GetLot(), item->GetCount(), item->GetSlot() });
|
||||
UpdateSlot(item->GetInfo().equipLocation, { item->GetId(), item->GetLot(), item->GetCount(), item->GetSlot(), item->GetConfig() });
|
||||
|
||||
ApplyBuff(item);
|
||||
|
||||
|
||||
@@ -75,6 +75,12 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId) : Component(par
|
||||
m_MovementAI = nullptr;
|
||||
m_TresureTime = 0;
|
||||
m_Preconditions = nullptr;
|
||||
|
||||
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parent->GetVar<std::u16string>(u"CheckPrecondition"));
|
||||
|
||||
if (!checkPreconditions.empty()) {
|
||||
SetPreconditions(checkPreconditions);
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "PropertyEntranceComponent.h"
|
||||
|
||||
#include <CDPropertyEntranceComponentTable.h>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "PropertyManagementComponent.h"
|
||||
#include "PropertySelectQueryProperty.h"
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "UserManager.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
@@ -22,20 +23,25 @@ PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entit
|
||||
this->m_PropertyName = entry.propertyName;
|
||||
}
|
||||
|
||||
void PropertyEntranceComponent::OnUse(Entity* entity)
|
||||
{
|
||||
GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), entity->GetSystemAddress());
|
||||
void PropertyEntranceComponent::OnUse(Entity* entity) {
|
||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (!characterComponent) return;
|
||||
|
||||
AMFArrayValue args;
|
||||
auto* rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity);
|
||||
if (!rocket) return;
|
||||
|
||||
GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), entity->GetSystemAddress());
|
||||
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* state = new AMFStringValue();
|
||||
state->SetStringValue("property_menu");
|
||||
|
||||
args.InsertValue("state", state);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args);
|
||||
|
||||
delete state;
|
||||
delete state;
|
||||
}
|
||||
|
||||
void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, bool returnToZone, const SystemAddress& sysAddr)
|
||||
@@ -75,7 +81,7 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index,
|
||||
|
||||
launcher->SetSelectedCloneId(entity->GetObjectID(), cloneId);
|
||||
|
||||
launcher->Launch(entity, LWOOBJID_EMPTY, launcher->GetTargetZone(), cloneId);
|
||||
launcher->Launch(entity, launcher->GetTargetZone(), cloneId);
|
||||
}
|
||||
|
||||
PropertySelectQueryProperty PropertyEntranceComponent::SetPropertyValues(PropertySelectQueryProperty property, LWOCLONEID cloneId, std::string ownerName, std::string propertyName, std::string propertyDescription, float reputation, bool isBFF, bool isFriend, bool isModeratorApproved, bool isAlt, bool isOwned, uint32_t privacyOption, uint32_t timeLastUpdated, float performanceCost) {
|
||||
|
||||
@@ -45,7 +45,14 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
|
||||
|
||||
outBitStream->Write(false);
|
||||
}
|
||||
|
||||
// If build state is completed and we've already serialized once in the completed state,
|
||||
// don't serializing this component anymore as this will cause the build to jump again.
|
||||
// If state changes, serialization will begin again.
|
||||
if (!m_StateDirty && m_State == REBUILD_COMPLETED) {
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write0();
|
||||
return;
|
||||
}
|
||||
// BEGIN Scripted Activity
|
||||
outBitStream->Write1();
|
||||
|
||||
@@ -79,6 +86,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
|
||||
outBitStream->Write(m_ActivatorPosition);
|
||||
outBitStream->Write(m_RepositionPlayer);
|
||||
}
|
||||
m_StateDirty = false;
|
||||
}
|
||||
|
||||
void RebuildComponent::Update(float deltaTime) {
|
||||
@@ -139,7 +147,6 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_Timer >= m_ResetTime) {
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
@@ -384,7 +391,7 @@ void RebuildComponent::StartRebuild(Entity* user) {
|
||||
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eFailReason::REASON_NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
|
||||
m_State = eRebuildState::REBUILD_BUILDING;
|
||||
|
||||
m_StateDirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
|
||||
auto* movingPlatform = m_Parent->GetComponent<MovingPlatformComponent>();
|
||||
@@ -427,6 +434,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
|
||||
|
||||
m_State = eRebuildState::REBUILD_COMPLETED;
|
||||
m_StateDirty = true;
|
||||
m_Timer = 0.0f;
|
||||
m_DrainedImagination = 0;
|
||||
|
||||
@@ -455,8 +463,6 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
LootGenerator::Instance().DropActivityLoot(builder, m_Parent, m_ActivityId, 1);
|
||||
}
|
||||
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
// Notify scripts
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
script->OnRebuildComplete(m_Parent, user);
|
||||
@@ -501,12 +507,11 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_RESETTING, LWOOBJID_EMPTY);
|
||||
|
||||
m_State = eRebuildState::REBUILD_RESETTING;
|
||||
m_StateDirty = true;
|
||||
m_Timer = 0.0f;
|
||||
m_TimerIncomplete = 0.0f;
|
||||
m_ShowResetEffect = false;
|
||||
m_DrainedImagination = 0;
|
||||
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
|
||||
@@ -541,6 +546,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo
|
||||
|
||||
// Now update the component itself
|
||||
m_State = eRebuildState::REBUILD_INCOMPLETE;
|
||||
m_StateDirty = true;
|
||||
|
||||
// Notify scripts and possible subscribers
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent))
|
||||
|
||||
@@ -216,7 +216,11 @@ public:
|
||||
*/
|
||||
void CancelRebuild(Entity* builder, eFailReason failReason, bool skipChecks = false);
|
||||
private:
|
||||
|
||||
/**
|
||||
* Whether or not the quickbuild state has been changed since we last serialized it.
|
||||
*/
|
||||
bool m_StateDirty = true;
|
||||
|
||||
/**
|
||||
* The state the rebuild is currently in
|
||||
*/
|
||||
@@ -235,7 +239,7 @@ private:
|
||||
/**
|
||||
* The position that the rebuild activator is spawned at
|
||||
*/
|
||||
NiPoint3 m_ActivatorPosition {};
|
||||
NiPoint3 m_ActivatorPosition = NiPoint3::ZERO;
|
||||
|
||||
/**
|
||||
* The entity that represents the rebuild activator
|
||||
|
||||
40
dGame/dComponents/RocketLaunchLupComponent.cpp
Normal file
40
dGame/dComponents/RocketLaunchLupComponent.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
|
||||
RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(parent) {
|
||||
m_Parent = parent;
|
||||
|
||||
// get the lup worlds from the cdclient
|
||||
std::string query = "SELECT * FROM LUPZoneIDs;";
|
||||
auto results = CDClientDatabase::ExecuteQuery(query);
|
||||
while (!results.eof()) {
|
||||
// fallback to 1600 incase there is an issue
|
||||
m_LUPWorlds.push_back(results.getIntField(0, 1600));
|
||||
results.nextRow();
|
||||
}
|
||||
results.finalize();
|
||||
}
|
||||
|
||||
RocketLaunchLupComponent::~RocketLaunchLupComponent() {}
|
||||
|
||||
void RocketLaunchLupComponent::OnUse(Entity* originator) {
|
||||
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
|
||||
if (!rocket) return;
|
||||
|
||||
// the LUP world menu is just the property menu, the client knows how to handle it
|
||||
GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), m_Parent->GetSystemAddress());
|
||||
}
|
||||
|
||||
void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) {
|
||||
// Add one to index because the actual LUP worlds start at index 1.
|
||||
index++;
|
||||
|
||||
auto* rocketLaunchpadControlComponent = m_Parent->GetComponent<RocketLaunchpadControlComponent>();
|
||||
|
||||
if (!rocketLaunchpadControlComponent) return;
|
||||
|
||||
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
|
||||
}
|
||||
39
dGame/dComponents/RocketLaunchLupComponent.h
Normal file
39
dGame/dComponents/RocketLaunchLupComponent.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Component.h"
|
||||
|
||||
/**
|
||||
* Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds.
|
||||
*
|
||||
*/
|
||||
class RocketLaunchLupComponent : public Component {
|
||||
public:
|
||||
static const uint32_t ComponentType = eReplicaComponentType::COMPONENT_TYPE_ROCKET_LAUNCH_LUP;
|
||||
|
||||
/**
|
||||
* Constructor for this component, builds the m_LUPWorlds vector
|
||||
* @param parent parent that contains this component
|
||||
*/
|
||||
RocketLaunchLupComponent(Entity* parent);
|
||||
~RocketLaunchLupComponent() override;
|
||||
|
||||
/**
|
||||
* Handles an OnUse event from some entity, preparing it for launch to some other world
|
||||
* @param originator the entity that triggered the event
|
||||
*/
|
||||
void OnUse(Entity* originator) override;
|
||||
|
||||
/**
|
||||
* Handles an OnUse event from some entity, preparing it for launch to some other world
|
||||
* @param originator the entity that triggered the event
|
||||
* @param index index of the world that was selected
|
||||
*/
|
||||
void OnSelectWorld(Entity* originator, uint32_t index);
|
||||
private:
|
||||
/**
|
||||
* vector of the LUP World Zone IDs, built from CDServer's LUPZoneIDs table
|
||||
*/
|
||||
std::vector<LWOMAPID> m_LUPWorlds {};
|
||||
};
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "ChatPackets.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "dServer.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "PacketUtils.h"
|
||||
@@ -40,19 +41,7 @@ RocketLaunchpadControlComponent::~RocketLaunchpadControlComponent() {
|
||||
delete m_AltPrecondition;
|
||||
}
|
||||
|
||||
void RocketLaunchpadControlComponent::RocketEquip(Entity* entity, LWOOBJID rocketID) {
|
||||
if (m_PlayersInRadius.find(entity->GetObjectID()) != m_PlayersInRadius.end()) {
|
||||
Launch(entity, rocketID);
|
||||
|
||||
//Go ahead and save the player
|
||||
//This causes a double-save, but it should prevent players from not being saved
|
||||
//before the next world server starts loading their data.
|
||||
if (entity->GetCharacter())
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOOBJID optionalRocketID, LWOMAPID mapId, LWOCLONEID cloneId) {
|
||||
void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, LWOCLONEID cloneId) {
|
||||
auto zone = mapId == LWOMAPID_INVALID ? m_TargetZone : mapId;
|
||||
|
||||
if (zone == 0)
|
||||
@@ -60,53 +49,22 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOOBJID option
|
||||
return;
|
||||
}
|
||||
|
||||
TellMasterToPrepZone(zone);
|
||||
|
||||
// This also gets triggered by a proximity monitor + item equip, I will set that up when havok is ready
|
||||
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
|
||||
auto* characterComponent = originator->GetComponent<CharacterComponent>();
|
||||
|
||||
auto* character = originator->GetCharacter();
|
||||
|
||||
if (inventoryComponent == nullptr || characterComponent == nullptr || character == nullptr) {
|
||||
if (!characterComponent || !character) return;
|
||||
|
||||
auto* rocket = characterComponent->GetRocket(originator);
|
||||
if (!rocket) {
|
||||
Game::logger->Log("RocketLaunchpadControlComponent", "Unable to find rocket!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Select the rocket
|
||||
|
||||
Item* rocket = nullptr;
|
||||
|
||||
if (optionalRocketID != LWOOBJID_EMPTY)
|
||||
{
|
||||
rocket = inventoryComponent->FindItemById(optionalRocketID);
|
||||
}
|
||||
|
||||
if (rocket == nullptr)
|
||||
{
|
||||
rocket = inventoryComponent->FindItemById(characterComponent->GetLastRocketItemID());
|
||||
}
|
||||
|
||||
if (rocket == nullptr)
|
||||
{
|
||||
rocket = inventoryComponent->FindItemByLot(6416);
|
||||
}
|
||||
|
||||
if (rocket == nullptr)
|
||||
{
|
||||
Game::logger->Log("RocketLaunchpadControlComponent", "Unable to find rocket (%llu)!\n", optionalRocketID);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (rocket->GetConfig().empty()) // Sanity check
|
||||
{
|
||||
rocket->SetCount(0, false, false);
|
||||
|
||||
return;
|
||||
}
|
||||
// we have the ability to launch, so now we prep the zone
|
||||
TellMasterToPrepZone(zone);
|
||||
|
||||
// Achievement unlocked: "All zones unlocked"
|
||||
|
||||
if (!m_AltLandingScene.empty() && m_AltPrecondition->Check(originator)) {
|
||||
character->SetTargetScene(m_AltLandingScene);
|
||||
}
|
||||
@@ -114,27 +72,6 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOOBJID option
|
||||
character->SetTargetScene(m_TargetScene);
|
||||
}
|
||||
|
||||
if (characterComponent) {
|
||||
for (LDFBaseData* data : rocket->GetConfig()) {
|
||||
if (data->GetKey() == u"assemblyPartLOTs") {
|
||||
std::string newRocketStr;
|
||||
for (char character : data->GetValueAsString()) {
|
||||
if (character == '+') {
|
||||
newRocketStr.push_back(';');
|
||||
}
|
||||
else {
|
||||
newRocketStr.push_back(character);
|
||||
}
|
||||
}
|
||||
newRocketStr.push_back(';');
|
||||
characterComponent->SetLastRocketConfig(GeneralUtils::ASCIIToUTF16(newRocketStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store the last used rocket item's ID
|
||||
characterComponent->SetLastRocketItemID(rocket->GetId());
|
||||
|
||||
characterComponent->UpdatePlayerStatistic(RocketsUsed);
|
||||
|
||||
character->SaveXMLToDatabase();
|
||||
@@ -143,23 +80,31 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOOBJID option
|
||||
|
||||
GameMessages::SendFireEventClientSide(m_Parent->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
|
||||
|
||||
rocket->Equip(true);
|
||||
|
||||
GameMessages::SendChangeObjectWorldState(rocket->GetId(), WORLDSTATE_ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(originator);
|
||||
}
|
||||
|
||||
void RocketLaunchpadControlComponent::OnUse(Entity* originator) {
|
||||
// If we are have the property or the LUP component, we don't want to immediately launch
|
||||
// instead we let their OnUse handlers do their things
|
||||
// which components of an Object have their OnUse called when using them
|
||||
// so we don't need to call it here
|
||||
auto* propertyEntrance = m_Parent->GetComponent<PropertyEntranceComponent>();
|
||||
|
||||
if (propertyEntrance != nullptr)
|
||||
{
|
||||
propertyEntrance->OnUse(originator);
|
||||
|
||||
if (propertyEntrance) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* rocketLaunchLUP = m_Parent->GetComponent<RocketLaunchLupComponent>();
|
||||
if (rocketLaunchLUP) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No rocket no launch
|
||||
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
|
||||
if (!rocket) {
|
||||
return;
|
||||
}
|
||||
Launch(originator);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,21 +22,13 @@ public:
|
||||
RocketLaunchpadControlComponent(Entity* parent, int rocketId);
|
||||
~RocketLaunchpadControlComponent() override;
|
||||
|
||||
/**
|
||||
* Launches the passed entity using the passed rocket and saves their data
|
||||
* @param entity the entity to launch
|
||||
* @param rocketID the ID of the rocket to use
|
||||
*/
|
||||
void RocketEquip(Entity* entity, LWOOBJID rocketID);
|
||||
|
||||
/**
|
||||
* Launches some entity to another world
|
||||
* @param originator the entity to launch
|
||||
* @param optionalRocketID the ID of the rocket to launch
|
||||
* @param mapId the world to go to
|
||||
* @param cloneId the clone ID (for properties)
|
||||
*/
|
||||
void Launch(Entity* originator, LWOOBJID optionalRocketID = LWOOBJID_EMPTY, LWOMAPID mapId = LWOMAPID_INVALID, LWOCLONEID cloneId = LWOCLONEID_INVALID);
|
||||
void Launch(Entity* originator, LWOMAPID mapId = LWOMAPID_INVALID, LWOCLONEID cloneId = LWOCLONEID_INVALID);
|
||||
|
||||
/**
|
||||
* Handles an OnUse event from some entity, preparing it for launch to some other world
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "TeamManager.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "GameConfig.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <future>
|
||||
@@ -2726,10 +2727,15 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti
|
||||
auto* player = Player::GetPlayer(sysAddr);
|
||||
|
||||
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||
if (entranceComponent != nullptr) {
|
||||
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entranceComponent == nullptr) return;
|
||||
|
||||
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
|
||||
auto rocketLaunchLupComponent = entity->GetComponent<RocketLaunchLupComponent>();
|
||||
if (rocketLaunchLupComponent != nullptr) {
|
||||
rocketLaunchLupComponent->OnSelectWorld(player, index);
|
||||
}
|
||||
}
|
||||
|
||||
void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)
|
||||
@@ -5323,21 +5329,11 @@ void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity)
|
||||
|
||||
Item* item = inv->FindItemById(objectID);
|
||||
if (!item) return;
|
||||
/*if (item->GetLot() == 6416) { // if it's a rocket
|
||||
std::vector<Entity*> rocketPads = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_ROCKET_LAUNCH);
|
||||
for (Entity* rocketPad : rocketPads) {
|
||||
RocketLaunchpadControlComponent* rocketComp = static_cast<RocketLaunchpadControlComponent*>(rocketPad->GetComponent(COMPONENT_TYPE_ROCKET_LAUNCH));
|
||||
if (rocketComp) {
|
||||
rocketComp->RocketEquip(entity, objectID);
|
||||
}
|
||||
}
|
||||
}
|
||||
else*/ {
|
||||
|
||||
item->Equip();
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity) {
|
||||
bool immediate;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "dCommonVars.h"
|
||||
#include "LDFFormat.h"
|
||||
|
||||
/**
|
||||
* An item that's equipped, generally as a smaller return type than the regular Item class
|
||||
@@ -26,4 +27,9 @@ struct EquippedItem
|
||||
* The slot this item is stored in
|
||||
*/
|
||||
uint32_t slot = 0;
|
||||
|
||||
/**
|
||||
* The configuration of the item with any extra data
|
||||
*/
|
||||
std::vector<LDFBaseData*> config = {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user