Merge branch 'main' into guild_temp

This commit is contained in:
Aaron Kimbre
2023-11-15 21:14:20 -06:00
842 changed files with 22115 additions and 15964 deletions

View File

@@ -0,0 +1,78 @@
#include "ActNinjaSensei.h"
#include "Entity.h"
#include "EntityManager.h"
#include "GameMessages.h"
void ActNinjaSensei::OnStartup(Entity* self) {
auto students = Game::entityManager->GetEntitiesInGroup(this->m_StudentGroup);
std::vector<Entity*> validStudents = {};
for (auto* student : students) {
if (student && student->GetLOT() == this->m_StudentLOT) validStudents.push_back(student);
}
self->SetVar(u"students", validStudents);
self->AddTimer("crane", 5);
}
void ActNinjaSensei::OnTimerDone(Entity* self, std::string timerName) {
auto students = self->GetVar<std::vector<Entity*>>(u"students");
if (students.empty()) return;
if (timerName == "crane") {
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"crane");
}
GameMessages::SendPlayAnimation(self, u"crane");
self->AddTimer("bow", 15.33);
}
if (timerName == "bow") {
GameMessages::SendPlayAnimation(self, u"bow");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"bow");
}
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("tiger", 5);
}
if (timerName == "tiger") {
GameMessages::SendPlayAnimation(self, u"tiger");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"tiger");
}
GameMessages::SendPlayAnimation(self, u"tiger");
self->AddTimer("bow2", 15.33);
}
if (timerName == "bow2") {
GameMessages::SendPlayAnimation(self, u"bow");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"bow");
}
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("mantis", 5);
}
if (timerName == "mantis") {
GameMessages::SendPlayAnimation(self, u"mantis");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"mantis");
}
GameMessages::SendPlayAnimation(self, u"mantis");
self->AddTimer("bow3", 15.3);
}
if (timerName == "bow3") {
GameMessages::SendPlayAnimation(self, u"bow");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"bow");
}
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("repeat", 5);
}
if (timerName == "repeat") {
self->CancelAllTimers();
self->AddTimer("crane", 5);
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class ActNinjaSensei : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
std::string m_StudentGroup = "Sensei_kids";
LOT m_StudentLOT = 2497;
};

View File

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

View File

@@ -3,11 +3,12 @@
#include "RebuildComponent.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "eEndBehavior.h"
void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
const auto myGroup = "AllPipes";
const auto groupObjs = EntityManager::Instance()->GetEntitiesInGroup(myGroup);
const auto groupObjs = Game::entityManager->GetEntitiesInGroup(myGroup);
auto indexCount = 0;
@@ -20,20 +21,20 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
auto* rebuildComponent = object->GetComponent<RebuildComponent>();
if (rebuildComponent->GetState() == REBUILD_COMPLETED) {
if (rebuildComponent->GetState() == eRebuildState::COMPLETED) {
indexCount++;
}
}
if (indexCount >= 2) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
const auto refinery = Game::entityManager->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {
GameMessages::SendPlayFXEffect(refinery[0]->GetObjectID(), 3999, u"create", "pipeFX");
}
for (auto* object : groupObjs) {
auto* player = EntityManager::Instance()->GetEntity(object->GetVar<LWOOBJID>(u"PlayerID"));
auto* player = Game::entityManager->GetEntity(object->GetVar<LWOOBJID>(u"PlayerID"));
if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>();
@@ -42,7 +43,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
missionComponent->ForceProgressTaskType(769, 1, 1, false);
}
GameMessages::SendPlayCinematic(player->GetObjectID(), u"ParadoxPipeFinish", player->GetSystemAddress(), true, true, false, false, 0, false, 2.0f);
GameMessages::SendPlayCinematic(player->GetObjectID(), u"ParadoxPipeFinish", player->GetSystemAddress(), true, true, false, false, eEndBehavior::RETURN, false, 2.0f);
}
object->SetVar(u"PlayerID", LWOOBJID_EMPTY);
@@ -51,8 +52,8 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
}
void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_RESETTING) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
if (state == eRebuildState::RESETTING) {
const auto refinery = Game::entityManager->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {
GameMessages::SendStopFXEffect(refinery[0], true, "pipeFX");

View File

@@ -1,4 +1,5 @@
set(DSCRIPTS_SOURCES_AI_FV
set(DSCRIPTS_SOURCES_AI_FV
"ActNinjaSensei.cpp"
"ActNinjaTurret.cpp"
"FvFlyingCreviceDragon.cpp"
"FvDragonSmashingGolemQb.cpp"
@@ -16,4 +17,5 @@ set(DSCRIPTS_SOURCES_AI_FV
"FvPassThroughWall.cpp"
"FvBounceOverWall.cpp"
"FvMaelstromGeyser.cpp"
"TriggerGas.cpp"
PARENT_SCOPE)

View File

@@ -29,7 +29,7 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
const auto nextPipeNum = pipeNum + 1;
const auto samePipeSpawners = dZoneManager::Instance()->GetSpawnersByName(myGroup);
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
if (!samePipeSpawners.empty()) {
samePipeSpawners[0]->SoftReset();
@@ -40,7 +40,7 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
if (killer != nullptr && killer->IsPlayer()) {
const auto nextPipe = pipeGroup + std::to_string(nextPipeNum);
const auto nextPipeSpawners = dZoneManager::Instance()->GetSpawnersByName(nextPipe);
const auto nextPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
if (!nextPipeSpawners.empty()) {
nextPipeSpawners[0]->Activate();
@@ -48,7 +48,7 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
} else {
const auto nextPipe = pipeGroup + "1";
const auto firstPipeSpawners = dZoneManager::Instance()->GetSpawnersByName(nextPipe);
const auto firstPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
if (!firstPipeSpawners.empty()) {
firstPipeSpawners[0]->Activate();
@@ -61,8 +61,8 @@ void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "reset") {
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr && rebuildComponent->GetState() == REBUILD_OPEN) {
self->Smash(self->GetObjectID(), SILENT);
if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::OPEN) {
self->Smash(self->GetObjectID(), eKillType::SILENT);
}
}
}

View File

@@ -1,6 +1,8 @@
#include "FvConsoleLeftQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
void FvConsoleLeftQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
@@ -8,19 +10,19 @@ void FvConsoleLeftQuickbuild::OnStartup(Entity* self) {
}
void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftUp");
}
} else if (state == REBUILD_RESETTING) {
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftDown");
@@ -36,12 +38,12 @@ void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftActive");
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
}

View File

@@ -1,6 +1,8 @@
#include "FvConsoleRightQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
@@ -8,19 +10,19 @@ void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
}
void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightUp");
}
} else if (state == REBUILD_RESETTING) {
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightDown");
@@ -36,12 +38,12 @@ void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightActive");
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
}

View File

@@ -1,6 +1,9 @@
#include "FvDragonSmashingGolemQb.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eRebuildState.h"
void FvDragonSmashingGolemQb::OnStartup(Entity* self) {
self->AddTimer("GolemBreakTimer", 10.5f);
@@ -13,12 +16,12 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) {
}
void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::REBUILD_COMPLETED) {
GameMessages::SendPlayAnimation(self, u"dragonsmash");
if (state == eRebuildState::COMPLETED) {
RenderComponent::PlayAnimation(self, u"dragonsmash");
const auto dragonId = self->GetVar<LWOOBJID>(u"Dragon");
auto* dragon = EntityManager::Instance()->GetEntity(dragonId);
auto* dragon = Game::entityManager->GetEntity(dragonId);
if (dragon != nullptr) {
dragon->OnFireEventServerSide(self, "rebuildDone");

View File

@@ -9,9 +9,9 @@ void FvFacilityBrick::OnStartup(Entity* self) {
}
void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
auto* brickSpawner = dZoneManager::Instance()->GetSpawnersByName("ImaginationBrick")[0];
auto* bugSpawner = dZoneManager::Instance()->GetSpawnersByName("MaelstromBug")[0];
auto* canisterSpawner = dZoneManager::Instance()->GetSpawnersByName("BrickCanister")[0];
auto* brickSpawner = Game::zoneManager->GetSpawnersByName("ImaginationBrick")[0];
auto* bugSpawner = Game::zoneManager->GetSpawnersByName("MaelstromBug")[0];
auto* canisterSpawner = Game::zoneManager->GetSpawnersByName("BrickCanister")[0];
if (name == "ConsoleLeftUp") {
GameMessages::SendStopFXEffect(self, true, "LeftPipeOff");
@@ -46,17 +46,17 @@ void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::st
}
if (self->GetVar<bool>(u"ConsoleLEFTActive") && self->GetVar<bool>(u"ConsoleRIGHTActive")) {
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
auto* object = Game::entityManager->GetEntitiesInGroup("Brick")[0];
if (object != nullptr) {
GameMessages::SendPlayFXEffect(object->GetObjectID(), 122, u"create", "bluebrick");
GameMessages::SendPlayFXEffect(object->GetObjectID(), 1034, u"cast", "imaginationexplosion");
}
object = EntityManager::Instance()->GetEntitiesInGroup("Canister")[0];
object = Game::entityManager->GetEntitiesInGroup("Canister")[0];
if (object != nullptr) {
object->Smash(self->GetObjectID(), SILENT);
object->Smash(self->GetObjectID(), eKillType::SILENT);
}
canisterSpawner->Reset();
@@ -64,7 +64,7 @@ void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::st
} else if (self->GetVar<bool>(u"ConsoleLEFTActive") || self->GetVar<bool>(u"ConsoleRIGHTActive")) {
brickSpawner->Activate();
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
auto* object = Game::entityManager->GetEntitiesInGroup("Brick")[0];
if (object != nullptr) {
GameMessages::SendStopFXEffect(object, true, "bluebrick");

View File

@@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "SkillComponent.h"
#include "GeneralUtils.h"
#include "RenderComponent.h"
void FvFlyingCreviceDragon::OnStartup(Entity* self) {
self->AddTimer("waypoint", 5);
@@ -33,7 +34,7 @@ void FvFlyingCreviceDragon::OnTimerDone(Entity* self, std::string timerName) {
groupName = "dragonFireballs3";
}
const auto& group = EntityManager::Instance()->GetEntitiesInGroup(groupName);
const auto& group = Game::entityManager->GetEntitiesInGroup(groupName);
if (group.empty()) {
return;
@@ -67,12 +68,12 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) {
auto point = self->GetVar<int32_t>(u"waypoint");
if (point == 4) {
GameMessages::SendPlayAnimation(self, u"attack1", 2);
RenderComponent::PlayAnimation(self, u"attack1", 2.0f);
self->AddTimer("platform1attack", 1.75f);
} else if (point == 12) {
GameMessages::SendPlayAnimation(self, u"attack2", 2);
RenderComponent::PlayAnimation(self, u"attack2", 2.0f);
const auto& group2 = EntityManager::Instance()->GetEntitiesInGroup("dragonFireballs2");
const auto& group2 = Game::entityManager->GetEntitiesInGroup("dragonFireballs2");
if (group2.empty()) {
return;
@@ -101,7 +102,7 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) {
}
}
} else if (point == 16) {
GameMessages::SendPlayAnimation(self, u"attack3", 2);
RenderComponent::PlayAnimation(self, u"attack3", 2.0f);
self->AddTimer("platform3attack", 0.5f);
}
}

View File

@@ -1,9 +1,10 @@
#include "FvFreeGfNinjas.h"
#include "Character.h"
#include "MissionComponent.h"
#include "eMissionState.h"
void FvFreeGfNinjas::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
if (missionID == 705 && missionState == MissionState::MISSION_STATE_AVAILABLE) {
void FvFreeGfNinjas::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
if (missionID == 705 && missionState == eMissionState::AVAILABLE) {
auto* missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent == nullptr)
return;
@@ -29,7 +30,7 @@ void FvFreeGfNinjas::OnUse(Entity* self, Entity* user) {
if (missionComponent == nullptr)
return;
if (missionComponent->GetMissionState(705) == MissionState::MISSION_STATE_ACTIVE) {
if (missionComponent->GetMissionState(705) == eMissionState::ACTIVE) {
auto* character = user->GetCharacter();
if (character != nullptr)
character->SetPlayerFlag(68, true);

View File

@@ -3,6 +3,6 @@
class FvFreeGfNinjas : public CppScripts::Script {
public:
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -1,6 +1,8 @@
#include "FvNinjaGuard.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
#include "EntityManager.h"
void FvNinjaGuard::OnStartup(Entity* self) {
if (self->GetLOT() == 7412) {
@@ -12,24 +14,24 @@ void FvNinjaGuard::OnStartup(Entity* self) {
void FvNinjaGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* target) {
if (emote != 392) {
GameMessages::SendPlayAnimation(self, u"no");
RenderComponent::PlayAnimation(self, u"no");
return;
}
GameMessages::SendPlayAnimation(self, u"scared");
RenderComponent::PlayAnimation(self, u"scared");
if (self->GetLOT() == 7412) {
auto* rightGuard = EntityManager::Instance()->GetEntity(m_RightGuard);
auto* rightGuard = Game::entityManager->GetEntity(m_RightGuard);
if (rightGuard != nullptr) {
GameMessages::SendPlayAnimation(rightGuard, u"laugh_rt");
RenderComponent::PlayAnimation(rightGuard, u"laugh_rt");
}
} else if (self->GetLOT() == 11128) {
auto* leftGuard = EntityManager::Instance()->GetEntity(m_LeftGuard);
auto* leftGuard = Game::entityManager->GetEntity(m_LeftGuard);
if (leftGuard != nullptr) {
GameMessages::SendPlayAnimation(leftGuard, u"laugh_lt");
RenderComponent::PlayAnimation(leftGuard, u"laugh_lt");
}
}
}

View File

@@ -1,6 +1,7 @@
#include "FvPandaServer.h"
#include "PetComponent.h"
#include "Character.h"
#include "ePetTamingNotifyType.h"
void FvPandaServer::OnStartup(Entity* self) {
const auto* petComponent = self->GetComponent<PetComponent>();
@@ -10,12 +11,12 @@ void FvPandaServer::OnStartup(Entity* self) {
}
}
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) {
if (type == NOTIFY_TYPE_BEGIN) {
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {
if (type == ePetTamingNotifyType::BEGIN) {
self->CancelAllTimers();
} else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) {
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
self->Smash();
} else if (type == NOTIFY_TYPE_SUCCESS) {
} else if (type == ePetTamingNotifyType::SUCCESS) {
// TODO: Remove from groups
auto* character = tamer->GetCharacter();
@@ -29,7 +30,7 @@ void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "killSelf") {
const auto* petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
self->Smash(self->GetObjectID(), SILENT);
self->Smash(self->GetObjectID(), eKillType::SILENT);
}
}
}

View File

@@ -3,6 +3,6 @@
class FvPandaServer : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override;
void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};

View File

@@ -2,13 +2,14 @@
#include "Character.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "EntityInfo.h"
#include "ScriptedActivityComponent.h"
void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
auto* character = target->GetCharacter();
if (character != nullptr && character->GetPlayerFlag(81)) {
auto raceObjects = EntityManager::Instance()->GetEntitiesInGroup("PandaRaceObject");
auto raceObjects = Game::entityManager->GetEntitiesInGroup("PandaRaceObject");
if (raceObjects.empty())
return;
@@ -18,7 +19,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
return;
// If the player already spawned a panda
auto playerPandas = EntityManager::Instance()->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
auto playerPandas = Game::entityManager->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
if (!playerPandas.empty()) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"playerPanda",
target->GetObjectID(), 0, 0, target->GetObjectID());
@@ -26,7 +27,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
}
// If there's already too many spawned pandas
auto pandas = EntityManager::Instance()->GetEntitiesInGroup("pandas");
auto pandas = Game::entityManager->GetEntitiesInGroup("pandas");
if (pandas.size() > 4) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"tooManyPandas",
target->GetObjectID(), 0, 0, target->GetObjectID());
@@ -42,7 +43,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
new LDFData<std::u16string>(u"groupID", u"panda" + (GeneralUtils::to_u16string(target->GetObjectID())) + u";pandas")
};
auto* panda = EntityManager::Instance()->CreateEntity(info);
EntityManager::Instance()->ConstructEntity(panda);
auto* panda = Game::entityManager->CreateEntity(info);
Game::entityManager->ConstructEntity(panda);
}
}

View File

@@ -0,0 +1,49 @@
#include "TriggerGas.h"
#include "InventoryComponent.h"
#include "SkillComponent.h"
#include "Entity.h"
#include "Logger.h"
void TriggerGas::OnStartup(Entity* self) {
self->AddTimer(this->m_TimerName, this->m_Time);
}
void TriggerGas::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target->IsPlayer()) return;
auto players = self->GetVar<std::vector<Entity*>>(u"players");
players.push_back(target);
self->SetVar(u"players", players);
}
void TriggerGas::OnOffCollisionPhantom(Entity* self, Entity* target) {
auto players = self->GetVar<std::vector<Entity*>>(u"players");
if (!target->IsPlayer() || players.empty()) return;
auto position = std::find(players.begin(), players.end(), target);
if (position != players.end()) players.erase(position);
self->SetVar(u"players", players);
}
void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
if (timerName != this->m_TimerName) return;
auto players = self->GetVar<std::vector<Entity*>>(u"players");
for (auto player : players) {
if (player->GetIsDead() || !player){
auto position = std::find(players.begin(), players.end(), player);
if (position != players.end()) players.erase(position);
continue;
}
auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (inventoryComponent) {
if (!inventoryComponent->IsEquipped(this->m_MaelstromHelmet)) {
auto* skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent) {
skillComponent->CastSkill(this->m_FogDamageSkill, player->GetObjectID());
}
}
}
}
self->SetVar(u"players", players);
self->AddTimer(this->m_TimerName, this->m_Time);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "CppScripts.h"
class TriggerGas : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnCollisionPhantom(Entity* self, Entity* target) override;
void OnOffCollisionPhantom(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
std::string m_TimerName = "gasTriggerDamage";
float m_Time = 3.0f;
uint32_t m_MaelstromHelmet = 3068;
uint32_t m_FogDamageSkill = 103;
};