Merge branch 'main' into movingPlatformWork

This commit is contained in:
David Markowitz
2024-02-10 19:10:55 -08:00
810 changed files with 18865 additions and 15976 deletions

View File

@@ -1,22 +1,22 @@
#include "ActMine.h"
#include "SkillComponent.h"
#include "DestroyableComponent.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
void ActMine::OnStartup(Entity* self) {
self->SetVar(u"RebuildComplete", false);
self->SetVar(u"QuickBuildComplete", false);
self->SetProximityRadius(MINE_RADIUS, "mineRadius");
}
void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
auto* rebuild = self->GetComponent<RebuildComponent>();
void ActMine::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::COMPLETED) {
auto* rebuild = self->GetComponent<QuickBuildComponent>();
if (rebuild) {
auto* builder = rebuild->GetBuilder();
self->SetVar(u"Builder", builder->GetObjectID());
}
self->SetVar(u"RebuildComplete", true);
self->SetVar(u"QuickBuildComplete", true);
self->SetVar(u"NumWarnings", 0);
self->AddToGroup("reset");
}
@@ -26,7 +26,7 @@ void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) {
void ActMine::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
auto* detroyable = self->GetComponent<DestroyableComponent>();
if (!detroyable) return;
if (status == "ENTER" && self->GetVar<bool>(u"RebuildComplete") == true && detroyable->IsEnemy(entering)) {
if (status == "ENTER" && self->GetVar<bool>(u"QuickBuildComplete") == true && detroyable->IsEnemy(entering)) {
GameMessages::SendPlayFXEffect(self->GetObjectID(), 242, u"orange", "sirenlight_B");
self->AddTimer("Tick", TICK_TIME);
}

View File

@@ -4,7 +4,7 @@
class ActMine : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:

View File

@@ -9,4 +9,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_ACT_FOOTRACE})
set(DSCRIPTS_SOURCES_AI_ACT ${DSCRIPTS_SOURCES_AI_ACT} "FootRace/${file}")
endforeach()
set(DSCRIPTS_SOURCES_AI_ACT ${DSCRIPTS_SOURCES_AI_ACT} PARENT_SCOPE)
add_library(dScriptsAiAct STATIC ${DSCRIPTS_SOURCES_AI_ACT})
target_include_directories(dScriptsAiAct PUBLIC "." "FootRace")
target_precompile_headers(dScriptsAiAct REUSE_FROM dScriptsBase)

View File

@@ -20,7 +20,7 @@ void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play
}
void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) {
void AgJetEffectServer::OnQuickBuildComplete(Entity* self, Entity* target) {
if (self->GetLOT() != 6209) return;
auto entities = Game::entityManager->GetEntitiesInGroup("Jet_FX");
if (entities.empty()) return;

View File

@@ -6,7 +6,7 @@ class AgJetEffectServer final : public CppScripts::Script
public:
void OnUse(Entity* self, Entity* user) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:

View File

@@ -11,7 +11,7 @@ void AgPicnicBlanket::OnUse(Entity* self, Entity* user) {
self->SetVar<bool>(u"active", true);
auto lootTable = std::unordered_map<LOT, int32_t>{ {935, 3} };
LootGenerator::Instance().DropLoot(user, self, lootTable, 0, 0);
Loot::DropLoot(user, self, lootTable, 0, 0);
self->AddCallbackTimer(5.0f, [self]() {
self->SetVar<bool>(u"active", false);

View File

@@ -8,7 +8,7 @@ void AgQbElevator::OnStartup(Entity* self) {
}
//when the QB is finished being built by a player
void AgQbElevator::OnRebuildComplete(Entity* self, Entity* target) {
void AgQbElevator::OnQuickBuildComplete(Entity* self, Entity* target) {
self->SetProximityRadius(proxRadius, "elevatorProx");
self->SetI64(u"qbPlayer", target->GetObjectID());

View File

@@ -4,7 +4,7 @@
class AgQbElevator : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
void OnTimerDone(Entity* self, std::string timerName) override;

View File

@@ -1,6 +1,6 @@
#include "AgQbWall.h"
void AgQbWall::OnRebuildComplete(Entity* self, Entity* player) {
void AgQbWall::OnQuickBuildComplete(Entity* self, Entity* player) {
self->SetVar(u"player", player->GetObjectID());
auto targetWallSpawners = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner"));
if (targetWallSpawners != "") {

View File

@@ -3,5 +3,5 @@
class AgQbWall : public CppScripts::Script {
public:
void OnRebuildComplete(Entity* self, Entity* player) override;
void OnQuickBuildComplete(Entity* self, Entity* player) override;
};

View File

@@ -12,6 +12,5 @@ void AgStromlingProperty::OnStartup(Entity* self) {
4
};
auto* movementAIComponent = new MovementAIComponent(self, movementInfo);
self->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAIComponent);
self->AddComponent<MovementAIComponent>(movementInfo);
}

View File

@@ -12,6 +12,6 @@ void AgTurret::OnTimerDone(Entity* self, std::string timerName) {
}
}
void AgTurret::OnRebuildStart(Entity* self, Entity* user) {
void AgTurret::OnQuickBuildStart(Entity* self, Entity* user) {
GameMessages::SendLockNodeRotation(self, "base");
}

View File

@@ -4,5 +4,5 @@
class AgTurret : public CppScripts::Script {
void OnStartup(Entity* self);
void OnTimerDone(Entity* self, std::string timerName);
void OnRebuildStart(Entity* self, Entity* user);
void OnQuickBuildStart(Entity* self, Entity* user);
};

View File

@@ -14,5 +14,8 @@ set(DSCRIPTS_SOURCES_AI_AG
"AgDarkSpiderling.cpp"
"AgPicnicBlanket.cpp"
"AgStagePlatforms.cpp"
"AgQbWall.cpp"
PARENT_SCOPE)
"AgQbWall.cpp")
add_library(dScriptsAiAG STATIC ${DSCRIPTS_SOURCES_AI_AG})
target_include_directories(dScriptsAiAG PUBLIC ".")
target_precompile_headers(dScriptsAiAG REUSE_FROM dScriptsBase)

View File

@@ -1,81 +1,32 @@
set(DSCRIPTS_SOURCES_AI)
add_subdirectory(ACT)
foreach(file ${DSCRIPTS_SOURCES_AI_ACT})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "ACT/${file}")
endforeach()
add_subdirectory(AG)
foreach(file ${DSCRIPTS_SOURCES_AI_AG})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "AG/${file}")
endforeach()
add_subdirectory(FV)
foreach(file ${DSCRIPTS_SOURCES_AI_FV})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "FV/${file}")
endforeach()
add_subdirectory(GENERAL)
foreach(file ${DSCRIPTS_SOURCES_AI_GENERAL})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "GENERAL/${file}")
endforeach()
add_subdirectory(GF)
foreach(file ${DSCRIPTS_SOURCES_AI_GF})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "GF/${file}")
endforeach()
add_subdirectory(MINIGAME)
foreach(file ${DSCRIPTS_SOURCES_AI_MINIGAME})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "MINIGAME/${file}")
endforeach()
add_subdirectory(NP)
foreach(file ${DSCRIPTS_SOURCES_AI_NP})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "NP/${file}")
endforeach()
add_subdirectory(NS)
foreach(file ${DSCRIPTS_SOURCES_AI_NS})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "NS/${file}")
endforeach()
add_subdirectory(PETS)
foreach(file ${DSCRIPTS_SOURCES_AI_PETS})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "PETS/${file}")
endforeach()
add_subdirectory(PROPERTY)
foreach(file ${DSCRIPTS_SOURCES_AI_PROPERTY})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "PROPERTY/${file}")
endforeach()
add_subdirectory(RACING)
foreach(file ${DSCRIPTS_SOURCES_AI_RACING})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "RACING/${file}")
endforeach()
add_subdirectory(SPEC)
foreach(file ${DSCRIPTS_SOURCES_AI_SPEC})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "SPEC/${file}")
endforeach()
add_subdirectory(WILD)
foreach(file ${DSCRIPTS_SOURCES_AI_WILD})
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} "WILD/${file}")
endforeach()
set(DSCRIPTS_SOURCES_AI ${DSCRIPTS_SOURCES_AI} PARENT_SCOPE)
add_library(dScriptsAI INTERFACE)
target_link_libraries(dScriptsAI INTERFACE
dScriptsAiAct
dScriptsAiAG
dScriptsAiFV
dScriptsAiGeneral
dScriptsAiGF
dScriptsAiMinigame
dScriptsAiNP
dScriptsAiNS
dScriptsAiPets
dScriptsAiProperty
dScriptsAiRacing
dScriptsAiSpec
dScriptsAiWild
)

View File

@@ -1,10 +1,10 @@
#include "ActNinjaTurret.h"
#include "eRebuildState.h"
#include "eQuickBuildState.h"
void ActNinjaTurret::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
void ActNinjaTurret::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::COMPLETED) {
self->SetVar(u"AmBuilt", true);
} else if (state == eRebuildState::RESETTING) {
} else if (state == eQuickBuildState::RESETTING) {
self->SetVar(u"AmBuilt", false);
}
}

View File

@@ -4,7 +4,7 @@
class ActNinjaTurret : public CppScripts::Script
{
public:
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) override;
};

View File

@@ -1,11 +1,11 @@
#include "ActParadoxPipeFix.h"
#include "EntityManager.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "eEndBehavior.h"
void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
void ActParadoxPipeFix::OnQuickBuildComplete(Entity* self, Entity* target) {
const auto myGroup = "AllPipes";
const auto groupObjs = Game::entityManager->GetEntitiesInGroup(myGroup);
@@ -19,9 +19,9 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
continue;
}
auto* rebuildComponent = object->GetComponent<RebuildComponent>();
auto* quickBuildComponent = object->GetComponent<QuickBuildComponent>();
if (rebuildComponent->GetState() == eRebuildState::COMPLETED) {
if (quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) {
indexCount++;
}
}
@@ -51,8 +51,8 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
}
}
void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::RESETTING) {
void ActParadoxPipeFix::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::RESETTING) {
const auto refinery = Game::entityManager->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {

View File

@@ -4,7 +4,7 @@
class ActParadoxPipeFix : public CppScripts::Script
{
public:
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
};

View File

@@ -16,5 +16,9 @@ set(DSCRIPTS_SOURCES_AI_FV
"FvPassThroughWall.cpp"
"FvBounceOverWall.cpp"
"FvMaelstromGeyser.cpp"
"TriggerGas.cpp"
PARENT_SCOPE)
"TriggerGas.cpp")
add_library(dScriptsAiFV STATIC ${DSCRIPTS_SOURCES_AI_FV})
target_include_directories(dScriptsAiFV PUBLIC ".")
target_precompile_headers(dScriptsAiFV REUSE_FROM dScriptsBase)

View File

@@ -2,15 +2,13 @@
#include "GeneralUtils.h"
#include "dZoneManager.h"
#include "Spawner.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
void FvBrickPuzzleServer::OnStartup(Entity* self) {
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
int32_t pipeNum = 0;
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
return;
}
const auto pipeNum = GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1));
if (!pipeNum) return;
if (pipeNum != 1) {
self->AddTimer("reset", 30);
@@ -20,14 +18,12 @@ void FvBrickPuzzleServer::OnStartup(Entity* self) {
void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
int32_t pipeNum = 0;
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
return;
}
const auto pipeNum = GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1));
if (!pipeNum) return;
const auto pipeGroup = myGroup.substr(0, 10);
const auto nextPipeNum = pipeNum + 1;
const auto nextPipeNum = pipeNum.value() + 1;
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
@@ -37,7 +33,7 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
samePipeSpawners[0]->Deactivate();
}
if (killer != nullptr && killer->IsPlayer()) {
if (killer && killer->IsPlayer()) {
const auto nextPipe = pipeGroup + std::to_string(nextPipeNum);
const auto nextPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
@@ -59,9 +55,9 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "reset") {
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::OPEN) {
if (quickBuildComponent != nullptr && quickBuildComponent->GetState() == eQuickBuildState::OPEN) {
self->Smash(self->GetObjectID(), eKillType::SILENT);
}
}

View File

@@ -2,15 +2,15 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
#include "eQuickBuildState.h"
void FvConsoleLeftQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
}
void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
void FvConsoleLeftQuickbuild::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
@@ -18,7 +18,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftUp");
}
} else if (state == eRebuildState::RESETTING) {
} else if (state == eQuickBuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);

View File

@@ -5,6 +5,6 @@ class FvConsoleLeftQuickbuild : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -2,15 +2,15 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
#include "eQuickBuildState.h"
void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
}
void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
void FvConsoleRightQuickbuild::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
@@ -18,7 +18,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightUp");
}
} else if (state == eRebuildState::RESETTING) {
} else if (state == eQuickBuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);

View File

@@ -5,6 +5,6 @@ class FvConsoleRightQuickbuild : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -3,7 +3,7 @@
#include "EntityManager.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eRebuildState.h"
#include "eQuickBuildState.h"
void FvDragonSmashingGolemQb::OnStartup(Entity* self) {
self->AddTimer("GolemBreakTimer", 10.5f);
@@ -15,8 +15,8 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) {
}
}
void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
void FvDragonSmashingGolemQb::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::COMPLETED) {
RenderComponent::PlayAnimation(self, u"dragonsmash");
const auto dragonId = self->GetVar<LWOOBJID>(u"Dragon");

View File

@@ -6,5 +6,5 @@ class FvDragonSmashingGolemQb : public CppScripts::Script
public:
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
};

View File

@@ -2,7 +2,7 @@
#include "InventoryComponent.h"
#include "SkillComponent.h"
#include "Entity.h"
#include "dLogger.h"
#include "Logger.h"
void TriggerGas::OnStartup(Entity* self) {

View File

@@ -1,4 +1,8 @@
set(DSCRIPTS_SOURCES_AI_GENERAL
"InstanceExitTransferPlayerToLastNonInstance.cpp"
"LegoDieRoll.cpp"
PARENT_SCOPE)
"LegoDieRoll.cpp")
add_library(dScriptsAiGeneral STATIC ${DSCRIPTS_SOURCES_AI_GENERAL})
target_include_directories(dScriptsAiGeneral PUBLIC ".")
target_precompile_headers(dScriptsAiGeneral REUSE_FROM dScriptsBase)

View File

@@ -1,6 +1,6 @@
#include "InstanceExitTransferPlayerToLastNonInstance.h"
#include "GameMessages.h"
#include "Player.h"
#include "CharacterComponent.h"
#include "Character.h"
#include "dServer.h"
#include "eTerminateType.h"
@@ -23,10 +23,8 @@ void InstanceExitTransferPlayerToLastNonInstance::OnUse(Entity* self, Entity* us
}
void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
auto* player = dynamic_cast<Player*>(sender);
if (player == nullptr)
return;
if (!sender->IsPlayer()) return;
auto* character = sender->GetCharacter();
if (character != nullptr) {
if (identifier == u"Instance_Exit" && button == 1) {
@@ -47,7 +45,8 @@ void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* s
}
}
player->SendToZone(lastInstance);
auto* characterComponent = sender->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(lastInstance);
}
}

View File

@@ -10,5 +10,8 @@ set(DSCRIPTS_SOURCES_AI_GF
"GfArchway.cpp"
"GfMaelstromGeyser.cpp"
"PirateRep.cpp"
"GfParrotCrash.cpp"
PARENT_SCOPE)
"GfParrotCrash.cpp")
add_library(dScriptsAiGF STATIC ${DSCRIPTS_SOURCES_AI_GF})
target_include_directories(dScriptsAiGF PUBLIC ".")
target_precompile_headers(dScriptsAiGF REUSE_FROM dScriptsBase)

View File

@@ -2,7 +2,7 @@
#include "Entity.h"
#include "SkillComponent.h"
void GfArchway::OnRebuildComplete(Entity* self, Entity* target) {
void GfArchway::OnQuickBuildComplete(Entity* self, Entity* target) {
auto* skillComponent = target->GetComponent<SkillComponent>();
if (skillComponent) skillComponent->CalculateBehavior(SHIELDING_SKILL, SHIELDING_BEHAVIOR, target->GetObjectID(), true);
}

View File

@@ -3,7 +3,7 @@
class GfArchway : public CppScripts::Script {
public:
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
private:
const uint32_t SHIELDING_SKILL = 863;
const uint32_t SHIELDING_BEHAVIOR = 3788;

View File

@@ -56,7 +56,7 @@ void GfBanana::OnHit(Entity* self, Entity* attacker) {
return;
}
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3::UNIT_Y * 8);
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3Constant::UNIT_Y * 8);
auto* bananaDestroyable = bananaEntity->GetComponent<DestroyableComponent>();

View File

@@ -1,9 +1,9 @@
#include "GfJailWalls.h"
#include "dZoneManager.h"
#include "GeneralUtils.h"
#include "eRebuildState.h"
#include "eQuickBuildState.h"
void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) {
void GfJailWalls::OnQuickBuildComplete(Entity* self, Entity* target) {
const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Wall"));
for (auto* spawner : Game::zoneManager->GetSpawnersByName("Jail0" + wall)) {
@@ -15,8 +15,8 @@ void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) {
}
}
void GfJailWalls::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state != eRebuildState::RESETTING) return;
void GfJailWalls::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state != eQuickBuildState::RESETTING) return;
const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Wall"));

View File

@@ -4,6 +4,6 @@
class GfJailWalls final : public CppScripts::Script
{
public:
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
};

View File

@@ -1,7 +1,7 @@
#include "GfParrotCrash.h"
#include "SkillComponent.h"
#include "Entity.h"
#include "dLogger.h"
#include "Logger.h"
void GfParrotCrash::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
auto* skillComponent = self->GetComponent<SkillComponent>();

View File

@@ -4,7 +4,7 @@
#include "MissionComponent.h"
#include "eMissionState.h"
void PetDigBuild::OnRebuildComplete(Entity* self, Entity* target) {
void PetDigBuild::OnQuickBuildComplete(Entity* self, Entity* target) {
auto flagNumber = self->GetVar<std::u16string>(u"flagNum");
EntityInfo info{};

View File

@@ -4,6 +4,6 @@
class PetDigBuild : public CppScripts::Script
{
public:
void OnRebuildComplete(Entity* self, Entity* target);
void OnQuickBuildComplete(Entity* self, Entity* target);
void OnDie(Entity* self, Entity* killer);
};

View File

@@ -6,4 +6,12 @@ foreach(file ${DSCRIPTS_SOURCES_AI_MINIGAME_SG_GF})
set(DSCRIPTS_SOURCES_AI_MINIGAME ${DSCRIPTS_SOURCES_AI_MINIGAME} "SG_GF/${file}")
endforeach()
set(DSCRIPTS_SOURCES_AI_MINIGAME ${DSCRIPTS_SOURCES_AI_MINIGAME} PARENT_SCOPE)
add_subdirectory(Objects)
foreach(file ${DSCRIPTS_SOURCES_AI_MINIGAME_OBJECTS})
set(DSCRIPTS_SOURCES_AI_MINIGAME ${DSCRIPTS_SOURCES_AI_MINIGAME} "Objects/${file}")
endforeach()
add_library(dScriptsAiMinigame STATIC ${DSCRIPTS_SOURCES_AI_MINIGAME})
target_include_directories(dScriptsAiMinigame PUBLIC "." "Objects" "SG_GF" "SG_GF/SERVER")
target_precompile_headers(dScriptsAiMinigame REUSE_FROM dScriptsBase)

View File

@@ -0,0 +1,4 @@
SET(DSCRIPTS_SOURCES_AI_MINIGAME_OBJECTS
"MinigameBlueMark.cpp"
PARENT_SCOPE
)

View File

@@ -0,0 +1,7 @@
#include "MinigameBlueMark.h"
#include "Game.h"
#include "dZoneManager.h"
void MinigameBlueMark::OnStartup(Entity* self) {
Game::zoneManager->GetZoneControlObject()->NotifyObject(self, "Blue_Mark");
}

View File

@@ -0,0 +1,6 @@
#include "CppScripts.h"
class MinigameBlueMark : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
};

View File

@@ -2,14 +2,13 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "dZoneManager.h"
#include "Player.h"
#include "Character.h"
#include "ShootingGalleryComponent.h"
#include "PossessorComponent.h"
#include "CharacterComponent.h"
#include "SimplePhysicsComponent.h"
#include "MovementAIComponent.h"
#include "../dWorldServer/ObjectIDManager.h"
#include "ObjectIDManager.h"
#include "MissionComponent.h"
#include "Loot.h"
#include "InventoryComponent.h"
@@ -20,7 +19,7 @@
#include "MovingPlatformComponent.h"
void SGCannon::OnStartup(Entity* self) {
Game::logger->Log("SGCannon", "OnStartup");
LOG("OnStartup");
m_Waves = GetWaves();
constants = GetConstants();
@@ -66,7 +65,7 @@ void SGCannon::OnStartup(Entity* self) {
}
void SGCannon::OnPlayerLoaded(Entity* self, Entity* player) {
Game::logger->Log("SGCannon", "Player loaded");
LOG("Player loaded");
self->SetVar<LWOOBJID>(PlayerIDVariable, player->GetObjectID());
}
@@ -77,15 +76,15 @@ void SGCannon::OnFireEventServerSide(Entity* self, Entity* sender, std::string a
void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1, int32_t value2,
const std::u16string& stringValue) {
Game::logger->Log("SGCannon", "Got activity state change request: %s", GeneralUtils::UTF16ToWTF8(stringValue).c_str());
LOG("Got activity state change request: %s", GeneralUtils::UTF16ToWTF8(stringValue).c_str());
if (stringValue == u"clientready") {
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
Game::logger->Log("SGCannon", "Player is ready");
LOG("Player is ready");
/*GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true);*/
Game::logger->Log("SGCannon", "Sending ActivityEnter");
LOG("Sending ActivityEnter");
GameMessages::SendActivityEnter(self->GetObjectID(), player->GetSystemAddress());
@@ -94,11 +93,11 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
if (shootingGalleryComponent != nullptr) {
shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID());
Game::logger->Log("SGCannon", "Setting player ID");
LOG("Setting player ID");
Game::entityManager->SerializeEntity(self);
} else {
Game::logger->Log("SGCannon", "Shooting gallery component is null");
LOG("Shooting gallery component is null");
}
auto* characterComponent = player->GetComponent<CharacterComponent>();
@@ -130,7 +129,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
//GameMessages::SendRequestActivityEnter(self->GetObjectID(), player->GetSystemAddress(), false, player->GetObjectID());
} else {
Game::logger->Log("SGCannon", "Player not found");
LOG("Player not found");
}
} else if (value1 == 1200) {
StartGame(self);
@@ -161,111 +160,205 @@ void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button
}
}
void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
if (name == SuperChargeTimer && !self->GetVar<bool>(SuperChargePausedVariable)) {
if (self->GetVar<bool>(WaveStatusVariable) || self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable) < 1) {
self->SetNetworkVar<uint32_t>(ChargeCountingVariable, 99);
self->SetNetworkVar<uint32_t>(SuperChargeBarVariable, 0);
ToggleSuperCharge(self, false);
void SGCannon::SuperChargeTimerFunc(Entity* self) {
if (self->GetVar<bool>(WaveStatusVariable) || self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable) < 1) {
self->SetNetworkVar<uint32_t>(ChargeCountingVariable, 99);
self->SetNetworkVar<uint32_t>(SuperChargeBarVariable, 0);
ToggleSuperCharge(self, false);
}
}
void SGCannon::SpawnWaveTimerFunc(Entity* self) {
if (self->GetVar<bool>(GameStartedVariable)) {
self->SetVar<bool>(WaveStatusVariable, true);
const auto wave = static_cast<int32_t>(self->GetVar<uint32_t>(ThisWaveVariable));
if (wave != 0 && self->GetVar<bool>(SuperChargePausedVariable)) {
StartChargedCannon(self, self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable));
self->SetVar<uint32_t>(CurrentSuperChargedTimeVariable, 0);
}
} else if (name == SpawnWaveTimer) {
if (self->GetVar<bool>(GameStartedVariable)) {
self->SetVar<bool>(WaveStatusVariable, true);
const auto wave = (int32_t)self->GetVar<uint32_t>(ThisWaveVariable);
if (wave != 0 && self->GetVar<bool>(SuperChargePausedVariable)) {
StartChargedCannon(self, self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable));
self->SetVar<uint32_t>(CurrentSuperChargedTimeVariable, 0);
}
TimerToggle(self, true);
TimerToggle(self, true);
for (const auto& enemyToSpawn : m_Waves.at(self->GetVar<uint32_t>(ThisWaveVariable))) {
SpawnObject(self, enemyToSpawn, true);
}
Game::logger->Log("SGCannon", "Current wave spawn: %i/%i", wave, m_Waves.size());
// All waves completed
const auto timeLimit = (float_t)self->GetVar<uint32_t>(TimeLimitVariable);
if (wave >= m_Waves.size()) {
ActivityTimerStart(self, GameOverTimer, timeLimit, timeLimit);
} else {
ActivityTimerStart(self, EndWaveTimer, timeLimit, timeLimit);
}
const auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
GameMessages::SendPlayFXEffect(player->GetObjectID(), -1, u"SG-start", "");
GameMessages::SendStartActivityTime(self->GetObjectID(), timeLimit, player->GetSystemAddress());
Game::logger->Log("SGCannon", "Sending ActivityPause false");
GameMessages::SendActivityPause(self->GetObjectID(), false, player->GetSystemAddress());
}
for (const auto& enemyToSpawn : m_Waves.at(self->GetVar<uint32_t>(ThisWaveVariable))) {
SpawnObject(self, enemyToSpawn, true);
}
} else if (name == EndWaveTimer) {
self->SetVar<bool>(WaveStatusVariable, false);
LOG("Current wave spawn: %i/%i", wave, m_Waves.size());
// All waves completed
const auto timeLimit = static_cast<float_t>(self->GetVar<uint32_t>(TimeLimitVariable));
if (wave >= m_Waves.size()) {
ActivityTimerStart(self, GameOverTimer, timeLimit, timeLimit);
} else {
ActivityTimerStart(self, EndWaveTimer, timeLimit, timeLimit);
}
const auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
GameMessages::SendPlayFXEffect(player->GetObjectID(), -1, u"SG-start", "");
GameMessages::SendStartActivityTime(self->GetObjectID(), timeLimit, player->GetSystemAddress());
LOG("Sending ActivityPause false");
GameMessages::SendActivityPause(self->GetObjectID(), false, player->GetSystemAddress());
}
}
}
void SGCannon::EndWaveTimerFunc(Entity* self) {
self->SetVar<bool>(WaveStatusVariable, false);
TimerToggle(self);
RecordPlayerScore(self);
if (self->GetVar<uint32_t>(ThisWaveVariable) >= 2) {
GameMessages::SendActivityPause(self->GetObjectID(), true);
ActivityTimerStart(self, GameOverTimer, 0.1, 0.1);
return;
}
self->SetVar<uint32_t>(ThisWaveVariable, self->GetVar<uint32_t>(ThisWaveVariable) + 1);
PlaySceneAnimation(self, u"wave" + GeneralUtils::to_u16string(self->GetVar<uint32_t>(ThisWaveVariable)), true, true, 1.7f);
self->SetNetworkVar<uint32_t>(WaveNumVariable, self->GetVar<uint32_t>(ThisWaveVariable) + 1);
self->SetNetworkVar<uint32_t>(WaveStrVariable, self->GetVar<uint32_t>(TimeLimitVariable));
LOG("Current wave: %i/%i", self->GetVar<uint32_t>(ThisWaveVariable), m_Waves.size());
if (self->GetVar<uint32_t>(ThisWaveVariable) >= m_Waves.size()) {
ActivityTimerStart(self, GameOverTimer, 0.1, 0.1);
} else {
ActivityTimerStart(self, SpawnWaveTimer, constants.inBetweenWavePause, constants.inBetweenWavePause);
}
LOG("Sending ActivityPause true");
GameMessages::SendActivityPause(self->GetObjectID(), true);
if (self->GetVar<bool>(SuperChargeActiveVariable) && !self->GetVar<bool>(SuperChargePausedVariable)) {
PauseChargeCannon(self);
}
}
void SGCannon::GameOverTimerFunc(Entity* self) {
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
LOG_DEBUG("Sending ActivityPause true");
GameMessages::SendActivityPause(self->GetObjectID(), true, player->GetSystemAddress());
/*const auto leftoverCannonballs = Game::entityManager->GetEntitiesInGroup("cannonball");
if (leftoverCannonballs.empty()) {
RecordPlayerScore(self);
} else {
ActivityTimerStart(self, EndGameBufferTimer, 1, leftoverCannonballs.size());
}*/
ActivityTimerStart(self, EndGameBufferTimer, 1, 1);
TimerToggle(self);
RecordPlayerScore(self);
}
}
if (self->GetVar<uint32_t>(ThisWaveVariable) >= 2) {
GameMessages::SendActivityPause(self->GetObjectID(), true);
ActivityTimerStart(self, GameOverTimer, 0.1, 0.1);
void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) {
if (self->GetVar<bool>(GameStartedVariable)) {
LOG_DEBUG("time name %s %s", name.c_str(), name.substr(7).c_str());
const auto spawnNumber = static_cast<uint32_t>(std::stoi(name.substr(7)));
const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable);
LOG_DEBUG("size %i, %i", activeSpawns.size(), spawnNumber);
if (activeSpawns.size() <= spawnNumber) {
LOG_DEBUG("Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size());
return;
}
self->SetVar<uint32_t>(ThisWaveVariable, self->GetVar<uint32_t>(ThisWaveVariable) + 1);
PlaySceneAnimation(self, u"wave" + GeneralUtils::to_u16string(self->GetVar<uint32_t>(ThisWaveVariable)), true, true, 1.7f);
self->SetNetworkVar<uint32_t>(WaveNumVariable, self->GetVar<uint32_t>(ThisWaveVariable) + 1);
self->SetNetworkVar<uint32_t>(WaveStrVariable, self->GetVar<uint32_t>(TimeLimitVariable));
Game::logger->Log("SGCannon", "Current wave: %i/%i", self->GetVar<uint32_t>(ThisWaveVariable), m_Waves.size());
if (self->GetVar<uint32_t>(ThisWaveVariable) >= m_Waves.size()) {
ActivityTimerStart(self, GameOverTimer, 0.1, 0.1);
} else {
ActivityTimerStart(self, SpawnWaveTimer, constants.inBetweenWavePause, constants.inBetweenWavePause);
const auto& toSpawn = activeSpawns.at(spawnNumber);
LOG_DEBUG("toSpawn %i", toSpawn.spawnPaths.size());
const auto pathIndex = GeneralUtils::GenerateRandomNumber<float_t>(0, toSpawn.spawnPaths.size() - 1);
LOG_DEBUG("index %f", pathIndex);
LOG_DEBUG("%s", toSpawn.spawnPaths.at(pathIndex).c_str());
const auto* path = Game::zoneManager->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex));
if (!path) {
LOG_DEBUG("Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex);
return;
}
Game::logger->Log("SGCannon", "Sending ActivityPause true");
LOG_DEBUG("%s", path->pathName.c_str());
GameMessages::SendActivityPause(self->GetObjectID(), true);
if (self->GetVar<bool>(SuperChargeActiveVariable) && !self->GetVar<bool>(SuperChargePausedVariable)) {
PauseChargeCannon(self);
auto info = EntityInfo{};
info.lot = toSpawn.lot;
info.spawnerID = self->GetObjectID();
info.pos = path->pathWaypoints.at(0).position;
info.settings = {
new LDFData<SGEnemy>(u"SpawnData", toSpawn),
new LDFData<std::string>(u"custom_script_server", "scripts/ai/ACT/SG_TARGET.lua"),
new LDFData<std::string>(u"custom_script_client", "scripts/client/ai/SG_TARGET_CLIENT.lua"),
new LDFData<std::string>(u"attached_path", path->pathName),
new LDFData<uint32_t>(u"attached_path_start", 0),
new LDFData<std::u16string>(u"groupID", u"SGEnemy")
};
LOG_DEBUG("Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str());
auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self);
Game::entityManager->ConstructEntity(enemy);
auto* movementAI = enemy->AddComponent<MovementAIComponent>(MovementAIInfo{});
movementAI->SetMaxSpeed(toSpawn.initialSpeed);
movementAI->SetCurrentSpeed(toSpawn.initialSpeed);
movementAI->SetHaltDistance(0.0f);
std::vector<NiPoint3> pathWaypoints;
for (const auto& waypoint : path->pathWaypoints) {
pathWaypoints.push_back(waypoint.position);
}
if (GeneralUtils::GenerateRandomNumber<float_t>(0, 1) < 0.5f) {
std::reverse(pathWaypoints.begin(), pathWaypoints.end());
}
movementAI->SetPath(pathWaypoints);
enemy->AddDieCallback([this, self, enemy, name]() {
RegisterHit(self, enemy, name);
});
// Save the enemy and tell it to start pathing
if (enemy != nullptr) {
const_cast<std::vector<LWOOBJID>&>(self->GetVar<std::vector<LWOOBJID>>(SpawnedObjects)).push_back(enemy->GetObjectID());
GameMessages::SendPlatformResync(enemy, UNASSIGNED_SYSTEM_ADDRESS);
}
}
}
void SGCannon::EndGameBufferTimerFunc(Entity* self) {
RecordPlayerScore(self);
StopGame(self, false);
}
void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
if (name == SuperChargeTimer && !self->GetVar<bool>(SuperChargePausedVariable)) {
SuperChargeTimerFunc(self);
} else if (name == SpawnWaveTimer) {
SpawnWaveTimerFunc(self);
} else if (name == EndWaveTimer) {
EndWaveTimerFunc(self);
} else if (name == GameOverTimer) {
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
Game::logger->Log("SGCannon", "Sending ActivityPause true");
GameMessages::SendActivityPause(self->GetObjectID(), true, player->GetSystemAddress());
/*const auto leftoverCannonballs = Game::entityManager->GetEntitiesInGroup("cannonball");
if (leftoverCannonballs.empty()) {
RecordPlayerScore(self);
} else {
ActivityTimerStart(self, EndGameBufferTimer, 1, leftoverCannonballs.size());
}*/
ActivityTimerStart(self, EndGameBufferTimer, 1, 1);
TimerToggle(self);
}
GameOverTimerFunc(self);
} else if (name.rfind(DoSpawnTimer, 0) == 0) {
if (self->GetVar<bool>(GameStartedVariable)) {
const auto spawnNumber = (uint32_t)std::stoi(name.substr(7));
const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable);
if (activeSpawns.size() < spawnNumber) {
Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size());
LOG("Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size());
return;
}
const auto& toSpawn = activeSpawns.at(spawnNumber);
const auto pathIndex = GeneralUtils::GenerateRandomNumber<float_t>(0, toSpawn.spawnPaths.size() - 1);
const auto* path = Game::zoneManager->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex));
if (!path) {
Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex);
LOG("Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex);
return;
}
@@ -283,7 +376,7 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
new LDFData<std::u16string>(u"groupID", u"SGEnemy")
};
Game::logger->Log("SGCannon", "Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str());
LOG("Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str());
auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self);
Game::entityManager->ConstructEntity(enemy);
@@ -319,8 +412,7 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
}
}
} else if (name == EndGameBufferTimer) {
RecordPlayerScore(self);
StopGame(self, false);
EndGameBufferTimerFunc(self);
}
}
@@ -343,7 +435,7 @@ void SGCannon::StartGame(Entity* self) {
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
GetLeaderboardData(self, player->GetObjectID(), GetActivityID(self), 1);
Game::logger->Log("SGCannon", "Sending ActivityStart");
LOG("Sending ActivityStart");
GameMessages::SendActivityStart(self->GetObjectID(), player->GetSystemAddress());
GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"start", "");
@@ -411,7 +503,7 @@ void SGCannon::SpawnNewModel(Entity* self) {
if (lootMatrix != 0) {
std::unordered_map<LOT, int32_t> toDrop = {};
toDrop = LootGenerator::Instance().RollLootMatrix(player, lootMatrix);
toDrop = Loot::RollLootMatrix(player, lootMatrix);
for (auto drop : toDrop) {
rewardModel->OnFireEventServerSide(self, ModelToBuildEvent, drop.first);
@@ -424,16 +516,12 @@ void SGCannon::SpawnNewModel(Entity* self) {
void SGCannon::RemovePlayer(LWOOBJID playerID) {
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr)
return;
if (!player) return;
auto* playerObject = dynamic_cast<Player*>(player);
if (playerObject == nullptr)
return;
auto* character = playerObject->GetCharacter();
if (character != nullptr) {
playerObject->SendToZone(character->GetLastNonInstanceZoneID());
auto* character = player->GetCharacter();
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent && character) {
characterComponent->SendToZone(character->GetLastNonInstanceZoneID());
}
}
@@ -489,7 +577,7 @@ void SGCannon::SpawnObject(Entity* self, const SGEnemy& toSpawn, bool spawnNow)
}
void SGCannon::RecordPlayerScore(Entity* self) {
const auto totalScore = self->GetVar<uint32_t>(TotalScoreVariable);
const auto totalScore = self->GetVar<int32_t>(TotalScoreVariable);
const auto currentWave = self->GetVar<uint32_t>(ThisWaveVariable);
if (currentWave > 0) {
@@ -526,7 +614,7 @@ void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationN
}
void SGCannon::PauseChargeCannon(Entity* self) {
const auto time = std::max((uint32_t)std::ceil(ActivityTimerGetCurrentTime(self, SuperChargeTimer)), (uint32_t)1);
const auto time = std::max(static_cast<uint32_t>(std::ceil(ActivityTimerGetCurrentTime(self, SuperChargeTimer))), static_cast<uint32_t>(1));
self->SetVar<bool>(SuperChargePausedVariable, true);
self->SetVar<uint32_t>(CurrentSuperChargedTimeVariable, time);
@@ -558,17 +646,17 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<uint32_t>(TotalScoreVariable), self->GetObjectID(), "performact_score");
missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<int32_t>(TotalScoreVariable), self->GetObjectID(), "performact_score");
missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<uint32_t>(MaxStreakVariable), self->GetObjectID(), "performact_streak");
missionComponent->Progress(eMissionTaskType::ACTIVITY, m_CannonLot, 0, "", self->GetVar<uint32_t>(TotalScoreVariable));
missionComponent->Progress(eMissionTaskType::ACTIVITY, m_CannonLot, 0, "", self->GetVar<int32_t>(TotalScoreVariable));
}
LootGenerator::Instance().GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable));
Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar<int32_t>(TotalScoreVariable));
SaveScore(self, player->GetObjectID(),
static_cast<float>(self->GetVar<uint32_t>(TotalScoreVariable)), static_cast<float>(self->GetVar<uint32_t>(MaxStreakVariable)), percentage);
static_cast<float>(self->GetVar<int32_t>(TotalScoreVariable)), static_cast<float>(self->GetVar<uint32_t>(MaxStreakVariable)), percentage);
StopActivity(self, player->GetObjectID(), self->GetVar<uint32_t>(TotalScoreVariable), self->GetVar<uint32_t>(MaxStreakVariable), percentage);
StopActivity(self, player->GetObjectID(), self->GetVar<int32_t>(TotalScoreVariable), self->GetVar<uint32_t>(MaxStreakVariable), percentage);
self->SetNetworkVar<bool>(AudioFinalWaveDoneVariable, true);
// Give the player the model rewards they earned
@@ -580,7 +668,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
}
self->SetNetworkVar<std::u16string>(u"UI_Rewards",
GeneralUtils::to_u16string(self->GetVar<uint32_t>(TotalScoreVariable)) + u"_0_0_0_0_0_0"
GeneralUtils::to_u16string(self->GetVar<int32_t>(TotalScoreVariable)) + u"_0_0_0_0_0_0"
);
}
@@ -605,7 +693,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
ActivityTimerStart(self, timerName, respawnTime, respawnTime);
}
int score = spawnInfo.score;
int32_t score = spawnInfo.score;
if (score > 0) {
score += score * GetCurrentBonus(self);
@@ -623,16 +711,16 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
auto lastSuperTotal = self->GetVar<uint32_t>(u"LastSuperTotal");
auto scScore = self->GetVar<uint32_t>(TotalScoreVariable) - lastSuperTotal;
auto scScore = self->GetVar<int32_t>(TotalScoreVariable) - lastSuperTotal;
Game::logger->Log("SGCannon", "LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i",
LOG("LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i",
lastSuperTotal, scScore, constants.chargedPoints
);
if (!self->GetVar<bool>(SuperChargeActiveVariable) && scScore >= constants.chargedPoints && score >= 0) {
StartChargedCannon(self);
self->SetNetworkVar<float>(u"SuperChargeBar", 100.0f);
self->SetVar<uint32_t>(u"LastSuperTotal", self->GetVar<uint32_t>(TotalScoreVariable));
self->SetVar<uint32_t>(u"LastSuperTotal", self->GetVar<int32_t>(TotalScoreVariable));
}
UpdateStreak(self);
@@ -644,13 +732,13 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
target->GetPosition()
);
auto newScore = (int)self->GetVar<uint32_t>(TotalScoreVariable) + score;
auto newScore = self->GetVar<int32_t>(TotalScoreVariable) + score;
if (newScore < 0) {
newScore = 0;
}
self->SetVar<uint32_t>(TotalScoreVariable, newScore);
self->SetVar<int32_t>(TotalScoreVariable, newScore);
self->SetNetworkVar<uint32_t>(u"updateScore", newScore);
@@ -709,7 +797,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player == nullptr) {
Game::logger->Log("SGCannon", "Player not found in toggle super charge");
LOG("Player not found in toggle super charge");
return;
}
@@ -717,7 +805,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
auto equippedItems = inventoryComponent->GetEquippedItems();
Game::logger->Log("SGCannon", "Player has %d equipped items", equippedItems.size());
LOG("Player has %d equipped items", equippedItems.size());
auto skillID = constants.cannonSkill;
auto cooldown = constants.cannonRefireRate;
@@ -725,12 +813,12 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
auto* selfInventoryComponent = self->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) {
Game::logger->Log("SGCannon", "Inventory component not found");
LOG("Inventory component not found");
return;
}
if (enable) {
Game::logger->Log("SGCannon", "Player is activating super charge");
LOG("Player is activating super charge");
selfInventoryComponent->UpdateSlot("greeble_r", { ObjectIDManager::GenerateRandomObjectID(), 6505, 1, 0 });
selfInventoryComponent->UpdateSlot("greeble_l", { ObjectIDManager::GenerateRandomObjectID(), 6506, 1, 0 });
@@ -743,19 +831,19 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
self->SetNetworkVar<float>(u"SuperChargeBar", 0);
Game::logger->Log("SGCannon", "Player disables super charge");
LOG("Player disables super charge");
// TODO: Unequip items
for (const auto& equipped : equippedItems) {
if (equipped.first == "special_r" || equipped.first == "special_l") {
Game::logger->Log("SGCannon", "Trying to unequip a weapon, %i", equipped.second.lot);
LOG("Trying to unequip a weapon, %i", equipped.second.lot);
auto* item = inventoryComponent->FindItemById(equipped.second.id);
if (item != nullptr) {
inventoryComponent->UnEquipItem(item);
} else {
Game::logger->Log("SGCannon", "Item not found, %i", equipped.second.lot);
LOG("Item not found, %i", equipped.second.lot);
}
}
}
@@ -1009,7 +1097,14 @@ void SGCannon::ResetVars(Entity* self) {
self->SetVar<uint32_t>(LastSuperTotalVariable, 0);
self->SetVar<LOT>(CurrentRewardVariable, LOT_NULL);
self->SetVar<std::vector<LOT>>(RewardsVariable, {});
self->SetVar<uint32_t>(TotalScoreVariable, 0);
self->SetVar<int32_t>(TotalScoreVariable, 0);
self->SetVar<uint32_t>(u"m_curStreak", 0);
self->SetNetworkVar<float>(u"SuperChargeBar", 0);
self->SetVar<uint32_t>(u"LastSuperTotal", 0);
self->SetNetworkVar<float>(u"SuperChargeBar", 0.0f);
self->SetNetworkVar<bool>(u"ShowStreak", 0);
self->SetNetworkVar<bool>(u"UnMarkAll", true);
const_cast<std::vector<SGEnemy>&>(self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable)).clear();
self->SetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable, {});

View File

@@ -68,6 +68,12 @@ public:
void OnActivityTimerDone(Entity* self, const std::string& name) override;
void OnActivityTimerUpdate(Entity* self, const std::string& name, float_t timeRemaining, float_t elapsedTime) override;
void OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) override;
void SuperChargeTimerFunc(Entity* self);
void SpawnWaveTimerFunc(Entity* self);
void EndWaveTimerFunc(Entity* self);
void GameOverTimerFunc(Entity* self);
void DoSpawnTimerFunc(Entity* self, const std::string& name);
void EndGameBufferTimerFunc(Entity* self);
private:
static std::vector<std::vector<SGEnemy>> GetWaves();
static SGConstants GetConstants();

View File

@@ -1,3 +1,6 @@
set(DSCRIPTS_SOURCES_AI_NP
"NpcNpSpacemanBob.cpp"
PARENT_SCOPE)
"NpcNpSpacemanBob.cpp")
add_library(dScriptsAiNP STATIC ${DSCRIPTS_SOURCES_AI_NP})
target_include_directories(dScriptsAiNP PUBLIC ".")
target_precompile_headers(dScriptsAiNP REUSE_FROM dScriptsBase)

View File

@@ -21,4 +21,8 @@ foreach(file ${DSCRIPTS_SOURCES_AI_NS_WH})
set(DSCRIPTS_SOURCES_AI_NS ${DSCRIPTS_SOURCES_AI_NS} "WH/${file}")
endforeach()
set(DSCRIPTS_SOURCES_AI_NS ${DSCRIPTS_SOURCES_AI_NS} PARENT_SCOPE)
add_library(dScriptsAiNS STATIC ${DSCRIPTS_SOURCES_AI_NS})
target_include_directories(dScriptsAiNS PUBLIC "." "NS_PP_01" "WH"
PRIVATE
${PROJECT_SOURCE_DIR}/dScripts/02_server/Map/NS) # NsConcertChoiceBuildManager.h
target_precompile_headers(dScriptsAiNS REUSE_FROM dScriptsBase)

View File

@@ -3,7 +3,7 @@
#include "Item.h"
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
#include "SoundTriggerComponent.h"
#include "InventoryComponent.h"
#include "MissionComponent.h"
@@ -20,13 +20,13 @@ void NsConcertInstrument::OnStartup(Entity* self) {
self->SetVar<LWOOBJID>(u"oldItemRight", LWOOBJID_EMPTY);
}
void NsConcertInstrument::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::RESETTING || state == eRebuildState::OPEN) {
void NsConcertInstrument::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::RESETTING || state == eQuickBuildState::OPEN) {
self->SetVar<LWOOBJID>(u"activePlayer", LWOOBJID_EMPTY);
}
}
void NsConcertInstrument::OnRebuildComplete(Entity* self, Entity* target) {
void NsConcertInstrument::OnQuickBuildComplete(Entity* self, Entity* target) {
if (!target->GetIsDead()) {
self->SetVar<LWOOBJID>(u"activePlayer", target->GetObjectID());
@@ -93,9 +93,9 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) {
activePlayer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
}
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr)
rebuildComponent->ResetRebuild(false);
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
if (quickBuildComponent != nullptr)
quickBuildComponent->ResetQuickBuild(false);
self->Smash(self->GetObjectID(), eKillType::VIOLENT);
self->SetVar<LWOOBJID>(u"activePlayer", LWOOBJID_EMPTY);

View File

@@ -11,10 +11,10 @@ enum InstrumentLot {
class NsConcertInstrument : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string name) override;
private:
static void StartPlayingInstrument(Entity* self, Entity* player);

View File

@@ -80,7 +80,7 @@ void NsConcertQuickBuild::OnDie(Entity* self, Entity* killer) {
finishedQuickBuilds.erase(position);
}
void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) {
void NsConcertQuickBuild::OnQuickBuildComplete(Entity* self, Entity* target) {
const auto groupNumber = self->GetVar<int32_t>(u"groupNumber");
finishedQuickBuilds.push_back(self->GetObjectID());
self->SetNetworkVar<float>(u"startEffect", -1.0f);

View File

@@ -9,7 +9,7 @@ struct QuickBuildSet {
class NsConcertQuickBuild : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnDie(Entity* self, Entity* killer) override;
private:
static std::vector<LWOOBJID> finishedQuickBuilds;

View File

@@ -6,7 +6,7 @@ void NsQbImaginationStatue::OnStartup(Entity* self) {
}
void NsQbImaginationStatue::OnRebuildComplete(Entity* self, Entity* target) {
void NsQbImaginationStatue::OnQuickBuildComplete(Entity* self, Entity* target) {
if (target == nullptr) return;
self->SetVar(u"Player", target->GetObjectID());

View File

@@ -5,7 +5,7 @@ class NsQbImaginationStatue : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string timerName) override;
void SpawnLoot(Entity* self);
};

View File

@@ -1,3 +1,6 @@
set(DSCRIPTS_SOURCES_AI_PETS
"HydrantSmashable.cpp"
PARENT_SCOPE)
"HydrantSmashable.cpp")
add_library(dScriptsAiPets STATIC ${DSCRIPTS_SOURCES_AI_PETS})
target_include_directories(dScriptsAiPets PUBLIC "." "NS_PP_01" "WH")
target_precompile_headers(dScriptsAiPets REUSE_FROM dScriptsBase)

View File

@@ -18,7 +18,7 @@ void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int mission
&& !character->GetPlayerFlag(flag)) {
// If the player just started the mission, play a cinematic highlighting the target
GameMessages::SendPlayCinematic(target->GetObjectID(), u"MissionCam", target->GetSystemAddress());
} else if (missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) {
} else if (missionState == eMissionState::READY_TO_COMPLETE) {
// Makes the guard disappear once the mission has been completed
const auto zoneControlID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
GameMessages::SendNotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(),

View File

@@ -8,4 +8,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_PROPERTY_AG})
set(DSCRIPTS_SOURCES_AI_PROPERTY ${DSCRIPTS_SOURCES_AI_PROPERTY} "AG/${file}")
endforeach()
set(DSCRIPTS_SOURCES_AI_PROPERTY ${DSCRIPTS_SOURCES_AI_PROPERTY} PARENT_SCOPE)
add_library(dScriptsAiProperty STATIC ${DSCRIPTS_SOURCES_AI_PROPERTY})
target_include_directories(dScriptsAiProperty PUBLIC "." "AG")
target_precompile_headers(dScriptsAiProperty REUSE_FROM dScriptsBase)

View File

@@ -6,4 +6,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_RACING_OBJECTS})
set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "OBJECTS/${file}")
endforeach()
set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} PARENT_SCOPE)
add_library(dScriptsAiRacing STATIC ${DSCRIPTS_SOURCES_AI_RACING})
target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS")
target_precompile_headers(dScriptsAiRacing REUSE_FROM dScriptsBase)

View File

@@ -30,8 +30,8 @@ void FvRaceSmashEggImagineServer::OnDie(Entity* self, Entity* killer) {
}
if (missionComponent == nullptr) return;
// Dragon eggs have their own smash server so we handle mission progression for them here.
missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES);
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE);
missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast<LWOOBJID>(eRacingTaskParam::SMASHABLES));
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast<LWOOBJID>(eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE));
}
}

View File

@@ -50,7 +50,7 @@ void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) {
// Progress racing smashable missions
if (missionComponent == nullptr) return;
missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES);
missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast<LWOOBJID>(eRacingTaskParam::SMASHABLES));
}
}
}

View File

@@ -32,6 +32,6 @@ void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std
auto* missionComponent = sender->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return;
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::COLLECT_IMAGINATION);
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast<LWOOBJID>(eRacingTaskParam::COLLECT_IMAGINATION));
}
}

View File

@@ -23,9 +23,9 @@ void RaceSmashServer::OnDie(Entity* self, Entity* killer) {
// Progress racing smashable missions
if (missionComponent == nullptr) return;
missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES);
missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast<LWOOBJID>(eRacingTaskParam::SMASHABLES));
// Progress missions that ask us to smash a specific smashable.
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE);
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast<LWOOBJID>(eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE));
}
}
}

View File

@@ -1,5 +1,8 @@
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialCoinSpawner.cpp"
"SpecialPowerupSpawner.cpp"
"SpecialSpeedBuffSpawner.cpp"
PARENT_SCOPE)
"SpecialSpeedBuffSpawner.cpp")
add_library(dScriptsAiSpec STATIC ${DSCRIPTS_SOURCES_AI_SPEC})
target_include_directories(dScriptsAiSpec PUBLIC ".")
target_precompile_headers(dScriptsAiSpec REUSE_FROM dScriptsBase)

View File

@@ -7,5 +7,8 @@ set(DSCRIPTS_SOURCES_AI_WILD
"WildNinjaBricks.cpp"
"WildNinjaStudent.cpp"
"WildNinjaSensei.cpp"
"WildPants.cpp"
PARENT_SCOPE)
"WildPants.cpp")
add_library(dScriptsAiWild STATIC ${DSCRIPTS_SOURCES_AI_WILD})
target_include_directories(dScriptsAiWild PUBLIC ".")
target_precompile_headers(dScriptsAiWild REUSE_FROM dScriptsBase)