mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-18 03:37:23 -06:00
Compare commits
8 Commits
friction-v
...
visual-deb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4adba09b4 | ||
|
|
fc0961ed76 | ||
|
|
b28b93b3f0 | ||
|
|
f3ace4e7ed | ||
| 14d4bf3cc5 | |||
| 26f2eb409f | |||
| 1af3e59348 | |||
|
|
e3077aa410 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -23,3 +23,6 @@
|
|||||||
[submodule "thirdparty/AccountManager"]
|
[submodule "thirdparty/AccountManager"]
|
||||||
path = thirdparty/AccountManager
|
path = thirdparty/AccountManager
|
||||||
url = https://github.com/DarkflameUniverse/AccountManager
|
url = https://github.com/DarkflameUniverse/AccountManager
|
||||||
|
[submodule "thirdparty/raylib"]
|
||||||
|
path = thirdparty/raylib
|
||||||
|
url = https://github.com/raysan5/raylib
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ endforeach()
|
|||||||
# Set the version
|
# Set the version
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
|
|
||||||
|
# Set our compile options
|
||||||
|
option(BUILD_VISUAL_DEBUGGER "Toggle for building visual debugger (default off)" OFF)
|
||||||
|
|
||||||
# Echo the version
|
# Echo the version
|
||||||
message(STATUS "Version: ${PROJECT_VERSION}")
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
|
|
||||||
@@ -140,6 +143,7 @@ set(INCLUDED_DIRECTORIES
|
|||||||
"dDatabase/Tables"
|
"dDatabase/Tables"
|
||||||
"dNet"
|
"dNet"
|
||||||
"dScripts"
|
"dScripts"
|
||||||
|
"dWorldServer"
|
||||||
|
|
||||||
"thirdparty/raknet/Source"
|
"thirdparty/raknet/Source"
|
||||||
"thirdparty/tinyxml2"
|
"thirdparty/tinyxml2"
|
||||||
@@ -216,6 +220,10 @@ add_subdirectory(dZoneManager)
|
|||||||
add_subdirectory(dNavigation)
|
add_subdirectory(dNavigation)
|
||||||
add_subdirectory(dPhysics)
|
add_subdirectory(dPhysics)
|
||||||
|
|
||||||
|
if (BUILD_VISUAL_DEBUGGER)
|
||||||
|
add_subdirectory(dVisualDebugger)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Create a list of common libraries shared between all binaries
|
# Create a list of common libraries shared between all binaries
|
||||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp")
|
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp")
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ std::vector<MetricVariable> Metrics::m_Variables = {
|
|||||||
MetricVariable::CPUTime,
|
MetricVariable::CPUTime,
|
||||||
MetricVariable::Sleep,
|
MetricVariable::Sleep,
|
||||||
MetricVariable::Frame,
|
MetricVariable::Frame,
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
MetricVariable::VisualDebugger,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void Metrics::AddMeasurement(MetricVariable variable, int64_t value) {
|
void Metrics::AddMeasurement(MetricVariable variable, int64_t value) {
|
||||||
@@ -132,7 +135,10 @@ std::string Metrics::MetricVariableToString(MetricVariable variable) {
|
|||||||
return "Frame";
|
return "Frame";
|
||||||
case MetricVariable::Ghosting:
|
case MetricVariable::Ghosting:
|
||||||
return "Ghosting";
|
return "Ghosting";
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
case MetricVariable::VisualDebugger:
|
||||||
|
return "VisualDebugger";
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ enum class MetricVariable : int32_t
|
|||||||
CPUTime,
|
CPUTime,
|
||||||
Sleep,
|
Sleep,
|
||||||
Frame,
|
Frame,
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
VisualDebugger
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Metric
|
struct Metric
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ float NiPoint3::SquaredLength(void) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the dot product of the vector dotted with another vector
|
//! Returns the dot product of the vector dotted with another vector
|
||||||
float NiPoint3::DotProduct(const Vector3& vec) const {
|
float NiPoint3::DotProduct(const NiPoint3& vec) const {
|
||||||
return ((this->x * vec.x) + (this->y * vec.y) + (this->z * vec.z));
|
return ((this->x * vec.x) + (this->y * vec.y) + (this->z * vec.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the cross product of the vector crossed with another vector
|
//! Returns the cross product of the vector crossed with another vector
|
||||||
Vector3 NiPoint3::CrossProduct(const Vector3& vec) const {
|
NiPoint3 NiPoint3::CrossProduct(const NiPoint3& vec) const {
|
||||||
return Vector3(((this->y * vec.z) - (this->z * vec.y)),
|
return NiPoint3(((this->y * vec.z) - (this->z * vec.y)),
|
||||||
((this->z * vec.x) - (this->x * vec.z)),
|
((this->z * vec.x) - (this->x * vec.z)),
|
||||||
((this->x * vec.y) - (this->y * vec.x)));
|
((this->x * vec.y) - (this->y * vec.x)));
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ bool NiPoint3::IsWithinAxisAlignedBox(const NiPoint3& minPoint, const NiPoint3&
|
|||||||
|
|
||||||
//! Checks to see if the point (or vector) is within a sphere
|
//! Checks to see if the point (or vector) is within a sphere
|
||||||
bool NiPoint3::IsWithinSpehere(const NiPoint3& sphereCenter, float radius) {
|
bool NiPoint3::IsWithinSpehere(const NiPoint3& sphereCenter, float radius) {
|
||||||
Vector3 diffVec = Vector3(x - sphereCenter.GetX(), y - sphereCenter.GetY(), z - sphereCenter.GetZ());
|
NiPoint3 diffVec = NiPoint3(x - sphereCenter.GetX(), y - sphereCenter.GetY(), z - sphereCenter.GetZ());
|
||||||
return (diffVec.SquaredLength() <= (radius * radius));
|
return (diffVec.SquaredLength() <= (radius * radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target,
|
|||||||
|
|
||||||
//This code is yoinked from the MS XNA code, so it should be right, even if it's horrible.
|
//This code is yoinked from the MS XNA code, so it should be right, even if it's horrible.
|
||||||
NiPoint3 NiPoint3::RotateByQuaternion(const NiQuaternion& rotation) {
|
NiPoint3 NiPoint3::RotateByQuaternion(const NiQuaternion& rotation) {
|
||||||
Vector3 vector;
|
NiPoint3 vector;
|
||||||
float num12 = rotation.x + rotation.x;
|
float num12 = rotation.x + rotation.x;
|
||||||
float num2 = rotation.y + rotation.y;
|
float num2 = rotation.y + rotation.y;
|
||||||
float num = rotation.z + rotation.z;
|
float num = rotation.z + rotation.z;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
class NiPoint3;
|
class NiPoint3;
|
||||||
class NiQuaternion;
|
class NiQuaternion;
|
||||||
typedef NiPoint3 Vector3; //!< The Vector3 class is technically the NiPoint3 class, but typedef'd for clarity in some cases
|
|
||||||
|
|
||||||
//! A custom class the defines a point in space
|
//! A custom class the defines a point in space
|
||||||
class NiPoint3 {
|
class NiPoint3 {
|
||||||
@@ -102,14 +101,14 @@ public:
|
|||||||
\param vec The second vector
|
\param vec The second vector
|
||||||
\return The dot product of the two vectors
|
\return The dot product of the two vectors
|
||||||
*/
|
*/
|
||||||
float DotProduct(const Vector3& vec) const;
|
float DotProduct(const NiPoint3& vec) const;
|
||||||
|
|
||||||
//! Returns the cross product of the vector crossed with another vector
|
//! Returns the cross product of the vector crossed with another vector
|
||||||
/*!
|
/*!
|
||||||
\param vec The second vector
|
\param vec The second vector
|
||||||
\return The cross product of the two vectors
|
\return The cross product of the two vectors
|
||||||
*/
|
*/
|
||||||
Vector3 CrossProduct(const Vector3& vec) const;
|
NiPoint3 CrossProduct(const NiPoint3& vec) const;
|
||||||
|
|
||||||
//! Unitize the vector
|
//! Unitize the vector
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -72,22 +72,22 @@ void NiQuaternion::SetZ(float z) {
|
|||||||
// MARK: Member Functions
|
// MARK: Member Functions
|
||||||
|
|
||||||
//! Returns the forward vector from the quaternion
|
//! Returns the forward vector from the quaternion
|
||||||
Vector3 NiQuaternion::GetForwardVector(void) const {
|
NiPoint3 NiQuaternion::GetForwardVector(void) const {
|
||||||
return Vector3(2 * (x * z + w * y), 2 * (y * z - w * x), 1 - 2 * (x * x + y * y));
|
return NiPoint3(2 * (x * z + w * y), 2 * (y * z - w * x), 1 - 2 * (x * x + y * y));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the up vector from the quaternion
|
//! Returns the up vector from the quaternion
|
||||||
Vector3 NiQuaternion::GetUpVector(void) const {
|
NiPoint3 NiQuaternion::GetUpVector(void) const {
|
||||||
return Vector3(2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x));
|
return NiPoint3(2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the right vector from the quaternion
|
//! Returns the right vector from the quaternion
|
||||||
Vector3 NiQuaternion::GetRightVector(void) const {
|
NiPoint3 NiQuaternion::GetRightVector(void) const {
|
||||||
return Vector3(1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y));
|
return NiPoint3(1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 NiQuaternion::GetEulerAngles() const {
|
NiPoint3 NiQuaternion::GetEulerAngles() const {
|
||||||
Vector3 angles;
|
NiPoint3 angles;
|
||||||
|
|
||||||
// roll (x-axis rotation)
|
// roll (x-axis rotation)
|
||||||
const float sinr_cosp = 2 * (w * x + y * z);
|
const float sinr_cosp = 2 * (w * x + y * z);
|
||||||
@@ -164,7 +164,7 @@ NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiP
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Creates a Quaternion from a specific axis and angle relative to that axis
|
//! Creates a Quaternion from a specific axis and angle relative to that axis
|
||||||
NiQuaternion NiQuaternion::CreateFromAxisAngle(const Vector3& axis, float angle) {
|
NiQuaternion NiQuaternion::CreateFromAxisAngle(const NiPoint3& axis, float angle) {
|
||||||
float halfAngle = angle * 0.5f;
|
float halfAngle = angle * 0.5f;
|
||||||
float s = static_cast<float>(sin(halfAngle));
|
float s = static_cast<float>(sin(halfAngle));
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class NiQuaternion;
|
class NiQuaternion;
|
||||||
typedef NiQuaternion Quaternion; //!< A typedef for a shorthand version of NiQuaternion
|
|
||||||
|
|
||||||
//! A class that defines a rotation in space
|
//! A class that defines a rotation in space
|
||||||
class NiQuaternion {
|
class NiQuaternion {
|
||||||
@@ -95,21 +94,21 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The forward vector of the quaternion
|
\return The forward vector of the quaternion
|
||||||
*/
|
*/
|
||||||
Vector3 GetForwardVector(void) const;
|
NiPoint3 GetForwardVector(void) const;
|
||||||
|
|
||||||
//! Returns the up vector from the quaternion
|
//! Returns the up vector from the quaternion
|
||||||
/*!
|
/*!
|
||||||
\return The up vector fo the quaternion
|
\return The up vector fo the quaternion
|
||||||
*/
|
*/
|
||||||
Vector3 GetUpVector(void) const;
|
NiPoint3 GetUpVector(void) const;
|
||||||
|
|
||||||
//! Returns the right vector from the quaternion
|
//! Returns the right vector from the quaternion
|
||||||
/*!
|
/*!
|
||||||
\return The right vector of the quaternion
|
\return The right vector of the quaternion
|
||||||
*/
|
*/
|
||||||
Vector3 GetRightVector(void) const;
|
NiPoint3 GetRightVector(void) const;
|
||||||
|
|
||||||
Vector3 GetEulerAngles() const;
|
NiPoint3 GetEulerAngles() const;
|
||||||
|
|
||||||
|
|
||||||
// MARK: Operators
|
// MARK: Operators
|
||||||
@@ -145,7 +144,7 @@ public:
|
|||||||
\param angle The angle relative to this axis
|
\param angle The angle relative to this axis
|
||||||
\return A quaternion created from the axis and angle
|
\return A quaternion created from the axis and angle
|
||||||
*/
|
*/
|
||||||
static NiQuaternion CreateFromAxisAngle(const Vector3& axis, float angle);
|
static NiQuaternion CreateFromAxisAngle(const NiPoint3& axis, float angle);
|
||||||
|
|
||||||
static NiQuaternion FromEulerAngles(const NiPoint3& eulerAngles);
|
static NiQuaternion FromEulerAngles(const NiPoint3& eulerAngles);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ const uint64_t LWOZONEID_INVALID = 0; //!< Invalid LWOZONEID
|
|||||||
|
|
||||||
typedef std::set<LWOOBJID> TSetObjID;
|
typedef std::set<LWOOBJID> TSetObjID;
|
||||||
|
|
||||||
const float PI = 3.14159f;
|
#ifndef PI
|
||||||
|
#define PI 3.14159265358979323846f
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__unix) || defined(__APPLE__)
|
#if defined(__unix) || defined(__APPLE__)
|
||||||
//For Linux:
|
//For Linux:
|
||||||
|
|||||||
14
dCommon/eUnequippableActiveType.h
Normal file
14
dCommon/eUnequippableActiveType.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __EUNEQUIPPABLEACTIVETYPE__H__
|
||||||
|
#define __EUNEQUIPPABLEACTIVETYPE__H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
enum class eUnequippableActiveType : int32_t {
|
||||||
|
INVALID = -1,
|
||||||
|
PET = 0,
|
||||||
|
MOUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //!__EUNEQUIPPABLEACTIVETYPE__H__
|
||||||
@@ -45,7 +45,7 @@ CDItemComponentTable::CDItemComponentTable(void) {
|
|||||||
entry.offsetGroupID = tableData.getIntField(19, -1);
|
entry.offsetGroupID = tableData.getIntField(19, -1);
|
||||||
entry.buildTypes = tableData.getIntField(20, -1);
|
entry.buildTypes = tableData.getIntField(20, -1);
|
||||||
entry.reqPrecondition = tableData.getStringField(21, "");
|
entry.reqPrecondition = tableData.getStringField(21, "");
|
||||||
entry.animationFlag = tableData.getIntField(22, -1);
|
entry.animationFlag = tableData.getIntField(22, 0);
|
||||||
entry.equipEffects = tableData.getIntField(23, -1);
|
entry.equipEffects = tableData.getIntField(23, -1);
|
||||||
entry.readyForQA = tableData.getIntField(24, -1) == 1 ? true : false;
|
entry.readyForQA = tableData.getIntField(24, -1) == 1 ? true : false;
|
||||||
entry.itemRating = tableData.getIntField(25, -1);
|
entry.itemRating = tableData.getIntField(25, -1);
|
||||||
@@ -123,7 +123,7 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
|||||||
entry.offsetGroupID = tableData.getIntField(19, -1);
|
entry.offsetGroupID = tableData.getIntField(19, -1);
|
||||||
entry.buildTypes = tableData.getIntField(20, -1);
|
entry.buildTypes = tableData.getIntField(20, -1);
|
||||||
entry.reqPrecondition = tableData.getStringField(21, "");
|
entry.reqPrecondition = tableData.getStringField(21, "");
|
||||||
entry.animationFlag = tableData.getIntField(22, -1);
|
entry.animationFlag = tableData.getIntField(22, 0);
|
||||||
entry.equipEffects = tableData.getIntField(23, -1);
|
entry.equipEffects = tableData.getIntField(23, -1);
|
||||||
entry.readyForQA = tableData.getIntField(24, -1) == 1 ? true : false;
|
entry.readyForQA = tableData.getIntField(24, -1) == 1 ? true : false;
|
||||||
entry.itemRating = tableData.getIntField(25, -1);
|
entry.itemRating = tableData.getIntField(25, -1);
|
||||||
|
|||||||
@@ -1454,6 +1454,13 @@ void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u
|
|||||||
Kill(EntityManager::Instance()->GetEntity(source));
|
Kill(EntityManager::Instance()->GetEntity(source));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto* possessorComponent = GetComponent<PossessorComponent>();
|
||||||
|
if (possessorComponent) {
|
||||||
|
if (possessorComponent->GetPossessable() != LWOOBJID_EMPTY) {
|
||||||
|
auto* mount = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
if (mount) possessorComponent->Dismount(mount, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
destroyableComponent->Smash(source, killType, deathType);
|
destroyableComponent->Smash(source, killType, deathType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
auto* presetTarget = EntityManager::Instance()->GetEntity(branch.target);
|
auto* presetTarget = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (presetTarget != nullptr) {
|
if (presetTarget != nullptr) {
|
||||||
if (this->m_radius * this->m_radius >= Vector3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
if (this->m_radius * this->m_radius >= NiPoint3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
||||||
targets.push_back(presetTarget);
|
targets.push_back(presetTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto distance = Vector3::DistanceSquared(reference, entity->GetPosition());
|
const auto distance = NiPoint3::DistanceSquared(reference, entity->GetPosition());
|
||||||
|
|
||||||
if (this->m_radius * this->m_radius >= distance && (this->m_maxTargets == 0 || targets.size() < this->m_maxTargets)) {
|
if (this->m_radius * this->m_radius >= distance && (this->m_maxTargets == 0 || targets.size() < this->m_maxTargets)) {
|
||||||
targets.push_back(entity);
|
targets.push_back(entity);
|
||||||
@@ -98,8 +98,8 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
||||||
const auto aDistance = Vector3::DistanceSquared(a->GetPosition(), reference);
|
const auto aDistance = NiPoint3::DistanceSquared(a->GetPosition(), reference);
|
||||||
const auto bDistance = Vector3::DistanceSquared(b->GetPosition(), reference);
|
const auto bDistance = NiPoint3::DistanceSquared(b->GetPosition(), reference);
|
||||||
|
|
||||||
return aDistance > bDistance;
|
return aDistance > bDistance;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
|||||||
|
|
||||||
const auto position = entity->GetPosition() + this->m_offset;
|
const auto position = entity->GetPosition() + this->m_offset;
|
||||||
|
|
||||||
const auto distance = Vector3::Distance(position, other->GetPosition());
|
const auto distance = NiPoint3::Distance(position, other->GetPosition());
|
||||||
|
|
||||||
const auto time = distance / this->m_projectileSpeed;
|
const auto time = distance / this->m_projectileSpeed;
|
||||||
|
|
||||||
|
|||||||
@@ -154,19 +154,19 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
// reference is the position of the caster.
|
// reference is the position of the caster.
|
||||||
// If we cast a ray forward from the caster, does it come within m_farWidth of the target?
|
// If we cast a ray forward from the caster, does it come within m_farWidth of the target?
|
||||||
|
|
||||||
const auto distance = Vector3::Distance(reference, otherPosition);
|
const auto distance = NiPoint3::Distance(reference, otherPosition);
|
||||||
|
|
||||||
if (m_method == 2) {
|
if (m_method == 2) {
|
||||||
NiPoint3 rayPoint = casterPosition + forward * distance;
|
NiPoint3 rayPoint = casterPosition + forward * distance;
|
||||||
|
|
||||||
if (m_farWidth > 0 && Vector3::DistanceSquared(rayPoint, otherPosition) > this->m_farWidth * this->m_farWidth) {
|
if (m_farWidth > 0 && NiPoint3::DistanceSquared(rayPoint, otherPosition) > this->m_farWidth * this->m_farWidth) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto normalized = (reference - otherPosition) / distance;
|
auto normalized = (reference - otherPosition) / distance;
|
||||||
|
|
||||||
const float degreeAngle = std::abs(Vector3::Angle(forward, normalized) * (180 / 3.14) - 180);
|
const float degreeAngle = std::abs(NiPoint3::Angle(forward, normalized) * (180 / 3.14) - 180);
|
||||||
|
|
||||||
if (distance >= this->m_minDistance && this->m_maxDistance >= distance && degreeAngle <= 2 * this->m_angle) {
|
if (distance >= this->m_minDistance && this->m_maxDistance >= distance && degreeAngle <= 2 * this->m_angle) {
|
||||||
targets.push_back(entity);
|
targets.push_back(entity);
|
||||||
@@ -174,8 +174,8 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
||||||
const auto aDistance = Vector3::DistanceSquared(reference, a->GetPosition());
|
const auto aDistance = NiPoint3::DistanceSquared(reference, a->GetPosition());
|
||||||
const auto bDistance = Vector3::DistanceSquared(reference, b->GetPosition());
|
const auto bDistance = NiPoint3::DistanceSquared(reference, b->GetPosition());
|
||||||
|
|
||||||
return aDistance > bDistance;
|
return aDistance > bDistance;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto distance = Vector3::DistanceSquared(self->GetPosition(), entity->GetPosition());
|
const auto distance = NiPoint3::DistanceSquared(self->GetPosition(), entity->GetPosition());
|
||||||
|
|
||||||
if (distance > this->m_range * this->m_range) {
|
if (distance > this->m_range * this->m_range) {
|
||||||
success = false;
|
success = false;
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
|||||||
if (target != nullptr && !m_DirtyThreat) {
|
if (target != nullptr && !m_DirtyThreat) {
|
||||||
const auto targetPosition = target->GetPosition();
|
const auto targetPosition = target->GetPosition();
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) < m_HardTetherRadius * m_HardTetherRadius) {
|
if (NiPoint3::DistanceSquared(targetPosition, m_StartPosition) < m_HardTetherRadius * m_HardTetherRadius) {
|
||||||
return m_Target;
|
return m_Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +433,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
|||||||
|
|
||||||
const auto maxDistanceSquared = m_HardTetherRadius * m_HardTetherRadius;
|
const auto maxDistanceSquared = m_HardTetherRadius * m_HardTetherRadius;
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) > maxDistanceSquared) {
|
if (NiPoint3::DistanceSquared(targetPosition, m_StartPosition) > maxDistanceSquared) {
|
||||||
if (threat > 0) {
|
if (threat > 0) {
|
||||||
SetThreat(entry, 0);
|
SetThreat(entry, 0);
|
||||||
}
|
}
|
||||||
@@ -448,7 +448,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto proximityThreat = -(Vector3::DistanceSquared(targetPosition, reference) - maxDistanceSquared) / 100; // Proximity threat takes last priority
|
const auto proximityThreat = -(NiPoint3::DistanceSquared(targetPosition, reference) - maxDistanceSquared) / 100; // Proximity threat takes last priority
|
||||||
|
|
||||||
if (proximityThreat > biggestThreat) {
|
if (proximityThreat > biggestThreat) {
|
||||||
biggestThreat = proximityThreat;
|
biggestThreat = proximityThreat;
|
||||||
@@ -477,7 +477,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
|||||||
|
|
||||||
const auto targetPosition = entity->GetPosition();
|
const auto targetPosition = entity->GetPosition();
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) > m_HardTetherRadius * m_HardTetherRadius) {
|
if (NiPoint3::DistanceSquared(targetPosition, m_StartPosition) > m_HardTetherRadius * m_HardTetherRadius) {
|
||||||
deadThreats.push_back(threatTarget.first);
|
deadThreats.push_back(threatTarget.first);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -508,7 +508,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
|||||||
for (auto id : m_Parent->GetTargetsInPhantom()) {
|
for (auto id : m_Parent->GetTargetsInPhantom()) {
|
||||||
auto* other = EntityManager::Instance()->GetEntity(id);
|
auto* other = EntityManager::Instance()->GetEntity(id);
|
||||||
|
|
||||||
const auto distance = Vector3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
|
const auto distance = NiPoint3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
|
||||||
|
|
||||||
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
||||||
|
|
||||||
@@ -657,7 +657,7 @@ void BaseCombatAIComponent::Wander() {
|
|||||||
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
|
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
if (NiPoint3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
||||||
m_MovementAI->Stop();
|
m_MovementAI->Stop();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -685,16 +685,16 @@ void BaseCombatAIComponent::OnAggro() {
|
|||||||
NiPoint3 currentPos = m_MovementAI->GetCurrentPosition();
|
NiPoint3 currentPos = m_MovementAI->GetCurrentPosition();
|
||||||
|
|
||||||
// If the player's position is within range, attack
|
// If the player's position is within range, attack
|
||||||
if (Vector3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
if (NiPoint3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
||||||
m_MovementAI->Stop();
|
m_MovementAI->Stop();
|
||||||
} else if (Vector3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
} else if (NiPoint3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
||||||
{
|
{
|
||||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||||
|
|
||||||
m_MovementAI->SetDestination(m_StartPosition);
|
m_MovementAI->SetDestination(m_StartPosition);
|
||||||
} else //Chase the player's new position
|
} else //Chase the player's new position
|
||||||
{
|
{
|
||||||
if (IsMech() && Vector3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
if (IsMech() && NiPoint3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
||||||
|
|
||||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||||
|
|
||||||
@@ -718,9 +718,9 @@ void BaseCombatAIComponent::OnTether() {
|
|||||||
NiPoint3 targetPos = target->GetPosition();
|
NiPoint3 targetPos = target->GetPosition();
|
||||||
NiPoint3 currentPos = m_MovementAI->ApproximateLocation();
|
NiPoint3 currentPos = m_MovementAI->ApproximateLocation();
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
if (NiPoint3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
||||||
m_MovementAI->Stop();
|
m_MovementAI->Stop();
|
||||||
} else if (Vector3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
} else if (NiPoint3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
||||||
{
|
{
|
||||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||||
|
|
||||||
@@ -728,7 +728,7 @@ void BaseCombatAIComponent::OnTether() {
|
|||||||
|
|
||||||
m_State = AiState::aggro;
|
m_State = AiState::aggro;
|
||||||
} else {
|
} else {
|
||||||
if (IsMech() && Vector3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
if (IsMech() && NiPoint3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
||||||
|
|
||||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||||
|
|
||||||
|
|||||||
@@ -167,18 +167,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetLastRocketItemID(LWOOBJID lastRocketItemID) { m_LastRocketItemID = lastRocketItemID; }
|
void SetLastRocketItemID(LWOOBJID lastRocketItemID) { m_LastRocketItemID = lastRocketItemID; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the object ID of the mount item that is being used
|
|
||||||
* @return the object ID of the mount item that is being used
|
|
||||||
*/
|
|
||||||
LWOOBJID GetMountItemID() const { return m_MountItemID; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the object ID of the mount item that is being used
|
|
||||||
* @param m_MountItemID the object ID of the mount item that is being used
|
|
||||||
*/
|
|
||||||
void SetMountItemID(LWOOBJID mountItemID) { m_MountItemID = mountItemID; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of this character
|
* Gets the name of this character
|
||||||
* @return the name of this character
|
* @return the name of this character
|
||||||
@@ -569,11 +557,6 @@ private:
|
|||||||
* ID of the last rocket used
|
* ID of the last rocket used
|
||||||
*/
|
*/
|
||||||
LWOOBJID m_LastRocketItemID = LWOOBJID_EMPTY;
|
LWOOBJID m_LastRocketItemID = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
/**
|
|
||||||
* Mount Item ID
|
|
||||||
*/
|
|
||||||
LWOOBJID m_MountItemID = LWOOBJID_EMPTY;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHARACTERCOMPONENT_H
|
#endif // CHARACTERCOMPONENT_H
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
|
|||||||
m_IgnoreMultipliers = false;
|
m_IgnoreMultipliers = false;
|
||||||
m_PickupRadius = 0.0f;
|
m_PickupRadius = 0.0f;
|
||||||
m_DirtyPickupRadiusScale = true;
|
m_DirtyPickupRadiusScale = true;
|
||||||
|
m_IsTeleporting = false;
|
||||||
|
|
||||||
if (entity->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
if (entity->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
||||||
return;
|
return;
|
||||||
@@ -128,7 +129,10 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write0();
|
outBitStream->Write0();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bIsInitialUpdate) outBitStream->Write0();
|
if (!bIsInitialUpdate) {
|
||||||
|
outBitStream->Write(m_IsTeleporting);
|
||||||
|
m_IsTeleporting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||||
|
|||||||
@@ -220,6 +220,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool GetStatic() const { return m_Static; }
|
bool GetStatic() const { return m_Static; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the entity is Teleporting,
|
||||||
|
* @param value whether or not the entity is Is Teleporting
|
||||||
|
*/
|
||||||
|
void SetIsTeleporting(const bool value) { m_IsTeleporting = value; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not this entity is currently is teleporting
|
||||||
|
* @return whether or not this entity is currently is teleporting
|
||||||
|
*/
|
||||||
|
bool GetIsTeleporting() const { return m_IsTeleporting; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Physics entity for the component
|
* Returns the Physics entity for the component
|
||||||
* @return Physics entity for the component
|
* @return Physics entity for the component
|
||||||
@@ -355,6 +367,11 @@ private:
|
|||||||
* The active pickup radius for this entity
|
* The active pickup radius for this entity
|
||||||
*/
|
*/
|
||||||
float m_PickupRadius;
|
float m_PickupRadius;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the entity is teleporting
|
||||||
|
*/
|
||||||
|
bool m_IsTeleporting;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLLABLEPHYSICSCOMPONENT_H
|
#endif // CONTROLLABLEPHYSICSCOMPONENT_H
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "MissionComponent.h"
|
#include "MissionComponent.h"
|
||||||
#include "CharacterComponent.h"
|
#include "CharacterComponent.h"
|
||||||
|
#include "PossessableComponent.h"
|
||||||
|
#include "PossessorComponent.h"
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
|
|
||||||
DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
||||||
@@ -608,6 +610,24 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
|||||||
SetHealth(health);
|
SetHealth(health);
|
||||||
SetIsShielded(absorb > 0);
|
SetIsShielded(absorb > 0);
|
||||||
|
|
||||||
|
// Dismount on the possessable hit
|
||||||
|
auto possessable = m_Parent->GetComponent<PossessableComponent>();
|
||||||
|
if (possessable && possessable->GetDepossessOnHit()) {
|
||||||
|
possessable->Dismount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dismount on the possessor hit
|
||||||
|
auto possessor = m_Parent->GetComponent<PossessorComponent>();
|
||||||
|
if (possessor) {
|
||||||
|
auto possessableId = possessor->GetPossessable();
|
||||||
|
if (possessableId != LWOOBJID_EMPTY) {
|
||||||
|
auto possessable = EntityManager::Instance()->GetEntity(possessableId);
|
||||||
|
if (possessable) {
|
||||||
|
possessor->Dismount(possessable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_Parent->GetLOT() != 1) {
|
if (m_Parent->GetLOT() != 1) {
|
||||||
echo = true;
|
echo = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
#include "eItemType.h"
|
#include "eItemType.h"
|
||||||
|
#include "eUnequippableActiveType.h"
|
||||||
|
|
||||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) {
|
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) {
|
||||||
this->m_Dirty = true;
|
this->m_Dirty = true;
|
||||||
@@ -62,23 +63,23 @@ InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* do
|
|||||||
const auto& info = Inventory::FindItemComponent(item.itemid);
|
const auto& info = Inventory::FindItemComponent(item.itemid);
|
||||||
|
|
||||||
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item.itemid), item.count, slot++ });
|
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item.itemid), item.count, slot++ });
|
||||||
|
|
||||||
// Equip this items proxies.
|
// Equip this items proxies.
|
||||||
auto subItems = info.subItems;
|
auto subItems = info.subItems;
|
||||||
|
|
||||||
subItems.erase(std::remove_if(subItems.begin(), subItems.end(), ::isspace), subItems.end());
|
subItems.erase(std::remove_if(subItems.begin(), subItems.end(), ::isspace), subItems.end());
|
||||||
|
|
||||||
if (!subItems.empty()) {
|
if (!subItems.empty()) {
|
||||||
const auto subItemsSplit = GeneralUtils::SplitString(subItems, ',');
|
const auto subItemsSplit = GeneralUtils::SplitString(subItems, ',');
|
||||||
|
|
||||||
for (auto proxyLotAsString : subItemsSplit) {
|
for (auto proxyLotAsString : subItemsSplit) {
|
||||||
const auto proxyLOT = static_cast<LOT>(std::stoi(proxyLotAsString));
|
const auto proxyLOT = static_cast<LOT>(std::stoi(proxyLotAsString));
|
||||||
|
|
||||||
const auto& proxyInfo = Inventory::FindItemComponent(proxyLOT);
|
const auto& proxyInfo = Inventory::FindItemComponent(proxyLOT);
|
||||||
const LWOOBJID proxyId = ObjectIDManager::Instance()->GenerateObjectID();
|
const LWOOBJID proxyId = ObjectIDManager::Instance()->GenerateObjectID();
|
||||||
|
|
||||||
// Use item.count since we equip item.count number of the item this is a requested proxy of
|
// Use item.count since we equip item.count number of the item this is a requested proxy of
|
||||||
UpdateSlot(proxyInfo.equipLocation, { proxyId, proxyLOT, item.count, slot++ } );
|
UpdateSlot(proxyInfo.equipLocation, { proxyId, proxyLOT, item.count, slot++ });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -795,9 +796,7 @@ void InventoryComponent::RemoveSlot(const std::string& location) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||||
if (!Inventory::IsValidItem(item->GetLot())) {
|
if (!Inventory::IsValidItem(item->GetLot())) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temp items should be equippable but other transfer items shouldn't be (for example the instruments in RB)
|
// Temp items should be equippable but other transfer items shouldn't be (for example the instruments in RB)
|
||||||
if (item->IsEquipped()
|
if (item->IsEquipped()
|
||||||
@@ -816,13 +815,11 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
|||||||
const auto position = m_Parent->GetPosition();
|
const auto position = m_Parent->GetPosition();
|
||||||
|
|
||||||
for (auto* lauchPad : rocketLauchPads) {
|
for (auto* lauchPad : rocketLauchPads) {
|
||||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
if (NiPoint3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||||
|
|
||||||
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||||
|
|
||||||
if (characterComponent != nullptr) {
|
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
||||||
characterComponent->SetLastRocketItemID(item->GetId());
|
|
||||||
}
|
|
||||||
|
|
||||||
lauchPad->OnUse(m_Parent);
|
lauchPad->OnUse(m_Parent);
|
||||||
|
|
||||||
@@ -836,94 +833,8 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
|||||||
|
|
||||||
const auto type = static_cast<eItemType>(item->GetInfo().itemType);
|
const auto type = static_cast<eItemType>(item->GetInfo().itemType);
|
||||||
|
|
||||||
if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == false) {
|
|
||||||
auto startPosition = m_Parent->GetPosition();
|
|
||||||
|
|
||||||
auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X);
|
if (!building && (item->GetLot() == 6086 || type == eItemType::ITEM_TYPE_LOOT_MODEL || type == eItemType::ITEM_TYPE_VEHICLE)) return;
|
||||||
auto angles = startRotation.GetEulerAngles();
|
|
||||||
angles.y -= PI;
|
|
||||||
startRotation = NiQuaternion::FromEulerAngles(angles);
|
|
||||||
|
|
||||||
GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true);
|
|
||||||
|
|
||||||
EntityInfo info{};
|
|
||||||
info.lot = 8092;
|
|
||||||
info.pos = startPosition;
|
|
||||||
info.rot = startRotation;
|
|
||||||
info.spawnerID = m_Parent->GetObjectID();
|
|
||||||
|
|
||||||
auto* carEntity = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent);
|
|
||||||
m_Parent->AddChild(carEntity);
|
|
||||||
|
|
||||||
auto* destroyableComponent = carEntity->GetComponent<DestroyableComponent>();
|
|
||||||
|
|
||||||
// Setup the vehicle stats.
|
|
||||||
if (destroyableComponent != nullptr) {
|
|
||||||
destroyableComponent->SetIsSmashable(false);
|
|
||||||
destroyableComponent->SetIsImmune(true);
|
|
||||||
}
|
|
||||||
// #108
|
|
||||||
auto* possessableComponent = carEntity->GetComponent<PossessableComponent>();
|
|
||||||
|
|
||||||
if (possessableComponent != nullptr) {
|
|
||||||
previousPossessableID = possessableComponent->GetPossessor();
|
|
||||||
possessableComponent->SetPossessor(m_Parent->GetObjectID());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* moduleAssemblyComponent = carEntity->GetComponent<ModuleAssemblyComponent>();
|
|
||||||
|
|
||||||
if (moduleAssemblyComponent != nullptr) {
|
|
||||||
moduleAssemblyComponent->SetSubKey(item->GetSubKey());
|
|
||||||
moduleAssemblyComponent->SetUseOptionalParts(false);
|
|
||||||
|
|
||||||
for (auto* config : item->GetConfig()) {
|
|
||||||
if (config->GetKey() == u"assemblyPartLOTs") {
|
|
||||||
moduleAssemblyComponent->SetAssemblyPartsLOTs(GeneralUtils::ASCIIToUTF16(config->GetValueAsString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// #107
|
|
||||||
auto* possessorComponent = m_Parent->GetComponent<PossessorComponent>();
|
|
||||||
|
|
||||||
if (possessorComponent) possessorComponent->SetPossessable(carEntity->GetObjectID());
|
|
||||||
|
|
||||||
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
|
||||||
|
|
||||||
if (characterComponent) characterComponent->SetIsRacing(true);
|
|
||||||
|
|
||||||
EntityManager::Instance()->ConstructEntity(carEntity);
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
|
||||||
GameMessages::SendSetJetPackMode(m_Parent, false);
|
|
||||||
|
|
||||||
GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
||||||
GameMessages::SendRacingPlayerLoaded(LWOOBJID_EMPTY, m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
||||||
GameMessages::SendVehicleUnlockInput(carEntity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
|
|
||||||
GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true);
|
|
||||||
GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true);
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
|
||||||
|
|
||||||
hasCarEquipped = true;
|
|
||||||
equippedCarEntity = carEntity;
|
|
||||||
return;
|
|
||||||
} else if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) {
|
|
||||||
GameMessages::SendNotifyRacingClient(LWOOBJID_EMPTY, 3, 0, LWOOBJID_EMPTY, u"", m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
||||||
auto player = dynamic_cast<Player*>(m_Parent);
|
|
||||||
player->SendToZone(player->GetCharacter()->GetZoneID());
|
|
||||||
equippedCarEntity->Kill();
|
|
||||||
hasCarEquipped = false;
|
|
||||||
equippedCarEntity = nullptr;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!building) {
|
|
||||||
if (item->GetLot() == 6086) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == eItemType::ITEM_TYPE_LOOT_MODEL || type == eItemType::ITEM_TYPE_VEHICLE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type != eItemType::ITEM_TYPE_LOOT_MODEL && type != eItemType::ITEM_TYPE_MODEL) {
|
if (type != eItemType::ITEM_TYPE_LOOT_MODEL && type != eItemType::ITEM_TYPE_MODEL) {
|
||||||
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_Parent)) {
|
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_Parent)) {
|
||||||
@@ -940,9 +851,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
|||||||
set->OnEquip(lot);
|
set->OnEquip(lot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->GetInfo().isBOE) {
|
if (item->GetInfo().isBOE) item->SetBound(true);
|
||||||
item->SetBound(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateProxies(item);
|
GenerateProxies(item);
|
||||||
|
|
||||||
@@ -989,6 +898,85 @@ void InventoryComponent::UnEquipItem(Item* item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InventoryComponent::HandlePossession(Item* item) {
|
||||||
|
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||||
|
if (!characterComponent) return;
|
||||||
|
|
||||||
|
auto* possessorComponent = m_Parent->GetComponent<PossessorComponent>();
|
||||||
|
if (!possessorComponent) return;
|
||||||
|
|
||||||
|
// Don't do anything if we are busy dismounting
|
||||||
|
if (possessorComponent->GetIsDismounting()) return;
|
||||||
|
|
||||||
|
// Check to see if we are already mounting something
|
||||||
|
auto* currentlyPossessedEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
auto currentlyPossessedItem = possessorComponent->GetMountItemID();
|
||||||
|
|
||||||
|
if (currentlyPossessedItem) {
|
||||||
|
if (currentlyPossessedEntity) possessorComponent->Dismount(currentlyPossessedEntity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStunState::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||||
|
|
||||||
|
// Set the mount Item ID so that we know what were handling
|
||||||
|
possessorComponent->SetMountItemID(item->GetId());
|
||||||
|
GameMessages::SendSetMountInventoryID(m_Parent, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
|
// Create entity to mount
|
||||||
|
auto startRotation = m_Parent->GetRotation();
|
||||||
|
|
||||||
|
EntityInfo info{};
|
||||||
|
info.lot = item->GetLot();
|
||||||
|
info.pos = m_Parent->GetPosition();
|
||||||
|
info.rot = startRotation;
|
||||||
|
info.spawnerID = m_Parent->GetObjectID();
|
||||||
|
|
||||||
|
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent);
|
||||||
|
|
||||||
|
// Check to see if the mount is a vehicle, if so, flip it
|
||||||
|
auto* vehicleComponent = mount->GetComponent<VehiclePhysicsComponent>();
|
||||||
|
if (vehicleComponent) {
|
||||||
|
auto angles = startRotation.GetEulerAngles();
|
||||||
|
// Make it right side up
|
||||||
|
angles.x -= PI;
|
||||||
|
// Make it going in the direction of the player
|
||||||
|
angles.y -= PI;
|
||||||
|
startRotation = NiQuaternion::FromEulerAngles(angles);
|
||||||
|
mount->SetRotation(startRotation);
|
||||||
|
// We're pod racing now
|
||||||
|
characterComponent->SetIsRacing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the destroyable stats
|
||||||
|
auto* destroyableComponent = mount->GetComponent<DestroyableComponent>();
|
||||||
|
if (destroyableComponent) {
|
||||||
|
destroyableComponent->SetIsSmashable(false);
|
||||||
|
destroyableComponent->SetIsImmune(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mount it
|
||||||
|
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||||
|
if (possessableComponent) {
|
||||||
|
possessableComponent->SetIsItemSpawned(true);
|
||||||
|
possessableComponent->SetPossessor(m_Parent->GetObjectID());
|
||||||
|
// Possess it
|
||||||
|
possessorComponent->SetPossessable(mount->GetObjectID());
|
||||||
|
possessorComponent->SetPossessableType(possessableComponent->GetPossessionType());
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMessages::SendSetJetPackMode(m_Parent, false);
|
||||||
|
|
||||||
|
// Make it go to the client
|
||||||
|
EntityManager::Instance()->ConstructEntity(mount);
|
||||||
|
// Update the possessor
|
||||||
|
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
|
// have to unlock the input so it vehicle can be driven
|
||||||
|
if (vehicleComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress());
|
||||||
|
GameMessages::SendMarkInventoryItemAsActive(m_Parent->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_Parent->GetSystemAddress());
|
||||||
|
}
|
||||||
|
|
||||||
void InventoryComponent::ApplyBuff(Item* item) const {
|
void InventoryComponent::ApplyBuff(Item* item) const {
|
||||||
const auto buffs = FindBuffs(item, true);
|
const auto buffs = FindBuffs(item, true);
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void UnEquipItem(Item* item);
|
void UnEquipItem(Item* item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unequips an Item from the inventory
|
||||||
|
* @param item the Item to unequip
|
||||||
|
* @return if we were successful
|
||||||
|
*/
|
||||||
|
void HandlePossession(Item* item);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a buff related to equipping a lot to the entity
|
* Adds a buff related to equipping a lot to the entity
|
||||||
* @param item the item to find buffs for
|
* @param item the item to find buffs for
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
|
|
||||||
SetPosition(source + velocity);
|
SetPosition(source + velocity);
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(GetCurrentPosition(), m_PullPoint) < 2 * 2) {
|
if (NiPoint3::DistanceSquared(GetCurrentPosition(), m_PullPoint) < 2 * 2) {
|
||||||
m_Interrupted = false;
|
m_Interrupted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_HaltDistance > 0) {
|
if (m_HaltDistance > 0) {
|
||||||
if (Vector3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) // Prevent us from hugging the target
|
if (NiPoint3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) // Prevent us from hugging the target
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ void MovementAIComponent::SetDestination(const NiPoint3& value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (Vector3::DistanceSquared(value, GetDestination()) < 2 * 2)
|
/*if (NiPoint3::DistanceSquared(value, GetDestination()) < 2 * 2)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ void MovingPlatformComponent::StartPathing() {
|
|||||||
SetMovementState(MovementPlatformState::Moving);
|
SetMovementState(MovementPlatformState::Moving);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5f;
|
const auto travelTime = NiPoint3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5f;
|
||||||
|
|
||||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
SetMovementState(MovementPlatformState::Moving);
|
SetMovementState(MovementPlatformState::Moving);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
auto travelTime = NiPoint3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
||||||
|
|
||||||
if (m_Parent->GetLOT() == 9483) {
|
if (m_Parent->GetLOT() == 9483) {
|
||||||
travelTime += 20;
|
travelTime += 20;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "dpWorld.h"
|
#include "dpWorld.h"
|
||||||
#include "PetDigServer.h"
|
#include "PetDigServer.h"
|
||||||
#include "../dWorldServer/ObjectIDManager.h"
|
#include "../dWorldServer/ObjectIDManager.h"
|
||||||
|
#include "eUnequippableActiveType.h"
|
||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
@@ -399,7 +400,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
auto destination = owner->GetPosition();
|
auto destination = owner->GetPosition();
|
||||||
NiPoint3 position = m_MovementAI->GetCurrentPosition();
|
NiPoint3 position = m_MovementAI->GetCurrentPosition();
|
||||||
|
|
||||||
float distanceToOwner = Vector3::DistanceSquared(position, destination);
|
float distanceToOwner = NiPoint3::DistanceSquared(position, destination);
|
||||||
|
|
||||||
if (distanceToOwner > 50 * 50 || m_TimerAway > 5) {
|
if (distanceToOwner > 50 * 50 || m_TimerAway > 5) {
|
||||||
m_MovementAI->Warp(destination);
|
m_MovementAI->Warp(destination);
|
||||||
@@ -429,7 +430,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
if (closestSwitch != nullptr) {
|
if (closestSwitch != nullptr) {
|
||||||
if (!closestSwitch->GetActive()) {
|
if (!closestSwitch->GetActive()) {
|
||||||
NiPoint3 switchPosition = closestSwitch->GetParentEntity()->GetPosition();
|
NiPoint3 switchPosition = closestSwitch->GetParentEntity()->GetPosition();
|
||||||
float distance = Vector3::DistanceSquared(position, switchPosition);
|
float distance = NiPoint3::DistanceSquared(position, switchPosition);
|
||||||
if (distance < 3 * 3) {
|
if (distance < 3 * 3) {
|
||||||
m_Interaction = closestSwitch->GetParentEntity()->GetObjectID();
|
m_Interaction = closestSwitch->GetParentEntity()->GetObjectID();
|
||||||
closestSwitch->EntityEnter(m_Parent);
|
closestSwitch->EntityEnter(m_Parent);
|
||||||
@@ -450,7 +451,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NiPoint3 tresurePosition = closestTresure->GetPosition();
|
NiPoint3 tresurePosition = closestTresure->GetPosition();
|
||||||
float distance = Vector3::DistanceSquared(position, tresurePosition);
|
float distance = NiPoint3::DistanceSquared(position, tresurePosition);
|
||||||
if (distance < 3 * 3) {
|
if (distance < 3 * 3) {
|
||||||
m_Interaction = closestTresure->GetObjectID();
|
m_Interaction = closestTresure->GetObjectID();
|
||||||
|
|
||||||
@@ -824,7 +825,7 @@ void PetComponent::Wander() {
|
|||||||
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
|
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
if (NiPoint3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
||||||
m_MovementAI->Stop();
|
m_MovementAI->Stop();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -883,7 +884,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
|
|||||||
GameMessages::SendSetPetNameModerated(m_Owner, m_DatabaseId, m_ModerationStatus, owner->GetSystemAddress());
|
GameMessages::SendSetPetNameModerated(m_Owner, m_DatabaseId, m_ModerationStatus, owner->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendMarkInventoryItemAsActive(m_Owner, true, 0, m_ItemId, GetOwner()->GetSystemAddress());
|
GameMessages::SendMarkInventoryItemAsActive(m_Owner, true, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
||||||
|
|
||||||
activePets[m_Owner] = m_Parent->GetObjectID();
|
activePets[m_Owner] = m_Parent->GetObjectID();
|
||||||
|
|
||||||
@@ -945,7 +946,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
|
|||||||
void PetComponent::Deactivate() {
|
void PetComponent::Deactivate() {
|
||||||
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
|
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
|
||||||
|
|
||||||
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, 0, m_ItemId, GetOwner()->GetSystemAddress());
|
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
||||||
|
|
||||||
activePets.erase(m_Owner);
|
activePets.erase(m_Owner);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId)
|
|||||||
|
|
||||||
// Should a result not exist for this default to attached visible
|
// Should a result not exist for this default to attached visible
|
||||||
if (!result.eof()) {
|
if (!result.eof()) {
|
||||||
m_PossessionType = static_cast<ePossessionType>(result.getIntField(0, 0));
|
m_PossessionType = static_cast<ePossessionType>(result.getIntField(0, 1)); // Default to Attached Visible
|
||||||
m_DepossessOnHit = static_cast<bool>(result.getIntField(1, 0));
|
m_DepossessOnHit = static_cast<bool>(result.getIntField(1, 0));
|
||||||
} else {
|
} else {
|
||||||
m_PossessionType = ePossessionType::ATTACHED_VISIBLE;
|
m_PossessionType = ePossessionType::ATTACHED_VISIBLE;
|
||||||
@@ -30,7 +30,7 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId)
|
|||||||
void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate);
|
outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate);
|
||||||
if (m_DirtyPossessable || bIsInitialUpdate) {
|
if (m_DirtyPossessable || bIsInitialUpdate) {
|
||||||
m_DirtyPossessable = false;
|
m_DirtyPossessable = false; // reset flag
|
||||||
outBitStream->Write(m_Possessor != LWOOBJID_EMPTY);
|
outBitStream->Write(m_Possessor != LWOOBJID_EMPTY);
|
||||||
if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor);
|
if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor);
|
||||||
|
|
||||||
@@ -38,9 +38,18 @@ void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
|
|||||||
if (m_AnimationFlag != eAnimationFlags::IDLE_INVALID) outBitStream->Write(m_AnimationFlag);
|
if (m_AnimationFlag != eAnimationFlags::IDLE_INVALID) outBitStream->Write(m_AnimationFlag);
|
||||||
|
|
||||||
outBitStream->Write(m_ImmediatelyDepossess);
|
outBitStream->Write(m_ImmediatelyDepossess);
|
||||||
|
m_ImmediatelyDepossess = false; // reset flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PossessableComponent::OnUse(Entity* originator) {
|
void PossessableComponent::Dismount() {
|
||||||
// TODO: Implement this
|
SetPossessor(LWOOBJID_EMPTY);
|
||||||
|
if (m_ItemSpawned) m_Parent->ScheduleKillAfterUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PossessableComponent::OnUse(Entity* originator) {
|
||||||
|
auto* possessor = originator->GetComponent<PossessorComponent>();
|
||||||
|
if (possessor) {
|
||||||
|
possessor->Mount(m_Parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,14 +20,24 @@ public:
|
|||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the possessor of this entity
|
* @brief mounts the Entity
|
||||||
|
*/
|
||||||
|
void Mount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief dismounts the Entity
|
||||||
|
*/
|
||||||
|
void Dismount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the possessor of this Entity
|
||||||
* @param value the ID of the possessor to set
|
* @param value the ID of the possessor to set
|
||||||
*/
|
*/
|
||||||
void SetPossessor(LWOOBJID value) { m_Possessor = value; m_DirtyPossessable = true; };
|
void SetPossessor(LWOOBJID value) { m_Possessor = value; m_DirtyPossessable = true; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the possessor of this entity
|
* Returns the possessor of this Entity
|
||||||
* @return the possessor of this entity
|
* @return the possessor of this Entity
|
||||||
*/
|
*/
|
||||||
LWOOBJID GetPossessor() const { return m_Possessor; };
|
LWOOBJID GetPossessor() const { return m_Possessor; };
|
||||||
|
|
||||||
@@ -38,19 +48,19 @@ public:
|
|||||||
void SetAnimationFlag(eAnimationFlags value) { m_AnimationFlag = value; m_DirtyPossessable = true; };
|
void SetAnimationFlag(eAnimationFlags value) { m_AnimationFlag = value; m_DirtyPossessable = true; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the possession type of this entity
|
* Returns the possession type of this Entity
|
||||||
* @return the possession type of this entity
|
* @return the possession type of this Entity
|
||||||
*/
|
*/
|
||||||
ePossessionType GetPossessionType() const { return m_PossessionType; };
|
ePossessionType GetPossessionType() const { return m_PossessionType; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the entity should deposses on hit
|
* Returns if the Entity should deposses on hit
|
||||||
* @return if the entity should deposses on hit
|
* @return if the Entity should deposses on hit
|
||||||
*/
|
*/
|
||||||
bool GetDepossessOnHit() const { return m_DepossessOnHit; };
|
bool GetDepossessOnHit() const { return m_DepossessOnHit; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forcibly depossess the entity
|
* Forcibly depossess the Entity
|
||||||
*/
|
*/
|
||||||
void ForceDepossess() { m_ImmediatelyDepossess = true; m_DirtyPossessable = true; };
|
void ForceDepossess() { m_ImmediatelyDepossess = true; m_DirtyPossessable = true; };
|
||||||
|
|
||||||
@@ -58,13 +68,13 @@ public:
|
|||||||
* Set if the parent entity was spawned from an item
|
* Set if the parent entity was spawned from an item
|
||||||
* @param value if the parent entity was spawned from an item
|
* @param value if the parent entity was spawned from an item
|
||||||
*/
|
*/
|
||||||
void SetItemSpawned(bool value) { m_ItemSpawned = value; };
|
void SetIsItemSpawned(bool value) { m_ItemSpawned = value; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the parent entity was spawned from an item
|
* Returns if the parent entity was spawned from an item
|
||||||
* @return if the parent entity was spawned from an item
|
* @return if the parent entity was spawned from an item
|
||||||
*/
|
*/
|
||||||
LWOOBJID GetItemSpawned() const { return m_ItemSpawned; };
|
LWOOBJID GetIsItemSpawned() const { return m_ItemSpawned; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an OnUsed event by some other entity, if said entity has a Possessor it becomes the possessor
|
* Handles an OnUsed event by some other entity, if said entity has a Possessor it becomes the possessor
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
#include "PossessorComponent.h"
|
#include "PossessorComponent.h"
|
||||||
|
#include "PossessableComponent.h"
|
||||||
|
#include "CharacterComponent.h"
|
||||||
|
#include "EntityManager.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
#include "eUnequippableActiveType.h"
|
||||||
|
|
||||||
PossessorComponent::PossessorComponent(Entity* parent) : Component(parent) {
|
PossessorComponent::PossessorComponent(Entity* parent) : Component(parent) {
|
||||||
m_Possessable = LWOOBJID_EMPTY;
|
m_Possessable = LWOOBJID_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
PossessorComponent::~PossessorComponent() {}
|
PossessorComponent::~PossessorComponent() {
|
||||||
|
if (m_Possessable != LWOOBJID_EMPTY) {
|
||||||
|
auto* mount = EntityManager::Instance()->GetEntity(m_Possessable);
|
||||||
|
if (mount) {
|
||||||
|
auto* possessable = mount->GetComponent<PossessableComponent>();
|
||||||
|
if (possessable) {
|
||||||
|
if (possessable->GetIsItemSpawned()) {
|
||||||
|
GameMessages::SendMarkInventoryItemAsActive(m_Parent->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_Parent->GetSystemAddress());
|
||||||
|
}
|
||||||
|
possessable->Dismount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate);
|
outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate);
|
||||||
@@ -19,3 +35,48 @@ void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit
|
|||||||
outBitStream->Write(m_PossessableType);
|
outBitStream->Write(m_PossessableType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PossessorComponent::Mount(Entity* mount) {
|
||||||
|
// Don't do anything if we are busy dismounting
|
||||||
|
if (GetIsDismounting() || !mount) return;
|
||||||
|
|
||||||
|
GameMessages::SendSetMountInventoryID(m_Parent, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||||
|
if (possessableComponent) {
|
||||||
|
possessableComponent->SetPossessor(m_Parent->GetObjectID());
|
||||||
|
SetPossessable(mount->GetObjectID());
|
||||||
|
SetPossessableType(possessableComponent->GetPossessionType());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||||
|
if (characterComponent) characterComponent->SetIsRacing(true);
|
||||||
|
|
||||||
|
// GM's to send
|
||||||
|
GameMessages::SendSetJetPackMode(m_Parent, false);
|
||||||
|
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress());
|
||||||
|
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStunState::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||||
|
EntityManager::Instance()->SerializeEntity(mount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
|
||||||
|
// Don't do anything if we are busy dismounting
|
||||||
|
if (GetIsDismounting() || !mount) return;
|
||||||
|
SetIsDismounting(true);
|
||||||
|
|
||||||
|
if (mount) {
|
||||||
|
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||||
|
if (possessableComponent) {
|
||||||
|
possessableComponent->SetPossessor(LWOOBJID_EMPTY);
|
||||||
|
if (forceDismount) possessableComponent->ForceDepossess();
|
||||||
|
}
|
||||||
|
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||||
|
EntityManager::Instance()->SerializeEntity(mount);
|
||||||
|
|
||||||
|
auto characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||||
|
if (characterComponent) characterComponent->SetIsRacing(false);
|
||||||
|
}
|
||||||
|
// Make sure we don't have wacky controls
|
||||||
|
GameMessages::SendSetPlayerControlScheme(m_Parent, eControlSceme::SCHEME_A);
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,35 +25,63 @@ public:
|
|||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entity that this entity is possessing
|
* @brief Mounts the entity
|
||||||
* @param value the ID of the entity this ID should posess
|
*
|
||||||
|
* @param mount Entity to be mounted
|
||||||
|
*/
|
||||||
|
void Mount(Entity* mount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dismounts the entity
|
||||||
|
*
|
||||||
|
* @param mount Entity to be dismounted
|
||||||
|
* @param forceDismount Should we forcibly dismount the entity
|
||||||
|
*/
|
||||||
|
void Dismount(Entity* mount, bool forceDismount = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ID that this entity is possessing
|
||||||
|
* @param value The ID that this entity is possessing
|
||||||
*/
|
*/
|
||||||
void SetPossessable(LWOOBJID value) { m_Possessable = value; m_DirtyPossesor = true; }
|
void SetPossessable(LWOOBJID value) { m_Possessable = value; m_DirtyPossesor = true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entity that this entity is currently posessing
|
* Returns the entity that this entity is currently posessing
|
||||||
* @return the entity that this entity is currently posessing
|
* @return The entity that this entity is currently posessing
|
||||||
*/
|
*/
|
||||||
LWOOBJID GetPossessable() const { return m_Possessable; }
|
LWOOBJID GetPossessable() const { return m_Possessable; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if we are busy mounting or dismounting
|
* Sets if we are busy dismounting
|
||||||
* @param value if we are busy mounting or dismounting
|
* @param value If we are busy dismounting
|
||||||
*/
|
*/
|
||||||
void SetIsBusy(bool value) { m_IsBusy = value; }
|
void SetIsDismounting(bool value) { m_IsDismounting = value; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if we are busy mounting or dismounting
|
* Returns if we are busy dismounting
|
||||||
* @return if we are busy mounting or dismounting
|
* @return If we are busy dismounting
|
||||||
*/
|
*/
|
||||||
bool GetIsBusy() const { return m_IsBusy; }
|
bool GetIsDismounting() const { return m_IsDismounting; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the possesible type that's currently used, merely used by the shooting gallery if it's 0
|
* Sets the possesible type that's currently used, merely used by the shooting gallery if it's 0
|
||||||
* @param value the possesible type to set
|
* @param value The possesible type to set
|
||||||
*/
|
*/
|
||||||
void SetPossessableType(ePossessionType value) { m_PossessableType = value; m_DirtyPossesor = true; }
|
void SetPossessableType(ePossessionType value) { m_PossessableType = value; m_DirtyPossesor = true; }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the object ID of the mount item that is being used
|
||||||
|
* @return The object ID of the mount item that is being used
|
||||||
|
*/
|
||||||
|
LWOOBJID GetMountItemID() const { return m_MountItemID; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the object ID of the mount item that is being used
|
||||||
|
* @param m_MountItemID The object ID of the mount item that is being used
|
||||||
|
*/
|
||||||
|
void SetMountItemID(LWOOBJID mountItemID) { m_MountItemID = mountItemID; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,14 +96,19 @@ private:
|
|||||||
ePossessionType m_PossessableType = ePossessionType::NO_POSSESSION;
|
ePossessionType m_PossessableType = ePossessionType::NO_POSSESSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief if the possessor is dirty
|
* @brief If the possessor is dirty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool m_DirtyPossesor = false;
|
bool m_DirtyPossesor = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief if the possessor is busy mounting or dismounting
|
* @brief If the possessor is busy dismounting
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool m_IsBusy = false;
|
bool m_IsDismounting = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mount Item ID
|
||||||
|
*/
|
||||||
|
LWOOBJID m_MountItemID = LWOOBJID_EMPTY;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -794,7 +794,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vector3::DistanceSquared(position, vehiclePosition) > 50 * 50) {
|
if (NiPoint3::DistanceSquared(position, vehiclePosition) > 50 * 50) {
|
||||||
++respawnIndex;
|
++respawnIndex;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ struct DynamicShootingGalleryParams {
|
|||||||
/**
|
/**
|
||||||
* The distance from the camera to the barrel
|
* The distance from the camera to the barrel
|
||||||
*/
|
*/
|
||||||
Vector3 cameraBarrelOffset;
|
NiPoint3 cameraBarrelOffset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The area the barrel is looking at
|
* The area the barrel is looking at
|
||||||
*/
|
*/
|
||||||
Vector3 facing;
|
NiPoint3 facing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The velocity of the cannonballs
|
* The velocity of the cannonballs
|
||||||
@@ -58,12 +58,12 @@ struct StaticShootingGalleryParams {
|
|||||||
/**
|
/**
|
||||||
* The position of the camera
|
* The position of the camera
|
||||||
*/
|
*/
|
||||||
Vector3 cameraPosition;
|
NiPoint3 cameraPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The position that the camera is looking at
|
* The position that the camera is looking at
|
||||||
*/
|
*/
|
||||||
Vector3 cameraLookatPosition;
|
NiPoint3 cameraLookatPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -314,9 +314,9 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
|||||||
|
|
||||||
const auto targetPosition = target->GetPosition();
|
const auto targetPosition = target->GetPosition();
|
||||||
|
|
||||||
const auto closestPoint = Vector3::ClosestPointOnLine(entry.lastPosition, position, targetPosition);
|
const auto closestPoint = NiPoint3::ClosestPointOnLine(entry.lastPosition, position, targetPosition);
|
||||||
|
|
||||||
const auto distance = Vector3::DistanceSquared(targetPosition, closestPoint);
|
const auto distance = NiPoint3::DistanceSquared(targetPosition, closestPoint);
|
||||||
|
|
||||||
if (distance > 3 * 3) {
|
if (distance > 3 * 3) {
|
||||||
/*
|
/*
|
||||||
@@ -328,7 +328,7 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
|||||||
|
|
||||||
const auto homingTarget = rotation.GetForwardVector() * speed;
|
const auto homingTarget = rotation.GetForwardVector() * speed;
|
||||||
|
|
||||||
Vector3 homing;
|
NiPoint3 homing;
|
||||||
|
|
||||||
// Move towards
|
// Move towards
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
|||||||
SwitchComponent* closest = nullptr;
|
SwitchComponent* closest = nullptr;
|
||||||
|
|
||||||
for (SwitchComponent* petSwitch : petSwitches) {
|
for (SwitchComponent* petSwitch : petSwitches) {
|
||||||
float distance = Vector3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position);
|
float distance = NiPoint3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position);
|
||||||
|
|
||||||
if (closest == nullptr || distance < closestDistance) {
|
if (closest == nullptr || distance < closestDistance) {
|
||||||
closestDistance = distance;
|
closestDistance = distance;
|
||||||
|
|||||||
@@ -653,6 +653,10 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
|||||||
GameMessages::HandleUpdatePlayerStatistic(inStream, entity);
|
GameMessages::HandleUpdatePlayerStatistic(inStream, entity);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GAME_MSG_DISMOUNT_COMPLETE:
|
||||||
|
GameMessages::HandleDismountComplete(inStream, entity, sysAddr);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//Game::logger->Log("GameMessageHandler", "Unknown game message ID: %X", messageID);
|
//Game::logger->Log("GameMessageHandler", "Unknown game message ID: %X", messageID);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "ChatPackets.h"
|
#include "ChatPackets.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
#include "RocketLaunchLupComponent.h"
|
#include "RocketLaunchLupComponent.h"
|
||||||
|
#include "eUnequippableActiveType.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <future>
|
#include <future>
|
||||||
@@ -3414,7 +3415,7 @@ void GameMessages::SendRegisterPetDBID(LWOOBJID objectId, LWOOBJID petDBID, cons
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive, int32_t iType, LWOOBJID itemID, const SystemAddress& sysAddr) {
|
void GameMessages::SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive, eUnequippableActiveType iType, LWOOBJID itemID, const SystemAddress& sysAddr) {
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
CMSGHEADER;
|
CMSGHEADER;
|
||||||
|
|
||||||
@@ -3423,8 +3424,8 @@ void GameMessages::SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive
|
|||||||
|
|
||||||
bitStream.Write(bActive);
|
bitStream.Write(bActive);
|
||||||
|
|
||||||
bitStream.Write(iType != 0);
|
bitStream.Write(iType != eUnequippableActiveType::INVALID);
|
||||||
if (iType != 0) bitStream.Write(iType);
|
if (iType != eUnequippableActiveType::INVALID) bitStream.Write(iType);
|
||||||
|
|
||||||
bitStream.Write(itemID != LWOOBJID_EMPTY);
|
bitStream.Write(itemID != LWOOBJID_EMPTY);
|
||||||
if (itemID != LWOOBJID_EMPTY) bitStream.Write(itemID);
|
if (itemID != LWOOBJID_EMPTY) bitStream.Write(itemID);
|
||||||
@@ -3861,7 +3862,6 @@ void GameMessages::SendDisplayChatBubble(LWOOBJID objectId, const std::u16string
|
|||||||
void GameMessages::SendSetMountInventoryID(Entity* entity, const LWOOBJID& objectID, const SystemAddress& sysAddr) {
|
void GameMessages::SendSetMountInventoryID(Entity* entity, const LWOOBJID& objectID, const SystemAddress& sysAddr) {
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
CMSGHEADER;
|
CMSGHEADER;
|
||||||
|
|
||||||
bitStream.Write(entity->GetObjectID());
|
bitStream.Write(entity->GetObjectID());
|
||||||
bitStream.Write(GAME_MSG::GAME_MSG_SET_MOUNT_INVENTORY_ID);
|
bitStream.Write(GAME_MSG::GAME_MSG_SET_MOUNT_INVENTORY_ID);
|
||||||
bitStream.Write(objectID);
|
bitStream.Write(objectID);
|
||||||
@@ -3871,30 +3871,53 @@ void GameMessages::SendSetMountInventoryID(Entity* entity, const LWOOBJID& objec
|
|||||||
|
|
||||||
|
|
||||||
void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||||
|
// Get the objectID from the bitstream
|
||||||
LWOOBJID objectId{};
|
LWOOBJID objectId{};
|
||||||
inStream->Read(objectId);
|
inStream->Read(objectId);
|
||||||
auto* mount = EntityManager::Instance()->GetEntity(objectId);
|
|
||||||
|
|
||||||
|
// If we aren't possessing somethings, the don't do anything
|
||||||
if (objectId != LWOOBJID_EMPTY) {
|
if (objectId != LWOOBJID_EMPTY) {
|
||||||
PossessorComponent* possessor;
|
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||||
if (entity->TryGetComponent(COMPONENT_TYPE_POSSESSOR, possessor)) {
|
auto* mount = EntityManager::Instance()->GetEntity(objectId);
|
||||||
if (mount) {
|
// make sure we have the things we need and they aren't null
|
||||||
possessor->SetIsBusy(false);
|
if (possessorComponent && mount) {
|
||||||
possessor->SetPossessable(LWOOBJID_EMPTY);
|
if (!possessorComponent->GetIsDismounting()) return;
|
||||||
possessor->SetPossessableType(ePossessionType::NO_POSSESSION);
|
possessorComponent->SetIsDismounting(false);
|
||||||
|
possessorComponent->SetPossessable(LWOOBJID_EMPTY);
|
||||||
|
possessorComponent->SetPossessableType(ePossessionType::NO_POSSESSION);
|
||||||
|
|
||||||
GameMessages::SendSetStunned(entity->GetObjectID(), eStunState::POP, UNASSIGNED_SYSTEM_ADDRESS, LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
// character related things
|
||||||
|
auto* character = entity->GetComponent<CharacterComponent>();
|
||||||
EntityManager::Instance()->SerializeEntity(entity);
|
if (character) {
|
||||||
|
// If we had an active item turn it off
|
||||||
|
if (possessorComponent->GetMountItemID() != LWOOBJID_EMPTY) GameMessages::SendMarkInventoryItemAsActive(entity->GetObjectID(), false, eUnequippableActiveType::MOUNT, possessorComponent->GetMountItemID(), entity->GetSystemAddress());
|
||||||
|
possessorComponent->SetMountItemID(LWOOBJID_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set that the controllabel phsyics comp is teleporting
|
||||||
|
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
if (controllablePhysicsComponent) controllablePhysicsComponent->SetIsTeleporting(true);
|
||||||
|
|
||||||
|
// Call dismoint on the possessable comp to let it handle killing the possessable
|
||||||
|
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||||
|
if (possessableComponent) possessableComponent->Dismount();
|
||||||
|
|
||||||
|
// Update the entity that was possessing
|
||||||
|
EntityManager::Instance()->SerializeEntity(entity);
|
||||||
|
|
||||||
|
// We aren't mounted so remove the stun
|
||||||
|
GameMessages::SendSetStunned(entity->GetObjectID(), eStunState::POP, UNASSIGNED_SYSTEM_ADDRESS, LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||||
Game::logger->Log("HandleAcknowledgePossession", "Got AcknowledgePossession from %i", entity->GetLOT());
|
|
||||||
EntityManager::Instance()->SerializeEntity(entity);
|
EntityManager::Instance()->SerializeEntity(entity);
|
||||||
|
LWOOBJID objectId{};
|
||||||
|
inStream->Read(objectId);
|
||||||
|
auto* mount = EntityManager::Instance()->GetEntity(objectId);
|
||||||
|
if (mount) EntityManager::Instance()->SerializeEntity(mount);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Racing
|
//Racing
|
||||||
@@ -4896,7 +4919,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
|
|||||||
const auto& referencePoint = entity->GetPosition();
|
const auto& referencePoint = entity->GetPosition();
|
||||||
|
|
||||||
for (auto* scripted : scriptedEntities) {
|
for (auto* scripted : scriptedEntities) {
|
||||||
if (Vector3::DistanceSquared(scripted->GetPosition(), referencePoint) > 5.0f * 5.0f) continue;
|
if (NiPoint3::DistanceSquared(scripted->GetPosition(), referencePoint) > 5.0f * 5.0f) continue;
|
||||||
|
|
||||||
scripted->OnEmoteReceived(emoteID, entity);
|
scripted->OnEmoteReceived(emoteID, entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class NiQuaternion;
|
|||||||
class User;
|
class User;
|
||||||
class Entity;
|
class Entity;
|
||||||
class NiPoint3;
|
class NiPoint3;
|
||||||
|
enum class eUnequippableActiveType;
|
||||||
|
|
||||||
namespace GameMessages {
|
namespace GameMessages {
|
||||||
class PropertyDataMessage;
|
class PropertyDataMessage;
|
||||||
@@ -318,7 +319,7 @@ namespace GameMessages {
|
|||||||
|
|
||||||
void SendRegisterPetDBID(LWOOBJID objectId, LWOOBJID petDBID, const SystemAddress& sysAddr);
|
void SendRegisterPetDBID(LWOOBJID objectId, LWOOBJID petDBID, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
void SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive, int32_t iType, LWOOBJID itemID, const SystemAddress& sysAddr);
|
void SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive, eUnequippableActiveType iType, LWOOBJID itemID, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
void SendClientExitTamingMinigame(LWOOBJID objectId, bool bVoluntaryExit, const SystemAddress& sysAddr);
|
void SendClientExitTamingMinigame(LWOOBJID objectId, bool bVoluntaryExit, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "RenderComponent.h"
|
#include "RenderComponent.h"
|
||||||
|
#include "PossessableComponent.h"
|
||||||
|
#include "CharacterComponent.h"
|
||||||
|
#include "eItemType.h"
|
||||||
|
|
||||||
class Inventory;
|
class Inventory;
|
||||||
|
|
||||||
@@ -71,6 +74,12 @@ Item::Item(
|
|||||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER);
|
id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER);
|
||||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT);
|
id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT);
|
||||||
|
|
||||||
|
const auto type = static_cast<eItemType>(info->itemType);
|
||||||
|
|
||||||
|
if (type == eItemType::ITEM_TYPE_MOUNT) {
|
||||||
|
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
||||||
|
}
|
||||||
|
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
|
||||||
inventory->AddManagedItem(this);
|
inventory->AddManagedItem(this);
|
||||||
@@ -254,49 +263,34 @@ bool Item::Consume() {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Item::UseNonEquip() {
|
void Item::UseNonEquip() {
|
||||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
const auto type = static_cast<eItemType>(info->itemType);
|
||||||
|
if (type == eItemType::ITEM_TYPE_MOUNT) {
|
||||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
GetInventory()->GetComponent()->HandlePossession(this);
|
||||||
|
} else if (type == eItemType::ITEM_TYPE_PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY) {
|
||||||
auto* packCompTable = CDClientManager::Instance()->GetTable<CDPackageComponentTable>("PackageComponent");
|
|
||||||
|
|
||||||
auto packages = packCompTable->Query([=](const CDPackageComponent entry) {return entry.id == static_cast<uint32_t>(packageComponentId); });
|
|
||||||
|
|
||||||
const auto success = !packages.empty();
|
|
||||||
|
|
||||||
auto inventoryComponent = inventory->GetComponent();
|
|
||||||
|
|
||||||
auto playerEntity = inventoryComponent->GetParent();
|
|
||||||
|
|
||||||
if (subKey != LWOOBJID_EMPTY) {
|
|
||||||
const auto& databasePet = GetInventory()->GetComponent()->GetDatabasePet(subKey);
|
const auto& databasePet = GetInventory()->GetComponent()->GetDatabasePet(subKey);
|
||||||
|
|
||||||
if (databasePet.lot != LOT_NULL) {
|
if (databasePet.lot != LOT_NULL) {
|
||||||
GetInventory()->GetComponent()->SpawnPet(this);
|
GetInventory()->GetComponent()->SpawnPet(this);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
} else if (type == eItemType::ITEM_TYPE_PACKAGE) {
|
||||||
if (success && (playerEntity->GetGMLevel() >= eGameMasterLevel::GAME_MASTER_LEVEL_JUNIOR_DEVELOPER || this->GetPreconditionExpression()->Check(playerEntity))) {
|
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||||
auto* entityParent = inventory->GetComponent()->GetParent();
|
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
||||||
|
auto* packCompTable = CDClientManager::Instance()->GetTable<CDPackageComponentTable>("PackageComponent");
|
||||||
|
auto packages = packCompTable->Query([=](const CDPackageComponent entry) {return entry.id == static_cast<uint32_t>(packageComponentId); });
|
||||||
|
|
||||||
for (auto& pack : packages) {
|
const auto success = !packages.empty();
|
||||||
std::unordered_map<LOT, int32_t> result{};
|
if (success) {
|
||||||
|
auto* entityParent = inventory->GetComponent()->GetParent();
|
||||||
result = LootGenerator::Instance().RollLootMatrix(entityParent, pack.LootMatrixIndex);
|
for (auto& pack : packages) {
|
||||||
|
std::unordered_map<LOT, int32_t> result{};
|
||||||
if (!inventory->GetComponent()->HasSpaceForLoot(result)) {
|
result = LootGenerator::Instance().RollLootMatrix(entityParent, pack.LootMatrixIndex);
|
||||||
return false;
|
if (!inventory->GetComponent()->HasSpaceForLoot(result)) {
|
||||||
|
}
|
||||||
|
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||||
}
|
}
|
||||||
|
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||||
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
|
||||||
}
|
}
|
||||||
Game::logger->Log("Item", "Used (%i)", lot);
|
|
||||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::Disassemble(const eInventoryType inventoryType) {
|
void Item::Disassemble(const eInventoryType inventoryType) {
|
||||||
|
|||||||
@@ -193,9 +193,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses this item if its non equip, essentially an interface for the linked GM
|
* Uses this item if its non equip, essentially an interface for the linked GM
|
||||||
* @return whether the use was successful, e.g. the skill was cast
|
|
||||||
*/
|
*/
|
||||||
bool UseNonEquip();
|
void UseNonEquip();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disassembles the part LOTs of this item back into the inventory, if it has any
|
* Disassembles the part LOTs of this item back into the inventory, if it has any
|
||||||
|
|||||||
@@ -419,6 +419,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||||
std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size());
|
std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size());
|
||||||
GameMessages::SendPlayAnimation(entity, anim);
|
GameMessages::SendPlayAnimation(entity, anim);
|
||||||
|
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||||
|
if (possessorComponent) {
|
||||||
|
auto* possessedComponent = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
if (possessedComponent) GameMessages::SendPlayAnimation(possessedComponent, anim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "list-spawns" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
if (chatCommand == "list-spawns" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||||
@@ -471,12 +476,24 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (controllablePhysicsComponent == nullptr) {
|
if (!controllablePhysicsComponent) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controllablePhysicsComponent->SetSpeedMultiplier(boost);
|
controllablePhysicsComponent->SetSpeedMultiplier(boost);
|
||||||
|
|
||||||
|
// speedboost possesables
|
||||||
|
auto possessor = entity->GetComponent<PossessorComponent>();
|
||||||
|
if (possessor) {
|
||||||
|
auto possessedID = possessor->GetPossessable();
|
||||||
|
if (possessedID != LWOOBJID_EMPTY) {
|
||||||
|
auto possessable = EntityManager::Instance()->GetEntity(possessedID);
|
||||||
|
if (possessable) {
|
||||||
|
auto* possessControllablePhysicsComponent = possessable->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
if (possessControllablePhysicsComponent) {
|
||||||
|
possessControllablePhysicsComponent->SetSpeedMultiplier(boost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(entity);
|
EntityManager::Instance()->SerializeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -894,21 +911,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /teleport <x> (<y>) <z> - if no Y given, will teleport to the height of the terrain (or any physics object).");
|
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /teleport <x> (<y>) <z> - if no Y given, will teleport to the height of the terrain (or any physics object).");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
|
||||||
|
|
||||||
if (possessorComponent != nullptr) {
|
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||||
|
if (possessorComponent) {
|
||||||
auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
|
||||||
if (possassableEntity != nullptr) {
|
if (possassableEntity != nullptr) {
|
||||||
auto* vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>();
|
auto* vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>();
|
||||||
|
if (vehiclePhysicsComponent) {
|
||||||
if (vehiclePhysicsComponent != nullptr) {
|
|
||||||
vehiclePhysicsComponent->SetPosition(pos);
|
vehiclePhysicsComponent->SetPosition(pos);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(possassableEntity);
|
EntityManager::Instance()->SerializeEntity(possassableEntity);
|
||||||
|
} else GameMessages::SendTeleport(possassableEntity->GetObjectID(), pos, NiQuaternion(), sysAddr);
|
||||||
Game::logger->Log("ClientPackets", "Forced updated vehicle position");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -926,18 +939,12 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "dismount" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
if (chatCommand == "dismount" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||||
PossessorComponent* possessorComponent;
|
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||||
if (entity->TryGetComponent(COMPONENT_TYPE_POSSESSOR, possessorComponent)) {
|
if (possessorComponent) {
|
||||||
Entity* vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
auto possessableId = possessorComponent->GetPossessable();
|
||||||
if (!vehicle) return;
|
if (possessableId != LWOOBJID_EMPTY) {
|
||||||
|
auto* possessableEntity = EntityManager::Instance()->GetEntity(possessableId);
|
||||||
PossessableComponent* possessableComponent;
|
if (possessableEntity) possessorComponent->Dismount(possessableEntity, true);
|
||||||
if (vehicle->TryGetComponent(COMPONENT_TYPE_POSSESSABLE, possessableComponent)) {
|
|
||||||
possessableComponent->SetPossessor(LWOOBJID_EMPTY);
|
|
||||||
possessorComponent->SetPossessable(LWOOBJID_EMPTY);
|
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(vehicle);
|
|
||||||
EntityManager::Instance()->SerializeEntity(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1231,6 +1238,18 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto vehiclePhysicsComponent = newEntity->GetComponent<VehiclePhysicsComponent>();
|
||||||
|
if (vehiclePhysicsComponent) {
|
||||||
|
auto newRot = newEntity->GetRotation();
|
||||||
|
auto angles = newRot.GetEulerAngles();
|
||||||
|
// make it right side up
|
||||||
|
angles.x -= PI;
|
||||||
|
// make it going in the direction of the player
|
||||||
|
angles.y -= PI;
|
||||||
|
newRot = NiQuaternion::FromEulerAngles(angles);
|
||||||
|
newEntity->SetRotation(newRot);
|
||||||
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1520,7 +1539,33 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendVehicleAddPassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
if (args.size() >= 1) {
|
||||||
|
float time;
|
||||||
|
|
||||||
|
if (!GeneralUtils::TryParse(args[0], time)) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid boost time.");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
GameMessages::SendVehicleAddPassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
entity->AddCallbackTimer(time, [vehicle]() {
|
||||||
|
if (!vehicle) return;
|
||||||
|
GameMessages::SendVehicleRemovePassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GameMessages::SendVehicleAddPassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((chatCommand == "unboost") && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||||
|
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||||
|
|
||||||
|
if (possessorComponent == nullptr) return;
|
||||||
|
auto* vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
|
||||||
|
if (vehicle == nullptr) return;
|
||||||
|
GameMessages::SendVehicleRemovePassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "activatespawner" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "activatespawner" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ RawFile::RawFile(std::string fileName) {
|
|||||||
m_Chunks.push_back(chunk);
|
m_Chunks.push_back(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_FinalMesh = new RawMesh();
|
||||||
|
|
||||||
this->GenerateFinalMeshFromChunks();
|
this->GenerateFinalMeshFromChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public:
|
|||||||
RawFile(std::string filePath);
|
RawFile(std::string filePath);
|
||||||
~RawFile();
|
~RawFile();
|
||||||
|
|
||||||
|
RawMesh* GetMesh() { return m_FinalMesh; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void GenerateFinalMeshFromChunks();
|
void GenerateFinalMeshFromChunks();
|
||||||
@@ -23,5 +25,5 @@ private:
|
|||||||
uint32_t m_Height;
|
uint32_t m_Height;
|
||||||
|
|
||||||
std::vector<RawChunk*> m_Chunks;
|
std::vector<RawChunk*> m_Chunks;
|
||||||
RawMesh* m_FinalMesh;
|
RawMesh* m_FinalMesh = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -140,14 +140,19 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
|||||||
inStream.Read(angVelocity.z);
|
inStream.Read(angVelocity.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasVehicle = false;
|
bool updateChar = true;
|
||||||
|
|
||||||
if (possessorComponent != nullptr) {
|
if (possessorComponent != nullptr) {
|
||||||
auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
|
|
||||||
if (possassableEntity != nullptr) {
|
if (possassableEntity != nullptr) {
|
||||||
auto* vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>();
|
auto* possessableComponent = possassableEntity->GetComponent<PossessableComponent>();
|
||||||
|
if (possessableComponent) {
|
||||||
|
// While possessing something, only update char if we are attached to the thing we are possessing
|
||||||
|
if (possessableComponent->GetPossessionType() != ePossessionType::ATTACHED_VISIBLE) updateChar = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>();
|
||||||
if (vehiclePhysicsComponent != nullptr) {
|
if (vehiclePhysicsComponent != nullptr) {
|
||||||
// This is flipped for whatever reason
|
// This is flipped for whatever reason
|
||||||
rotation = NiQuaternion(rotation.z, rotation.y, rotation.x, rotation.w);
|
rotation = NiQuaternion(rotation.z, rotation.y, rotation.x, rotation.w);
|
||||||
@@ -160,19 +165,30 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
|||||||
vehiclePhysicsComponent->SetDirtyVelocity(velocityFlag);
|
vehiclePhysicsComponent->SetDirtyVelocity(velocityFlag);
|
||||||
vehiclePhysicsComponent->SetAngularVelocity(angVelocity);
|
vehiclePhysicsComponent->SetAngularVelocity(angVelocity);
|
||||||
vehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
|
vehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
|
||||||
|
} else {
|
||||||
EntityManager::Instance()->SerializeEntity(possassableEntity);
|
// Need to get the mount's controllable physics
|
||||||
|
auto* controllablePhysicsComponent = possassableEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
hasVehicle = true;
|
if (!controllablePhysicsComponent) return;
|
||||||
|
controllablePhysicsComponent->SetPosition(position);
|
||||||
|
controllablePhysicsComponent->SetRotation(rotation);
|
||||||
|
controllablePhysicsComponent->SetIsOnGround(onGround);
|
||||||
|
controllablePhysicsComponent->SetIsOnRail(onRail);
|
||||||
|
controllablePhysicsComponent->SetVelocity(velocity);
|
||||||
|
controllablePhysicsComponent->SetDirtyVelocity(velocityFlag);
|
||||||
|
controllablePhysicsComponent->SetAngularVelocity(angVelocity);
|
||||||
|
controllablePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
|
||||||
}
|
}
|
||||||
|
EntityManager::Instance()->SerializeEntity(possassableEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasVehicle) {
|
if (!updateChar) {
|
||||||
velocity = NiPoint3::ZERO;
|
velocity = NiPoint3::ZERO;
|
||||||
angVelocity = NiPoint3::ZERO;
|
angVelocity = NiPoint3::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle statistics
|
// Handle statistics
|
||||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent != nullptr) {
|
if (characterComponent != nullptr) {
|
||||||
@@ -192,9 +208,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
|||||||
player->SetGhostReferencePoint(position);
|
player->SetGhostReferencePoint(position);
|
||||||
EntityManager::Instance()->QueueGhostUpdate(player->GetObjectID());
|
EntityManager::Instance()->QueueGhostUpdate(player->GetObjectID());
|
||||||
|
|
||||||
if (!hasVehicle) {
|
if (updateChar) EntityManager::Instance()->SerializeEntity(entity);
|
||||||
EntityManager::Instance()->SerializeEntity(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: add moving platform stuffs
|
//TODO: add moving platform stuffs
|
||||||
/*bool movingPlatformFlag;
|
/*bool movingPlatformFlag;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ bool dpCollisionChecks::CheckSpheres(dpEntity* a, dpEntity* b) {
|
|||||||
if (!a || !b) return false;
|
if (!a || !b) return false;
|
||||||
|
|
||||||
auto posA = a->GetPosition();
|
auto posA = a->GetPosition();
|
||||||
auto distance = Vector3::DistanceSquared(posA, b->GetPosition());
|
auto distance = NiPoint3::DistanceSquared(posA, b->GetPosition());
|
||||||
|
|
||||||
auto sphereA = static_cast<dpShapeSphere*>(a->GetShape());
|
auto sphereA = static_cast<dpShapeSphere*>(a->GetShape());
|
||||||
auto sphereB = static_cast<dpShapeSphere*>(b->GetShape());
|
auto sphereB = static_cast<dpShapeSphere*>(b->GetShape());
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public:
|
|||||||
void RemoveEntity(dpEntity* entity);
|
void RemoveEntity(dpEntity* entity);
|
||||||
|
|
||||||
dNavMesh* GetNavMesh() { return m_NavMesh; }
|
dNavMesh* GetNavMesh() { return m_NavMesh; }
|
||||||
|
std::vector<dpEntity*>* GetStaticEntities() { return &m_StaticEntities; }
|
||||||
|
std::vector<dpEntity*>* GetDynamicEntities() { return &m_DynamicEntites; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dpGrid* m_Grid;
|
dpGrid* m_Grid;
|
||||||
|
|||||||
@@ -33,16 +33,16 @@ void AgLaserSensorServer::OnCollisionPhantom(Entity* self, Entity* target) {
|
|||||||
const auto source = script->GetPosition();
|
const auto source = script->GetPosition();
|
||||||
const auto obj = self->GetObjectID();
|
const auto obj = self->GetObjectID();
|
||||||
|
|
||||||
if (obj == 76690936093053 && Vector3::DistanceSquared(source, NiPoint3(149.007f, 417.083f, 218.346f)) <= 1.0f) {
|
if (obj == 76690936093053 && NiPoint3::DistanceSquared(source, NiPoint3(149.007f, 417.083f, 218.346f)) <= 1.0f) {
|
||||||
laser = script;
|
laser = script;
|
||||||
break;
|
break;
|
||||||
} else if (obj == 75866302318824 && Vector3::DistanceSquared(source, NiPoint3(48.6403f, 403.803f, 196.711f)) <= 1.0f) {
|
} else if (obj == 75866302318824 && NiPoint3::DistanceSquared(source, NiPoint3(48.6403f, 403.803f, 196.711f)) <= 1.0f) {
|
||||||
laser = script;
|
laser = script;
|
||||||
break;
|
break;
|
||||||
} else if (obj == 75866302318822 && Vector3::DistanceSquared(source, NiPoint3(19.2155f, 420.083f, 249.226f)) <= 1.0f) {
|
} else if (obj == 75866302318822 && NiPoint3::DistanceSquared(source, NiPoint3(19.2155f, 420.083f, 249.226f)) <= 1.0f) {
|
||||||
laser = script;
|
laser = script;
|
||||||
break;
|
break;
|
||||||
} else if (obj == 75866302318823 && Vector3::DistanceSquared(source, NiPoint3(-6.61596f, 404.633f, 274.323f)) <= 1.0f) {
|
} else if (obj == 75866302318823 && NiPoint3::DistanceSquared(source, NiPoint3(-6.61596f, 404.633f, 274.323f)) <= 1.0f) {
|
||||||
laser = script;
|
laser = script;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
15
dScripts/AgQbWall.cpp
Normal file
15
dScripts/AgQbWall.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "AgQbWall.h"
|
||||||
|
|
||||||
|
void AgQbWall::OnRebuildComplete(Entity* self, Entity* player) {
|
||||||
|
self->SetVar(u"player", player->GetObjectID());
|
||||||
|
auto targetWallSpawners = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner"));
|
||||||
|
if (targetWallSpawners != "") {
|
||||||
|
auto groupObjs = EntityManager::Instance()->GetEntitiesInGroup(targetWallSpawners);
|
||||||
|
for (auto* obj : groupObjs) {
|
||||||
|
if (obj) {
|
||||||
|
obj->SetVar(u"player", player->GetObjectID());
|
||||||
|
obj->OnFireEventServerSide(self, "spawnMobs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
dScripts/AgQbWall.h
Normal file
7
dScripts/AgQbWall.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CppScripts.h"
|
||||||
|
|
||||||
|
class AgQbWall : public CppScripts::Script {
|
||||||
|
public:
|
||||||
|
void OnRebuildComplete(Entity* self, Entity* player) override;
|
||||||
|
};
|
||||||
@@ -21,6 +21,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp"
|
|||||||
"AgPropGuard.cpp"
|
"AgPropGuard.cpp"
|
||||||
"AgPropguards.cpp"
|
"AgPropguards.cpp"
|
||||||
"AgQbElevator.cpp"
|
"AgQbElevator.cpp"
|
||||||
|
"AgQbWall.cpp"
|
||||||
"AgSalutingNpcs.cpp"
|
"AgSalutingNpcs.cpp"
|
||||||
"AgShipPlayerDeathTrigger.cpp"
|
"AgShipPlayerDeathTrigger.cpp"
|
||||||
"AgShipPlayerShockServer.cpp"
|
"AgShipPlayerShockServer.cpp"
|
||||||
@@ -206,6 +207,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp"
|
|||||||
"PrSeagullFly.cpp"
|
"PrSeagullFly.cpp"
|
||||||
"PrWhistle.cpp"
|
"PrWhistle.cpp"
|
||||||
"QbEnemyStunner.cpp"
|
"QbEnemyStunner.cpp"
|
||||||
|
"QbSpawner.cpp"
|
||||||
"RaceImagineCrateServer.cpp"
|
"RaceImagineCrateServer.cpp"
|
||||||
"RaceImaginePowerup.cpp"
|
"RaceImaginePowerup.cpp"
|
||||||
"RaceMaelstromGeiser.cpp"
|
"RaceMaelstromGeiser.cpp"
|
||||||
@@ -245,6 +247,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp"
|
|||||||
"WaveBossHammerling.cpp"
|
"WaveBossHammerling.cpp"
|
||||||
"WaveBossHorsemen.cpp"
|
"WaveBossHorsemen.cpp"
|
||||||
"WaveBossSpiderling.cpp"
|
"WaveBossSpiderling.cpp"
|
||||||
|
"WblGenericZone.cpp"
|
||||||
"WhFans.cpp"
|
"WhFans.cpp"
|
||||||
"WildAmbients.cpp"
|
"WildAmbients.cpp"
|
||||||
"WishingWellServer.cpp"
|
"WishingWellServer.cpp"
|
||||||
|
|||||||
@@ -61,6 +61,8 @@
|
|||||||
#include "VeMissionConsole.h"
|
#include "VeMissionConsole.h"
|
||||||
#include "VeEpsilonServer.h"
|
#include "VeEpsilonServer.h"
|
||||||
#include "AgSurvivalBuffStation.h"
|
#include "AgSurvivalBuffStation.h"
|
||||||
|
#include "QbSpawner.h"
|
||||||
|
#include "AgQbWall.h"
|
||||||
|
|
||||||
// NS Scripts
|
// NS Scripts
|
||||||
#include "NsModularBuild.h"
|
#include "NsModularBuild.h"
|
||||||
@@ -286,6 +288,9 @@
|
|||||||
#include "RockHydrantBroken.h"
|
#include "RockHydrantBroken.h"
|
||||||
#include "WhFans.h"
|
#include "WhFans.h"
|
||||||
|
|
||||||
|
// WBL scripts
|
||||||
|
#include "WblGenericZone.h"
|
||||||
|
|
||||||
//Big bad global bc this is a namespace and not a class:
|
//Big bad global bc this is a namespace and not a class:
|
||||||
InvalidScript* invalidToReturn = new InvalidScript();
|
InvalidScript* invalidToReturn = new InvalidScript();
|
||||||
std::map<std::string, CppScripts::Script*> m_Scripts;
|
std::map<std::string, CppScripts::Script*> m_Scripts;
|
||||||
@@ -466,6 +471,10 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = new WildAmbients();
|
script = new WildAmbients();
|
||||||
else if (scriptName == "scripts\\ai\\NS\\NS_PP_01\\L_NS_PP_01_TELEPORT.lua")
|
else if (scriptName == "scripts\\ai\\NS\\NS_PP_01\\L_NS_PP_01_TELEPORT.lua")
|
||||||
script = new PropertyDeathPlane();
|
script = new PropertyDeathPlane();
|
||||||
|
else if (scriptName == "scripts\\02_server\\Map\\General\\L_QB_SPAWNER.lua")
|
||||||
|
script = new QbSpawner();
|
||||||
|
else if (scriptName == "scripts\\ai\\AG\\L_AG_QB_Wall.lua")
|
||||||
|
script = new AgQbWall();
|
||||||
|
|
||||||
//GF:
|
//GF:
|
||||||
else if (scriptName == "scripts\\02_server\\Map\\GF\\L_GF_TORCH.lua")
|
else if (scriptName == "scripts\\02_server\\Map\\GF\\L_GF_TORCH.lua")
|
||||||
@@ -828,12 +837,17 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = new BuccaneerValiantShip();
|
script = new BuccaneerValiantShip();
|
||||||
else if (scriptName == "scripts\\EquipmentScripts\\FireFirstSkillonStartup.lua")
|
else if (scriptName == "scripts\\EquipmentScripts\\FireFirstSkillonStartup.lua")
|
||||||
script = new FireFirstSkillonStartup();
|
script = new FireFirstSkillonStartup();
|
||||||
|
|
||||||
// FB
|
// FB
|
||||||
else if (scriptName == "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua")
|
else if (scriptName == "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua")
|
||||||
script = new RockHydrantBroken();
|
script = new RockHydrantBroken();
|
||||||
else if (scriptName == "scripts\\ai\\NS\\L_NS_WH_FANS.lua")
|
else if (scriptName == "scripts\\ai\\NS\\L_NS_WH_FANS.lua")
|
||||||
script = new WhFans();
|
script = new WhFans();
|
||||||
|
|
||||||
|
// WBL
|
||||||
|
else if (scriptName == "scripts\\zone\\LUPs\\WBL_generic_zone.lua")
|
||||||
|
script = new WblGenericZone();
|
||||||
|
|
||||||
//Ignore these scripts:
|
//Ignore these scripts:
|
||||||
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
||||||
script = invalidToReturn;
|
script = invalidToReturn;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
|
|||||||
if (!self->GetBoolean(u"bIsHit")) {
|
if (!self->GetBoolean(u"bIsHit")) {
|
||||||
for (Entity* en : entities) {
|
for (Entity* en : entities) {
|
||||||
if (en->GetObjectID() == attacker->GetObjectID()) {
|
if (en->GetObjectID() == attacker->GetObjectID()) {
|
||||||
if (Vector3::DistanceSquared(en->GetPosition(), self->GetPosition()) > 10 * 10) continue;
|
if (NiPoint3::DistanceSquared(en->GetPosition(), self->GetPosition()) > 10 * 10) continue;
|
||||||
|
|
||||||
auto* destroyable = en->GetComponent<DestroyableComponent>();
|
auto* destroyable = en->GetComponent<DestroyableComponent>();
|
||||||
if (destroyable == nullptr) {
|
if (destroyable == nullptr) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
|
|||||||
|
|
||||||
const auto rads = degrees * (static_cast<float>(M_PI) / 180.0f);
|
const auto rads = degrees * (static_cast<float>(M_PI) / 180.0f);
|
||||||
|
|
||||||
const Vector3 newPlayerRot = { 0, rads, 0 };
|
const NiPoint3 newPlayerRot = { 0, rads, 0 };
|
||||||
|
|
||||||
auto position = self->GetPosition();
|
auto position = self->GetPosition();
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ Entity* PetDigServer::GetClosestTresure(NiPoint3 position) {
|
|||||||
|
|
||||||
if (tresure == nullptr) continue;
|
if (tresure == nullptr) continue;
|
||||||
|
|
||||||
float distance = Vector3::DistanceSquared(tresure->GetPosition(), position);
|
float distance = NiPoint3::DistanceSquared(tresure->GetPosition(), position);
|
||||||
|
|
||||||
if (closest == nullptr || distance < closestDistance) {
|
if (closest == nullptr || distance < closestDistance) {
|
||||||
closestDistance = distance;
|
closestDistance = distance;
|
||||||
|
|||||||
136
dScripts/QbSpawner.cpp
Normal file
136
dScripts/QbSpawner.cpp
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
#include "QbSpawner.h"
|
||||||
|
#include "BaseCombatAIComponent.h"
|
||||||
|
#include "MovementAIComponent.h"
|
||||||
|
|
||||||
|
void QbSpawner::OnStartup(Entity* self) {
|
||||||
|
auto mobNum = self->GetVar<int>(u"mobNum");
|
||||||
|
auto spawnDist = self->GetVar<float>(u"spawnDist");
|
||||||
|
auto mobTemplate = self->GetVar<LWOOBJID>(u"mobTemplate");
|
||||||
|
auto spawnTime = self->GetVar<float>(u"spawnTime");
|
||||||
|
|
||||||
|
if (!mobNum) self->SetVar<int>(u"mobNum", m_DefaultMobNum);
|
||||||
|
if (!spawnDist) self->SetVar<float>(u"spawnDist", m_DefaultSpawnDist);
|
||||||
|
if (!mobTemplate) self->SetVar<LWOOBJID>(u"mobTemplate", m_DefaultMobTemplate);
|
||||||
|
if (!spawnTime) self->SetVar<float>(u"spawnTime", m_DefaultSpawnTime);
|
||||||
|
|
||||||
|
// go ahead and setup the mob table here
|
||||||
|
std::vector<LWOOBJID> mobTable;
|
||||||
|
mobTable.assign(self->GetVar<int>(u"mobNum"), LWOOBJID_EMPTY);
|
||||||
|
|
||||||
|
self->SetVar<std::vector<LWOOBJID>>(u"mobTable", mobTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QbSpawner::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
||||||
|
auto gateObjID = sender->GetObjectID();
|
||||||
|
if (!gateObjID) return;
|
||||||
|
if (args == "spawnMobs") {
|
||||||
|
self->SetVar(u"gateObj", gateObjID);
|
||||||
|
auto spawnTime = self->GetVar<float>(u"spawnTime");
|
||||||
|
self->AddTimer("SpawnMobEnemies", spawnTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QbSpawner::OnTimerDone(Entity* self, std::string timerName) {
|
||||||
|
if (timerName == "SpawnMobEnemies") {
|
||||||
|
auto mobTable = self->GetVar<std::vector<LWOOBJID>>(u"mobTable");
|
||||||
|
|
||||||
|
auto spawnDist = self->GetVar<float>(u"spawnDist");
|
||||||
|
auto mobTemplate = self->GetVar<LWOOBJID>(u"mobTemplate");
|
||||||
|
|
||||||
|
auto gateObjID = self->GetVar<LWOOBJID>(u"gateObj");
|
||||||
|
if (!gateObjID) return;
|
||||||
|
|
||||||
|
auto* gate = EntityManager::Instance()->GetEntity(gateObjID);
|
||||||
|
if (!gate) return;
|
||||||
|
|
||||||
|
auto oPos = gate->GetPosition();
|
||||||
|
auto oDir = gate->GetRotation().GetForwardVector();
|
||||||
|
NiPoint3 newPos(
|
||||||
|
oPos.x + (oDir.x * spawnDist),
|
||||||
|
oPos.y,
|
||||||
|
oPos.z + (oDir.z * spawnDist)
|
||||||
|
);
|
||||||
|
auto newRot = NiQuaternion::LookAt(newPos, oPos);
|
||||||
|
|
||||||
|
for (int i = 0; i < mobTable.size(); i++) {
|
||||||
|
int posOffset = -10;
|
||||||
|
if (mobTable[i] == LWOOBJID_EMPTY) {
|
||||||
|
posOffset = posOffset + 5 * i;
|
||||||
|
auto newOffset = newPos;
|
||||||
|
newOffset.z = newOffset.z + posOffset;
|
||||||
|
|
||||||
|
EntityInfo info{};
|
||||||
|
info.lot = mobTemplate;
|
||||||
|
info.pos = newOffset;
|
||||||
|
info.rot = newRot;
|
||||||
|
info.spawnerID = self->GetObjectID();
|
||||||
|
info.spawnerNodeID = 0;
|
||||||
|
info.settings = {
|
||||||
|
new LDFData<bool>(u"no_timed_spawn", true),
|
||||||
|
new LDFData<float>(u"aggroRadius", 70),
|
||||||
|
new LDFData<float>(u"softtetherRadius", 80),
|
||||||
|
new LDFData<float>(u"tetherRadius", 90),
|
||||||
|
new LDFData<float>(u"wanderRadius", 5),
|
||||||
|
new LDFData<int>(u"mobTableLoc", i)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto* child = EntityManager::Instance()->CreateEntity(info, nullptr, self);
|
||||||
|
EntityManager::Instance()->ConstructEntity(child);
|
||||||
|
|
||||||
|
OnChildLoaded(self, child);
|
||||||
|
} else {
|
||||||
|
auto* mob = EntityManager::Instance()->GetEntity(mobTable[i]);
|
||||||
|
AggroTargetObject(self, mob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QbSpawner::OnChildLoaded(Entity* self, Entity* child) {
|
||||||
|
auto mobTable = self->GetVar<std::vector<LWOOBJID>>(u"mobTable");
|
||||||
|
auto tableLoc = child->GetVar<int>(u"mobTableLoc");
|
||||||
|
|
||||||
|
mobTable[tableLoc] = child->GetObjectID();
|
||||||
|
self->SetVar<std::vector<LWOOBJID>>(u"mobTable", mobTable);
|
||||||
|
|
||||||
|
AggroTargetObject(self, child);
|
||||||
|
|
||||||
|
const auto selfID = self->GetObjectID();
|
||||||
|
|
||||||
|
child->AddDieCallback([this, selfID, child]() {
|
||||||
|
auto* self = EntityManager::Instance()->GetEntity(selfID);
|
||||||
|
OnChildRemoved(self, child);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QbSpawner::OnChildRemoved(Entity* self, Entity* child) {
|
||||||
|
auto mobTable = self->GetVar<std::vector<LWOOBJID>>(u"mobTable");
|
||||||
|
auto tableLoc = child->GetVar<int>(u"mobTableLoc");
|
||||||
|
|
||||||
|
mobTable[tableLoc] = LWOOBJID_EMPTY;
|
||||||
|
self->SetVar<std::vector<LWOOBJID>>(u"mobTable", mobTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QbSpawner::AggroTargetObject(Entity* self, Entity* enemy) {
|
||||||
|
auto* baseCombatAIComponent = enemy->GetComponent<BaseCombatAIComponent>();
|
||||||
|
if (!baseCombatAIComponent) return;
|
||||||
|
|
||||||
|
auto gateObjID = self->GetVar<LWOOBJID>(u"gateObj");
|
||||||
|
if (gateObjID) {
|
||||||
|
auto* gate = EntityManager::Instance()->GetEntity(gateObjID);
|
||||||
|
if (gate) {
|
||||||
|
auto* movementAIComponent = enemy->GetComponent<MovementAIComponent>();
|
||||||
|
if (movementAIComponent) movementAIComponent->SetDestination(gate->GetPosition());
|
||||||
|
baseCombatAIComponent->Taunt(gateObjID, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto playerObjID = self->GetVar<LWOOBJID>(u"player");
|
||||||
|
if (playerObjID) {
|
||||||
|
baseCombatAIComponent->Taunt(playerObjID, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
17
dScripts/QbSpawner.h
Normal file
17
dScripts/QbSpawner.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CppScripts.h"
|
||||||
|
|
||||||
|
class QbSpawner : 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 OnTimerDone(Entity* self, std::string timerName) override;
|
||||||
|
void OnChildLoaded(Entity* self, Entity* child);
|
||||||
|
void OnChildRemoved(Entity* self, Entity* child);
|
||||||
|
void AggroTargetObject(Entity* self, Entity* enemy);
|
||||||
|
private:
|
||||||
|
const int m_DefaultMobNum = 3;
|
||||||
|
const float m_DefaultSpawnDist = 25.0;
|
||||||
|
const LWOOBJID m_DefaultMobTemplate = 4712;
|
||||||
|
const float m_DefaultSpawnTime = 2.0;
|
||||||
|
};
|
||||||
@@ -21,19 +21,19 @@ void SGCannon::OnStartup(Entity* self) {
|
|||||||
ResetVars(self);
|
ResetVars(self);
|
||||||
|
|
||||||
self->SetVar<bool>(GameStartedVariable, false);
|
self->SetVar<bool>(GameStartedVariable, false);
|
||||||
self->SetVar<Vector3>(InitialVelocityVariable, {});
|
self->SetVar<NiPoint3>(InitialVelocityVariable, {});
|
||||||
self->SetVar<uint32_t>(ImpactSkillVariale, constants.impactSkillID);
|
self->SetVar<uint32_t>(ImpactSkillVariale, constants.impactSkillID);
|
||||||
|
|
||||||
auto* shootingGalleryComponent = self->GetComponent<ShootingGalleryComponent>();
|
auto* shootingGalleryComponent = self->GetComponent<ShootingGalleryComponent>();
|
||||||
if (shootingGalleryComponent != nullptr) {
|
if (shootingGalleryComponent != nullptr) {
|
||||||
shootingGalleryComponent->SetStaticParams({
|
shootingGalleryComponent->SetStaticParams({
|
||||||
Vector3 { -327.8609924316406, 256.8999938964844, 1.6482199430465698 },
|
NiPoint3 { -327.8609924316406, 256.8999938964844, 1.6482199430465698 },
|
||||||
Vector3 { -181.4320068359375, 212.39999389648438, 2.5182199478149414 }
|
NiPoint3 { -181.4320068359375, 212.39999389648438, 2.5182199478149414 }
|
||||||
});
|
});
|
||||||
|
|
||||||
shootingGalleryComponent->SetDynamicParams({
|
shootingGalleryComponent->SetDynamicParams({
|
||||||
Vector3 { 0.0, 4.3, 9.0 },
|
NiPoint3 { 0.0, 4.3, 9.0 },
|
||||||
Vector3 { },
|
NiPoint3 { },
|
||||||
129.0,
|
129.0,
|
||||||
800.0,
|
800.0,
|
||||||
30.0,
|
30.0,
|
||||||
@@ -1030,17 +1030,17 @@ void SGCannon::ResetVars(Entity* self) {
|
|||||||
|
|
||||||
SGConstants SGCannon::GetConstants() {
|
SGConstants SGCannon::GetConstants() {
|
||||||
return {
|
return {
|
||||||
Vector3 { -908.542480, 229.773178, -908.542480 },
|
NiPoint3 { -908.542480, 229.773178, -908.542480 },
|
||||||
Quaternion { 0.91913521289825, 0, 0.39394217729568, 0 },
|
NiQuaternion { 0.91913521289825, 0, 0.39394217729568, 0 },
|
||||||
1864,
|
1864,
|
||||||
34,
|
34,
|
||||||
1822,
|
1822,
|
||||||
Vector3 { 6.652, -2, 1.5 },
|
NiPoint3 { 6.652, -2, 1.5 },
|
||||||
157,
|
157,
|
||||||
129.0,
|
129.0,
|
||||||
30.0,
|
30.0,
|
||||||
800.0,
|
800.0,
|
||||||
Vector3 { 0, 4.3, 9 },
|
NiPoint3 { 0, 4.3, 9 },
|
||||||
6297,
|
6297,
|
||||||
1822,
|
1822,
|
||||||
249,
|
249,
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ struct SGEnemy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct SGConstants {
|
struct SGConstants {
|
||||||
Vector3 playerStartPosition;
|
NiPoint3 playerStartPosition;
|
||||||
Quaternion playerStartRotation;
|
NiQuaternion playerStartRotation;
|
||||||
LOT cannonLot;
|
LOT cannonLot;
|
||||||
uint32_t impactSkillID;
|
uint32_t impactSkillID;
|
||||||
LOT projectileLot;
|
LOT projectileLot;
|
||||||
Vector3 playerOffset;
|
NiPoint3 playerOffset;
|
||||||
uint32_t rewardModelMatrix;
|
uint32_t rewardModelMatrix;
|
||||||
float_t cannonVelocity;
|
float_t cannonVelocity;
|
||||||
float_t cannonMinDistance;
|
float_t cannonMinDistance;
|
||||||
float_t cannonRefireRate;
|
float_t cannonRefireRate;
|
||||||
Vector3 cannonBarrelOffset;
|
NiPoint3 cannonBarrelOffset;
|
||||||
LOT cannonSuperchargedProjectileLot;
|
LOT cannonSuperchargedProjectileLot;
|
||||||
LOT cannonProjectileLot;
|
LOT cannonProjectileLot;
|
||||||
uint32_t cannonSuperChargeSkill;
|
uint32_t cannonSuperChargeSkill;
|
||||||
|
|||||||
10
dScripts/WblGenericZone.cpp
Normal file
10
dScripts/WblGenericZone.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "WblGenericZone.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
void WblGenericZone::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
||||||
|
if (args == m_WblAbortMsg) {
|
||||||
|
if (!sender) return;
|
||||||
|
auto player = dynamic_cast<Player*>(sender);
|
||||||
|
if (player) player->SendToZone(m_WblMainZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
dScripts/WblGenericZone.h
Normal file
10
dScripts/WblGenericZone.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CppScripts.h"
|
||||||
|
class WblGenericZone : 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 LWOMAPID m_WblMainZone = 1600;
|
||||||
|
const std::string m_WblAbortMsg = "AbortWBLZone";
|
||||||
|
};
|
||||||
2
dVisualDebugger/CMakeLists.txt
Normal file
2
dVisualDebugger/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
add_library(dVisualDebugger dVisualDebugger.cpp)
|
||||||
|
target_link_libraries(dVisualDebugger raylib Recast Detour)
|
||||||
167
dVisualDebugger/dVisualDebugger.cpp
Normal file
167
dVisualDebugger/dVisualDebugger.cpp
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
#include "dVisualDebugger.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include "Game.h"
|
||||||
|
#include "dpWorld.h"
|
||||||
|
#include "dpEntity.h"
|
||||||
|
#include "dpShapeBox.h"
|
||||||
|
#include "dpShapeSphere.h"
|
||||||
|
#include "EntityManager.h"
|
||||||
|
#include "PerformanceManager.h"
|
||||||
|
#include "dTerrain/RawFile.h"
|
||||||
|
#include "dTerrain/RawMesh.h"
|
||||||
|
#include "SimplePhysicsComponent.h"
|
||||||
|
#include "dZoneManager.h"
|
||||||
|
|
||||||
|
inline Vector3 NiPointToVector3(NiPoint3 pos) { return { pos.x, pos.y, pos.z }; };
|
||||||
|
inline NiPoint3 Vector3ToNiPoint(Vector3 pos) { return { pos.x, pos.y, pos.z }; };
|
||||||
|
|
||||||
|
inline Quaternion NiQuaternionToQuaternion(NiQuaternion rot) { return { rot.x, rot.y, rot.z, rot.w }; };
|
||||||
|
inline NiQuaternion QuaternionToNiQuaternion(Quaternion rot) { return { rot.x, rot.y, rot.z, rot.w }; };
|
||||||
|
|
||||||
|
dVisualDebugger::dVisualDebugger(std::string zoneName) {
|
||||||
|
SetTraceLogLevel(LOG_FATAL);
|
||||||
|
InitWindow(m_Width, m_Height, ("dVisualDebugger: " + zoneName).c_str());
|
||||||
|
|
||||||
|
CreateCamera();
|
||||||
|
CreateInGameCamera();
|
||||||
|
|
||||||
|
std::string zonePath = dZoneManager::Instance()->GetZone()->GetFilePathForZoneID();
|
||||||
|
|
||||||
|
zonePath = zonePath.substr(0, zonePath.rfind('/') + 1);
|
||||||
|
zonePath += dZoneManager::Instance()->GetZone()->GetZoneRawPath();
|
||||||
|
|
||||||
|
m_Terrain = new RawFile(zonePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
dVisualDebugger::~dVisualDebugger() {
|
||||||
|
if (m_Camera) delete m_Camera;
|
||||||
|
if (m_Terrain) delete m_Terrain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::CreateInGameCamera() {
|
||||||
|
EntityInfo info;
|
||||||
|
info.lot = m_CameraID;
|
||||||
|
info.pos = { m_Camera->position.x, m_Camera->position.y, m_Camera->position.z };
|
||||||
|
info.rot = NiQuaternion::LookAt(info.pos, { m_Camera->target.x, m_Camera->target.y, m_Camera->target.z });
|
||||||
|
info.spawner = nullptr;
|
||||||
|
info.spawnerID = dZoneManager::Instance()->GetZoneControlObject()->GetObjectID();
|
||||||
|
info.spawnerNodeID = 0;
|
||||||
|
|
||||||
|
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||||
|
m_CameraObjid = newEntity->GetObjectID();
|
||||||
|
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::CreateCamera() {
|
||||||
|
Camera3D* camera = new Camera3D();
|
||||||
|
|
||||||
|
camera->position = { 0.f, 0.f, 0.f };
|
||||||
|
camera->target = { 0.f, 1.f, 0.f };
|
||||||
|
camera->up = { 0.f, 1.f, 0.f };
|
||||||
|
camera->fovy = 40.0f;
|
||||||
|
camera->projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
m_Camera = camera;
|
||||||
|
|
||||||
|
SetCameraMode(*m_Camera, CAMERA_FIRST_PERSON);
|
||||||
|
|
||||||
|
float frameRateAprox = 1000 / PerformanceManager::GetServerFramerate();
|
||||||
|
|
||||||
|
SetTargetFPS((int32_t)frameRateAprox); // truncate exact frame rate
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::Step(float delta) {
|
||||||
|
if (WindowShouldClose()) {
|
||||||
|
CloseWindow();
|
||||||
|
exit(0); // Kill entire server, this is a dev tool at the end of the day
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateCamera(m_Camera);
|
||||||
|
|
||||||
|
this->UpdateCameraPosition();
|
||||||
|
this->UpdateInGameCameraPosition();
|
||||||
|
|
||||||
|
this->HandleInputs();
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
BeginMode3D(*m_Camera);
|
||||||
|
this->RenderEntities(Game::physicsWorld->GetDynamicEntities(), true);
|
||||||
|
this->RenderEntities(Game::physicsWorld->GetStaticEntities(), false);
|
||||||
|
this->RenderTerrainMesh();
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
DrawText((std::to_string(m_Camera->position.x) + " " + std::to_string(m_Camera->position.y) + " " + std::to_string(m_Camera->position.z)).c_str(), 10, 0, 10, BLACK);
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::HandleInputs() {
|
||||||
|
if (IsKeyDown(KEY_SPACE)) m_BindToGM = !m_BindToGM;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::UpdateCameraPosition() {
|
||||||
|
if (!m_BindToGM) return;
|
||||||
|
|
||||||
|
auto characters = EntityManager::Instance()->GetEntitiesByLOT(1);
|
||||||
|
if (characters.size() != 1) return;
|
||||||
|
|
||||||
|
m_Camera->position = NiPointToVector3(characters[0]->GetPosition());
|
||||||
|
m_Camera->target = NiPointToVector3();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::UpdateInGameCameraPosition() {
|
||||||
|
auto* camera = EntityManager::Instance()->GetEntity(m_CameraObjid);
|
||||||
|
|
||||||
|
if (!camera) return;
|
||||||
|
|
||||||
|
auto* physComp = camera->GetComponent<SimplePhysicsComponent>();
|
||||||
|
|
||||||
|
auto cameraPos = Vector3ToNiPoint(m_Camera->position);
|
||||||
|
|
||||||
|
cameraPos.SetY(cameraPos.GetY() + 10);
|
||||||
|
physComp->SetPosition(cameraPos);
|
||||||
|
physComp->SetRotation(NiQuaternion::LookAt(Vector3ToNiPoint(m_Camera->position), Vector3ToNiPoint(m_Camera->target)));
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::RenderTerrainMesh() {
|
||||||
|
if (!m_Terrain->GetMesh()) return;
|
||||||
|
|
||||||
|
for (int i = 0; i < m_Terrain->GetMesh()->m_Triangles.size(); i += 3) {
|
||||||
|
auto v1 = m_Terrain->GetMesh()->m_Vertices[m_Terrain->GetMesh()->m_Triangles[i]];
|
||||||
|
auto v2 = m_Terrain->GetMesh()->m_Vertices[m_Terrain->GetMesh()->m_Triangles[i + 1]];
|
||||||
|
auto v3 = m_Terrain->GetMesh()->m_Vertices[m_Terrain->GetMesh()->m_Triangles[i + 2]];
|
||||||
|
|
||||||
|
DrawTriangle3D(NiPointToVector3(v1), NiPointToVector3(v2), NiPointToVector3(v3), GRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dVisualDebugger::RenderEntities(std::vector<dpEntity*>* entities, bool dynamic) {
|
||||||
|
auto colour = dynamic ? RED : BLUE;
|
||||||
|
|
||||||
|
for (auto* item : *entities) {
|
||||||
|
auto* shape = item->GetShape();
|
||||||
|
|
||||||
|
switch (shape->GetShapeType()) {
|
||||||
|
case dpShapeType::Box: {
|
||||||
|
auto box = static_cast<dpShapeBox*>(shape);
|
||||||
|
DrawCube(NiPointToVector3(item->GetPosition()), box->GetWidth(), box->GetHeight(), box->GetDepth(), colour);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case dpShapeType::Sphere: {
|
||||||
|
auto sphere = static_cast<dpShapeSphere*>(shape);
|
||||||
|
DrawSphere(NiPointToVector3(item->GetPosition()), sphere->GetRadius(), colour);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
default: {
|
||||||
|
break; // We can ignore this
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
37
dVisualDebugger/dVisualDebugger.h
Normal file
37
dVisualDebugger/dVisualDebugger.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Camera3D;
|
||||||
|
class dpEntity;
|
||||||
|
class RawFile;
|
||||||
|
|
||||||
|
class dVisualDebugger {
|
||||||
|
public:
|
||||||
|
dVisualDebugger(std::string zoneName);
|
||||||
|
~dVisualDebugger();
|
||||||
|
|
||||||
|
void Step(float delta);
|
||||||
|
private:
|
||||||
|
Camera3D* m_Camera;
|
||||||
|
RawFile* m_Terrain;
|
||||||
|
uint64_t m_CameraObjid;
|
||||||
|
bool m_BindToGM = false;
|
||||||
|
|
||||||
|
void CreateCamera();
|
||||||
|
void CreateInGameCamera();
|
||||||
|
|
||||||
|
void UpdateCameraPosition();
|
||||||
|
void UpdateInGameCameraPosition();
|
||||||
|
|
||||||
|
void HandleInputs();
|
||||||
|
|
||||||
|
void RenderEntities(std::vector<dpEntity*>* entities, bool dynamic);
|
||||||
|
void RenderTerrainMesh();
|
||||||
|
|
||||||
|
const int32_t m_Width = 800;
|
||||||
|
const int32_t m_Height = 450;
|
||||||
|
const int32_t m_CameraID = 5204;
|
||||||
|
};
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
|
if (BUILD_VISUAL_DEBUGGER)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_VISUAL_DEBUGGER=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(DWORLDSERVER_SOURCES "ObjectIDManager.cpp"
|
set(DWORLDSERVER_SOURCES "ObjectIDManager.cpp"
|
||||||
"PerformanceManager.cpp"
|
"PerformanceManager.cpp"
|
||||||
"WorldServer.cpp")
|
"WorldServer.cpp")
|
||||||
|
|
||||||
add_executable(WorldServer ${DWORLDSERVER_SOURCES})
|
add_executable(WorldServer ${DWORLDSERVER_SOURCES})
|
||||||
target_link_libraries(WorldServer ${COMMON_LIBRARIES} dChatFilter dGame dZoneManager Detour Recast dPhysics tinyxml2 dNavigation)
|
|
||||||
|
set(DWORLDSERVER_LIBRARIES dChatFilter dGame dZoneManager Detour Recast dPhysics tinyxml2 dNavigation)
|
||||||
|
|
||||||
|
if (BUILD_VISUAL_DEBUGGER)
|
||||||
|
set(DWORLDSERVER_LIBRARIES ${DWORLDSERVER_LIBRARIES} dVisualDebugger raylib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(WorldServer ${COMMON_LIBRARIES} ${DWORLDSERVER_LIBRARIES})
|
||||||
|
|||||||
@@ -56,6 +56,10 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "PropertyManagementComponent.h"
|
#include "PropertyManagementComponent.h"
|
||||||
|
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
#include "../dVisualDebugger/dVisualDebugger.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ZCompression.h"
|
#include "ZCompression.h"
|
||||||
|
|
||||||
namespace Game {
|
namespace Game {
|
||||||
@@ -66,6 +70,9 @@ namespace Game {
|
|||||||
dChatFilter* chatFilter;
|
dChatFilter* chatFilter;
|
||||||
dConfig* config;
|
dConfig* config;
|
||||||
dLocale* locale;
|
dLocale* locale;
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
dVisualDebugger* visualDebugger;
|
||||||
|
#endif
|
||||||
std::mt19937 randomEngine;
|
std::mt19937 randomEngine;
|
||||||
|
|
||||||
RakPeerInterface* chatServer;
|
RakPeerInterface* chatServer;
|
||||||
@@ -237,7 +244,9 @@ int main(int argc, char** argv) {
|
|||||||
Game::physicsWorld = &dpWorld::Instance(); //just in case some old code references it
|
Game::physicsWorld = &dpWorld::Instance(); //just in case some old code references it
|
||||||
dZoneManager::Instance()->Initialize(LWOZONEID(zoneID, instanceID, cloneID));
|
dZoneManager::Instance()->Initialize(LWOZONEID(zoneID, instanceID, cloneID));
|
||||||
g_CloneID = cloneID;
|
g_CloneID = cloneID;
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
Game::visualDebugger = new dVisualDebugger(dZoneManager::Instance()->GetZone()->GetZoneName());
|
||||||
|
#endif
|
||||||
// pre calculate the FDB checksum
|
// pre calculate the FDB checksum
|
||||||
if (Game::config->GetValue("check_fdb") == "1") {
|
if (Game::config->GetValue("check_fdb") == "1") {
|
||||||
std::ifstream fileStream;
|
std::ifstream fileStream;
|
||||||
@@ -347,6 +356,12 @@ int main(int argc, char** argv) {
|
|||||||
Metrics::StartMeasurement(MetricVariable::UpdateSpawners);
|
Metrics::StartMeasurement(MetricVariable::UpdateSpawners);
|
||||||
dZoneManager::Instance()->Update(deltaTime);
|
dZoneManager::Instance()->Update(deltaTime);
|
||||||
Metrics::EndMeasurement(MetricVariable::UpdateSpawners);
|
Metrics::EndMeasurement(MetricVariable::UpdateSpawners);
|
||||||
|
|
||||||
|
#ifdef BUILD_VISUAL_DEBUGGER
|
||||||
|
Metrics::StartMeasurement(MetricVariable::VisualDebugger);
|
||||||
|
Game::visualDebugger->Step(deltaTime);
|
||||||
|
Metrics::EndMeasurement(MetricVariable::VisualDebugger);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Metrics::StartMeasurement(MetricVariable::PacketHandling);
|
Metrics::StartMeasurement(MetricVariable::PacketHandling);
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ These commands are primarily for development and testing. The usage of many of t
|
|||||||
|teleport|`/teleport <x> (y) <z>`|Teleports you. If no Y is given, you are teleported to the height of the terrain or physics object at (x, z). Alias: `/tele`.|6|
|
|teleport|`/teleport <x> (y) <z>`|Teleports you. If no Y is given, you are teleported to the height of the terrain or physics object at (x, z). Alias: `/tele`.|6|
|
||||||
|activatespawner|`/activatespawner <spawner name>`|Activates spawner by name.|8|
|
|activatespawner|`/activatespawner <spawner name>`|Activates spawner by name.|8|
|
||||||
|addmission|`/addmission <mission id>`|Accepts the mission, adding it to your journal.|8|
|
|addmission|`/addmission <mission id>`|Accepts the mission, adding it to your journal.|8|
|
||||||
|boost|`/boost`|Adds a passive boost action if you are in a vehicle.|8|
|
|boost|`/boost (time)`|Adds a passive boost action if you are in a vehicle. If time is given it will end after that amount of time|8|
|
||||||
|
|unboost|`/unboost`|Removes a passive vehicle boost|8|
|
||||||
|buff|`/buff <id> <duration>`|Applies the buff with the given id for the given number of seconds.|8|
|
|buff|`/buff <id> <duration>`|Applies the buff with the given id for the given number of seconds.|8|
|
||||||
|buffme|`/buffme`|Sets health, armor, and imagination to 999.|8|
|
|buffme|`/buffme`|Sets health, armor, and imagination to 999.|8|
|
||||||
|buffmed|`/buffmed`|Sets health, armor, and imagination to 9.|8|
|
|buffmed|`/buffmed`|Sets health, armor, and imagination to 9.|8|
|
||||||
@@ -71,7 +72,7 @@ These commands are primarily for development and testing. The usage of many of t
|
|||||||
|completemission|`/completemission <mission id>`|Completes the mission, removing it from your journal.|8|
|
|completemission|`/completemission <mission id>`|Completes the mission, removing it from your journal.|8|
|
||||||
|createprivate|`/createprivate <zone id> <clone id> <password>`|Creates a private zone with password.|8|
|
|createprivate|`/createprivate <zone id> <clone id> <password>`|Creates a private zone with password.|8|
|
||||||
|debugui|`/debugui`|Toggle Debug UI.|8|
|
|debugui|`/debugui`|Toggle Debug UI.|8|
|
||||||
|dismount|`/dismount`|Dismounts you from the vehicle.|8|
|
|dismount|`/dismount`|Dismounts you from the vehicle or mount.|8|
|
||||||
|force-save|`/force-save`|While saving to database usually happens on regular intervals and when you disconnect from the server, this command saves your player's data to the database.|8|
|
|force-save|`/force-save`|While saving to database usually happens on regular intervals and when you disconnect from the server, this command saves your player's data to the database.|8|
|
||||||
|freecam|`/freecam`|Toggles freecam mode.|8|
|
|freecam|`/freecam`|Toggles freecam mode.|8|
|
||||||
|freemoney|`/freemoney <coins>`|Gives coins.|8|
|
|freemoney|`/freemoney <coins>`|Gives coins.|8|
|
||||||
|
|||||||
21
thirdparty/CMakeLists.txt
vendored
21
thirdparty/CMakeLists.txt
vendored
@@ -6,13 +6,15 @@ set(tinyxml2_BUILD_TESTING OFF)
|
|||||||
# Source Code for tinyxml2
|
# Source Code for tinyxml2
|
||||||
add_subdirectory(tinyxml2)
|
add_subdirectory(tinyxml2)
|
||||||
|
|
||||||
# Source Code for libbcrypt
|
# Source Code for libbcrypt. Uses a file glob instead to get around Windows build issues.
|
||||||
# Disable warning about no project version.
|
file(
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
|
GLOB SOURCES_LIBBCRYPT
|
||||||
# Disable warning about the minimum version of cmake used for bcrypt being deprecated in the future
|
LIST_DIRECTORIES false
|
||||||
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)
|
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/*.c
|
||||||
add_subdirectory(libbcrypt)
|
${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/src/*.c
|
||||||
|
)
|
||||||
|
add_library(bcrypt ${SOURCES_LIBBCRYPT})
|
||||||
|
|
||||||
# Source code for sqlite
|
# Source code for sqlite
|
||||||
add_subdirectory(SQLite)
|
add_subdirectory(SQLite)
|
||||||
@@ -23,6 +25,11 @@ include(CMakeMariaDBLists.txt)
|
|||||||
# Create our third party library objects
|
# Create our third party library objects
|
||||||
add_subdirectory(raknet)
|
add_subdirectory(raknet)
|
||||||
|
|
||||||
|
if(BUILD_VISUAL_DEBUGGER)
|
||||||
|
# If we are supposed to build the visual debugger include raylib
|
||||||
|
add_subdirectory(raylib)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Download Backtrace if configured
|
# Download Backtrace if configured
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|||||||
1
thirdparty/raylib
vendored
Submodule
1
thirdparty/raylib
vendored
Submodule
Submodule thirdparty/raylib added at 082920eb80
Reference in New Issue
Block a user