mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
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:
14
dScripts/ai/GF/CMakeLists.txt
Normal file
14
dScripts/ai/GF/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
set(DSCRIPTS_SOURCES_AI_GF
|
||||
"GfCampfire.cpp"
|
||||
"GfOrgan.cpp"
|
||||
"GfBanana.cpp"
|
||||
"GfBananaCluster.cpp"
|
||||
"GfJailkeepMission.cpp"
|
||||
"TriggerAmbush.cpp"
|
||||
"GfJailWalls.cpp"
|
||||
"PetDigBuild.cpp"
|
||||
"GfArchway.cpp"
|
||||
"GfMaelstromGeyser.cpp"
|
||||
"PirateRep.cpp"
|
||||
"GfParrotCrash.cpp"
|
||||
PARENT_SCOPE)
|
8
dScripts/ai/GF/GfArchway.cpp
Normal file
8
dScripts/ai/GF/GfArchway.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "GfArchway.h"
|
||||
#include "Entity.h"
|
||||
#include "SkillComponent.h"
|
||||
|
||||
void GfArchway::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
auto* skillComponent = target->GetComponent<SkillComponent>();
|
||||
if (skillComponent) skillComponent->CalculateBehavior(SHIELDING_SKILL, SHIELDING_BEHAVIOR, target->GetObjectID(), true);
|
||||
}
|
10
dScripts/ai/GF/GfArchway.h
Normal file
10
dScripts/ai/GF/GfArchway.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfArchway : public CppScripts::Script {
|
||||
public:
|
||||
void OnRebuildComplete(Entity* self, Entity* target) override;
|
||||
private:
|
||||
const uint32_t SHIELDING_SKILL = 863;
|
||||
const uint32_t SHIELDING_BEHAVIOR = 3788;
|
||||
};
|
93
dScripts/ai/GF/GfBanana.cpp
Normal file
93
dScripts/ai/GF/GfBanana.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#include "GfBanana.h"
|
||||
|
||||
#include "Entity.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
void GfBanana::SpawnBanana(Entity* self) {
|
||||
auto position = self->GetPosition();
|
||||
const auto rotation = self->GetRotation();
|
||||
|
||||
position.y += 12;
|
||||
position.x -= rotation.GetRightVector().x * 5;
|
||||
position.z -= rotation.GetRightVector().z * 5;
|
||||
|
||||
EntityInfo info{};
|
||||
|
||||
info.pos = position;
|
||||
info.rot = rotation;
|
||||
info.lot = 6909;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
|
||||
self->SetVar(u"banana", entity->GetObjectID());
|
||||
|
||||
entity->AddDieCallback([self]() {
|
||||
self->SetVar(u"banana", LWOOBJID_EMPTY);
|
||||
|
||||
self->AddTimer("bananaTimer", 30);
|
||||
});
|
||||
}
|
||||
|
||||
void GfBanana::OnStartup(Entity* self) {
|
||||
SpawnBanana(self);
|
||||
}
|
||||
|
||||
void GfBanana::OnHit(Entity* self, Entity* attacker) {
|
||||
auto* destroyable = self->GetComponent<DestroyableComponent>();
|
||||
|
||||
destroyable->SetHealth(9999);
|
||||
|
||||
const auto bananaId = self->GetVar<LWOOBJID>(u"banana");
|
||||
|
||||
if (bananaId == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* bananaEntity = EntityManager::Instance()->GetEntity(bananaId);
|
||||
|
||||
if (bananaEntity == nullptr) {
|
||||
self->SetVar(u"banana", LWOOBJID_EMPTY);
|
||||
|
||||
self->AddTimer("bananaTimer", 30);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3::UNIT_Y * 8);
|
||||
|
||||
auto* bananaDestroyable = bananaEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
bananaDestroyable->SetHealth(0);
|
||||
|
||||
bananaDestroyable->Smash(attacker->GetObjectID());
|
||||
|
||||
/*
|
||||
auto position = self->GetPosition();
|
||||
const auto rotation = self->GetRotation();
|
||||
|
||||
position.y += 12;
|
||||
position.x -= rotation.GetRightVector().x * 5;
|
||||
position.z -= rotation.GetRightVector().z * 5;
|
||||
|
||||
EntityInfo info {};
|
||||
|
||||
info.pos = position;
|
||||
info.rot = rotation;
|
||||
info.lot = 6718;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(entity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
*/
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
}
|
||||
|
||||
void GfBanana::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "bananaTimer") {
|
||||
SpawnBanana(self);
|
||||
}
|
||||
}
|
14
dScripts/ai/GF/GfBanana.h
Normal file
14
dScripts/ai/GF/GfBanana.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfBanana final : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void SpawnBanana(Entity* self);
|
||||
|
||||
void OnStartup(Entity* self) override;
|
||||
|
||||
void OnHit(Entity* self, Entity* attacker) override;
|
||||
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
12
dScripts/ai/GF/GfBananaCluster.cpp
Normal file
12
dScripts/ai/GF/GfBananaCluster.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "GfBananaCluster.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void GfBananaCluster::OnStartup(Entity* self) {
|
||||
self->AddTimer("startup", 100);
|
||||
}
|
||||
|
||||
void GfBananaCluster::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "startup") {
|
||||
self->ScheduleKillAfterUpdate(nullptr);
|
||||
}
|
||||
}
|
10
dScripts/ai/GF/GfBananaCluster.h
Normal file
10
dScripts/ai/GF/GfBananaCluster.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfBananaCluster final : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
100
dScripts/ai/GF/GfCampfire.cpp
Normal file
100
dScripts/ai/GF/GfCampfire.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "GfCampfire.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
void GfCampfire::OnStartup(Entity* self) {
|
||||
self->SetI32(u"counter", static_cast<int32_t>(0));
|
||||
self->SetProximityRadius(2.0f, "placeholder");
|
||||
self->SetBoolean(u"isBurning", true);
|
||||
|
||||
auto* render = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
if (render == nullptr)
|
||||
return;
|
||||
|
||||
render->PlayEffect(295, u"running", "Burn");
|
||||
}
|
||||
|
||||
void GfCampfire::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) {
|
||||
if (args == "physicsReady") {
|
||||
auto* render = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
|
||||
render->PlayEffect(295, u"running", "Burn");
|
||||
}
|
||||
}
|
||||
|
||||
void GfCampfire::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
auto* skill = self->GetComponent<SkillComponent>();
|
||||
|
||||
if (self->GetBoolean(u"isBurning")) {
|
||||
if (status == "ENTER") {
|
||||
if (entering->GetCharacter()) {
|
||||
int32_t counter = self->GetI32(u"counter");
|
||||
counter = counter + 1;
|
||||
self->SetI32(u"counter", counter);
|
||||
|
||||
if (counter == 1) {
|
||||
skill->CalculateBehavior(m_skillCastId, 115, entering->GetObjectID());
|
||||
self->AddTimer("TimeBetweenCast", FIRE_COOLDOWN);
|
||||
|
||||
//self->SetVar<LWOOBJID>("target", entering->GetObjectID());
|
||||
|
||||
auto* missionComponet = entering->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponet != nullptr) {
|
||||
missionComponet->ForceProgress(440, 658, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int32_t counter = self->GetI32(u"counter");
|
||||
if (counter > 0) {
|
||||
counter = counter - 1;
|
||||
self->SetI32(u"counter", counter);
|
||||
if (counter == 0) {
|
||||
self->CancelAllTimers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GfCampfire::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
|
||||
if (message == "waterspray" && self->GetVar<bool>(u"isBurning")) {
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
if (renderComponent != nullptr) {
|
||||
renderComponent->StopEffect("Burn");
|
||||
renderComponent->PlayEffect(295, u"idle", "Off");
|
||||
|
||||
self->SetVar<bool>(u"isBurning", false);
|
||||
self->AddTimer("FireRestart", 37);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GfCampfire::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "TimeBetweenCast") {
|
||||
/*
|
||||
self->AddTimer("TimeBetweenCast", FIRE_COOLDOWN);
|
||||
|
||||
const auto targetId = self->GetVar<LWOOBJID>("target");
|
||||
|
||||
auto* entering = EntityManager::Instance()->GetEntity(targetId);
|
||||
|
||||
if (entering == nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
} else if (timerName == "FireRestart" && !self->GetVar<bool>(u"isBurning")) {
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
if (renderComponent != nullptr) {
|
||||
renderComponent->StopEffect("Off");
|
||||
renderComponent->PlayEffect(295, u"running", "Burn");
|
||||
self->SetVar<bool>(u"isBurning", true);
|
||||
}
|
||||
}
|
||||
}
|
16
dScripts/ai/GF/GfCampfire.h
Normal file
16
dScripts/ai/GF/GfCampfire.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfCampfire : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) override;
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
void OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) override;
|
||||
private:
|
||||
int32_t m_skillCastId = 43;
|
||||
int32_t FIRE_COOLDOWN = 2;
|
||||
};
|
29
dScripts/ai/GF/GfJailWalls.cpp
Normal file
29
dScripts/ai/GF/GfJailWalls.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "GfJailWalls.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Wall"));
|
||||
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName("Jail0" + wall)) {
|
||||
spawner->Deactivate();
|
||||
}
|
||||
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName("JailCaptain0" + wall)) {
|
||||
spawner->Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void GfJailWalls::OnRebuildNotifyState(Entity* self, eRebuildState state) {
|
||||
if (state != eRebuildState::REBUILD_RESETTING) return;
|
||||
|
||||
const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Wall"));
|
||||
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName("Jail0" + wall)) {
|
||||
spawner->Activate();
|
||||
}
|
||||
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName("JailCaptain0" + wall)) {
|
||||
spawner->Activate();
|
||||
}
|
||||
}
|
9
dScripts/ai/GF/GfJailWalls.h
Normal file
9
dScripts/ai/GF/GfJailWalls.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfJailWalls final : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnRebuildComplete(Entity* self, Entity* target) override;
|
||||
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
|
||||
};
|
38
dScripts/ai/GF/GfJailkeepMission.cpp
Normal file
38
dScripts/ai/GF/GfJailkeepMission.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "GfJailkeepMission.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "Character.h"
|
||||
|
||||
void GfJailkeepMission::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
|
||||
auto* missionComponent = target->GetComponent<MissionComponent>();
|
||||
if (missionComponent == nullptr)
|
||||
return;
|
||||
|
||||
if (missionID == 385 && missionState == MissionState::MISSION_STATE_AVAILABLE) {
|
||||
missionComponent->AcceptMission(386, true);
|
||||
missionComponent->AcceptMission(387, true);
|
||||
missionComponent->AcceptMission(388, true);
|
||||
missionComponent->AcceptMission(390, true);
|
||||
} else if (missionID == 385 && missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) {
|
||||
auto* character = target->GetCharacter();
|
||||
if (character != nullptr && character->GetPlayerFlag(68)) {
|
||||
missionComponent->AcceptMission(701);
|
||||
missionComponent->AcceptMission(702);
|
||||
missionComponent->AcceptMission(703);
|
||||
missionComponent->AcceptMission(704);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GfJailkeepMission::OnUse(Entity* self, Entity* user) {
|
||||
auto* missionComponent = user->GetComponent<MissionComponent>();
|
||||
if (missionComponent == nullptr)
|
||||
return;
|
||||
|
||||
if (missionComponent->GetMissionState(385) == MissionState::MISSION_STATE_ACTIVE) {
|
||||
missionComponent->AcceptMission(386, true);
|
||||
missionComponent->AcceptMission(387, true);
|
||||
missionComponent->AcceptMission(388, true);
|
||||
missionComponent->AcceptMission(390, true);
|
||||
}
|
||||
}
|
||||
|
9
dScripts/ai/GF/GfJailkeepMission.h
Normal file
9
dScripts/ai/GF/GfJailkeepMission.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfJailkeepMission final : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
|
||||
};
|
18
dScripts/ai/GF/GfMaelstromGeyser.cpp
Normal file
18
dScripts/ai/GF/GfMaelstromGeyser.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "GfMaelstromGeyser.h"
|
||||
#include "SkillComponent.h"
|
||||
|
||||
void GfMaelstromGeyser::OnStartup(Entity* self) {
|
||||
self->AddTimer(m_StartSkillTimerName, m_StartSkillTimerTime);
|
||||
self->AddTimer(m_KillSelfTimerName, m_KillSelfTimerTime);
|
||||
}
|
||||
|
||||
void GfMaelstromGeyser::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);
|
||||
}
|
||||
}
|
||||
|
17
dScripts/ai/GF/GfMaelstromGeyser.h
Normal file
17
dScripts/ai/GF/GfMaelstromGeyser.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfMaelstromGeyser 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 = 7.5;
|
||||
const uint32_t m_SkillID = 607;
|
||||
const uint32_t m_BehaviorID = 10500;
|
||||
};
|
21
dScripts/ai/GF/GfOrgan.cpp
Normal file
21
dScripts/ai/GF/GfOrgan.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "GfOrgan.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
void GfOrgan::OnUse(Entity* self, Entity* user) {
|
||||
if (self->GetBoolean(u"bIsInUse")) {
|
||||
m_canUse = false;
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, "{15d5f8bd-139a-4c31-8904-970c480cd70f}");
|
||||
self->SetBoolean(u"bIsInUse", true);
|
||||
self->AddTimer("reset", 5.0f);
|
||||
|
||||
GameMessages::SendPlayAnimation(user, u"jig");
|
||||
}
|
||||
|
||||
void GfOrgan::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "reset") {
|
||||
self->SetBoolean(u"bIsInUse", false);
|
||||
}
|
||||
}
|
11
dScripts/ai/GF/GfOrgan.h
Normal file
11
dScripts/ai/GF/GfOrgan.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfOrgan : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnUse(Entity* self, Entity* user);
|
||||
void OnTimerDone(Entity* self, std::string timerName);
|
||||
private:
|
||||
bool m_canUse;
|
||||
};
|
13
dScripts/ai/GF/GfParrotCrash.cpp
Normal file
13
dScripts/ai/GF/GfParrotCrash.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "GfParrotCrash.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "Entity.h"
|
||||
#include "dLogger.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>();
|
||||
if (args == "Slow") {
|
||||
skillComponent->CalculateBehavior(m_SlowSkillID, m_SlowBehaviorID, sender->GetObjectID());
|
||||
} else if (args == "Unslow") {
|
||||
skillComponent->CalculateBehavior(m_UnslowSkillID, m_UnslowBehaviorID, sender->GetObjectID());
|
||||
}
|
||||
}
|
13
dScripts/ai/GF/GfParrotCrash.h
Normal file
13
dScripts/ai/GF/GfParrotCrash.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfParrotCrash : 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 uint32_t m_SlowSkillID = 795;
|
||||
const uint32_t m_SlowBehaviorID = 14214;
|
||||
const uint32_t m_UnslowSkillID = 796;
|
||||
const uint32_t m_UnslowBehaviorID = 14215;
|
||||
};
|
||||
|
49
dScripts/ai/GF/PetDigBuild.cpp
Normal file
49
dScripts/ai/GF/PetDigBuild.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "PetDigBuild.h"
|
||||
#include "EntityManager.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
void PetDigBuild::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
auto flagNumber = self->GetVar<std::u16string>(u"flagNum");
|
||||
|
||||
EntityInfo info{};
|
||||
auto pos = self->GetPosition();
|
||||
pos.SetY(pos.GetY() + 0.5f);
|
||||
info.pos = pos;
|
||||
info.rot = self->GetRotation();
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
info.settings = {
|
||||
new LDFData<LWOOBJID>(u"builder", target->GetObjectID()),
|
||||
new LDFData<LWOOBJID>(u"X", self->GetObjectID())
|
||||
};
|
||||
|
||||
if (!flagNumber.empty()) {
|
||||
info.lot = 7410; // Normal GF treasure
|
||||
info.settings.push_back(new LDFData<std::u16string>(u"groupID", u"Flag" + flagNumber));
|
||||
} else {
|
||||
auto* missionComponent = target->GetComponent<MissionComponent>();
|
||||
if (missionComponent != nullptr && missionComponent->GetMissionState(746) == MissionState::MISSION_STATE_ACTIVE) {
|
||||
info.lot = 9307; // Special Captain Jack treasure that drops a mission item
|
||||
} else {
|
||||
info.lot = 3495; // Normal AG treasure
|
||||
}
|
||||
}
|
||||
|
||||
auto* treasure = EntityManager::Instance()->CreateEntity(info);
|
||||
EntityManager::Instance()->ConstructEntity(treasure);
|
||||
self->SetVar<LWOOBJID>(u"chestObj", treasure->GetObjectID());
|
||||
}
|
||||
|
||||
void PetDigBuild::OnDie(Entity* self, Entity* killer) {
|
||||
auto treasureID = self->GetVar<LWOOBJID>(u"chestObj");
|
||||
if (treasureID == LWOOBJID_EMPTY)
|
||||
return;
|
||||
|
||||
auto treasure = EntityManager::Instance()->GetEntity(treasureID);
|
||||
if (treasure == nullptr)
|
||||
return;
|
||||
|
||||
// If the quick build expired and the treasure was not collected, hide the treasure
|
||||
if (!treasure->GetIsDead()) {
|
||||
treasure->Smash(self->GetObjectID(), SILENT);
|
||||
}
|
||||
}
|
9
dScripts/ai/GF/PetDigBuild.h
Normal file
9
dScripts/ai/GF/PetDigBuild.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class PetDigBuild : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnRebuildComplete(Entity* self, Entity* target);
|
||||
void OnDie(Entity* self, Entity* killer);
|
||||
};
|
11
dScripts/ai/GF/PirateRep.cpp
Normal file
11
dScripts/ai/GF/PirateRep.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "PirateRep.h"
|
||||
#include "Character.h"
|
||||
|
||||
void PirateRep::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
|
||||
if (missionID == m_PirateRepMissionID && missionState >= MissionState::MISSION_STATE_READY_TO_COMPLETE) {
|
||||
auto* character = target->GetCharacter();
|
||||
if (character) {
|
||||
character->SetPlayerFlag(ePlayerFlags::GF_PIRATE_REP, true);
|
||||
}
|
||||
}
|
||||
}
|
9
dScripts/ai/GF/PirateRep.h
Normal file
9
dScripts/ai/GF/PirateRep.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class PirateRep : public CppScripts::Script {
|
||||
public:
|
||||
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
|
||||
private:
|
||||
const int m_PirateRepMissionID = 301;
|
||||
};
|
37
dScripts/ai/GF/TriggerAmbush.cpp
Normal file
37
dScripts/ai/GF/TriggerAmbush.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "TriggerAmbush.h"
|
||||
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void TriggerAmbush::OnStartup(Entity* self) {
|
||||
self->SetProximityRadius(20, "ambush");
|
||||
}
|
||||
|
||||
void TriggerAmbush::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
if (name != "ambush" || status != "ENTER" || !entering->IsPlayer()) return;
|
||||
|
||||
if (self->GetVar<bool>(u"triggered")) return;
|
||||
|
||||
self->SetVar(u"triggered", true);
|
||||
|
||||
const auto spawners = dZoneManager::Instance()->GetSpawnersByName("Ambush");
|
||||
|
||||
for (auto* spawner : spawners) {
|
||||
spawner->Activate();
|
||||
}
|
||||
|
||||
self->AddTimer("TriggeredTimer", 45);
|
||||
}
|
||||
|
||||
void TriggerAmbush::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName != "TriggeredTimer") return;
|
||||
|
||||
self->SetVar(u"triggered", false);
|
||||
|
||||
const auto spawners = dZoneManager::Instance()->GetSpawnersByName("Ambush");
|
||||
|
||||
for (auto* spawner : spawners) {
|
||||
spawner->Reset();
|
||||
|
||||
spawner->Deactivate();
|
||||
}
|
||||
}
|
12
dScripts/ai/GF/TriggerAmbush.h
Normal file
12
dScripts/ai/GF/TriggerAmbush.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class TriggerAmbush : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
Reference in New Issue
Block a user