mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 05:53:34 +00:00
Implement Rocket Launch Lup Component
This commit is contained in:
parent
427c4a8c33
commit
bd3e8aee51
@ -22,6 +22,7 @@
|
|||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "ControllablePhysicsComponent.h"
|
#include "ControllablePhysicsComponent.h"
|
||||||
#include "RenderComponent.h"
|
#include "RenderComponent.h"
|
||||||
|
#include "RocketLaunchLupComponent.h"
|
||||||
#include "CharacterComponent.h"
|
#include "CharacterComponent.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
#include "BuffComponent.h"
|
#include "BuffComponent.h"
|
||||||
@ -456,9 +457,10 @@ void Entity::Initialize()
|
|||||||
else comp = new InventoryComponent(this);
|
else comp = new InventoryComponent(this);
|
||||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_INVENTORY, comp));
|
m_Components.insert(std::make_pair(COMPONENT_TYPE_INVENTORY, comp));
|
||||||
}
|
}
|
||||||
|
// if this component exists, then we initialize it. it's value is always 0
|
||||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ROCKET_LAUNCH_LUP) > 0) {
|
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ROCKET_LAUNCH_LUP, -1) != -1) {
|
||||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_ROCKET_LAUNCH_LUP, nullptr));
|
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;
|
std::string customScriptServer;
|
||||||
bool hasCustomServerScript = false;
|
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 customScriptServerName = GetVarAsString(u"custom_script_server");
|
||||||
const auto customScriptClientName = GetVarAsString(u"custom_script_client");
|
const auto customScriptClientName = GetVarAsString(u"custom_script_client");
|
||||||
|
|
||||||
|
55
dGame/dComponents/RocketLaunchLupComponent.cpp
Normal file
55
dGame/dComponents/RocketLaunchLupComponent.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "RocketLaunchLupComponent.h"
|
||||||
|
#include "CDClientDatabase.h"
|
||||||
|
#include "RocketLaunchpadControlComponent.h"
|
||||||
|
#include "CharacterComponent.h"
|
||||||
|
#include "Item.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() {
|
||||||
|
if (!m_rocket) return;
|
||||||
|
// when we exit the ui we need to unequip the rocket
|
||||||
|
m_rocket->UnEquip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RocketLaunchLupComponent::OnUse(Entity* originator) {
|
||||||
|
// the LUP world menu is just the property menu, the client knows how to handle it
|
||||||
|
GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), m_Parent->GetSystemAddress());
|
||||||
|
|
||||||
|
// get the rocket to "equip" it so we are holding it
|
||||||
|
// taken from the RocketLaunchControlComponent
|
||||||
|
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
|
||||||
|
auto* characterComponent = originator->GetComponent<CharacterComponent>();
|
||||||
|
|
||||||
|
if (!inventoryComponent || !characterComponent) return;
|
||||||
|
|
||||||
|
m_rocket = inventoryComponent->FindItemById(characterComponent->GetLastRocketItemID());
|
||||||
|
if (!m_rocket) return;
|
||||||
|
|
||||||
|
m_rocket->Equip(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index, const SystemAddress& sysAddr) {
|
||||||
|
if (m_rocket) m_rocket->UnEquip();
|
||||||
|
|
||||||
|
// 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, LWOOBJID_EMPTY, m_LUPWorlds[index], 0);
|
||||||
|
}
|
25
dGame/dComponents/RocketLaunchLupComponent.h
Normal file
25
dGame/dComponents/RocketLaunchLupComponent.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
#include "Component.h"
|
||||||
|
#include "Item.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;
|
||||||
|
|
||||||
|
RocketLaunchLupComponent(Entity* parent);
|
||||||
|
~RocketLaunchLupComponent() override;
|
||||||
|
|
||||||
|
void OnUse(Entity* originator) override;
|
||||||
|
|
||||||
|
void OnSelectWorld(Entity* originator, uint32_t index, const SystemAddress& sysAddr);
|
||||||
|
private:
|
||||||
|
std::vector<LWOMAPID> m_LUPWorlds {};
|
||||||
|
Item* m_rocket = nullptr;
|
||||||
|
};
|
@ -26,6 +26,7 @@
|
|||||||
#include "TeamManager.h"
|
#include "TeamManager.h"
|
||||||
#include "ChatPackets.h"
|
#include "ChatPackets.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
|
#include "RocketLaunchLupComponent.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <future>
|
#include <future>
|
||||||
@ -2726,10 +2727,15 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti
|
|||||||
auto* player = Player::GetPlayer(sysAddr);
|
auto* player = Player::GetPlayer(sysAddr);
|
||||||
|
|
||||||
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||||
|
if (entranceComponent != nullptr) {
|
||||||
|
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (entranceComponent == nullptr) return;
|
auto rocketLaunchLupComponent = entity->GetComponent<RocketLaunchLupComponent>();
|
||||||
|
if (rocketLaunchLupComponent) {
|
||||||
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
|
rocketLaunchLupComponent->OnSelectWorld(player, index, sysAddr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)
|
void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)
|
||||||
|
@ -19,21 +19,6 @@ void BaseConsoleTeleportServer::BaseOnMessageBoxResponse(Entity* self, Entity* s
|
|||||||
|
|
||||||
if (button == 1)
|
if (button == 1)
|
||||||
{
|
{
|
||||||
if (self->GetLOT() == 14333)
|
|
||||||
{
|
|
||||||
auto* rocketLaunchComponent = self->GetComponent<RocketLaunchpadControlComponent>();
|
|
||||||
|
|
||||||
if (rocketLaunchComponent == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& teleportZone = self->GetVar<std::u16string>(u"transferZoneID");
|
|
||||||
|
|
||||||
rocketLaunchComponent->Launch(player, LWOOBJID_EMPTY, std::stoi(GeneralUtils::UTF16ToWTF8(teleportZone)));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMessages::SendSetStunned(player->GetObjectID(), PUSH, player->GetSystemAddress(), player->GetObjectID(),
|
GameMessages::SendSetStunned(player->GetObjectID(), PUSH, player->GetSystemAddress(), player->GetObjectID(),
|
||||||
true, true, true, true, true, true, true
|
true, true, true, true, true, true, true
|
||||||
|
@ -203,7 +203,6 @@
|
|||||||
#include "NtSleepingGuard.h"
|
#include "NtSleepingGuard.h"
|
||||||
|
|
||||||
// DLU Scripts
|
// DLU Scripts
|
||||||
#include "SbLupTeleport.h"
|
|
||||||
#include "DLUVanityNPC.h"
|
#include "DLUVanityNPC.h"
|
||||||
|
|
||||||
// AM Scripts
|
// AM Scripts
|
||||||
@ -767,8 +766,6 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = new NjNyaMissionitems();
|
script = new NjNyaMissionitems();
|
||||||
|
|
||||||
//DLU:
|
//DLU:
|
||||||
else if (scriptName == "scripts\\02_server\\DLU\\L_SB_LUP_TELEPORT.lua")
|
|
||||||
script = new SbLupTeleport();
|
|
||||||
else if (scriptName == "scripts\\02_server\\DLU\\DLUVanityNPC.lua")
|
else if (scriptName == "scripts\\02_server\\DLU\\DLUVanityNPC.lua")
|
||||||
script = new DLUVanityNPC();
|
script = new DLUVanityNPC();
|
||||||
|
|
||||||
|
@ -1,154 +0,0 @@
|
|||||||
#include "SbLupTeleport.h"
|
|
||||||
#include "dZoneManager.h"
|
|
||||||
#include "EntityManager.h"
|
|
||||||
#include "GeneralUtils.h"
|
|
||||||
#include "GameMessages.h"
|
|
||||||
|
|
||||||
void SbLupTeleport::OnStartup(Entity* self)
|
|
||||||
{
|
|
||||||
self->SetVar(u"currentZone", (int32_t) dZoneManager::Instance()->GetZoneID().GetMapID());
|
|
||||||
self->SetVar(u"choiceZone", m_ChoiceZoneID);
|
|
||||||
self->SetVar(u"teleportAnim", m_TeleportAnim);
|
|
||||||
self->SetVar(u"teleportString", m_TeleportString);
|
|
||||||
self->SetVar(u"spawnPoint", m_SpawnPoint);
|
|
||||||
|
|
||||||
args = {};
|
|
||||||
|
|
||||||
AMFStringValue* callbackClient = new AMFStringValue();
|
|
||||||
callbackClient->SetStringValue(std::to_string(self->GetObjectID()));
|
|
||||||
args.InsertValue("callbackClient", callbackClient);
|
|
||||||
|
|
||||||
AMFStringValue* strIdentifier = new AMFStringValue();
|
|
||||||
strIdentifier->SetStringValue("choiceDoor");
|
|
||||||
args.InsertValue("strIdentifier", strIdentifier);
|
|
||||||
|
|
||||||
AMFStringValue* title = new AMFStringValue();
|
|
||||||
title->SetStringValue("%[LUP_Starbase3001_Launchpad]");
|
|
||||||
args.InsertValue("title", title);
|
|
||||||
|
|
||||||
AMFArrayValue* choiceOptions = new AMFArrayValue();
|
|
||||||
|
|
||||||
{
|
|
||||||
AMFArrayValue* nsArgs = new AMFArrayValue();
|
|
||||||
|
|
||||||
AMFStringValue* image = new AMFStringValue();
|
|
||||||
image->SetStringValue("textures/ui/zone_thumnails/Deep_Freeze.dds");
|
|
||||||
nsArgs->InsertValue("image", image);
|
|
||||||
|
|
||||||
AMFStringValue* caption = new AMFStringValue();
|
|
||||||
caption->SetStringValue("%[ZoneTable_1601_DisplayDescription]");
|
|
||||||
nsArgs->InsertValue("caption", caption);
|
|
||||||
|
|
||||||
AMFStringValue* identifier = new AMFStringValue();
|
|
||||||
identifier->SetStringValue("zoneID_1601");
|
|
||||||
nsArgs->InsertValue("identifier", identifier);
|
|
||||||
|
|
||||||
AMFStringValue* tooltipText = new AMFStringValue();
|
|
||||||
tooltipText->SetStringValue("%[ZoneTable_1601_summary]");
|
|
||||||
nsArgs->InsertValue("tooltipText", tooltipText);
|
|
||||||
|
|
||||||
choiceOptions->PushBackValue(nsArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
AMFArrayValue* ntArgs = new AMFArrayValue();
|
|
||||||
|
|
||||||
AMFStringValue* image = new AMFStringValue();
|
|
||||||
image->SetStringValue("textures/ui/zone_thumnails/Robot_City.dds");
|
|
||||||
ntArgs->InsertValue("image", image);
|
|
||||||
|
|
||||||
AMFStringValue* caption = new AMFStringValue();
|
|
||||||
caption->SetStringValue("%[ZoneTable_1602_DisplayDescription]");
|
|
||||||
ntArgs->InsertValue("caption", caption);
|
|
||||||
|
|
||||||
AMFStringValue* identifier = new AMFStringValue();
|
|
||||||
identifier->SetStringValue("zoneID_1602");
|
|
||||||
ntArgs->InsertValue("identifier", identifier);
|
|
||||||
|
|
||||||
AMFStringValue* tooltipText = new AMFStringValue();
|
|
||||||
tooltipText->SetStringValue("%[ZoneTable_1602_summary]");
|
|
||||||
ntArgs->InsertValue("tooltipText", tooltipText);
|
|
||||||
|
|
||||||
choiceOptions->PushBackValue(ntArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
AMFArrayValue* ntArgs = new AMFArrayValue();
|
|
||||||
|
|
||||||
AMFStringValue* image = new AMFStringValue();
|
|
||||||
image->SetStringValue("textures/ui/zone_thumnails/Moon_Base.dds");
|
|
||||||
ntArgs->InsertValue("image", image);
|
|
||||||
|
|
||||||
AMFStringValue* caption = new AMFStringValue();
|
|
||||||
caption->SetStringValue("%[ZoneTable_1603_DisplayDescription]");
|
|
||||||
ntArgs->InsertValue("caption", caption);
|
|
||||||
|
|
||||||
AMFStringValue* identifier = new AMFStringValue();
|
|
||||||
identifier->SetStringValue("zoneID_1603");
|
|
||||||
ntArgs->InsertValue("identifier", identifier);
|
|
||||||
|
|
||||||
AMFStringValue* tooltipText = new AMFStringValue();
|
|
||||||
tooltipText->SetStringValue("%[ZoneTable_1603_summary]");
|
|
||||||
ntArgs->InsertValue("tooltipText", tooltipText);
|
|
||||||
|
|
||||||
choiceOptions->PushBackValue(ntArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
AMFArrayValue* ntArgs = new AMFArrayValue();
|
|
||||||
|
|
||||||
AMFStringValue* image = new AMFStringValue();
|
|
||||||
image->SetStringValue("textures/ui/zone_thumnails/Porto_Bello.dds");
|
|
||||||
ntArgs->InsertValue("image", image);
|
|
||||||
|
|
||||||
AMFStringValue* caption = new AMFStringValue();
|
|
||||||
caption->SetStringValue("%[ZoneTable_1604_DisplayDescription]");
|
|
||||||
ntArgs->InsertValue("caption", caption);
|
|
||||||
|
|
||||||
AMFStringValue* identifier = new AMFStringValue();
|
|
||||||
identifier->SetStringValue("zoneID_1604");
|
|
||||||
ntArgs->InsertValue("identifier", identifier);
|
|
||||||
|
|
||||||
AMFStringValue* tooltipText = new AMFStringValue();
|
|
||||||
tooltipText->SetStringValue("%[ZoneTable_1604_summary]");
|
|
||||||
ntArgs->InsertValue("tooltipText", tooltipText);
|
|
||||||
|
|
||||||
choiceOptions->PushBackValue(ntArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
args.InsertValue("options", choiceOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SbLupTeleport::OnUse(Entity* self, Entity* user)
|
|
||||||
{
|
|
||||||
auto* player = user;
|
|
||||||
|
|
||||||
//if (CheckChoice(self, player))
|
|
||||||
{
|
|
||||||
GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", &args);
|
|
||||||
}
|
|
||||||
/*else
|
|
||||||
{
|
|
||||||
BaseOnUse(self, player);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void SbLupTeleport::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData)
|
|
||||||
{
|
|
||||||
BaseOnMessageBoxResponse(self, sender, button, identifier, userData);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SbLupTeleport::OnChoiceBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier)
|
|
||||||
{
|
|
||||||
BaseChoiceBoxRespond(self, sender, button, buttonIdentifier, identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SbLupTeleport::OnTimerDone(Entity* self, std::string timerName)
|
|
||||||
{
|
|
||||||
BaseOnTimerDone(self, timerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SbLupTeleport::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3)
|
|
||||||
{
|
|
||||||
BaseOnFireEventServerSide(self, sender, args, param1, param2, param3);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "CppScripts.h"
|
|
||||||
#include "ChooseYourDestinationNsToNt.h"
|
|
||||||
#include "BaseConsoleTeleportServer.h"
|
|
||||||
#include "AMFFormat.h"
|
|
||||||
|
|
||||||
class SbLupTeleport : public CppScripts::Script, ChooseYourDestinationNsToNt, BaseConsoleTeleportServer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void OnStartup(Entity* self) override;
|
|
||||||
void OnUse(Entity* self, Entity* user) override;
|
|
||||||
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) override;
|
|
||||||
void OnChoiceBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) override;
|
|
||||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
|
||||||
void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32_t m_ChoiceZoneID = 1600;
|
|
||||||
std::string m_SpawnPoint = "NS_LW";
|
|
||||||
std::u16string m_TeleportAnim = u"lup-teleport";
|
|
||||||
std::u16string m_TeleportString = u"UI_TRAVEL_TO_LUP_STATION";
|
|
||||||
AMFArrayValue args = {};
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user