From 900c9b6abee2c4513d8a5276375d4e00633b925d Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 1 Jan 2025 10:54:21 -0800 Subject: [PATCH] fix: add missing racing scripts (#1708) --- dGame/dComponents/PhysicsComponent.cpp | 4 ++ dGame/dComponents/RacingControlComponent.cpp | 5 +- dGame/dComponents/RacingControlComponent.h | 2 +- dScripts/CppScripts.cpp | 6 ++ dScripts/ai/RACING/CMakeLists.txt | 14 ++++- dScripts/ai/RACING/OBJECTS/CMakeLists.txt | 1 + .../VehicleDeathTriggerWaterServer.cpp | 16 ++++++ .../OBJECTS/VehicleDeathTriggerWaterServer.h | 11 ++++ dScripts/ai/RACING/TRACK_FV/CMakeLists.txt | 3 + dScripts/ai/RACING/TRACK_FV/FvRaceServer.cpp | 55 +++++++++++++++++++ dScripts/ai/RACING/TRACK_FV/FvRaceServer.h | 11 ++++ dScripts/ai/RACING/TRACK_GF/CMakeLists.txt | 3 + dScripts/ai/RACING/TRACK_GF/GfRaceServer.cpp | 55 +++++++++++++++++++ dScripts/ai/RACING/TRACK_GF/GfRaceServer.h | 11 ++++ 14 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.cpp create mode 100644 dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.h create mode 100644 dScripts/ai/RACING/TRACK_FV/CMakeLists.txt create mode 100644 dScripts/ai/RACING/TRACK_FV/FvRaceServer.cpp create mode 100644 dScripts/ai/RACING/TRACK_FV/FvRaceServer.h create mode 100644 dScripts/ai/RACING/TRACK_GF/CMakeLists.txt create mode 100644 dScripts/ai/RACING/TRACK_GF/GfRaceServer.cpp create mode 100644 dScripts/ai/RACING/TRACK_GF/GfRaceServer.h diff --git a/dGame/dComponents/PhysicsComponent.cpp b/dGame/dComponents/PhysicsComponent.cpp index 67fca8d9..15a6d61f 100644 --- a/dGame/dComponents/PhysicsComponent.cpp +++ b/dGame/dComponents/PhysicsComponent.cpp @@ -84,6 +84,10 @@ dpEntity* PhysicsComponent::CreatePhysicsEntity(eReplicaComponentType type) { } else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx") { toReturn = new dpEntity(m_Parent->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true); m_Position.y -= (111.467964f * m_Parent->GetDefaultScale()) / 2; + } else if (info->physicsAsset == "env\\GFTrack_DeathVolume1_CaveExit.hkx") { + toReturn = new dpEntity(m_Parent->GetObjectID(), 112.416870f, 50.363434f, 87.679268f); + } else if (info->physicsAsset == "env\\GFTrack_DeathVolume2_RoadGaps.hkx") { + toReturn = new dpEntity(m_Parent->GetObjectID(), 48.386536f, 50.363434f, 259.361755f); } else { // LOG_DEBUG("This one is supposed to have %s", info->physicsAsset.c_str()); diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index f03fb9b4..02a7ca0e 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -285,7 +285,7 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) { Game::entityManager->SerializeEntity(m_Parent); } -void RacingControlComponent::OnRequestDie(Entity* player) { +void RacingControlComponent::OnRequestDie(Entity* player, const std::u16string& deathType) { // Sent by the client when they collide with something which should smash // them. @@ -301,8 +301,9 @@ void RacingControlComponent::OnRequestDie(Entity* player) { if (!racingPlayer.noSmashOnReload) { racingPlayer.smashedTimes++; + LOG("Death type %s", GeneralUtils::UTF16ToWTF8(deathType).c_str()); GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true, - eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0); + eKillType::VIOLENT, deathType, 0, 0, 90.0f, false, true, 0); auto* destroyableComponent = vehicle->GetComponent(); uint32_t respawnImagination = 0; diff --git a/dGame/dComponents/RacingControlComponent.h b/dGame/dComponents/RacingControlComponent.h index 4a661ca7..67884d0d 100644 --- a/dGame/dComponents/RacingControlComponent.h +++ b/dGame/dComponents/RacingControlComponent.h @@ -135,7 +135,7 @@ public: /** * Invoked when the client says it should be smashed. */ - void OnRequestDie(Entity* player); + void OnRequestDie(Entity* player, const std::u16string& deathType = u""); /** * Invoked when the player has finished respawning. diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 696fa590..636c5923 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -294,6 +294,9 @@ #include "ShardArmor.h" #include "TeslaPack.h" #include "StunImmunity.h" +#include "GfRaceServer.h" +#include "FvRaceServer.h" +#include "VehicleDeathTriggerWaterServer.h" // Survival scripts #include "AgSurvivalStromling.h" @@ -694,6 +697,9 @@ namespace { {"scripts\\ai\\AG\\L_AG_SPIDER_BOSS_MESSAGE.lua", []() {return new AgSpiderBossMessage();}}, {"scripts\\ai\\GF\\L_GF_RACE_INSTANCER.lua", []() {return new GfRaceInstancer();}}, {"scripts\\ai\\RACING\\TRACK_NS\\NS_RACE_SERVER.lua", []() {return new NsRaceServer();}}, + {"scripts\\ai\\RACING\\TRACK_GF\\GF_RACE_SERVER.lua", []() {return new GfRaceServer();}}, + {"scripts\\ai\\RACING\\TRACK_FV\\FV_RACE_SERVER.lua", []() {return new FvRaceServer();}}, + {"scripts\\ai\\RACING\\OBJECTS\\VEHICLE_DEATH_TRIGGER_WATER_SERVER.lua", []() {return new VehicleDeathTriggerWaterServer();}}, }; diff --git a/dScripts/ai/RACING/CMakeLists.txt b/dScripts/ai/RACING/CMakeLists.txt index 1fef44d7..a51273e6 100644 --- a/dScripts/ai/RACING/CMakeLists.txt +++ b/dScripts/ai/RACING/CMakeLists.txt @@ -13,6 +13,18 @@ foreach(file ${DSCRIPTS_SOURCES_AI_RACING_TRACK_NS}) set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "TRACK_NS/${file}") endforeach() +add_subdirectory(TRACK_GF) + +foreach(file ${DSCRIPTS_SOURCES_AI_RACING_TRACK_GF}) + set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "TRACK_GF/${file}") +endforeach() + +add_subdirectory(TRACK_FV) + +foreach(file ${DSCRIPTS_SOURCES_AI_RACING_TRACK_FV}) + set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "TRACK_FV/${file}") +endforeach() + add_library(dScriptsAiRacing OBJECT ${DSCRIPTS_SOURCES_AI_RACING}) -target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS" "TRACK_NS") +target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS" "TRACK_NS" "TRACK_GF" "TRACK_FV") target_precompile_headers(dScriptsAiRacing REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/RACING/OBJECTS/CMakeLists.txt b/dScripts/ai/RACING/OBJECTS/CMakeLists.txt index 83f4b8b3..a1bd7362 100644 --- a/dScripts/ai/RACING/OBJECTS/CMakeLists.txt +++ b/dScripts/ai/RACING/OBJECTS/CMakeLists.txt @@ -7,4 +7,5 @@ set(DSCRIPTS_SOURCES_AI_RACING_OBJECTS "FvRacePillarDServer.cpp" "FvRaceSmashEggImagineServer.cpp" "RaceSmashServer.cpp" + "VehicleDeathTriggerWaterServer.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.cpp b/dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.cpp new file mode 100644 index 00000000..f04c74ed --- /dev/null +++ b/dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.cpp @@ -0,0 +1,16 @@ +#include "VehicleDeathTriggerWaterServer.h" + +#include "PossessorComponent.h" +#include "RacingControlComponent.h" + +void VehicleDeathTriggerWaterServer::OnCollisionPhantom(Entity* self, Entity* target) { + if (target->IsPlayer() && !target->GetIsDead()) { + const std::vector racingControllers = Game::entityManager->GetEntitiesByComponent(RacingControlComponent::ComponentType); + for (auto* const racingController : racingControllers) { + auto* racingControlComponent = racingController->GetComponent(); + if (racingControlComponent) { + racingControlComponent->OnRequestDie(target, u"death_water"); + } + } + } +} diff --git a/dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.h b/dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.h new file mode 100644 index 00000000..95d878b9 --- /dev/null +++ b/dScripts/ai/RACING/OBJECTS/VehicleDeathTriggerWaterServer.h @@ -0,0 +1,11 @@ +#ifndef VEHICLEDEATHTRIGGERWATERSERVER_H +#define VEHICLEDEATHTRIGGERWATERSERVER_H + +#include "CppScripts.h" + +class VehicleDeathTriggerWaterServer : public CppScripts::Script { +public: + void OnCollisionPhantom(Entity* self, Entity* target) override; +}; + +#endif //!VEHICLEDEATHTRIGGERWATERSERVER_H diff --git a/dScripts/ai/RACING/TRACK_FV/CMakeLists.txt b/dScripts/ai/RACING/TRACK_FV/CMakeLists.txt new file mode 100644 index 00000000..f8a0867b --- /dev/null +++ b/dScripts/ai/RACING/TRACK_FV/CMakeLists.txt @@ -0,0 +1,3 @@ +set(DSCRIPTS_SOURCES_AI_RACING_TRACK_FV + "FvRaceServer.cpp" + PARENT_SCOPE) diff --git a/dScripts/ai/RACING/TRACK_FV/FvRaceServer.cpp b/dScripts/ai/RACING/TRACK_FV/FvRaceServer.cpp new file mode 100644 index 00000000..5dd43f48 --- /dev/null +++ b/dScripts/ai/RACING/TRACK_FV/FvRaceServer.cpp @@ -0,0 +1,55 @@ +#include "FvRaceServer.h" + +#include "RacingControlComponent.h" +#include "Entity.h" + +using std::unique_ptr; +using std::make_unique; + +void FvRaceServer::OnStartup(Entity* self) { + GameMessages::ConfigureRacingControl config; + auto& raceSet = config.racingSettings; + + raceSet.push_back(make_unique>(u"GameType", u"Racing")); + raceSet.push_back(make_unique>(u"GameState", u"Starting")); + raceSet.push_back(make_unique>(u"Number_Of_PlayersPerTeam", 6)); + raceSet.push_back(make_unique>(u"Minimum_Players_to_Start", 2)); + raceSet.push_back(make_unique>(u"Minimum_Players_for_Group_Achievements", 2)); + + raceSet.push_back(make_unique>(u"Car_Object", 7703)); + raceSet.push_back(make_unique>(u"Race_PathName", u"MainPath")); + raceSet.push_back(make_unique>(u"Current_Lap", 1)); + raceSet.push_back(make_unique>(u"Number_of_Laps", 3)); + raceSet.push_back(make_unique>(u"activityID", 54)); + + raceSet.push_back(make_unique>(u"Place_1", 100)); + raceSet.push_back(make_unique>(u"Place_2", 90)); + raceSet.push_back(make_unique>(u"Place_3", 80)); + raceSet.push_back(make_unique>(u"Place_4", 70)); + raceSet.push_back(make_unique>(u"Place_5", 60)); + raceSet.push_back(make_unique>(u"Place_6", 50)); + + raceSet.push_back(make_unique>(u"Num_of_Players_1", 15)); + raceSet.push_back(make_unique>(u"Num_of_Players_2", 25)); + raceSet.push_back(make_unique>(u"Num_of_Players_3", 50)); + raceSet.push_back(make_unique>(u"Num_of_Players_4", 85)); + raceSet.push_back(make_unique>(u"Num_of_Players_5", 90)); + raceSet.push_back(make_unique>(u"Num_of_Players_6", 100)); + + raceSet.push_back(make_unique>(u"Number_of_Spawn_Groups", 1)); + raceSet.push_back(make_unique>(u"Red_Spawners", 4847)); + raceSet.push_back(make_unique>(u"Blue_Spawners", 4848)); + raceSet.push_back(make_unique>(u"Blue_Flag", 4850)); + raceSet.push_back(make_unique>(u"Red_Flag", 4851)); + raceSet.push_back(make_unique>(u"Red_Point", 4846)); + raceSet.push_back(make_unique>(u"Blue_Point", 4845)); + raceSet.push_back(make_unique>(u"Red_Mark", 4844)); + raceSet.push_back(make_unique>(u"Blue_Mark", 4843)); + + const std::vector racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL); + for (auto* const racingController : racingControllers) { + auto* racingComponent = racingController->GetComponent(); + if (racingComponent) racingComponent->MsgConfigureRacingControl(config); + } +} + diff --git a/dScripts/ai/RACING/TRACK_FV/FvRaceServer.h b/dScripts/ai/RACING/TRACK_FV/FvRaceServer.h new file mode 100644 index 00000000..b807c870 --- /dev/null +++ b/dScripts/ai/RACING/TRACK_FV/FvRaceServer.h @@ -0,0 +1,11 @@ +#ifndef FVRACESERVER_H +#define FVRACESERVER_H + +#include "RaceImaginationServer.h" + +class FvRaceServer : public RaceImaginationServer { +public: + void OnStartup(Entity* self) override; +}; + +#endif //!FVRACESERVER_H diff --git a/dScripts/ai/RACING/TRACK_GF/CMakeLists.txt b/dScripts/ai/RACING/TRACK_GF/CMakeLists.txt new file mode 100644 index 00000000..3d5501b1 --- /dev/null +++ b/dScripts/ai/RACING/TRACK_GF/CMakeLists.txt @@ -0,0 +1,3 @@ +set(DSCRIPTS_SOURCES_AI_RACING_TRACK_GF + "GfRaceServer.cpp" + PARENT_SCOPE) diff --git a/dScripts/ai/RACING/TRACK_GF/GfRaceServer.cpp b/dScripts/ai/RACING/TRACK_GF/GfRaceServer.cpp new file mode 100644 index 00000000..d465d57f --- /dev/null +++ b/dScripts/ai/RACING/TRACK_GF/GfRaceServer.cpp @@ -0,0 +1,55 @@ +#include "GfRaceServer.h" + +#include "RacingControlComponent.h" +#include "Entity.h" + +using std::unique_ptr; +using std::make_unique; + +void GfRaceServer::OnStartup(Entity* self) { + GameMessages::ConfigureRacingControl config; + auto& raceSet = config.racingSettings; + + raceSet.push_back(make_unique>(u"GameType", u"Racing")); + raceSet.push_back(make_unique>(u"GameState", u"Starting")); + raceSet.push_back(make_unique>(u"Number_Of_PlayersPerTeam", 6)); + raceSet.push_back(make_unique>(u"Minimum_Players_to_Start", 2)); + raceSet.push_back(make_unique>(u"Minimum_Players_for_Group_Achievements", 2)); + + raceSet.push_back(make_unique>(u"Car_Object", 7703)); + raceSet.push_back(make_unique>(u"Race_PathName", u"MainPath")); + raceSet.push_back(make_unique>(u"Current_Lap", 1)); + raceSet.push_back(make_unique>(u"Number_of_Laps", 3)); + raceSet.push_back(make_unique>(u"activityID", 39)); + + raceSet.push_back(make_unique>(u"Place_1", 100)); + raceSet.push_back(make_unique>(u"Place_2", 90)); + raceSet.push_back(make_unique>(u"Place_3", 80)); + raceSet.push_back(make_unique>(u"Place_4", 70)); + raceSet.push_back(make_unique>(u"Place_5", 60)); + raceSet.push_back(make_unique>(u"Place_6", 50)); + + raceSet.push_back(make_unique>(u"Num_of_Players_1", 15)); + raceSet.push_back(make_unique>(u"Num_of_Players_2", 25)); + raceSet.push_back(make_unique>(u"Num_of_Players_3", 50)); + raceSet.push_back(make_unique>(u"Num_of_Players_4", 85)); + raceSet.push_back(make_unique>(u"Num_of_Players_5", 90)); + raceSet.push_back(make_unique>(u"Num_of_Players_6", 100)); + + raceSet.push_back(make_unique>(u"Number_of_Spawn_Groups", 1)); + raceSet.push_back(make_unique>(u"Red_Spawners", 4847)); + raceSet.push_back(make_unique>(u"Blue_Spawners", 4848)); + raceSet.push_back(make_unique>(u"Blue_Flag", 4850)); + raceSet.push_back(make_unique>(u"Red_Flag", 4851)); + raceSet.push_back(make_unique>(u"Red_Point", 4846)); + raceSet.push_back(make_unique>(u"Blue_Point", 4845)); + raceSet.push_back(make_unique>(u"Red_Mark", 4844)); + raceSet.push_back(make_unique>(u"Blue_Mark", 4843)); + + const std::vector racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL); + for (auto* const racingController : racingControllers) { + auto* racingComponent = racingController->GetComponent(); + if (racingComponent) racingComponent->MsgConfigureRacingControl(config); + } +} + diff --git a/dScripts/ai/RACING/TRACK_GF/GfRaceServer.h b/dScripts/ai/RACING/TRACK_GF/GfRaceServer.h new file mode 100644 index 00000000..c17b907b --- /dev/null +++ b/dScripts/ai/RACING/TRACK_GF/GfRaceServer.h @@ -0,0 +1,11 @@ +#ifndef GFRACESERVER_H +#define GFRACESERVER_H + +#include "RaceImaginationServer.h" + +class GfRaceServer : public RaceImaginationServer { +public: + void OnStartup(Entity* self) override; +}; + +#endif //!GFRACESERVER_H