Files
.github
dAuthServer
dChatFilter
dChatServer
dCommon
dDatabase
dGame
dMasterServer
dNavigation
dNet
dPhysics
dScripts
02_server
DLU
Enemy
Equipment
Map
AG
AG_Spider_Queen
AM
FV
GF
CMakeLists.txt
GfCaptainsCannon.cpp
GfCaptainsCannon.h
GfTikiTorch.cpp
GfTikiTorch.h
MastTeleport.cpp
MastTeleport.h
SpawnLionServer.cpp
SpawnLionServer.h
General
NS
NT
PR
Property
SS
VE
njhub
CMakeLists.txt
Minigame
Objects
Pets
CMakeLists.txt
EquipmentScripts
EquipmentTriggers
ai
client
zone
ActivityManager.cpp
ActivityManager.h
BaseConsoleTeleportServer.cpp
BaseConsoleTeleportServer.h
BasePropertyServer.cpp
BasePropertyServer.h
BaseRandomServer.cpp
BaseRandomServer.h
BaseSurvivalServer.cpp
BaseSurvivalServer.h
BaseWavesGenericEnemy.cpp
BaseWavesGenericEnemy.h
BaseWavesServer.cpp
BaseWavesServer.h
CMakeLists.txt
ChooseYourDestinationNsToNt.cpp
ChooseYourDestinationNsToNt.h
CppScripts.cpp
CppScripts.h
Darkitect.cpp
Darkitect.h
NPCAddRemoveItem.cpp
NPCAddRemoveItem.h
NtFactionSpyServer.cpp
NtFactionSpyServer.h
ScriptComponent.cpp
ScriptComponent.h
ScriptedPowerupSpawner.cpp
ScriptedPowerupSpawner.h
SpawnPetBaseServer.cpp
SpawnPetBaseServer.h
dWorldServer
dZoneManager
docker
docs
migrations
resources
tests
thirdparty
vanity
.dockerignore
.editorconfig
.env.example
.git-blame-ignore-revs
.gitattributes
.gitignore
.gitmodules
CMakeLists.txt
CMakePresets.json
CMakeVariables.txt
CONTRIBUTING.md
Docker.md
Docker_Windows.md
LICENSE
README.md
SECURITY.md
build.sh
docker-compose.yml
logo.png
versions.txt
DarkflameServer/dScripts/02_server/Map/GF/MastTeleport.cpp
Aaron Kimbrell 6aa90ad5b2 Breakout rest of the enums from dCommonVars and clean it up ()
* Breakout rest of the enums from dcommonvars
so we don't have to deal with merge conflicts
ePlayerFlags is not a scoped enum, yet, due to it's complexity

* address feedback

* make player flag types consistent

* fix typo
2023-05-02 17:39:21 -05:00

97 lines
3.4 KiB
C++

#include "MastTeleport.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "Preconditions.h"
#include "eEndBehavior.h"
#include "DestroyableComponent.h"
#include "eStateChangeType.h"
#ifdef _WIN32
#define _USE_MATH_DEFINES
#include <math.h>
#endif
void MastTeleport::OnStartup(Entity* self) {
self->SetNetworkVar<std::string>(u"hookPreconditions", "154;44", UNASSIGNED_SYSTEM_ADDRESS);
}
void MastTeleport::OnRebuildComplete(Entity* self, Entity* target) {
if (Preconditions::Check(target, 154) && Preconditions::Check(target, 44)) {
self->SetVar<LWOOBJID>(u"userID", target->GetObjectID());
GameMessages::SendSetStunned(target->GetObjectID(), eStateChangeType::PUSH, target->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true
);
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent) destroyableComponent->SetStatusImmunity(eStateChangeType::PUSH, true, true, true, true, true, false, false, true, true);
self->AddTimer("Start", 3);
}
}
void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
const auto playerId = self->GetVar<LWOOBJID>(u"userID");
auto* player = EntityManager::Instance()->GetEntity(playerId);
if (player == nullptr) return;
if (timerName == "Start") {
auto position = self->GetPosition();
auto rotation = self->GetRotation();
GameMessages::SendTeleport(playerId, position, rotation, player->GetSystemAddress(), true);
// Hacky fix for odd rotations
if (self->GetVar<std::u16string>(u"MastName") != u"Jail") {
GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 140.0f, player->GetSystemAddress());
} else {
GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 100.0f, player->GetSystemAddress());
}
const auto cinematic = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Cinematic"));
const auto leanIn = self->GetVar<float>(u"LeanIn");
if (!cinematic.empty()) {
GameMessages::SendPlayCinematic(playerId, GeneralUtils::ASCIIToUTF16(cinematic), player->GetSystemAddress(),
true, true, false, false, eEndBehavior::RETURN, false, leanIn
);
}
GameMessages::SendPlayFXEffect(playerId, 6039, u"hook", "hook", LWOOBJID_EMPTY, 1, 1, true);
GameMessages::SendPlayAnimation(player, u"crow-swing-no-equip", 4.0f);
GameMessages::SendPlayAnimation(self, u"swing");
self->AddTimer("PlayerAnimDone", 6.25f);
} else if (timerName == "PlayerAnimDone") {
GameMessages::SendStopFXEffect(player, true, "hook");
auto forward = self->GetRotation().GetForwardVector();
const auto degrees = -25.0f;
const auto rads = degrees * (static_cast<float>(M_PI) / 180.0f);
const Vector3 newPlayerRot = { 0, rads, 0 };
auto position = self->GetPosition();
position.x += (forward.x * 20.5f);
position.y += 12;
position.z += (forward.z * 20.5f);
GameMessages::SendOrientToAngle(playerId, true, rads, player->GetSystemAddress());
GameMessages::SendTeleport(playerId, position, NiQuaternion::IDENTITY, player->GetSystemAddress());
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true
);
auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
if (destroyableComponent) destroyableComponent->SetStatusImmunity(eStateChangeType::POP, true, true, true, true, true, false, false, true, true);
EntityManager::Instance()->SerializeEntity(player);
}
}