DarkflameServer/dScripts/NtDirtCloudServer.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

#include "NtDirtCloudServer.h"
#include "MissionComponent.h"
2022-07-28 13:39:57 +00:00
std::map<std::string, std::vector<int32_t>> NtDirtCloudServer::m_Missions =
{
2022-07-28 13:39:57 +00:00
{"Dirt_Clouds_Sent", {1333,1253}},
{"Dirt_Clouds_Assem", {1333,1276}},
{"Dirt_Clouds_Para", {1333,1277}},
{"Dirt_Clouds_Halls", {1333,1283}}
};
2022-07-28 13:39:57 +00:00
void NtDirtCloudServer::OnStartup(Entity* self) {
self->SetVar(u"CloudOn", true);
}
2022-07-28 13:39:57 +00:00
void NtDirtCloudServer::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
if (message != "soapspray") {
return;
}
if (!self->GetVar<bool>(u"CloudOn")) {
return;
}
2022-07-28 13:39:57 +00:00
const auto mySpawner = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
2022-07-28 13:39:57 +00:00
if (m_Missions.count(mySpawner) == 0) {
return;
}
2022-07-28 13:39:57 +00:00
const auto& myMis = m_Missions[mySpawner];
2022-07-28 13:39:57 +00:00
auto* missionComponent = caster->GetComponent<MissionComponent>();
2022-07-28 13:39:57 +00:00
if (missionComponent == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
for (const auto missionID : myMis) {
missionComponent->ForceProgressTaskType(missionID, 1, 1);
}
2022-07-28 13:39:57 +00:00
self->SetVar(u"CloudOn", false);
2022-07-28 13:39:57 +00:00
self->Smash(self->GetObjectID(), VIOLENT);
}