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:
39
dScripts/ai/PROPERTY/AG/AgPropGuard.cpp
Normal file
39
dScripts/ai/PROPERTY/AG/AgPropGuard.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "AgPropGuard.h"
|
||||
#include "Entity.h"
|
||||
#include "Character.h"
|
||||
#include "EntityManager.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "Item.h"
|
||||
|
||||
void AgPropGuard::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
|
||||
auto* character = target->GetCharacter();
|
||||
auto* missionComponent = target->GetComponent<MissionComponent>();
|
||||
auto* inventoryComponent = target->GetComponent<InventoryComponent>();
|
||||
|
||||
const auto state = missionComponent->GetMissionState(320);
|
||||
if (missionID == 768 && missionState == MissionState::MISSION_STATE_AVAILABLE) {
|
||||
if (!character->GetPlayerFlag(71)) {
|
||||
// TODO: Cinematic "MissionCam"
|
||||
}
|
||||
} else if (missionID == 768 && missionState >= MissionState::MISSION_STATE_READY_TO_COMPLETE) {
|
||||
//remove the inventory items
|
||||
for (int item : gearSets) {
|
||||
auto* id = inventoryComponent->FindItemByLot(item);
|
||||
|
||||
if (id) {
|
||||
inventoryComponent->UnEquipItem(id);
|
||||
inventoryComponent->RemoveItem(id->GetLot(), id->GetCount());
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
(missionID == 320 && state == MissionState::MISSION_STATE_AVAILABLE) /*||
|
||||
(state == MissionState::MISSION_STATE_COMPLETE && missionID == 891 && missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE)*/
|
||||
) {
|
||||
//GameMessages::SendNotifyClientObject(EntityManager::Instance()->GetZoneControlEntity()->GetObjectID(), u"GuardChat", target->GetObjectID(), 0, target->GetObjectID(), "", target->GetSystemAddress());
|
||||
|
||||
target->GetCharacter()->SetPlayerFlag(113, true);
|
||||
|
||||
EntityManager::Instance()->GetZoneControlEntity()->AddTimer("GuardFlyAway", 1.0f);
|
||||
}
|
||||
}
|
11
dScripts/ai/PROPERTY/AG/AgPropGuard.h
Normal file
11
dScripts/ai/PROPERTY/AG/AgPropGuard.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class AgPropGuard final : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
|
||||
|
||||
private:
|
||||
std::vector<int> gearSets = { 14359,14321,14353,14315 };
|
||||
};
|
3
dScripts/ai/PROPERTY/AG/CMakeLists.txt
Normal file
3
dScripts/ai/PROPERTY/AG/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
set(DSCRIPTS_SOURCES_AI_PROPERTY_AG
|
||||
"AgPropGuard.cpp"
|
||||
PARENT_SCOPE)
|
56
dScripts/ai/PROPERTY/AgPropguards.cpp
Normal file
56
dScripts/ai/PROPERTY/AgPropguards.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "AgPropguards.h"
|
||||
#include "Character.h"
|
||||
#include "GameMessages.h"
|
||||
#include "EntityManager.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
|
||||
auto* character = target->GetCharacter();
|
||||
if (character == nullptr)
|
||||
return;
|
||||
|
||||
const auto flag = GetFlagForMission(missionID);
|
||||
if (flag == 0)
|
||||
return;
|
||||
|
||||
if ((missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_ACTIVE)
|
||||
&& !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 == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) {
|
||||
// Makes the guard disappear once the mission has been completed
|
||||
const auto zoneControlID = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
|
||||
GameMessages::SendNotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(),
|
||||
"", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
self->AddCallbackTimer(5.0f, [self]() {
|
||||
auto spawnerName = self->GetVar<std::string>(u"spawner_name");
|
||||
if (spawnerName.empty())
|
||||
spawnerName = "Guard";
|
||||
|
||||
auto spawners = dZoneManager::Instance()->GetSpawnersByName(spawnerName);
|
||||
for (auto* spawner : spawners) {
|
||||
spawner->Deactivate();
|
||||
}
|
||||
|
||||
self->Smash();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AgPropguards::GetFlagForMission(uint32_t missionID) {
|
||||
switch (missionID) {
|
||||
case 872:
|
||||
return 97;
|
||||
case 873:
|
||||
return 98;
|
||||
case 874:
|
||||
return 99;
|
||||
case 1293:
|
||||
return 118;
|
||||
case 1322:
|
||||
return 122;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
8
dScripts/ai/PROPERTY/AgPropguards.h
Normal file
8
dScripts/ai/PROPERTY/AgPropguards.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class AgPropguards : public CppScripts::Script {
|
||||
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
|
||||
private:
|
||||
static uint32_t GetFlagForMission(uint32_t missionID);
|
||||
};
|
11
dScripts/ai/PROPERTY/CMakeLists.txt
Normal file
11
dScripts/ai/PROPERTY/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
set(DSCRIPTS_SOURCES_AI_PROPERTY
|
||||
"AgPropguards.cpp"
|
||||
"PropertyFXDamage.cpp")
|
||||
|
||||
add_subdirectory(AG)
|
||||
|
||||
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)
|
18
dScripts/ai/PROPERTY/PropertyFXDamage.cpp
Normal file
18
dScripts/ai/PROPERTY/PropertyFXDamage.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "PropertyFXDamage.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
|
||||
void PropertyFXDamage::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (target == nullptr)
|
||||
return;
|
||||
|
||||
auto* skills = self->GetComponent<SkillComponent>();
|
||||
auto* targetStats = target->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (skills != nullptr && targetStats != nullptr) {
|
||||
auto targetFactions = targetStats->GetFactionIDs();
|
||||
if (std::find(targetFactions.begin(), targetFactions.end(), 1) != targetFactions.end()) {
|
||||
skills->CalculateBehavior(11386, 692, target->GetObjectID());
|
||||
}
|
||||
}
|
||||
}
|
6
dScripts/ai/PROPERTY/PropertyFXDamage.h
Normal file
6
dScripts/ai/PROPERTY/PropertyFXDamage.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class PropertyFXDamage : public CppScripts::Script {
|
||||
void OnCollisionPhantom(Entity* self, Entity* target) override;
|
||||
};
|
Reference in New Issue
Block a user