From 6c5c6b7b8e8896105021e7abcfe0e1092ff232f1 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 9 Feb 2022 21:21:10 -0800 Subject: [PATCH 1/5] commit when car work --- dGame/dComponents/InventoryComponent.cpp | 64 ++++++++++++++++++++---- dGame/dComponents/InventoryComponent.h | 6 +++ 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 922b2de..359ea45 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -23,6 +23,7 @@ #include "CharacterComponent.h" #include "dZoneManager.h" #include "PropertyManagementComponent.h" +#include "DestroyableComponent.h" InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) { @@ -909,16 +910,34 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) const auto type = static_cast(item->GetInfo().itemType); - if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) + if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == false) { + auto startPosition = m_Parent->GetPosition() + NiPoint3::UNIT_Y + 10; + + auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X); + auto angles = startRotation.GetEulerAngles(); + angles.y -= M_PI; + startRotation = NiQuaternion::FromEulerAngles(angles); + + GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); + EntityInfo info {}; info.lot = 8092; - info.pos = m_Parent->GetPosition(); - info.rot = m_Parent->GetRotation(); + info.pos = startPosition; + info.rot = startRotation; info.spawnerID = m_Parent->GetObjectID(); - auto* carEntity = EntityManager::Instance()->CreateEntity(info, nullptr, dZoneManager::Instance()->GetZoneControlObject()); - dZoneManager::Instance()->GetZoneControlObject()->AddChild(carEntity); + auto* carEntity = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); + m_Parent->AddChild(carEntity); + + // auto *destroyableComponent = carEntity->GetComponent(); + + // // Setup the vehicle stats. + // if (destroyableComponent != nullptr) { + // destroyableComponent->SetMaxImagination(60); + // destroyableComponent->SetImagination(0); + // destroyableComponent->SetIsImmune(true); + // } auto* possessableComponent = carEntity->GetComponent(); @@ -929,7 +948,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) auto* moduleAssemblyComponent = carEntity->GetComponent(); - if (moduleAssemblyComponent) + if (moduleAssemblyComponent != nullptr) { moduleAssemblyComponent->SetSubKey(item->GetSubKey()); moduleAssemblyComponent->SetUseOptionalParts(false); @@ -960,14 +979,33 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) EntityManager::Instance()->ConstructEntity(carEntity); EntityManager::Instance()->SerializeEntity(m_Parent); - //EntityManager::Instance()->SerializeEntity(dZoneManager::Instance()->GetZoneControlObject()); + GameMessages::SendSetJetPackMode(m_Parent, false); - GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendRacingPlayerLoaded(m_Parent->GetObjectID(), m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendRacingPlayerLoaded(m_Parent->GetObjectID(), m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendVehicleUnlockInput(carEntity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); - //GameMessages::SendVehicleSetWheelLockState(carEntity->GetObjectID(), false, false, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); + GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); + EntityManager::Instance()->SerializeEntity(m_Parent); + // m_Parent->AddDieCallback([item, this](){ + // this->UnEquipItem(item); + // this->EquipItem(item); + // }); + // carEntity->AddDieCallback([item, this](){ + // this->UnEquipItem(item); + // this->EquipItem(item); + // }); + hasCarEquipped = true; + equippedCarEntity = carEntity; return; + } else if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) + { + // auto *playerInstance = dynamic_cast(m_Parent); + // playerInstance->SendToZone(1200); + + // equippedCarEntity->Kill(); } if (!building) @@ -1019,6 +1057,14 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) void InventoryComponent::UnEquipItem(Item* item) { + // if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) + // { + // auto *playerInstance = dynamic_cast(m_Parent); + // playerInstance->SendToZone(1200); + + // equippedCarEntity->Kill(); + // return; + // } if (!item->IsEquipped()) { return; diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 7082cff..f337ae8 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -15,6 +15,7 @@ #include "Component.h" #include "ItemSetPassiveAbility.h" #include "ItemSetPassiveAbilityID.h" +#include "PossessorComponent.h" class Entity; class ItemSet; @@ -384,6 +385,11 @@ private: */ LOT m_Consumable; + /** + * Currently has a car equipped + */ + bool hasCarEquipped = false; + Entity* equippedCarEntity = nullptr; /** * Creates all the proxy items (subitems) for a parent item * @param parent the parent item to generate all the subitems for From 9021c5209faf8ea23155a30ef616701d804ec66a Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 10 Feb 2022 01:03:51 -0800 Subject: [PATCH 2/5] backup commit with comments --- dGame/dComponents/InventoryComponent.cpp | 65 ++++++++++++++++++------ dGame/dComponents/InventoryComponent.h | 2 + 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 359ea45..06f1d50 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -911,8 +911,8 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) const auto type = static_cast(item->GetInfo().itemType); if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == false) - { - auto startPosition = m_Parent->GetPosition() + NiPoint3::UNIT_Y + 10; + { // Spawn above current position so we dont fall through floor? + auto startPosition = m_Parent->GetPosition() + NiPoint3::UNIT_Y + 2; auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X); auto angles = startRotation.GetEulerAngles(); @@ -930,19 +930,19 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) auto* carEntity = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); m_Parent->AddChild(carEntity); - // auto *destroyableComponent = carEntity->GetComponent(); - - // // Setup the vehicle stats. - // if (destroyableComponent != nullptr) { - // destroyableComponent->SetMaxImagination(60); - // destroyableComponent->SetImagination(0); - // destroyableComponent->SetIsImmune(true); - // } + auto *destroyableComponent = carEntity->GetComponent(); + // Setup the vehicle stats. + if (destroyableComponent != nullptr) { + destroyableComponent->SetIsSmashable(false); + destroyableComponent->SetIsImmune(true); + } + // #108 auto* possessableComponent = carEntity->GetComponent(); if (possessableComponent != nullptr) { + previousPossessableID = possessableComponent->GetPossessor(); possessableComponent->SetPossessor(m_Parent->GetObjectID()); } @@ -961,11 +961,12 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) } } } - + // #107 auto* possessorComponent = m_Parent->GetComponent(); if (possessorComponent != nullptr) { + previousPossessorID = possessorComponent->GetPossessable(); possessorComponent->SetPossessable(carEntity->GetObjectID()); } @@ -982,8 +983,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) GameMessages::SendSetJetPackMode(m_Parent, false); GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendRacingPlayerLoaded(m_Parent->GetObjectID(), m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendRacingPlayerLoaded(m_Parent->GetObjectID(), m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendRacingPlayerLoaded(LWOOBJID_EMPTY, m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendVehicleUnlockInput(carEntity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); @@ -1002,10 +1002,43 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) return; } else if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) { - // auto *playerInstance = dynamic_cast(m_Parent); - // playerInstance->SendToZone(1200); + //GameMessages::SendTeleport(m_Parent->GetObjectID(), m_Parent->GetPosition(), m_Parent->GetRotation(), m_Parent->GetSystemAddress(), true, true); + // reset character component back to what it was + // auto* characterComponent = m_Parent->GetComponent(); - // equippedCarEntity->Kill(); + // if (characterComponent != nullptr) + // { + // characterComponent->SetIsRacing(false); + // characterComponent->SetVehicleObjectID(LWOOBJID_EMPTY); + // } + + // auto* possessableComponent = equippedCarEntity->GetComponent(); + + // if (possessableComponent != nullptr) + // { + // possessableComponent->SetPossessor(previousPossessableID); + // previousPossessableID = LWOOBJID_EMPTY; + // } + + // // #107 + // auto* possessorComponent = m_Parent->GetComponent(); + + // if (possessorComponent != nullptr) + // { + // possessorComponent->SetPossessable(previousPossessorID); + // previousPossessorID = LWOOBJID_EMPTY; + // } + GameMessages::SendNotifyRacingClient(LWOOBJID_EMPTY, 3, 0, LWOOBJID_EMPTY, u"", m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + // GameMessages::SendNotifyVehicleOfRacingObject(equippedCarEntity->GetObjectID(), LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS); + // GameMessages::SendRacingPlayerLoaded(LWOOBJID_EMPTY, m_Parent->GetObjectID(), LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS); + //GameMessages::SendTeleport(m_Parent->GetObjectID(), equippedCarEntity->GetPosition(), equippedCarEntity->GetRotation(), m_Parent->GetSystemAddress(), true, true); + // EntityManager::Instance()->SerializeEntity(m_Parent); + auto player = dynamic_cast(m_Parent); + player->SendToZone(player->GetCharacter()->GetZoneID()); + equippedCarEntity->Kill(); + hasCarEquipped = false; + equippedCarEntity = nullptr; + return; } if (!building) diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index f337ae8..7c62170 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -390,6 +390,8 @@ private: */ bool hasCarEquipped = false; Entity* equippedCarEntity = nullptr; + LWOOBJID previousPossessableID = LWOOBJID_EMPTY; + LWOOBJID previousPossessorID = LWOOBJID_EMPTY; /** * Creates all the proxy items (subitems) for a parent item * @param parent the parent item to generate all the subitems for From 7c80c12b90a9149a2276caa09d8a31faf3708218 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 10 Feb 2022 01:40:57 -0800 Subject: [PATCH 3/5] Removed comments --- dGame/dComponents/InventoryComponent.cpp | 42 ++---------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 06f1d50..cbf6154 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -911,8 +911,8 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) const auto type = static_cast(item->GetInfo().itemType); if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == false) - { // Spawn above current position so we dont fall through floor? - auto startPosition = m_Parent->GetPosition() + NiPoint3::UNIT_Y + 2; + { + auto startPosition = m_Parent->GetPosition(); auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X); auto angles = startRotation.GetEulerAngles(); @@ -989,50 +989,12 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); EntityManager::Instance()->SerializeEntity(m_Parent); - // m_Parent->AddDieCallback([item, this](){ - // this->UnEquipItem(item); - // this->EquipItem(item); - // }); - // carEntity->AddDieCallback([item, this](){ - // this->UnEquipItem(item); - // this->EquipItem(item); - // }); hasCarEquipped = true; equippedCarEntity = carEntity; return; } else if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) { - //GameMessages::SendTeleport(m_Parent->GetObjectID(), m_Parent->GetPosition(), m_Parent->GetRotation(), m_Parent->GetSystemAddress(), true, true); - // reset character component back to what it was - // auto* characterComponent = m_Parent->GetComponent(); - - // if (characterComponent != nullptr) - // { - // characterComponent->SetIsRacing(false); - // characterComponent->SetVehicleObjectID(LWOOBJID_EMPTY); - // } - - // auto* possessableComponent = equippedCarEntity->GetComponent(); - - // if (possessableComponent != nullptr) - // { - // possessableComponent->SetPossessor(previousPossessableID); - // previousPossessableID = LWOOBJID_EMPTY; - // } - - // // #107 - // auto* possessorComponent = m_Parent->GetComponent(); - - // if (possessorComponent != nullptr) - // { - // possessorComponent->SetPossessable(previousPossessorID); - // previousPossessorID = LWOOBJID_EMPTY; - // } GameMessages::SendNotifyRacingClient(LWOOBJID_EMPTY, 3, 0, LWOOBJID_EMPTY, u"", m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); - // GameMessages::SendNotifyVehicleOfRacingObject(equippedCarEntity->GetObjectID(), LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS); - // GameMessages::SendRacingPlayerLoaded(LWOOBJID_EMPTY, m_Parent->GetObjectID(), LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS); - //GameMessages::SendTeleport(m_Parent->GetObjectID(), equippedCarEntity->GetPosition(), equippedCarEntity->GetRotation(), m_Parent->GetSystemAddress(), true, true); - // EntityManager::Instance()->SerializeEntity(m_Parent); auto player = dynamic_cast(m_Parent); player->SendToZone(player->GetCharacter()->GetZoneID()); equippedCarEntity->Kill(); From 5fbb1e9cc2705aeac414d15df4448cfacec74e6f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 10 Feb 2022 02:16:33 -0800 Subject: [PATCH 4/5] removed comments --- dGame/dComponents/InventoryComponent.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index cbf6154..a026fb0 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -1052,14 +1052,6 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) void InventoryComponent::UnEquipItem(Item* item) { - // if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) - // { - // auto *playerInstance = dynamic_cast(m_Parent); - // playerInstance->SendToZone(1200); - - // equippedCarEntity->Kill(); - // return; - // } if (!item->IsEquipped()) { return; From 78fbe3c7feb249b1793bb311fa20e6d32f72ed82 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 17 Feb 2022 03:17:41 -0800 Subject: [PATCH 5/5] Added support for Windows Native --- dGame/dComponents/InventoryComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index a026fb0..f1bd8db 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -916,7 +916,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X); auto angles = startRotation.GetEulerAngles(); - angles.y -= M_PI; + angles.y -= PI; startRotation = NiQuaternion::FromEulerAngles(angles); GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true);