Organize dScripts (#814)

* Organize dScripts

whitespace

Remove parent scope

Remove parent scope from initial setter

Remove debug

Remove helper programs

* Fix NtImagimeterVisibility script

Co-authored-by: aronwk-aaron <aronwk.aaron@gmail.com>
This commit is contained in:
David Markowitz
2022-11-03 10:57:54 -07:00
committed by GitHub
parent b974eed8f5
commit 8d37d9b681
567 changed files with 886 additions and 252 deletions

View File

@@ -0,0 +1,17 @@
#include "ActNinjaTurret.h"
void ActNinjaTurret::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::REBUILD_COMPLETED) {
self->SetVar(u"AmBuilt", true);
} else if (state == eRebuildState::REBUILD_RESETTING) {
self->SetVar(u"AmBuilt", false);
}
}
void
ActNinjaTurret::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) {
if (args == "ISpawned" && self->GetVar<bool>(u"AmBuilt")) {
sender->Smash();
}
}

View File

@@ -0,0 +1,11 @@
#pragma once
#include "CppScripts.h"
class ActNinjaTurret : public CppScripts::Script
{
public:
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) override;
};

View File

@@ -0,0 +1,61 @@
#include "ActParadoxPipeFix.h"
#include "EntityManager.h"
#include "RebuildComponent.h"
#include "GameMessages.h"
#include "MissionComponent.h"
void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
const auto myGroup = "AllPipes";
const auto groupObjs = EntityManager::Instance()->GetEntitiesInGroup(myGroup);
auto indexCount = 0;
self->SetVar(u"PlayerID", target->GetObjectID());
for (auto* object : groupObjs) {
if (object == self) {
continue;
}
auto* rebuildComponent = object->GetComponent<RebuildComponent>();
if (rebuildComponent->GetState() == REBUILD_COMPLETED) {
indexCount++;
}
}
if (indexCount >= 2) {
const auto refinery = EntityManager::Instance()->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"));
if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
missionComponent->ForceProgressTaskType(769, 1, 1, false);
}
GameMessages::SendPlayCinematic(player->GetObjectID(), u"ParadoxPipeFinish", player->GetSystemAddress(), true, true, false, false, 0, false, 2.0f);
}
object->SetVar(u"PlayerID", LWOOBJID_EMPTY);
}
}
}
void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_RESETTING) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {
GameMessages::SendStopFXEffect(refinery[0], true, "pipeFX");
}
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class ActParadoxPipeFix : public CppScripts::Script
{
public:
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
};

View File

@@ -0,0 +1,18 @@
set(DSCRIPTS_SOURCES_AI_FV
"ActNinjaTurret.cpp"
"FvFlyingCreviceDragon.cpp"
"FvDragonSmashingGolemQb.cpp"
"FvFreeGfNinjas.cpp"
"FvPandaSpawnerServer.cpp"
"FvPandaServer.cpp"
"FvBrickPuzzleServer.cpp"
"FvConsoleLeftQuickbuild.cpp"
"FvConsoleRightQuickbuild.cpp"
"FvFacilityBrick.cpp"
"FvFacilityPipes.cpp"
"ActParadoxPipeFix.cpp"
"FvNinjaGuard.cpp"
"FvPassThroughWall.cpp"
"FvBounceOverWall.cpp"
"FvMaelstromGeyser.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,10 @@
#include "FvBounceOverWall.h"
#include "MissionComponent.h"
void FvBounceOverWall::OnCollisionPhantom(Entity* self, Entity* target) {
auto missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return;
// We force progress here to the Gate Crasher mission due to an overlap in LOTs with the 'Shark Bite' missions.
missionComponent->ForceProgress(GateCrasherMissionId, GateCrasherMissionUid, 1);
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include "CppScripts.h"
class FvBounceOverWall : public CppScripts::Script
{
/**
* @brief When a collision has been made with self this method is called.
*
* @param self The Entity that called this function.
* @param target The target Entity of self.
*/
void OnCollisionPhantom(Entity* self, Entity* target) override;
private:
/**
* MissionId for the Gate Crasher mission.
*/
int32_t GateCrasherMissionId = 849;
/**
* MissionUid for the Gate Crasher mission.
*/
int32_t GateCrasherMissionUid = 1241;
};

View File

@@ -0,0 +1,68 @@
#include "FvBrickPuzzleServer.h"
#include "GeneralUtils.h"
#include "dZoneManager.h"
#include "Spawner.h"
#include "RebuildComponent.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;
}
if (pipeNum != 1) {
self->AddTimer("reset", 30);
}
}
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 pipeGroup = myGroup.substr(0, 10);
const auto nextPipeNum = pipeNum + 1;
const auto samePipeSpawners = dZoneManager::Instance()->GetSpawnersByName(myGroup);
if (!samePipeSpawners.empty()) {
samePipeSpawners[0]->SoftReset();
samePipeSpawners[0]->Deactivate();
}
if (killer != nullptr && killer->IsPlayer()) {
const auto nextPipe = pipeGroup + std::to_string(nextPipeNum);
const auto nextPipeSpawners = dZoneManager::Instance()->GetSpawnersByName(nextPipe);
if (!nextPipeSpawners.empty()) {
nextPipeSpawners[0]->Activate();
}
} else {
const auto nextPipe = pipeGroup + "1";
const auto firstPipeSpawners = dZoneManager::Instance()->GetSpawnersByName(nextPipe);
if (!firstPipeSpawners.empty()) {
firstPipeSpawners[0]->Activate();
}
}
}
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);
}
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class FvBrickPuzzleServer : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnDie(Entity* self, Entity* killer) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};

View File

@@ -0,0 +1,47 @@
#include "FvConsoleLeftQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.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 == REBUILD_COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftUp");
}
} else if (state == REBUILD_RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftDown");
}
}
}
void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"AmActive")) {
return;
}
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftActive");
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class FvConsoleLeftQuickbuild : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -0,0 +1,47 @@
#include "FvConsoleRightQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.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 == REBUILD_COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightUp");
}
} else if (state == REBUILD_RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightDown");
}
}
}
void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"AmActive")) {
return;
}
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightActive");
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class FvConsoleRightQuickbuild : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

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

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
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;
};

View File

@@ -0,0 +1,97 @@
#include "FvFacilityBrick.h"
#include "GameMessages.h"
#include "dZoneManager.h"
#include "EntityManager.h"
void FvFacilityBrick::OnStartup(Entity* self) {
self->SetVar(u"ConsoleLEFTActive", false);
self->SetVar(u"ConsoleRIGHTtActive", false);
}
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];
if (name == "ConsoleLeftUp") {
GameMessages::SendStopFXEffect(self, true, "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2775, u"create", "LeftPipeEnergy");
} else if (name == "ConsoleLeftDown") {
self->SetVar(u"ConsoleLEFTActive", false);
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendStopFXEffect(self, true, "LeftPipeOn");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2774, u"create", "LeftPipeOff");
} else if (name == "ConsoleLeftActive") {
self->SetVar(u"ConsoleLEFTActive", true);
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2776, u"create", "LeftPipeOn");
}
else if (name == "ConsoleRightUp") {
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2778, u"create", "RightPipeEnergy");
} else if (name == "ConsoleRightDown") {
self->SetVar(u"ConsoleRIGHTActive", false);
GameMessages::SendStopFXEffect(self, true, "RightPipeEnergy");
GameMessages::SendStopFXEffect(self, true, "RightPipeOn");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2777, u"create", "RightPipeOff");
} else if (name == "ConsoleRightActive") {
self->SetVar(u"ConsoleRIGHTActive", true);
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2779, u"create", "RightPipeEnergy");
}
if (self->GetVar<bool>(u"ConsoleLEFTActive") && self->GetVar<bool>(u"ConsoleRIGHTActive")) {
auto* object = EntityManager::Instance()->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];
if (object != nullptr) {
object->Smash(self->GetObjectID(), SILENT);
}
canisterSpawner->Reset();
canisterSpawner->Deactivate();
} else if (self->GetVar<bool>(u"ConsoleLEFTActive") || self->GetVar<bool>(u"ConsoleRIGHTActive")) {
brickSpawner->Activate();
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
if (object != nullptr) {
GameMessages::SendStopFXEffect(object, true, "bluebrick");
}
bugSpawner->Reset();
bugSpawner->Deactivate();
canisterSpawner->Reset();
canisterSpawner->Activate();
} else {
brickSpawner->Reset();
brickSpawner->Deactivate();
bugSpawner->Reset();
bugSpawner->Activate();
}
}
void FvFacilityBrick::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) {
if (args != "PlayFX") {
return;
}
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2774, u"create", "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2777, u"create", "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2750, u"create", "imagination_canister");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2751, u"create", "canister_light_filler");
}

View File

@@ -0,0 +1,11 @@
#pragma once
#include "CppScripts.h"
class FvFacilityBrick : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) override;
};

View File

@@ -0,0 +1,10 @@
#include "FvFacilityPipes.h"
#include "GameMessages.h"
void FvFacilityPipes::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
if (args == "startFX") {
GameMessages::SendPlayFXEffect(self->GetObjectID(), m_LeftPipeEffectID, m_EffectType, m_LeftPipeEffectName);
GameMessages::SendPlayFXEffect(self->GetObjectID(), m_RightPipeEffectID, m_EffectType, m_RightPipeEffectName);
GameMessages::SendPlayFXEffect(self->GetObjectID(), m_ImaginationCanisterEffectID, m_EffectType, m_ImaginationCanisterEffectName);
}
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "CppScripts.h"
class FvFacilityPipes : public CppScripts::Script {
public:
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
private:
const std::u16string m_EffectType = u"create";
const std::string m_LeftPipeEffectName = "LeftPipeOff";
const int32_t m_LeftPipeEffectID = 2774;
const std::string m_RightPipeEffectName = "RightPipeOff";
const int32_t m_RightPipeEffectID = 2777;
const std::string m_ImaginationCanisterEffectName = "imagination_canister";
const int32_t m_ImaginationCanisterEffectID = 2750;
};

View File

@@ -0,0 +1,107 @@
#include "FvFlyingCreviceDragon.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "SkillComponent.h"
#include "GeneralUtils.h"
void FvFlyingCreviceDragon::OnStartup(Entity* self) {
self->AddTimer("waypoint", 5);
}
void FvFlyingCreviceDragon::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "waypoint") {
auto point = self->GetVar<int32_t>(u"waypoint");
if (point >= 20) {
point = 0;
}
self->SetVar<int32_t>(u"waypoint", point + 1);
self->AddTimer("waypoint", 5);
OnArrived(self);
return;
}
std::string groupName = "";
if (timerName == "platform1attack") {
groupName = "dragonFireballs1";
} else if (timerName == "platform3attack") {
groupName = "dragonFireballs3";
}
const auto& group = EntityManager::Instance()->GetEntitiesInGroup(groupName);
if (group.empty()) {
return;
}
auto* skillComponent = group[0]->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY, true);
}
auto minionCount = 1;
for (size_t i = 1; i < group.size(); i++) {
if (minionCount == 4) {
return;
}
if (/*GeneralUtils::GenerateRandomNumber<int32_t>(1, 5) > 3*/ true) {
skillComponent = group[i]->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY);
++minionCount;
}
}
}
}
void FvFlyingCreviceDragon::OnArrived(Entity* self) {
auto point = self->GetVar<int32_t>(u"waypoint");
if (point == 4) {
GameMessages::SendPlayAnimation(self, u"attack1", 2);
self->AddTimer("platform1attack", 1.75f);
} else if (point == 12) {
GameMessages::SendPlayAnimation(self, u"attack2", 2);
const auto& group2 = EntityManager::Instance()->GetEntitiesInGroup("dragonFireballs2");
if (group2.empty()) {
return;
}
auto* skillComponent = group2[0]->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY);
}
auto minionCount = 1;
for (size_t i = 1; i < group2.size(); i++) {
if (minionCount == 4) {
return;
}
if (GeneralUtils::GenerateRandomNumber<int32_t>(1, 5) > 3) {
skillComponent = group2[i]->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY, true);
++minionCount;
}
}
}
} else if (point == 16) {
GameMessages::SendPlayAnimation(self, u"attack3", 2);
self->AddTimer("platform3attack", 0.5f);
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class FvFlyingCreviceDragon : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
void OnArrived(Entity* self);
};

View File

@@ -0,0 +1,42 @@
#include "FvFreeGfNinjas.h"
#include "Character.h"
#include "MissionComponent.h"
void FvFreeGfNinjas::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
if (missionID == 705 && missionState == MissionState::MISSION_STATE_AVAILABLE) {
auto* missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent == nullptr)
return;
missionComponent->AcceptMission(701);
missionComponent->AcceptMission(702);
missionComponent->AcceptMission(703);
missionComponent->AcceptMission(704);
auto* character = target->GetCharacter();
if (character != nullptr)
character->SetPlayerFlag(68, true);
} else if (missionID == 786) {
auto* character = target->GetCharacter();
if (character != nullptr)
character->SetPlayerFlag(81, true);
}
}
void FvFreeGfNinjas::OnUse(Entity* self, Entity* user) {
// To allow player who already have the mission to progress.
auto* missionComponent = user->GetComponent<MissionComponent>();
if (missionComponent == nullptr)
return;
if (missionComponent->GetMissionState(705) == MissionState::MISSION_STATE_ACTIVE) {
auto* character = user->GetCharacter();
if (character != nullptr)
character->SetPlayerFlag(68, true);
missionComponent->AcceptMission(701, true);
missionComponent->AcceptMission(702, true);
missionComponent->AcceptMission(703, true);
missionComponent->AcceptMission(704, true);
}
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include "CppScripts.h"
class FvFreeGfNinjas : public CppScripts::Script {
public:
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -0,0 +1,18 @@
#include "FvMaelstromGeyser.h"
#include "SkillComponent.h"
void FvMaelstromGeyser::OnStartup(Entity* self) {
self->AddTimer(m_StartSkillTimerName, m_StartSkillTimerTime);
self->AddTimer(m_KillSelfTimerName, m_KillSelfTimerTime);
}
void FvMaelstromGeyser::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == m_StartSkillTimerName) {
auto* skillComponent = self->GetComponent<SkillComponent>();
skillComponent->CalculateBehavior(m_SkillID, m_BehaviorID, LWOOBJID_EMPTY, true);
}
if (timerName == m_KillSelfTimerName) {
self->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "CppScripts.h"
class FvMaelstromGeyser final : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
const std::string m_StartSkillTimerName = "startSkill";
const float m_StartSkillTimerTime = 2.0;
const std::string m_KillSelfTimerName = "killSelf";
const float m_KillSelfTimerTime = 5.5;
const uint32_t m_SkillID = 831;
const uint32_t m_BehaviorID = 15500;
};

View File

@@ -0,0 +1,42 @@
#include "FvNinjaGuard.h"
#include "GameMessages.h"
#include "MissionComponent.h"
void FvNinjaGuard::OnStartup(Entity* self) {
if (self->GetLOT() == 7412) {
m_LeftGuard = self->GetObjectID();
} else if (self->GetLOT() == 11128) {
m_RightGuard = self->GetObjectID();
}
}
void FvNinjaGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* target) {
if (emote != 392) {
GameMessages::SendPlayAnimation(self, u"no");
return;
}
GameMessages::SendPlayAnimation(self, u"scared");
auto* missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent != nullptr && missionComponent->HasMission(737)) {
missionComponent->ForceProgressTaskType(737, 5, 1, false);
}
if (self->GetLOT() == 7412) {
auto* rightGuard = EntityManager::Instance()->GetEntity(m_RightGuard);
if (rightGuard != nullptr) {
GameMessages::SendPlayAnimation(rightGuard, u"laugh_rt");
}
} else if (self->GetLOT() == 11128) {
auto* leftGuard = EntityManager::Instance()->GetEntity(m_LeftGuard);
if (leftGuard != nullptr) {
GameMessages::SendPlayAnimation(leftGuard, u"laugh_lt");
}
}
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "CppScripts.h"
class FvNinjaGuard final : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnEmoteReceived(Entity* self, int32_t emote, Entity* target) override;
private:
LWOOBJID m_LeftGuard;
LWOOBJID m_RightGuard;
};

View File

@@ -0,0 +1,35 @@
#include "FvPandaServer.h"
#include "PetComponent.h"
#include "Character.h"
void FvPandaServer::OnStartup(Entity* self) {
const auto* petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
self->SetNetworkVar<std::string>(u"pandatamer", std::to_string(self->GetVar<LWOOBJID>(u"tamer")));
self->AddTimer("killSelf", 45);
}
}
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) {
if (type == NOTIFY_TYPE_BEGIN) {
self->CancelAllTimers();
} else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) {
self->Smash();
} else if (type == NOTIFY_TYPE_SUCCESS) {
// TODO: Remove from groups
auto* character = tamer->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(82, true);
}
}
}
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);
}
}
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include "CppScripts.h"
class FvPandaServer : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};

View File

@@ -0,0 +1,48 @@
#include "FvPandaSpawnerServer.h"
#include "Character.h"
#include "EntityManager.h"
#include "GameMessages.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");
if (raceObjects.empty())
return;
// Check if the player is currently in a footrace
auto* scriptedActivityComponent = raceObjects.at(0)->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent == nullptr || !scriptedActivityComponent->IsPlayedBy(target))
return;
// If the player already spawned a panda
auto playerPandas = EntityManager::Instance()->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
if (!playerPandas.empty()) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"playerPanda",
target->GetObjectID(), 0, 0, target->GetObjectID());
return;
}
// If there's already too many spawned pandas
auto pandas = EntityManager::Instance()->GetEntitiesInGroup("pandas");
if (pandas.size() > 4) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"tooManyPandas",
target->GetObjectID(), 0, 0, target->GetObjectID());
return;
}
EntityInfo info{};
info.spawnerID = target->GetObjectID();
info.pos = self->GetPosition();
info.lot = 5643;
info.settings = {
new LDFData<LWOOBJID>(u"tamer", target->GetObjectID()),
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);
}
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "CppScripts.h"
class FvPandaSpawnerServer : public CppScripts::Script {
void OnCollisionPhantom(Entity* self, Entity* target) override;
};

View File

@@ -0,0 +1,18 @@
#include "FvPassThroughWall.h"
#include "InventoryComponent.h"
#include "MissionComponent.h"
void FvPassThroughWall::OnCollisionPhantom(Entity* self, Entity* target) {
auto missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return;
//Because at the moment we do not have an ItemComponent component, we check to make sure a Maelstrom-Infused hood is equipped. There are only three in the game right now.
auto inventoryComponent = target->GetComponent<InventoryComponent>();
// If no inventory component is found then abort.
if (inventoryComponent == nullptr) return;
// If no Maelstrom hoods are equipped then abort.
if (!inventoryComponent->IsEquipped(WhiteMaelstromHood) && !inventoryComponent->IsEquipped(BlackMaelstromHood) && !inventoryComponent->IsEquipped(RedMaelstromHood)) return;
// Progress mission Friend of the Ninja since all prerequisites are met.
missionComponent->ForceProgress(friendOfTheNinjaMissionId, friendOfTheNinjaMissionUid, 1);
}

View File

@@ -0,0 +1,34 @@
#pragma once
#include "CppScripts.h"
class FvPassThroughWall : public CppScripts::Script
{
/**
* @brief This method is called when there is a collision with self from target.
*
* @param self The Entity that called this method.
* @param target The Entity that self is targetting.
*/
void OnCollisionPhantom(Entity* self, Entity* target) override;
private:
/**
* Mission ID for Friend of the Ninjas.
*/
int32_t friendOfTheNinjaMissionId = 848;
/**
* Mission UID for Friend of the Ninjas.
*/
int32_t friendOfTheNinjaMissionUid = 1221;
/**
* Item LOT for Maelstrom-Infused White Ninja Hood
*/
int32_t WhiteMaelstromHood = 2641;
/**
* Item LOT for Maelstrom-Infused Black Ninja Hood
*/
int32_t BlackMaelstromHood = 2642;
/**
* Item LOT for Red Ninja Hood - Maelstrom Infused
*/
int32_t RedMaelstromHood = 1889;
};