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:
4
dScripts/ai/GENERAL/CMakeLists.txt
Normal file
4
dScripts/ai/GENERAL/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
set(DSCRIPTS_SOURCES_AI_GENERAL
|
||||
"InstanceExitTransferPlayerToLastNonInstance.cpp"
|
||||
"LegoDieRoll.cpp"
|
||||
PARENT_SCOPE)
|
@@ -0,0 +1,56 @@
|
||||
#include "InstanceExitTransferPlayerToLastNonInstance.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Player.h"
|
||||
#include "Character.h"
|
||||
#include "dServer.h"
|
||||
|
||||
void InstanceExitTransferPlayerToLastNonInstance::OnUse(Entity* self, Entity* user) {
|
||||
auto transferText = self->GetVar<std::u16string>(u"transferText");
|
||||
if (transferText.empty())
|
||||
transferText = u"DRAGON_EXIT_QUESTION";
|
||||
|
||||
GameMessages::SendDisplayMessageBox(
|
||||
user->GetObjectID(),
|
||||
true,
|
||||
self->GetObjectID(),
|
||||
u"Instance_Exit",
|
||||
1,
|
||||
transferText,
|
||||
u"",
|
||||
user->GetSystemAddress()
|
||||
);
|
||||
}
|
||||
|
||||
void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
||||
auto* player = dynamic_cast<Player*>(sender);
|
||||
if (player == nullptr)
|
||||
return;
|
||||
|
||||
auto* character = sender->GetCharacter();
|
||||
if (character != nullptr) {
|
||||
if (identifier == u"Instance_Exit" && button == 1) {
|
||||
auto lastInstance = character->GetLastNonInstanceZoneID();
|
||||
|
||||
// Sanity check
|
||||
if (lastInstance == 0) {
|
||||
switch (Game::server->GetZoneID()) {
|
||||
case 2001:
|
||||
lastInstance = 2000;
|
||||
break;
|
||||
case 1402:
|
||||
lastInstance = 1400;
|
||||
break;
|
||||
default:
|
||||
lastInstance = 1100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
player->SendToZone(lastInstance);
|
||||
}
|
||||
}
|
||||
|
||||
GameMessages::SendTerminateInteraction(sender->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class InstanceExitTransferPlayerToLastNonInstance : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) override;
|
||||
};
|
52
dScripts/ai/GENERAL/LegoDieRoll.cpp
Normal file
52
dScripts/ai/GENERAL/LegoDieRoll.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "LegoDieRoll.h"
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
void LegoDieRoll::OnStartup(Entity* self) {
|
||||
self->AddTimer("DoneRolling", 10.0f);
|
||||
self->AddTimer("ThrowDice", LegoDieRoll::animTime);
|
||||
}
|
||||
|
||||
void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "DoneRolling") {
|
||||
self->Smash(self->GetObjectID(), SILENT);
|
||||
} else if (timerName == "ThrowDice") {
|
||||
int dieRoll = GeneralUtils::GenerateRandomNumber<int>(1, 6);
|
||||
|
||||
switch (dieRoll) {
|
||||
case 1:
|
||||
GameMessages::SendPlayAnimation(self, u"roll-die-1");
|
||||
break;
|
||||
case 2:
|
||||
GameMessages::SendPlayAnimation(self, u"roll-die-2");
|
||||
break;
|
||||
case 3:
|
||||
GameMessages::SendPlayAnimation(self, u"roll-die-3");
|
||||
break;
|
||||
case 4:
|
||||
GameMessages::SendPlayAnimation(self, u"roll-die-4");
|
||||
break;
|
||||
case 5:
|
||||
GameMessages::SendPlayAnimation(self, u"roll-die-5");
|
||||
break;
|
||||
case 6:
|
||||
{
|
||||
GameMessages::SendPlayAnimation(self, u"roll-die-6");
|
||||
// tracking the It's Truly Random Achievement
|
||||
auto* owner = self->GetOwner();
|
||||
auto* missionComponent = owner->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent != nullptr) {
|
||||
const auto rollMissionState = missionComponent->GetMissionState(756);
|
||||
if (rollMissionState == MissionState::MISSION_STATE_ACTIVE) {
|
||||
missionComponent->ForceProgress(756, 1103, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
11
dScripts/ai/GENERAL/LegoDieRoll.h
Normal file
11
dScripts/ai/GENERAL/LegoDieRoll.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class LegoDieRoll : public CppScripts::Script {
|
||||
public:
|
||||
void OnStartup(Entity* self);
|
||||
void OnTimerDone(Entity* self, std::string timerName);
|
||||
private:
|
||||
constexpr static const float animTime = 2.0f;
|
||||
};
|
||||
|
Reference in New Issue
Block a user