mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 15:37:20 +00:00
Rename some variables
- Add order for loading Components - Enforce all components have Entity* in the first argument
This commit is contained in:
parent
f555ba8c25
commit
6f057204be
@ -96,14 +96,14 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity)
|
|||||||
m_CollectibleID = 0;
|
m_CollectibleID = 0;
|
||||||
m_NetworkID = 0;
|
m_NetworkID = 0;
|
||||||
m_Observers = 0;
|
m_Observers = 0;
|
||||||
m_Groups = {};
|
|
||||||
m_OwnerOverride = LWOOBJID_EMPTY;
|
m_OwnerOverride = LWOOBJID_EMPTY;
|
||||||
m_Timers = {};
|
m_Groups.clear();
|
||||||
m_ChildEntities = {};
|
m_Timers.clear();
|
||||||
|
m_ChildEntities.clear();
|
||||||
|
m_TargetsInPhantom.clear();
|
||||||
|
m_DieCallbacks.clear();
|
||||||
|
m_PhantomCollisionCallbacks.clear();
|
||||||
m_ScheduleKiller = nullptr;
|
m_ScheduleKiller = nullptr;
|
||||||
m_TargetsInPhantom = {};
|
|
||||||
m_DieCallbacks = {};
|
|
||||||
m_PhantomCollisionCallbacks = {};
|
|
||||||
m_IsParentChildDirty = true;
|
m_IsParentChildDirty = true;
|
||||||
m_IsGhostingCandidate = false;
|
m_IsGhostingCandidate = false;
|
||||||
m_PlayerIsReadyForUpdates = false;
|
m_PlayerIsReadyForUpdates = false;
|
||||||
@ -378,6 +378,23 @@ void Entity::Initialize() {
|
|||||||
Game::logger->Log("Entity", "blah %i %i", componentId, m_TemplateID);
|
Game::logger->Log("Entity", "blah %i %i", componentId, m_TemplateID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto&[componentId, component] : m_Components) {
|
||||||
|
component->LoadTemplateData();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto&[componentId, component] : m_Components) {
|
||||||
|
component->LoadConfigData();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto&[componentId, component] : m_Components) {
|
||||||
|
component->Startup();
|
||||||
|
}
|
||||||
|
if (!IsPlayer()) return; // No save data to load for non players
|
||||||
|
|
||||||
|
for (const auto&[componentId, component] : m_Components) {
|
||||||
|
component->LoadFromXml(m_Character->GetXMLDoc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::operator==(const Entity& other) const {
|
bool Entity::operator==(const Entity& other) const {
|
||||||
|
@ -103,43 +103,43 @@ Entity::Initialize() {
|
|||||||
new PropertyEntranceComponent(propertyEntranceComponentID, this)));
|
new PropertyEntranceComponent(propertyEntranceComponentID, this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) {
|
// if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) {
|
||||||
ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this);
|
// ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this);
|
||||||
|
|
||||||
if (m_Character) {
|
// if (m_Character) {
|
||||||
controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());
|
// controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());
|
||||||
|
|
||||||
const auto mapID = Game::server->GetZoneID();
|
// const auto mapID = Game::server->GetZoneID();
|
||||||
|
|
||||||
//If we came from another zone, put us in the starting loc
|
// //If we came from another zone, put us in the starting loc
|
||||||
if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
// if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
||||||
NiPoint3 pos;
|
// NiPoint3 pos;
|
||||||
NiQuaternion rot;
|
// NiQuaternion rot;
|
||||||
|
|
||||||
const auto& targetSceneName = m_Character->GetTargetScene();
|
// const auto& targetSceneName = m_Character->GetTargetScene();
|
||||||
auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
// auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||||
|
|
||||||
if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
// if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||||
pos = m_Character->GetRespawnPoint(mapID);
|
// pos = m_Character->GetRespawnPoint(mapID);
|
||||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
// rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||||
} else if (targetScene != nullptr) {
|
// } else if (targetScene != nullptr) {
|
||||||
pos = targetScene->GetPosition();
|
// pos = targetScene->GetPosition();
|
||||||
rot = targetScene->GetRotation();
|
// rot = targetScene->GetRotation();
|
||||||
} else {
|
// } else {
|
||||||
pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
// pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
// rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||||
}
|
// }
|
||||||
|
|
||||||
controllablePhysics->SetPosition(pos);
|
// controllablePhysics->SetPosition(pos);
|
||||||
controllablePhysics->SetRotation(rot);
|
// controllablePhysics->SetRotation(rot);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
controllablePhysics->SetPosition(m_DefaultPosition);
|
// controllablePhysics->SetPosition(m_DefaultPosition);
|
||||||
controllablePhysics->SetRotation(m_DefaultRotation);
|
// controllablePhysics->SetRotation(m_DefaultRotation);
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_Components.insert(std::make_pair(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysics));
|
// m_Components.insert(std::make_pair(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysics));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// If an entity is marked a phantom, simple physics is made into phantom phyics.
|
// If an entity is marked a phantom, simple physics is made into phantom phyics.
|
||||||
bool markedAsPhantom = GetVar<bool>(u"markedAsPhantom");
|
bool markedAsPhantom = GetVar<bool>(u"markedAsPhantom");
|
||||||
|
@ -65,10 +65,10 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
|
|||||||
|
|
||||||
// Get aggro and tether radius from settings and use this if it is present. Only overwrite the
|
// Get aggro and tether radius from settings and use this if it is present. Only overwrite the
|
||||||
// radii if it is greater than the one in the database.
|
// radii if it is greater than the one in the database.
|
||||||
if (m_OwningEntity) {
|
if (m_ParentEntity) {
|
||||||
auto aggroRadius = m_OwningEntity->GetVar<float>(u"aggroRadius");
|
auto aggroRadius = m_ParentEntity->GetVar<float>(u"aggroRadius");
|
||||||
m_AggroRadius = aggroRadius != 0 ? aggroRadius : m_AggroRadius;
|
m_AggroRadius = aggroRadius != 0 ? aggroRadius : m_AggroRadius;
|
||||||
auto tetherRadius = m_OwningEntity->GetVar<float>(u"tetherRadius");
|
auto tetherRadius = m_ParentEntity->GetVar<float>(u"tetherRadius");
|
||||||
m_HardTetherRadius = tetherRadius != 0 ? tetherRadius : m_HardTetherRadius;
|
m_HardTetherRadius = tetherRadius != 0 ? tetherRadius : m_HardTetherRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,14 +120,14 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Create a phantom physics volume so we can detect when we're aggro'd.
|
//Create a phantom physics volume so we can detect when we're aggro'd.
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), m_AggroRadius);
|
||||||
m_dpEntityEnemy = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius, false);
|
m_dpEntityEnemy = new dpEntity(m_ParentEntity->GetObjectID(), m_AggroRadius, false);
|
||||||
|
|
||||||
m_dpEntity->SetCollisionGroup(collisionGroup);
|
m_dpEntity->SetCollisionGroup(collisionGroup);
|
||||||
m_dpEntityEnemy->SetCollisionGroup(collisionGroup);
|
m_dpEntityEnemy->SetCollisionGroup(collisionGroup);
|
||||||
|
|
||||||
m_dpEntity->SetPosition(m_OwningEntity->GetPosition());
|
m_dpEntity->SetPosition(m_ParentEntity->GetPosition());
|
||||||
m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition());
|
m_dpEntityEnemy->SetPosition(m_ParentEntity->GetPosition());
|
||||||
|
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntityEnemy);
|
dpWorld::Instance().AddEntity(m_dpEntityEnemy);
|
||||||
@ -146,17 +146,17 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
|||||||
//First, we need to process physics:
|
//First, we need to process physics:
|
||||||
if (!m_dpEntity) return;
|
if (!m_dpEntity) return;
|
||||||
|
|
||||||
m_dpEntity->SetPosition(m_OwningEntity->GetPosition()); //make sure our position is synced with our dpEntity
|
m_dpEntity->SetPosition(m_ParentEntity->GetPosition()); //make sure our position is synced with our dpEntity
|
||||||
m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition());
|
m_dpEntityEnemy->SetPosition(m_ParentEntity->GetPosition());
|
||||||
|
|
||||||
//Process enter events
|
//Process enter events
|
||||||
for (auto en : m_dpEntity->GetNewObjects()) {
|
for (auto en : m_dpEntity->GetNewObjects()) {
|
||||||
m_OwningEntity->OnCollisionPhantom(en->GetObjectID());
|
m_ParentEntity->OnCollisionPhantom(en->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process exit events
|
//Process exit events
|
||||||
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
||||||
m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
m_ParentEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we should stop the tether effect
|
// Check if we should stop the tether effect
|
||||||
@ -165,32 +165,32 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
|||||||
const auto& info = m_MovementAI->GetInfo();
|
const auto& info = m_MovementAI->GetInfo();
|
||||||
if (m_Target != LWOOBJID_EMPTY || (NiPoint3::DistanceSquared(
|
if (m_Target != LWOOBJID_EMPTY || (NiPoint3::DistanceSquared(
|
||||||
m_StartPosition,
|
m_StartPosition,
|
||||||
m_OwningEntity->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
|
m_ParentEntity->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
|
||||||
) {
|
) {
|
||||||
GameMessages::SendStopFXEffect(m_OwningEntity, true, "tether");
|
GameMessages::SendStopFXEffect(m_ParentEntity, true, "tether");
|
||||||
m_TetherEffectActive = false;
|
m_TetherEffectActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_SoftTimer <= 0.0f) {
|
if (m_SoftTimer <= 0.0f) {
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
m_SoftTimer = 5.0f;
|
m_SoftTimer = 5.0f;
|
||||||
} else {
|
} else {
|
||||||
m_SoftTimer -= deltaTime;
|
m_SoftTimer -= deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Disabled || m_OwningEntity->GetIsDead())
|
if (m_Disabled || m_ParentEntity->GetIsDead())
|
||||||
return;
|
return;
|
||||||
bool stunnedThisFrame = m_Stunned;
|
bool stunnedThisFrame = m_Stunned;
|
||||||
CalculateCombat(deltaTime); // Putting this here for now
|
CalculateCombat(deltaTime); // Putting this here for now
|
||||||
|
|
||||||
if (m_StartPosition == NiPoint3::ZERO) {
|
if (m_StartPosition == NiPoint3::ZERO) {
|
||||||
m_StartPosition = m_OwningEntity->GetPosition();
|
m_StartPosition = m_ParentEntity->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_MovementAI == nullptr) {
|
if (m_MovementAI == nullptr) {
|
||||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
m_MovementAI = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||||
if (m_MovementAI == nullptr) {
|
if (m_MovementAI == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
|||||||
bool hadRemainingDowntime = m_SkillTime > 0.0f;
|
bool hadRemainingDowntime = m_SkillTime > 0.0f;
|
||||||
if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime;
|
if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime;
|
||||||
|
|
||||||
auto* rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
|
auto* rebuild = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||||
|
|
||||||
if (rebuild != nullptr) {
|
if (rebuild != nullptr) {
|
||||||
const auto state = rebuild->GetState();
|
const auto state = rebuild->GetState();
|
||||||
@ -254,7 +254,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* skillComponent = m_OwningEntity->GetComponent<SkillComponent>();
|
auto* skillComponent = m_ParentEntity->GetComponent<SkillComponent>();
|
||||||
|
|
||||||
if (skillComponent == nullptr) {
|
if (skillComponent == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -288,7 +288,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) {
|
if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) {
|
||||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
|
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
|
||||||
auto serilizationRequired = false;
|
auto serilizationRequired = false;
|
||||||
@ -306,10 +306,10 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (serilizationRequired) {
|
if (serilizationRequired) {
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 6270, u"tether", "tether");
|
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), 6270, u"tether", "tether");
|
||||||
|
|
||||||
m_TetherEffectActive = true;
|
m_TetherEffectActive = true;
|
||||||
|
|
||||||
@ -497,10 +497,10 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
|||||||
std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
||||||
std::vector<LWOOBJID> targets;
|
std::vector<LWOOBJID> targets;
|
||||||
|
|
||||||
for (auto id : m_OwningEntity->GetTargetsInPhantom()) {
|
for (auto id : m_ParentEntity->GetTargetsInPhantom()) {
|
||||||
auto* other = EntityManager::Instance()->GetEntity(id);
|
auto* other = EntityManager::Instance()->GetEntity(id);
|
||||||
|
|
||||||
const auto distance = Vector3::DistanceSquared(m_OwningEntity->GetPosition(), other->GetPosition());
|
const auto distance = Vector3::DistanceSquared(m_ParentEntity->GetPosition(), other->GetPosition());
|
||||||
|
|
||||||
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BaseCombatAIComponent::IsMech() {
|
bool BaseCombatAIComponent::IsMech() {
|
||||||
switch (m_OwningEntity->GetLOT()) {
|
switch (m_ParentEntity->GetLOT()) {
|
||||||
case 6253:
|
case 6253:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ void BaseCombatAIComponent::SetAiState(AiState newState) {
|
|||||||
if (newState == this->m_State) return;
|
if (newState == this->m_State) return;
|
||||||
this->m_State = newState;
|
this->m_State = newState;
|
||||||
m_DirtyStateOrTarget = true;
|
m_DirtyStateOrTarget = true;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
||||||
@ -554,10 +554,10 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* referenceDestroyable = m_OwningEntity->GetComponent<DestroyableComponent>();
|
auto* referenceDestroyable = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (referenceDestroyable == nullptr) {
|
if (referenceDestroyable == nullptr) {
|
||||||
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID());
|
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -589,7 +589,7 @@ void BaseCombatAIComponent::SetTarget(const LWOOBJID target) {
|
|||||||
if (this->m_Target == target) return;
|
if (this->m_Target == target) return;
|
||||||
m_Target = target;
|
m_Target = target;
|
||||||
m_DirtyStateOrTarget = true;
|
m_DirtyStateOrTarget = true;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* BaseCombatAIComponent::GetTargetEntity() const {
|
Entity* BaseCombatAIComponent::GetTargetEntity() const {
|
||||||
@ -598,7 +598,7 @@ Entity* BaseCombatAIComponent::GetTargetEntity() const {
|
|||||||
|
|
||||||
void BaseCombatAIComponent::Taunt(LWOOBJID offender, float threat) {
|
void BaseCombatAIComponent::Taunt(LWOOBJID offender, float threat) {
|
||||||
// Can't taunt self
|
// Can't taunt self
|
||||||
if (offender == m_OwningEntity->GetObjectID())
|
if (offender == m_ParentEntity->GetObjectID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ThreatEntries[offender] += threat;
|
m_ThreatEntries[offender] += threat;
|
||||||
@ -789,7 +789,7 @@ void BaseCombatAIComponent::LookAt(const NiPoint3& point) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OwningEntity->SetRotation(NiQuaternion::LookAt(m_OwningEntity->GetPosition(), point));
|
m_ParentEntity->SetRotation(NiQuaternion::LookAt(m_ParentEntity->GetPosition(), point));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseCombatAIComponent::SetDisabled(bool value) {
|
void BaseCombatAIComponent::SetDisabled(bool value) {
|
||||||
|
@ -30,28 +30,28 @@ void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* BouncerComponent::GetParentEntity() const {
|
Entity* BouncerComponent::GetParentEntity() const {
|
||||||
return m_OwningEntity;
|
return m_ParentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BouncerComponent::SetPetEnabled(bool value) {
|
void BouncerComponent::SetPetEnabled(bool value) {
|
||||||
m_PetEnabled = value;
|
m_PetEnabled = value;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BouncerComponent::SetPetBouncerEnabled(bool value) {
|
void BouncerComponent::SetPetBouncerEnabled(bool value) {
|
||||||
m_PetBouncerEnabled = value;
|
m_PetBouncerEnabled = value;
|
||||||
|
|
||||||
GameMessages::SendBouncerActiveStatus(m_OwningEntity->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendBouncerActiveStatus(m_ParentEntity->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
m_OwningEntity->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_OwningEntity);
|
m_ParentEntity->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_ParentEntity);
|
||||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 1513, u"create", "PetOnSwitch", LWOOBJID_EMPTY, 1, 1, true);
|
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), 1513, u"create", "PetOnSwitch", LWOOBJID_EMPTY, 1, 1, true);
|
||||||
} else {
|
} else {
|
||||||
m_OwningEntity->TriggerEvent(eTriggerEventType::PET_OFF_SWITCH, m_OwningEntity);
|
m_ParentEntity->TriggerEvent(eTriggerEventType::PET_OFF_SWITCH, m_ParentEntity);
|
||||||
GameMessages::SendStopFXEffect(m_OwningEntity, true, "PetOnSwitch");
|
GameMessages::SendStopFXEffect(m_ParentEntity, true, "PetOnSwitch");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ bool BouncerComponent::GetPetBouncerEnabled() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BouncerComponent::LookupPetSwitch() {
|
void BouncerComponent::LookupPetSwitch() {
|
||||||
const auto& groups = m_OwningEntity->GetGroups();
|
const auto& groups = m_ParentEntity->GetGroups();
|
||||||
|
|
||||||
for (const auto& group : groups) {
|
for (const auto& group : groups) {
|
||||||
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group);
|
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group);
|
||||||
@ -79,7 +79,7 @@ void BouncerComponent::LookupPetSwitch() {
|
|||||||
m_PetSwitchLoaded = true;
|
m_PetSwitchLoaded = true;
|
||||||
m_PetEnabled = true;
|
m_PetEnabled = true;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
Game::logger->Log("BouncerComponent", "Loaded pet bouncer");
|
Game::logger->Log("BouncerComponent", "Loaded pet bouncer");
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ void BouncerComponent::LookupPetSwitch() {
|
|||||||
if (!m_PetSwitchLoaded) {
|
if (!m_PetSwitchLoaded) {
|
||||||
Game::logger->Log("BouncerComponent", "Failed to load pet bouncer");
|
Game::logger->Log("BouncerComponent", "Failed to load pet bouncer");
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(0.5f, [this]() {
|
m_ParentEntity->AddCallbackTimer(0.5f, [this]() {
|
||||||
LookupPetSwitch();
|
LookupPetSwitch();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void BuffComponent::Update(float deltaTime) {
|
|||||||
buff.second.tickTime = buff.second.tick;
|
buff.second.tickTime = buff.second.tick;
|
||||||
buff.second.stacks--;
|
buff.second.stacks--;
|
||||||
|
|
||||||
SkillComponent::HandleUnmanaged(buff.second.behaviorID, m_OwningEntity->GetObjectID(), buff.second.source);
|
SkillComponent::HandleUnmanaged(buff.second.behaviorID, m_ParentEntity->GetObjectID(), buff.second.source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendAddBuff(m_OwningEntity->GetObjectID(), source, (uint32_t)id,
|
GameMessages::SendAddBuff(m_ParentEntity->GetObjectID(), source, (uint32_t)id,
|
||||||
(uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath,
|
(uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath,
|
||||||
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendRemoveBuff(m_OwningEntity, fromUnEquip, removeImmunity, id);
|
GameMessages::SendRemoveBuff(m_ParentEntity, fromUnEquip, removeImmunity, id);
|
||||||
|
|
||||||
m_Buffs.erase(iter);
|
m_Buffs.erase(iter);
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ void BuffComponent::ReApplyBuffs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* BuffComponent::GetParentEntity() const {
|
Entity* BuffComponent::GetParentEntity() const {
|
||||||
return m_OwningEntity;
|
return m_ParentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||||
|
@ -19,7 +19,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
|
|||||||
if (originator->GetCharacter()) {
|
if (originator->GetCharacter()) {
|
||||||
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
|
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
|
||||||
|
|
||||||
auto buildArea = m_OwningEntity->GetObjectID();
|
auto buildArea = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
if (!entities.empty()) {
|
if (!entities.empty()) {
|
||||||
buildArea = entities[0]->GetObjectID();
|
buildArea = entities[0]->GetObjectID();
|
||||||
@ -63,7 +63,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
|
|||||||
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
|
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* inv = m_OwningEntity->GetComponent<InventoryComponent>();
|
auto* inv = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||||
if (!inv) return;
|
if (!inv) return;
|
||||||
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
|
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ void CharacterComponent::TrackRaceCompleted(bool won) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) {
|
void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) {
|
||||||
const auto distance = NiPoint3::Distance(newPosition, m_OwningEntity->GetPosition());
|
const auto distance = NiPoint3::Distance(newPosition, m_ParentEntity->GetPosition());
|
||||||
|
|
||||||
if (m_IsRacing) {
|
if (m_IsRacing) {
|
||||||
UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance);
|
UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance);
|
||||||
@ -731,8 +731,8 @@ void CharacterComponent::RemoveVentureVisionEffect(std::string ventureVisionType
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const {
|
void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const {
|
||||||
if (!m_OwningEntity) return;
|
if (!m_ParentEntity) return;
|
||||||
AMFArrayValue arrayToSend;
|
AMFArrayValue arrayToSend;
|
||||||
arrayToSend.Insert(ventureVisionType, showFaction);
|
arrayToSend.Insert(ventureVisionType, showFaction);
|
||||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity ? m_OwningEntity->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend);
|
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity ? m_ParentEntity->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Component::Component(Entity* owningEntity) {
|
Component::Component(Entity* owningEntity) {
|
||||||
DluAssert(owningEntity != nullptr);
|
DluAssert(owningEntity != nullptr);
|
||||||
m_OwningEntity = owningEntity;
|
m_ParentEntity = owningEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component::~Component() {
|
Component::~Component() {
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
* Gets the owner of this component
|
* Gets the owner of this component
|
||||||
* @return the owner of this component
|
* @return the owner of this component
|
||||||
*/
|
*/
|
||||||
Entity* GetParentEntity() const { return m_OwningEntity; };
|
Entity* GetParentEntity() const { return m_ParentEntity; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event called when this component is being used, e.g. when some entity interacted with it
|
* Event called when this component is being used, e.g. when some entity interacted with it
|
||||||
@ -70,5 +70,5 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* The entity that owns this component
|
* The entity that owns this component
|
||||||
*/
|
*/
|
||||||
Entity* m_OwningEntity;
|
Entity* m_ParentEntity;
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "dServer.h"
|
||||||
|
|
||||||
#include "dpWorld.h"
|
#include "dpWorld.h"
|
||||||
#include "dpEntity.h"
|
#include "dpEntity.h"
|
||||||
@ -51,18 +52,16 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
|
|||||||
m_ImmuneToStunTurnCount = 0;
|
m_ImmuneToStunTurnCount = 0;
|
||||||
m_ImmuneToStunUseItemCount = 0;
|
m_ImmuneToStunUseItemCount = 0;
|
||||||
|
|
||||||
if (entity->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
// Other physics entities we care about will be added by BaseCombatAI
|
||||||
return;
|
if (entity->GetLOT() != 1) return;
|
||||||
|
|
||||||
if (entity->GetLOT() == 1) {
|
|
||||||
Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics");
|
Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics");
|
||||||
|
|
||||||
float radius = 1.5f;
|
float radius = 1.5f;
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), radius, false);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), radius, false);
|
||||||
m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY);
|
m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
||||||
if (m_dpEntity) {
|
if (m_dpEntity) {
|
||||||
@ -70,7 +69,18 @@ ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::Update(float deltaTime) {
|
void ControllablePhysicsComponent::Startup() {
|
||||||
|
NiPoint3 pos = m_ParentEntity->GetDefaultPosition();
|
||||||
|
NiQuaternion rot = m_ParentEntity->GetDefaultRotation();
|
||||||
|
SetPosition(pos);
|
||||||
|
SetRotation(rot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllablePhysicsComponent::LoadConfigData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllablePhysicsComponent::LoadTemplateData() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,22 +172,45 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||||
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
tinyxml2::XMLElement* characterElem = doc->FirstChildElement("obj")->FirstChildElement("char");
|
||||||
if (!character) {
|
if (!characterElem) {
|
||||||
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!");
|
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OwningEntity->GetCharacter()->LoadXmlRespawnCheckpoints();
|
m_ParentEntity->GetCharacter()->LoadXmlRespawnCheckpoints();
|
||||||
|
|
||||||
character->QueryAttribute("lzx", &m_Position.x);
|
characterElem->QueryAttribute("lzx", &m_Position.x);
|
||||||
character->QueryAttribute("lzy", &m_Position.y);
|
characterElem->QueryAttribute("lzy", &m_Position.y);
|
||||||
character->QueryAttribute("lzz", &m_Position.z);
|
characterElem->QueryAttribute("lzz", &m_Position.z);
|
||||||
character->QueryAttribute("lzrx", &m_Rotation.x);
|
characterElem->QueryAttribute("lzrx", &m_Rotation.x);
|
||||||
character->QueryAttribute("lzry", &m_Rotation.y);
|
characterElem->QueryAttribute("lzry", &m_Rotation.y);
|
||||||
character->QueryAttribute("lzrz", &m_Rotation.z);
|
characterElem->QueryAttribute("lzrz", &m_Rotation.z);
|
||||||
character->QueryAttribute("lzrw", &m_Rotation.w);
|
characterElem->QueryAttribute("lzrw", &m_Rotation.w);
|
||||||
|
|
||||||
|
auto* character = GetParentEntity()->GetCharacter();
|
||||||
|
const auto mapID = Game::server->GetZoneID();
|
||||||
|
|
||||||
|
//If we came from another zone, put us in the starting loc
|
||||||
|
if (character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
||||||
|
const auto& targetSceneName = character->GetTargetScene();
|
||||||
|
auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||||
|
|
||||||
|
NiPoint3 pos;
|
||||||
|
NiQuaternion rot;
|
||||||
|
if (character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||||
|
pos = character->GetRespawnPoint(mapID);
|
||||||
|
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||||
|
} else if (targetScene) {
|
||||||
|
pos = targetScene->GetPosition();
|
||||||
|
rot = targetScene->GetRotation();
|
||||||
|
} else {
|
||||||
|
pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||||
|
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||||
|
}
|
||||||
|
SetPosition(pos);
|
||||||
|
SetRotation(rot);
|
||||||
|
}
|
||||||
m_DirtyPosition = true;
|
m_DirtyPosition = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,9 +241,7 @@ void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||||
if (m_Static) {
|
if (m_Static || pos == m_Position) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Position.x = pos.x;
|
m_Position.x = pos.x;
|
||||||
m_Position.y = pos.y;
|
m_Position.y = pos.y;
|
||||||
@ -221,9 +252,7 @@ void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
void ControllablePhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
||||||
if (m_Static) {
|
if (m_Static || rot == m_Rotation) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Rotation = rot;
|
m_Rotation = rot;
|
||||||
m_DirtyPosition = true;
|
m_DirtyPosition = true;
|
||||||
@ -244,7 +273,7 @@ void ControllablePhysicsComponent::SetVelocity(const NiPoint3& vel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
||||||
if (m_Static) {
|
if (m_Static || vel == m_AngularVelocity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,13 +283,15 @@ void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetIsOnGround(bool val) {
|
void ControllablePhysicsComponent::SetIsOnGround(bool val) {
|
||||||
m_DirtyPosition = true;
|
if (m_IsOnGround == val) return;
|
||||||
m_IsOnGround = val;
|
m_IsOnGround = val;
|
||||||
|
m_DirtyPosition = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetIsOnRail(bool val) {
|
void ControllablePhysicsComponent::SetIsOnRail(bool val) {
|
||||||
m_DirtyPosition = true;
|
if (m_IsOnRail == val) return;
|
||||||
m_IsOnRail = val;
|
m_IsOnRail = val;
|
||||||
|
m_DirtyPosition = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetDirtyPosition(bool val) {
|
void ControllablePhysicsComponent::SetDirtyPosition(bool val) {
|
||||||
@ -300,7 +331,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) {
|
|||||||
auto candidateRadius = m_ActivePickupRadiusScales[i];
|
auto candidateRadius = m_ActivePickupRadiusScales[i];
|
||||||
if (m_PickupRadius < candidateRadius) m_PickupRadius = candidateRadius;
|
if (m_PickupRadius < candidateRadius) m_PickupRadius = candidateRadius;
|
||||||
}
|
}
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::AddSpeedboost(float value) {
|
void ControllablePhysicsComponent::AddSpeedboost(float value) {
|
||||||
@ -321,13 +352,13 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
|||||||
// Recalculate speedboost since we removed one
|
// Recalculate speedboost since we removed one
|
||||||
m_SpeedBoost = 0.0f;
|
m_SpeedBoost = 0.0f;
|
||||||
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
|
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
|
||||||
auto* levelProgressionComponent = m_OwningEntity->GetComponent<LevelProgressionComponent>();
|
auto* levelProgressionComponent = m_ParentEntity->GetComponent<LevelProgressionComponent>();
|
||||||
if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase();
|
if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase();
|
||||||
} else { // Used the last applied speedboost
|
} else { // Used the last applied speedboost
|
||||||
m_SpeedBoost = m_ActiveSpeedBoosts.back();
|
m_SpeedBoost = m_ActiveSpeedBoosts.back();
|
||||||
}
|
}
|
||||||
SetSpeedMultiplier(m_SpeedBoost / 500.0f); // 500 being the base speed
|
SetSpeedMultiplier(m_SpeedBoost / 500.0f); // 500 being the base speed
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims) {
|
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims) {
|
||||||
@ -339,13 +370,13 @@ void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bo
|
|||||||
m_IsInBubble = true;
|
m_IsInBubble = true;
|
||||||
m_DirtyBubble = true;
|
m_DirtyBubble = true;
|
||||||
m_SpecialAnims = specialAnims;
|
m_SpecialAnims = specialAnims;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::DeactivateBubbleBuff() {
|
void ControllablePhysicsComponent::DeactivateBubbleBuff() {
|
||||||
m_DirtyBubble = true;
|
m_DirtyBubble = true;
|
||||||
m_IsInBubble = false;
|
m_IsInBubble = false;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ControllablePhysicsComponent::SetStunImmunity(
|
void ControllablePhysicsComponent::SetStunImmunity(
|
||||||
@ -378,7 +409,7 @@ void ControllablePhysicsComponent::SetStunImmunity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendSetStunImmunity(
|
GameMessages::SendSetStunImmunity(
|
||||||
m_OwningEntity->GetObjectID(), state, m_OwningEntity->GetSystemAddress(), originator,
|
m_ParentEntity->GetObjectID(), state, m_ParentEntity->GetSystemAddress(), originator,
|
||||||
bImmuneToStunAttack,
|
bImmuneToStunAttack,
|
||||||
bImmuneToStunEquip,
|
bImmuneToStunEquip,
|
||||||
bImmuneToStunInteract,
|
bImmuneToStunInteract,
|
||||||
|
@ -26,11 +26,13 @@ public:
|
|||||||
ControllablePhysicsComponent(Entity* entity);
|
ControllablePhysicsComponent(Entity* entity);
|
||||||
~ControllablePhysicsComponent() override;
|
~ControllablePhysicsComponent() override;
|
||||||
|
|
||||||
void Update(float deltaTime) override;
|
|
||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
void LoadFromXml(tinyxml2::XMLDocument* doc) override;
|
void LoadFromXml(tinyxml2::XMLDocument* doc) override;
|
||||||
void ResetFlags();
|
void ResetFlags();
|
||||||
void UpdateXml(tinyxml2::XMLDocument* doc) override;
|
void UpdateXml(tinyxml2::XMLDocument* doc) override;
|
||||||
|
void Startup() override;
|
||||||
|
void LoadConfigData() override;
|
||||||
|
void LoadTemplateData() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the position of this entity, also ensures this update is serialized next tick.
|
* Sets the position of this entity, also ensures this update is serialized next tick.
|
||||||
|
@ -185,7 +185,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* buffComponent = m_OwningEntity->GetComponent<BuffComponent>();
|
auto* buffComponent = m_ParentEntity->GetComponent<BuffComponent>();
|
||||||
|
|
||||||
if (buffComponent != nullptr) {
|
if (buffComponent != nullptr) {
|
||||||
buffComponent->LoadFromXml(doc);
|
buffComponent->LoadFromXml(doc);
|
||||||
@ -207,7 +207,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* buffComponent = m_OwningEntity->GetComponent<BuffComponent>();
|
auto* buffComponent = m_ParentEntity->GetComponent<BuffComponent>();
|
||||||
|
|
||||||
if (buffComponent != nullptr) {
|
if (buffComponent != nullptr) {
|
||||||
buffComponent->UpdateXml(doc);
|
buffComponent->UpdateXml(doc);
|
||||||
@ -224,7 +224,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
|||||||
void DestroyableComponent::SetHealth(int32_t value) {
|
void DestroyableComponent::SetHealth(int32_t value) {
|
||||||
m_DirtyHealth = true;
|
m_DirtyHealth = true;
|
||||||
|
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent != nullptr) {
|
if (characterComponent != nullptr) {
|
||||||
characterComponent->TrackHealthDelta(value - m_iHealth);
|
characterComponent->TrackHealthDelta(value - m_iHealth);
|
||||||
}
|
}
|
||||||
@ -244,16 +244,16 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
|
|||||||
|
|
||||||
if (playAnim) {
|
if (playAnim) {
|
||||||
// Now update the player bar
|
// Now update the player bar
|
||||||
if (!m_OwningEntity->GetParentUser()) return;
|
if (!m_ParentEntity->GetParentUser()) return;
|
||||||
|
|
||||||
AMFArrayValue args;
|
AMFArrayValue args;
|
||||||
args.Insert("amount", std::to_string(difference));
|
args.Insert("amount", std::to_string(difference));
|
||||||
args.Insert("type", "health");
|
args.Insert("type", "health");
|
||||||
|
|
||||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyableComponent::SetArmor(int32_t value) {
|
void DestroyableComponent::SetArmor(int32_t value) {
|
||||||
@ -262,14 +262,14 @@ void DestroyableComponent::SetArmor(int32_t value) {
|
|||||||
// If Destroyable Component already has zero armor do not trigger the passive ability again.
|
// If Destroyable Component already has zero armor do not trigger the passive ability again.
|
||||||
bool hadArmor = m_iArmor > 0;
|
bool hadArmor = m_iArmor > 0;
|
||||||
|
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent != nullptr) {
|
if (characterComponent != nullptr) {
|
||||||
characterComponent->TrackArmorDelta(value - m_iArmor);
|
characterComponent->TrackArmorDelta(value - m_iArmor);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iArmor = value;
|
m_iArmor = value;
|
||||||
|
|
||||||
auto* inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
auto* inventroyComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||||
if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) {
|
if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) {
|
||||||
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor);
|
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor);
|
||||||
}
|
}
|
||||||
@ -285,29 +285,29 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
|
|||||||
|
|
||||||
if (playAnim) {
|
if (playAnim) {
|
||||||
// Now update the player bar
|
// Now update the player bar
|
||||||
if (!m_OwningEntity->GetParentUser()) return;
|
if (!m_ParentEntity->GetParentUser()) return;
|
||||||
|
|
||||||
AMFArrayValue args;
|
AMFArrayValue args;
|
||||||
args.Insert("amount", std::to_string(value));
|
args.Insert("amount", std::to_string(value));
|
||||||
args.Insert("type", "armor");
|
args.Insert("type", "armor");
|
||||||
|
|
||||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyableComponent::SetImagination(int32_t value) {
|
void DestroyableComponent::SetImagination(int32_t value) {
|
||||||
m_DirtyHealth = true;
|
m_DirtyHealth = true;
|
||||||
|
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent != nullptr) {
|
if (characterComponent != nullptr) {
|
||||||
characterComponent->TrackImaginationDelta(value - m_iImagination);
|
characterComponent->TrackImaginationDelta(value - m_iImagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iImagination = value;
|
m_iImagination = value;
|
||||||
|
|
||||||
auto* inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
auto* inventroyComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||||
if (m_iImagination == 0 && inventroyComponent != nullptr) {
|
if (m_iImagination == 0 && inventroyComponent != nullptr) {
|
||||||
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination);
|
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination);
|
||||||
}
|
}
|
||||||
@ -325,15 +325,15 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
|
|||||||
|
|
||||||
if (playAnim) {
|
if (playAnim) {
|
||||||
// Now update the player bar
|
// Now update the player bar
|
||||||
if (!m_OwningEntity->GetParentUser()) return;
|
if (!m_ParentEntity->GetParentUser()) return;
|
||||||
|
|
||||||
AMFArrayValue args;
|
AMFArrayValue args;
|
||||||
args.Insert("amount", std::to_string(difference));
|
args.Insert("amount", std::to_string(difference));
|
||||||
args.Insert("type", "imagination");
|
args.Insert("type", "imagination");
|
||||||
|
|
||||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||||
}
|
}
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyableComponent::SetDamageToAbsorb(int32_t value) {
|
void DestroyableComponent::SetDamageToAbsorb(int32_t value) {
|
||||||
@ -455,8 +455,8 @@ bool DestroyableComponent::IsImmune() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DestroyableComponent::IsKnockbackImmune() const {
|
bool DestroyableComponent::IsKnockbackImmune() const {
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
auto* inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||||
|
|
||||||
if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) {
|
if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) {
|
||||||
const auto hasPassive = inventoryComponent->HasAnyPassive({
|
const auto hasPassive = inventoryComponent->HasAnyPassive({
|
||||||
@ -532,7 +532,7 @@ void DestroyableComponent::Heal(const uint32_t health) {
|
|||||||
|
|
||||||
SetHealth(current);
|
SetHealth(current);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ void DestroyableComponent::Imagine(const int32_t deltaImagination) {
|
|||||||
|
|
||||||
SetImagination(current);
|
SetImagination(current);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ void DestroyableComponent::Repair(const uint32_t armor) {
|
|||||||
|
|
||||||
SetArmor(current);
|
SetArmor(current);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -616,13 +616,13 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
|||||||
SetIsShielded(absorb > 0);
|
SetIsShielded(absorb > 0);
|
||||||
|
|
||||||
// Dismount on the possessable hit
|
// Dismount on the possessable hit
|
||||||
auto* possessable = m_OwningEntity->GetComponent<PossessableComponent>();
|
auto* possessable = m_ParentEntity->GetComponent<PossessableComponent>();
|
||||||
if (possessable && possessable->GetDepossessOnHit()) {
|
if (possessable && possessable->GetDepossessOnHit()) {
|
||||||
possessable->Dismount();
|
possessable->Dismount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dismount on the possessor hit
|
// Dismount on the possessor hit
|
||||||
auto* possessor = m_OwningEntity->GetComponent<PossessorComponent>();
|
auto* possessor = m_ParentEntity->GetComponent<PossessorComponent>();
|
||||||
if (possessor) {
|
if (possessor) {
|
||||||
auto possessableId = possessor->GetPossessable();
|
auto possessableId = possessor->GetPossessable();
|
||||||
if (possessableId != LWOOBJID_EMPTY) {
|
if (possessableId != LWOOBJID_EMPTY) {
|
||||||
@ -633,17 +633,17 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_OwningEntity->GetLOT() != 1) {
|
if (m_ParentEntity->GetLOT() != 1) {
|
||||||
echo = true;
|
echo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (echo) {
|
if (echo) {
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* attacker = EntityManager::Instance()->GetEntity(source);
|
auto* attacker = EntityManager::Instance()->GetEntity(source);
|
||||||
m_OwningEntity->OnHit(attacker);
|
m_ParentEntity->OnHit(attacker);
|
||||||
m_OwningEntity->OnHitOrHealResult(attacker, sourceDamage);
|
m_ParentEntity->OnHitOrHealResult(attacker, sourceDamage);
|
||||||
NotifySubscribers(attacker, sourceDamage);
|
NotifySubscribers(attacker, sourceDamage);
|
||||||
|
|
||||||
for (const auto& cb : m_OnHitCallbacks) {
|
for (const auto& cb : m_OnHitCallbacks) {
|
||||||
@ -651,7 +651,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (health != 0) {
|
if (health != 0) {
|
||||||
auto* combatComponent = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
auto* combatComponent = m_ParentEntity->GetComponent<BaseCombatAIComponent>();
|
||||||
|
|
||||||
if (combatComponent != nullptr) {
|
if (combatComponent != nullptr) {
|
||||||
combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary
|
combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary
|
||||||
@ -670,7 +670,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
|||||||
|
|
||||||
void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) {
|
void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) {
|
||||||
m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd));
|
m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd));
|
||||||
Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_OwningEntity->GetObjectID());
|
Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_ParentEntity->GetObjectID());
|
||||||
Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size());
|
Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,16 +678,16 @@ void DestroyableComponent::Unsubscribe(LWOOBJID scriptObjId) {
|
|||||||
auto foundScript = m_SubscribedScripts.find(scriptObjId);
|
auto foundScript = m_SubscribedScripts.find(scriptObjId);
|
||||||
if (foundScript != m_SubscribedScripts.end()) {
|
if (foundScript != m_SubscribedScripts.end()) {
|
||||||
m_SubscribedScripts.erase(foundScript);
|
m_SubscribedScripts.erase(foundScript);
|
||||||
Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_OwningEntity->GetObjectID());
|
Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_ParentEntity->GetObjectID());
|
||||||
} else {
|
} else {
|
||||||
Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_OwningEntity->GetObjectID(), scriptObjId);
|
Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_ParentEntity->GetObjectID(), scriptObjId);
|
||||||
}
|
}
|
||||||
Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size());
|
Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) {
|
void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) {
|
||||||
for (auto script : m_SubscribedScripts) {
|
for (auto script : m_SubscribedScripts) {
|
||||||
script.second->NotifyHitOrHealResult(m_OwningEntity, attacker, damage);
|
script.second->NotifyHitOrHealResult(m_ParentEntity, attacker, damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
SetArmor(0);
|
SetArmor(0);
|
||||||
SetHealth(0);
|
SetHealth(0);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_KillerID = source;
|
m_KillerID = source;
|
||||||
@ -708,12 +708,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
|
|
||||||
auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID());
|
auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID());
|
||||||
|
|
||||||
const auto isEnemy = m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr;
|
const auto isEnemy = m_ParentEntity->GetComponent<BaseCombatAIComponent>() != nullptr;
|
||||||
|
|
||||||
auto* inventoryComponent = owner->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = owner->GetComponent<InventoryComponent>();
|
||||||
|
|
||||||
if (inventoryComponent != nullptr && isEnemy) {
|
if (inventoryComponent != nullptr && isEnemy) {
|
||||||
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_OwningEntity);
|
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* missions = owner->GetComponent<MissionComponent>();
|
auto* missions = owner->GetComponent<MissionComponent>();
|
||||||
@ -729,28 +729,28 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
|
|
||||||
if (memberMissions == nullptr) continue;
|
if (memberMissions == nullptr) continue;
|
||||||
|
|
||||||
memberMissions->Progress(eMissionTaskType::SMASH, m_OwningEntity->GetLOT());
|
memberMissions->Progress(eMissionTaskType::SMASH, m_ParentEntity->GetLOT());
|
||||||
memberMissions->Progress(eMissionTaskType::USE_SKILL, m_OwningEntity->GetLOT(), skillID);
|
memberMissions->Progress(eMissionTaskType::USE_SKILL, m_ParentEntity->GetLOT(), skillID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
missions->Progress(eMissionTaskType::SMASH, m_OwningEntity->GetLOT());
|
missions->Progress(eMissionTaskType::SMASH, m_ParentEntity->GetLOT());
|
||||||
missions->Progress(eMissionTaskType::USE_SKILL, m_OwningEntity->GetLOT(), skillID);
|
missions->Progress(eMissionTaskType::USE_SKILL, m_ParentEntity->GetLOT(), skillID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto isPlayer = m_OwningEntity->IsPlayer();
|
const auto isPlayer = m_ParentEntity->IsPlayer();
|
||||||
|
|
||||||
GameMessages::SendDie(m_OwningEntity, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1);
|
GameMessages::SendDie(m_ParentEntity, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1);
|
||||||
|
|
||||||
//NANI?!
|
//NANI?!
|
||||||
if (!isPlayer) {
|
if (!isPlayer) {
|
||||||
if (owner != nullptr) {
|
if (owner != nullptr) {
|
||||||
auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID());
|
auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID());
|
||||||
|
|
||||||
if (team != nullptr && m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr) {
|
if (team != nullptr && m_ParentEntity->GetComponent<BaseCombatAIComponent>() != nullptr) {
|
||||||
LWOOBJID specificOwner = LWOOBJID_EMPTY;
|
LWOOBJID specificOwner = LWOOBJID_EMPTY;
|
||||||
auto* scriptedActivityComponent = m_OwningEntity->GetComponent<ScriptedActivityComponent>();
|
auto* scriptedActivityComponent = m_ParentEntity->GetComponent<ScriptedActivityComponent>();
|
||||||
uint32_t teamSize = team->members.size();
|
uint32_t teamSize = team->members.size();
|
||||||
uint32_t lootMatrixId = GetLootMatrixID();
|
uint32_t lootMatrixId = GetLootMatrixID();
|
||||||
|
|
||||||
@ -763,24 +763,24 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
|
|
||||||
auto* member = EntityManager::Instance()->GetEntity(specificOwner);
|
auto* member = EntityManager::Instance()->GetEntity(specificOwner);
|
||||||
|
|
||||||
if (member) LootGenerator::Instance().DropLoot(member, m_OwningEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
if (member) LootGenerator::Instance().DropLoot(member, m_ParentEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||||
} else {
|
} else {
|
||||||
for (const auto memberId : team->members) { // Free for all
|
for (const auto memberId : team->members) { // Free for all
|
||||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||||
|
|
||||||
if (member == nullptr) continue;
|
if (member == nullptr) continue;
|
||||||
|
|
||||||
LootGenerator::Instance().DropLoot(member, m_OwningEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
LootGenerator::Instance().DropLoot(member, m_ParentEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // drop loot for non team user
|
} else { // drop loot for non team user
|
||||||
LootGenerator::Instance().DropLoot(owner, m_OwningEntity, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
LootGenerator::Instance().DropLoot(owner, m_ParentEntity, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Check if this zone allows coin drops
|
//Check if this zone allows coin drops
|
||||||
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) {
|
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) {
|
||||||
auto* character = m_OwningEntity->GetCharacter();
|
auto* character = m_ParentEntity->GetCharacter();
|
||||||
uint64_t coinsTotal = character->GetCoins();
|
uint64_t coinsTotal = character->GetCoins();
|
||||||
const uint64_t minCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMin;
|
const uint64_t minCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMin;
|
||||||
if (coinsTotal >= minCoinsToLose) {
|
if (coinsTotal >= minCoinsToLose) {
|
||||||
@ -792,27 +792,27 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
|
|
||||||
coinsTotal -= coinsToLose;
|
coinsTotal -= coinsToLose;
|
||||||
|
|
||||||
LootGenerator::Instance().DropLoot(m_OwningEntity, m_OwningEntity, -1, coinsToLose, coinsToLose);
|
LootGenerator::Instance().DropLoot(m_ParentEntity, m_ParentEntity, -1, coinsToLose, coinsToLose);
|
||||||
character->SetCoins(coinsTotal, eLootSourceType::PICKUP);
|
character->SetCoins(coinsTotal, eLootSourceType::PICKUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||||
script->OnPlayerDied(zoneControl, m_OwningEntity);
|
script->OnPlayerDied(zoneControl, m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||||
for (Entity* scriptEntity : scriptedActs) {
|
for (Entity* scriptEntity : scriptedActs) {
|
||||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
||||||
script->OnPlayerDied(scriptEntity, m_OwningEntity);
|
script->OnPlayerDied(scriptEntity, m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OwningEntity->Kill(owner);
|
m_ParentEntity->Kill(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyableComponent::SetFaction(int32_t factionID, bool ignoreChecks) {
|
void DestroyableComponent::SetFaction(int32_t factionID, bool ignoreChecks) {
|
||||||
@ -858,7 +858,7 @@ void DestroyableComponent::SetStatusImmunity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendSetStatusImmunity(
|
GameMessages::SendSetStatusImmunity(
|
||||||
m_OwningEntity->GetObjectID(), state, m_OwningEntity->GetSystemAddress(),
|
m_ParentEntity->GetObjectID(), state, m_ParentEntity->GetSystemAddress(),
|
||||||
bImmuneToBasicAttack,
|
bImmuneToBasicAttack,
|
||||||
bImmuneToDamageOverTime,
|
bImmuneToDamageOverTime,
|
||||||
bImmuneToKnockback,
|
bImmuneToKnockback,
|
||||||
@ -974,19 +974,19 @@ void DestroyableComponent::AddOnHitCallback(const std::function<void(Entity*)>&
|
|||||||
|
|
||||||
void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||||
//check if this is a player:
|
//check if this is a player:
|
||||||
if (m_OwningEntity->IsPlayer()) {
|
if (m_ParentEntity->IsPlayer()) {
|
||||||
//remove hardcore_lose_uscore_on_death_percent from the player's uscore:
|
//remove hardcore_lose_uscore_on_death_percent from the player's uscore:
|
||||||
auto* character = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* character = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
auto uscore = character->GetUScore();
|
auto uscore = character->GetUScore();
|
||||||
|
|
||||||
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
||||||
character->SetUScore(uscore - uscoreToLose);
|
character->SetUScore(uscore - uscoreToLose);
|
||||||
|
|
||||||
GameMessages::SendModifyLEGOScore(m_OwningEntity, m_OwningEntity->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
|
GameMessages::SendModifyLEGOScore(m_ParentEntity, m_ParentEntity->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
|
||||||
|
|
||||||
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
|
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
|
||||||
//drop all items from inventory:
|
//drop all items from inventory:
|
||||||
auto* inventory = m_OwningEntity->GetComponent<InventoryComponent>();
|
auto* inventory = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||||
if (inventory) {
|
if (inventory) {
|
||||||
//get the items inventory:
|
//get the items inventory:
|
||||||
auto items = inventory->GetInventory(eInventoryType::ITEMS);
|
auto items = inventory->GetInventory(eInventoryType::ITEMS);
|
||||||
@ -998,17 +998,17 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
|||||||
if (!item.second) continue;
|
if (!item.second) continue;
|
||||||
// don't drop the thinkng cap
|
// don't drop the thinkng cap
|
||||||
if (item.second->GetLot() == 6086) continue;
|
if (item.second->GetLot() == 6086) continue;
|
||||||
GameMessages::SendDropClientLoot(m_OwningEntity, source, item.second->GetLot(), 0, m_OwningEntity->GetPosition(), item.second->GetCount());
|
GameMessages::SendDropClientLoot(m_ParentEntity, source, item.second->GetLot(), 0, m_ParentEntity->GetPosition(), item.second->GetCount());
|
||||||
item.second->SetCount(0, false, false);
|
item.second->SetCount(0, false, false);
|
||||||
}
|
}
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get character:
|
//get character:
|
||||||
auto* chars = m_OwningEntity->GetCharacter();
|
auto* chars = m_ParentEntity->GetCharacter();
|
||||||
if (chars) {
|
if (chars) {
|
||||||
auto coins = chars->GetCoins();
|
auto coins = chars->GetCoins();
|
||||||
|
|
||||||
@ -1016,13 +1016,13 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
|||||||
chars->SetCoins(0, eLootSourceType::NONE);
|
chars->SetCoins(0, eLootSourceType::NONE);
|
||||||
|
|
||||||
//drop all coins:
|
//drop all coins:
|
||||||
GameMessages::SendDropClientLoot(m_OwningEntity, source, LOT_NULL, coins, m_OwningEntity->GetPosition());
|
GameMessages::SendDropClientLoot(m_ParentEntity, source, LOT_NULL, coins, m_ParentEntity->GetPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload the player since we can't normally reduce uscore from the server and we want the UI to update
|
// Reload the player since we can't normally reduce uscore from the server and we want the UI to update
|
||||||
// do this last so we don't get killed.... again
|
// do this last so we don't get killed.... again
|
||||||
EntityManager::Instance()->DestructEntity(m_OwningEntity);
|
EntityManager::Instance()->DestructEntity(m_ParentEntity);
|
||||||
EntityManager::Instance()->ConstructEntity(m_OwningEntity);
|
EntityManager::Instance()->ConstructEntity(m_ParentEntity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1039,7 +1039,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
|||||||
playerStats->SetUScore(playerStats->GetUScore() + uscore);
|
playerStats->SetUScore(playerStats->GetUScore() + uscore);
|
||||||
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION);
|
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
|
|
||||||
void HavokVehiclePhysicsComponent::Update(float deltaTime) {
|
void HavokVehiclePhysicsComponent::Update(float deltaTime) {
|
||||||
if (m_SoftUpdate > 5) {
|
if (m_SoftUpdate > 5) {
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
m_SoftUpdate = 0;
|
m_SoftUpdate = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,7 +189,7 @@ void InventoryComponent::AddItem(
|
|||||||
inventoryType = Inventory::FindInventoryTypeForLot(lot);
|
inventoryType = Inventory::FindInventoryTypeForLot(lot);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* missions = m_OwningEntity->GetComponent<MissionComponent>();
|
auto* missions = m_ParentEntity->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
auto* inventory = GetInventory(inventoryType);
|
auto* inventory = GetInventory(inventoryType);
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ void InventoryComponent::AddItem(
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
GameMessages::SendDropClientLoot(this->m_OwningEntity, this->m_OwningEntity->GetObjectID(), lot, 0, this->m_OwningEntity->GetPosition(), 1);
|
GameMessages::SendDropClientLoot(this->m_ParentEntity, this->m_ParentEntity->GetObjectID(), lot, 0, this->m_ParentEntity->GetPosition(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -378,7 +378,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
|
|||||||
item->SetCount(item->GetCount() - delta, false, false);
|
item->SetCount(item->GetCount() - delta, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* missionComponent = m_OwningEntity->GetComponent<MissionComponent>();
|
auto* missionComponent = m_ParentEntity->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
if (missionComponent != nullptr) {
|
if (missionComponent != nullptr) {
|
||||||
if (IsTransferInventory(inventory)) {
|
if (IsTransferInventory(inventory)) {
|
||||||
@ -479,7 +479,7 @@ bool InventoryComponent::HasSpaceForLoot(const std::unordered_map<LOT, int32_t>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (slotsNeeded > 0) {
|
if (slotsNeeded > 0) {
|
||||||
GameMessages::SendNotifyNotEnoughInvSpace(m_OwningEntity->GetObjectID(), slotsNeeded, ITEMS, m_OwningEntity->GetSystemAddress());
|
GameMessages::SendNotifyNotEnoughInvSpace(m_ParentEntity->GetObjectID(), slotsNeeded, ITEMS, m_ParentEntity->GetSystemAddress());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -821,23 +821,23 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* character = m_OwningEntity->GetCharacter();
|
auto* character = m_ParentEntity->GetCharacter();
|
||||||
|
|
||||||
if (character != nullptr && !skipChecks) {
|
if (character != nullptr && !skipChecks) {
|
||||||
// Hacky proximity rocket
|
// Hacky proximity rocket
|
||||||
if (item->GetLot() == 6416) {
|
if (item->GetLot() == 6416) {
|
||||||
const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCHPAD_CONTROL);
|
const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCHPAD_CONTROL);
|
||||||
|
|
||||||
const auto position = m_OwningEntity->GetPosition();
|
const auto position = m_ParentEntity->GetPosition();
|
||||||
|
|
||||||
for (auto* lauchPad : rocketLauchPads) {
|
for (auto* lauchPad : rocketLauchPads) {
|
||||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||||
|
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
|
|
||||||
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
||||||
|
|
||||||
lauchPad->OnUse(m_OwningEntity);
|
lauchPad->OnUse(m_ParentEntity);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -853,7 +853,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
|||||||
if (!building && (item->GetLot() == 6086 || type == eItemType::LOOT_MODEL || type == eItemType::VEHICLE)) return;
|
if (!building && (item->GetLot() == 6086 || type == eItemType::LOOT_MODEL || type == eItemType::VEHICLE)) return;
|
||||||
|
|
||||||
if (type != eItemType::LOOT_MODEL && type != eItemType::MODEL) {
|
if (type != eItemType::LOOT_MODEL && type != eItemType::MODEL) {
|
||||||
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_OwningEntity)) {
|
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_ParentEntity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,7 +879,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
|||||||
|
|
||||||
EquipScripts(item);
|
EquipScripts(item);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryComponent::UnEquipItem(Item* item) {
|
void InventoryComponent::UnEquipItem(Item* item) {
|
||||||
@ -909,12 +909,12 @@ void InventoryComponent::UnEquipItem(Item* item) {
|
|||||||
|
|
||||||
UnequipScripts(item);
|
UnequipScripts(item);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
// Trigger property event
|
// Trigger property event
|
||||||
if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) {
|
if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) {
|
||||||
PropertyManagementComponent::Instance()->GetParentEntity()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity);
|
PropertyManagementComponent::Instance()->GetParentEntity()->OnZonePropertyModelRemovedWhileEquipped(m_ParentEntity);
|
||||||
dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity);
|
dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,11 +926,11 @@ void InventoryComponent::EquipScripts(Item* equippedItem) {
|
|||||||
if (scriptComponentID > -1) {
|
if (scriptComponentID > -1) {
|
||||||
CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||||
auto* itemScript = CppScripts::GetScript(m_OwningEntity, scriptCompData.script_name);
|
auto* itemScript = CppScripts::GetScript(m_ParentEntity, scriptCompData.script_name);
|
||||||
if (!itemScript) {
|
if (!itemScript) {
|
||||||
Game::logger->Log("InventoryComponent", "null script?");
|
Game::logger->Log("InventoryComponent", "null script?");
|
||||||
}
|
}
|
||||||
itemScript->OnFactionTriggerItemEquipped(m_OwningEntity, equippedItem->GetId());
|
itemScript->OnFactionTriggerItemEquipped(m_ParentEntity, equippedItem->GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,19 +941,19 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) {
|
|||||||
if (scriptComponentID > -1) {
|
if (scriptComponentID > -1) {
|
||||||
CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||||
auto* itemScript = CppScripts::GetScript(m_OwningEntity, scriptCompData.script_name);
|
auto* itemScript = CppScripts::GetScript(m_ParentEntity, scriptCompData.script_name);
|
||||||
if (!itemScript) {
|
if (!itemScript) {
|
||||||
Game::logger->Log("InventoryComponent", "null script?");
|
Game::logger->Log("InventoryComponent", "null script?");
|
||||||
}
|
}
|
||||||
itemScript->OnFactionTriggerItemUnequipped(m_OwningEntity, unequippedItem->GetId());
|
itemScript->OnFactionTriggerItemUnequipped(m_ParentEntity, unequippedItem->GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryComponent::HandlePossession(Item* item) {
|
void InventoryComponent::HandlePossession(Item* item) {
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
if (!characterComponent) return;
|
if (!characterComponent) return;
|
||||||
|
|
||||||
auto* possessorComponent = m_OwningEntity->GetComponent<PossessorComponent>();
|
auto* possessorComponent = m_ParentEntity->GetComponent<PossessorComponent>();
|
||||||
if (!possessorComponent) return;
|
if (!possessorComponent) return;
|
||||||
|
|
||||||
// Don't do anything if we are busy dismounting
|
// Don't do anything if we are busy dismounting
|
||||||
@ -968,22 +968,22 @@ void InventoryComponent::HandlePossession(Item* item) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendSetStunned(m_OwningEntity->GetObjectID(), eStateChangeType::PUSH, m_OwningEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
GameMessages::SendSetStunned(m_ParentEntity->GetObjectID(), eStateChangeType::PUSH, m_ParentEntity->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
|
// Set the mount Item ID so that we know what were handling
|
||||||
possessorComponent->SetMountItemID(item->GetId());
|
possessorComponent->SetMountItemID(item->GetId());
|
||||||
GameMessages::SendSetMountInventoryID(m_OwningEntity, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendSetMountInventoryID(m_ParentEntity, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
// Create entity to mount
|
// Create entity to mount
|
||||||
auto startRotation = m_OwningEntity->GetRotation();
|
auto startRotation = m_ParentEntity->GetRotation();
|
||||||
|
|
||||||
EntityInfo info{};
|
EntityInfo info{};
|
||||||
info.lot = item->GetLot();
|
info.lot = item->GetLot();
|
||||||
info.pos = m_OwningEntity->GetPosition();
|
info.pos = m_ParentEntity->GetPosition();
|
||||||
info.rot = startRotation;
|
info.rot = startRotation;
|
||||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
|
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_ParentEntity);
|
||||||
|
|
||||||
// Check to see if the mount is a vehicle, if so, flip it
|
// Check to see if the mount is a vehicle, if so, flip it
|
||||||
auto* havokVehiclePhysicsComponent = mount->GetComponent<HavokVehiclePhysicsComponent>();
|
auto* havokVehiclePhysicsComponent = mount->GetComponent<HavokVehiclePhysicsComponent>();
|
||||||
@ -1010,29 +1010,29 @@ void InventoryComponent::HandlePossession(Item* item) {
|
|||||||
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||||
if (possessableComponent) {
|
if (possessableComponent) {
|
||||||
possessableComponent->SetIsItemSpawned(true);
|
possessableComponent->SetIsItemSpawned(true);
|
||||||
possessableComponent->SetPossessor(m_OwningEntity->GetObjectID());
|
possessableComponent->SetPossessor(m_ParentEntity->GetObjectID());
|
||||||
// Possess it
|
// Possess it
|
||||||
possessorComponent->SetPossessable(mount->GetObjectID());
|
possessorComponent->SetPossessable(mount->GetObjectID());
|
||||||
possessorComponent->SetPossessableType(possessableComponent->GetPossessionType());
|
possessorComponent->SetPossessableType(possessableComponent->GetPossessionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendSetJetPackMode(m_OwningEntity, false);
|
GameMessages::SendSetJetPackMode(m_ParentEntity, false);
|
||||||
|
|
||||||
// Make it go to the client
|
// Make it go to the client
|
||||||
EntityManager::Instance()->ConstructEntity(mount);
|
EntityManager::Instance()->ConstructEntity(mount);
|
||||||
// Update the possessor
|
// Update the possessor
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
// have to unlock the input so it vehicle can be driven
|
// have to unlock the input so it vehicle can be driven
|
||||||
if (havokVehiclePhysicsComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress());
|
if (havokVehiclePhysicsComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_ParentEntity->GetSystemAddress());
|
||||||
GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_OwningEntity->GetSystemAddress());
|
GameMessages::SendMarkInventoryItemAsActive(m_ParentEntity->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_ParentEntity->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);
|
||||||
|
|
||||||
for (const auto buff : buffs) {
|
for (const auto buff : buffs) {
|
||||||
SkillComponent::HandleUnmanaged(buff, m_OwningEntity->GetObjectID());
|
SkillComponent::HandleUnmanaged(buff, m_ParentEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1041,7 +1041,7 @@ void InventoryComponent::RemoveBuff(Item* item) const {
|
|||||||
const auto buffs = FindBuffs(item, false);
|
const auto buffs = FindBuffs(item, false);
|
||||||
|
|
||||||
for (const auto buff : buffs) {
|
for (const auto buff : buffs) {
|
||||||
SkillComponent::HandleUnCast(buff, m_OwningEntity->GetObjectID());
|
SkillComponent::HandleUnCast(buff, m_ParentEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,14 +1076,14 @@ void InventoryComponent::PopEquippedItems() {
|
|||||||
|
|
||||||
m_Pushed.clear();
|
m_Pushed.clear();
|
||||||
|
|
||||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
// Reset stats to full
|
// Reset stats to full
|
||||||
if (destroyableComponent) {
|
if (destroyableComponent) {
|
||||||
destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
|
destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
|
||||||
destroyableComponent->SetArmor(static_cast<int32_t>(destroyableComponent->GetMaxArmor()));
|
destroyableComponent->SetArmor(static_cast<int32_t>(destroyableComponent->GetMaxArmor()));
|
||||||
destroyableComponent->SetImagination(static_cast<int32_t>(destroyableComponent->GetMaxImagination()));
|
destroyableComponent->SetImagination(static_cast<int32_t>(destroyableComponent->GetMaxImagination()));
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Dirty = true;
|
m_Dirty = true;
|
||||||
@ -1169,10 +1169,10 @@ void InventoryComponent::AddItemSkills(const LOT lot) {
|
|||||||
if (index != m_Skills.end()) {
|
if (index != m_Skills.end()) {
|
||||||
const auto old = index->second;
|
const auto old = index->second;
|
||||||
|
|
||||||
GameMessages::SendRemoveSkill(m_OwningEntity, old);
|
GameMessages::SendRemoveSkill(m_ParentEntity, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendAddSkill(m_OwningEntity, skill, static_cast<int>(slot));
|
GameMessages::SendAddSkill(m_ParentEntity, skill, static_cast<int>(slot));
|
||||||
|
|
||||||
m_Skills.insert_or_assign(slot, skill);
|
m_Skills.insert_or_assign(slot, skill);
|
||||||
}
|
}
|
||||||
@ -1194,14 +1194,14 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
|||||||
|
|
||||||
const auto old = index->second;
|
const auto old = index->second;
|
||||||
|
|
||||||
GameMessages::SendRemoveSkill(m_OwningEntity, old);
|
GameMessages::SendRemoveSkill(m_ParentEntity, old);
|
||||||
|
|
||||||
m_Skills.erase(slot);
|
m_Skills.erase(slot);
|
||||||
|
|
||||||
if (slot == BehaviorSlot::Primary) {
|
if (slot == BehaviorSlot::Primary) {
|
||||||
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);
|
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);
|
||||||
|
|
||||||
GameMessages::SendAddSkill(m_OwningEntity, 1, static_cast<int>(BehaviorSlot::Primary));
|
GameMessages::SendAddSkill(m_ParentEntity, 1, static_cast<int>(BehaviorSlot::Primary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1227,7 +1227,7 @@ bool InventoryComponent::HasAnyPassive(const std::vector<eItemSetPassiveAbilityI
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InventoryComponent::DespawnPet() {
|
void InventoryComponent::DespawnPet() {
|
||||||
auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID());
|
auto current = PetComponent::GetActivePet(m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
if (current != nullptr) {
|
if (current != nullptr) {
|
||||||
current->Deactivate();
|
current->Deactivate();
|
||||||
@ -1235,7 +1235,7 @@ void InventoryComponent::DespawnPet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InventoryComponent::SpawnPet(Item* item) {
|
void InventoryComponent::SpawnPet(Item* item) {
|
||||||
auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID());
|
auto current = PetComponent::GetActivePet(m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
if (current != nullptr) {
|
if (current != nullptr) {
|
||||||
current->Deactivate();
|
current->Deactivate();
|
||||||
@ -1246,18 +1246,18 @@ void InventoryComponent::SpawnPet(Item* item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First check if we can summon the pet. You need 1 imagination to do so.
|
// First check if we can summon the pet. You need 1 imagination to do so.
|
||||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (Game::config->GetValue("pets_take_imagination") == "1" && destroyableComponent && destroyableComponent->GetImagination() <= 0) {
|
if (Game::config->GetValue("pets_take_imagination") == "1" && destroyableComponent && destroyableComponent->GetImagination() <= 0) {
|
||||||
GameMessages::SendUseItemRequirementsResponse(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
|
GameMessages::SendUseItemRequirementsResponse(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityInfo info{};
|
EntityInfo info{};
|
||||||
info.lot = item->GetLot();
|
info.lot = item->GetLot();
|
||||||
info.pos = m_OwningEntity->GetPosition();
|
info.pos = m_ParentEntity->GetPosition();
|
||||||
info.rot = NiQuaternion::IDENTITY;
|
info.rot = NiQuaternion::IDENTITY;
|
||||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
auto* pet = EntityManager::Instance()->CreateEntity(info);
|
auto* pet = EntityManager::Instance()->CreateEntity(info);
|
||||||
|
|
||||||
@ -1339,7 +1339,7 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
|
|||||||
return entry.objectTemplate == static_cast<unsigned int>(item->GetLot());
|
return entry.objectTemplate == static_cast<unsigned int>(item->GetLot());
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* missions = m_OwningEntity->GetComponent<MissionComponent>();
|
auto* missions = m_ParentEntity->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
for (const auto& result : results) {
|
for (const auto& result : results) {
|
||||||
if (result.castOnType == 1) {
|
if (result.castOnType == 1) {
|
||||||
@ -1376,7 +1376,7 @@ void InventoryComponent::SetNPCItems(const std::vector<LOT>& items) {
|
|||||||
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item), 1, slot++ }, true);
|
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item), 1, slot++ }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryComponent::~InventoryComponent() {
|
InventoryComponent::~InventoryComponent() {
|
||||||
|
@ -35,7 +35,7 @@ void LUPExhibitComponent::NextExhibit() {
|
|||||||
|
|
||||||
m_Exhibit = m_Exhibits[m_ExhibitIndex];
|
m_Exhibit = m_Exhibits[m_ExhibitIndex];
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
|
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "CDRewardsTable.h"
|
#include "CDRewardsTable.h"
|
||||||
|
|
||||||
LevelProgressionComponent::LevelProgressionComponent(Entity* parent) : Component(parent) {
|
LevelProgressionComponent::LevelProgressionComponent(Entity* parent) : Component(parent) {
|
||||||
m_OwningEntity = parent;
|
m_ParentEntity = parent;
|
||||||
m_Level = 1;
|
m_Level = 1;
|
||||||
m_SpeedBase = 500.0f;
|
m_SpeedBase = 500.0f;
|
||||||
m_CharacterVersion = eCharacterVersion::LIVE;
|
m_CharacterVersion = eCharacterVersion::LIVE;
|
||||||
@ -49,12 +49,12 @@ void LevelProgressionComponent::HandleLevelUp() {
|
|||||||
const auto& rewards = rewardsTable->GetByLevelID(m_Level);
|
const auto& rewards = rewardsTable->GetByLevelID(m_Level);
|
||||||
bool rewardingItem = rewards.size() > 0;
|
bool rewardingItem = rewards.size() > 0;
|
||||||
|
|
||||||
auto* inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (!inventoryComponent || !controllablePhysicsComponent) return;
|
if (!inventoryComponent || !controllablePhysicsComponent) return;
|
||||||
// Tell the client we beginning to send level rewards.
|
// Tell the client we beginning to send level rewards.
|
||||||
if (rewardingItem) GameMessages::NotifyLevelRewards(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), m_Level, rewardingItem);
|
if (rewardingItem) GameMessages::NotifyLevelRewards(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress(), m_Level, rewardingItem);
|
||||||
|
|
||||||
for (auto* reward : rewards) {
|
for (auto* reward : rewards) {
|
||||||
switch (reward->rewardType) {
|
switch (reward->rewardType) {
|
||||||
@ -79,11 +79,11 @@ void LevelProgressionComponent::HandleLevelUp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Tell the client we have finished sending level rewards.
|
// Tell the client we have finished sending level rewards.
|
||||||
if (rewardingItem) GameMessages::NotifyLevelRewards(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), m_Level, !rewardingItem);
|
if (rewardingItem) GameMessages::NotifyLevelRewards(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress(), m_Level, !rewardingItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelProgressionComponent::SetRetroactiveBaseSpeed(){
|
void LevelProgressionComponent::SetRetroactiveBaseSpeed(){
|
||||||
if (m_Level >= 20) m_SpeedBase = 525.0f;
|
if (m_Level >= 20) m_SpeedBase = 525.0f;
|
||||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f);
|
if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f);
|
||||||
}
|
}
|
||||||
|
@ -103,9 +103,9 @@ void MissionComponent::AcceptMission(const uint32_t missionId, const bool skipCh
|
|||||||
if (missionId == 1728) {
|
if (missionId == 1728) {
|
||||||
//Needs to send a mail
|
//Needs to send a mail
|
||||||
|
|
||||||
auto address = m_OwningEntity->GetSystemAddress();
|
auto address = m_ParentEntity->GetSystemAddress();
|
||||||
|
|
||||||
Mail::HandleNotificationRequest(address, m_OwningEntity->GetObjectID());
|
Mail::HandleNotificationRequest(address, m_ParentEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,14 +109,14 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
|||||||
if (mission != nullptr) {
|
if (mission != nullptr) {
|
||||||
if (specifiedMissionId <= 0) {
|
if (specifiedMissionId <= 0) {
|
||||||
// Handles the odd case where the offer object should not display the mission again
|
// Handles the odd case where the offer object should not display the mission again
|
||||||
if (!mission->IsComplete() && mission->GetClientInfo().offer_objectID == m_OwningEntity->GetLOT() && mission->GetClientInfo().target_objectID != m_OwningEntity->GetLOT() && mission->IsFetchMission()) {
|
if (!mission->IsComplete() && mission->GetClientInfo().offer_objectID == m_ParentEntity->GetLOT() && mission->GetClientInfo().target_objectID != m_ParentEntity->GetLOT() && mission->IsFetchMission()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have the mission, if it is not complete, offer it
|
// We have the mission, if it is not complete, offer it
|
||||||
if (mission->IsActive() || mission->IsReadyToComplete()) {
|
if (mission->IsActive() || mission->IsReadyToComplete()) {
|
||||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_OwningEntity->GetObjectID());
|
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
offered.push_back(missionId);
|
offered.push_back(missionId);
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
|||||||
const auto& iter = std::find(randomMissionPool.begin(), randomMissionPool.end(), specifiedMissionId);
|
const auto& iter = std::find(randomMissionPool.begin(), randomMissionPool.end(), specifiedMissionId);
|
||||||
|
|
||||||
if (iter != randomMissionPool.end() && MissionPrerequisites::CanAccept(specifiedMissionId, missionComponent->GetMissions())) {
|
if (iter != randomMissionPool.end() && MissionPrerequisites::CanAccept(specifiedMissionId, missionComponent->GetMissions())) {
|
||||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), specifiedMissionId, m_OwningEntity->GetObjectID());
|
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), specifiedMissionId, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_OwningEntity->GetObjectID());
|
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
canAcceptPool.clear();
|
canAcceptPool.clear();
|
||||||
|
|
||||||
@ -202,9 +202,9 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
|||||||
|
|
||||||
const auto selected = canAcceptPool[GeneralUtils::GenerateRandomNumber<int>(0, canAcceptPool.size() - 1)];
|
const auto selected = canAcceptPool[GeneralUtils::GenerateRandomNumber<int>(0, canAcceptPool.size() - 1)];
|
||||||
|
|
||||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_OwningEntity->GetObjectID());
|
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_ParentEntity->GetObjectID());
|
||||||
} else if (std::find(offered.begin(), offered.end(), missionId) == offered.end() && offeredMission->GetOfferMission()) {
|
} else if (std::find(offered.begin(), offered.end(), missionId) == offered.end() && offeredMission->GetOfferMission()) {
|
||||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_OwningEntity->GetObjectID());
|
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_ParentEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
|
||||||
ModelBehaviorComponent::ModelBehaviorComponent(Entity* parent) : Component(parent) {
|
ModelBehaviorComponent::ModelBehaviorComponent(Entity* parent) : Component(parent) {
|
||||||
m_OriginalPosition = m_OwningEntity->GetDefaultPosition();
|
m_OriginalPosition = m_ParentEntity->GetDefaultPosition();
|
||||||
m_OriginalRotation = m_OwningEntity->GetDefaultRotation();
|
m_OriginalRotation = m_ParentEntity->GetDefaultRotation();
|
||||||
|
|
||||||
m_userModelID = m_OwningEntity->GetVarAs<LWOOBJID>(u"userModelID");
|
m_userModelID = m_ParentEntity->GetVarAs<LWOOBJID>(u"userModelID");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void ModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
// ItemComponent Serialization. Pets do not get this serialization.
|
// ItemComponent Serialization. Pets do not get this serialization.
|
||||||
if (!m_OwningEntity->HasComponent(eReplicaComponentType::PET)) {
|
if (!m_ParentEntity->HasComponent(eReplicaComponentType::PET)) {
|
||||||
outBitStream->Write1();
|
outBitStream->Write1();
|
||||||
outBitStream->Write<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_OwningEntity->GetObjectID());
|
outBitStream->Write<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_ParentEntity->GetObjectID());
|
||||||
outBitStream->Write<int>(0);
|
outBitStream->Write<int>(0);
|
||||||
outBitStream->Write0();
|
outBitStream->Write0();
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
|
|||||||
|
|
||||||
m_BaseCombatAI = nullptr;
|
m_BaseCombatAI = nullptr;
|
||||||
|
|
||||||
m_BaseCombatAI = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
m_BaseCombatAI = m_ParentEntity->GetComponent<BaseCombatAIComponent>();
|
||||||
|
|
||||||
//Try and fix the insane values:
|
//Try and fix the insane values:
|
||||||
if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f;
|
if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f;
|
||||||
if (m_Info.wanderRadius > 8.0f) m_Info.wanderRadius = 8.0f;
|
if (m_Info.wanderRadius > 8.0f) m_Info.wanderRadius = 8.0f;
|
||||||
if (m_Info.wanderSpeed > 0.5f) m_Info.wanderSpeed = m_Info.wanderSpeed * 0.5f;
|
if (m_Info.wanderSpeed > 0.5f) m_Info.wanderSpeed = m_Info.wanderSpeed * 0.5f;
|
||||||
|
|
||||||
m_BaseSpeed = GetBaseSpeed(m_OwningEntity->GetLOT());
|
m_BaseSpeed = GetBaseSpeed(m_ParentEntity->GetLOT());
|
||||||
|
|
||||||
m_NextWaypoint = GetCurrentPosition();
|
m_NextWaypoint = GetCurrentPosition();
|
||||||
m_Acceleration = 0.4f;
|
m_Acceleration = 0.4f;
|
||||||
@ -149,7 +149,7 @@ nextAction:
|
|||||||
|
|
||||||
SetVelocity(velocity);
|
SetVelocity(velocity);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MovementAIInfo& MovementAIComponent::GetInfo() const {
|
const MovementAIInfo& MovementAIComponent::GetInfo() const {
|
||||||
@ -179,7 +179,7 @@ NiPoint3 MovementAIComponent::GetNextWaypoint() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NiPoint3 MovementAIComponent::GetCurrentPosition() const {
|
NiPoint3 MovementAIComponent::GetCurrentPosition() const {
|
||||||
return m_OwningEntity->GetPosition();
|
return m_ParentEntity->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
NiPoint3 MovementAIComponent::ApproximateLocation() const {
|
NiPoint3 MovementAIComponent::ApproximateLocation() const {
|
||||||
@ -221,7 +221,7 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
|
|||||||
|
|
||||||
SetPosition(destination);
|
SetPosition(destination);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ void MovementAIComponent::Stop() {
|
|||||||
|
|
||||||
m_CurrentSpeed = 0;
|
m_CurrentSpeed = 0;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::PullToPoint(const NiPoint3& point) {
|
void MovementAIComponent::PullToPoint(const NiPoint3& point) {
|
||||||
@ -322,7 +322,7 @@ foundComponent:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::SetPosition(const NiPoint3& value) {
|
void MovementAIComponent::SetPosition(const NiPoint3& value) {
|
||||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (controllablePhysicsComponent != nullptr) {
|
if (controllablePhysicsComponent != nullptr) {
|
||||||
controllablePhysicsComponent->SetPosition(value);
|
controllablePhysicsComponent->SetPosition(value);
|
||||||
@ -330,7 +330,7 @@ void MovementAIComponent::SetPosition(const NiPoint3& value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
|
auto* simplePhysicsComponent = m_ParentEntity->GetComponent<SimplePhysicsComponent>();
|
||||||
|
|
||||||
if (simplePhysicsComponent != nullptr) {
|
if (simplePhysicsComponent != nullptr) {
|
||||||
simplePhysicsComponent->SetPosition(value);
|
simplePhysicsComponent->SetPosition(value);
|
||||||
@ -342,7 +342,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (controllablePhysicsComponent != nullptr) {
|
if (controllablePhysicsComponent != nullptr) {
|
||||||
controllablePhysicsComponent->SetRotation(value);
|
controllablePhysicsComponent->SetRotation(value);
|
||||||
@ -350,7 +350,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
|
auto* simplePhysicsComponent = m_ParentEntity->GetComponent<SimplePhysicsComponent>();
|
||||||
|
|
||||||
if (simplePhysicsComponent != nullptr) {
|
if (simplePhysicsComponent != nullptr) {
|
||||||
simplePhysicsComponent->SetRotation(value);
|
simplePhysicsComponent->SetRotation(value);
|
||||||
@ -358,7 +358,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::SetVelocity(const NiPoint3& value) {
|
void MovementAIComponent::SetVelocity(const NiPoint3& value) {
|
||||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (controllablePhysicsComponent != nullptr) {
|
if (controllablePhysicsComponent != nullptr) {
|
||||||
controllablePhysicsComponent->SetVelocity(value);
|
controllablePhysicsComponent->SetVelocity(value);
|
||||||
@ -366,7 +366,7 @@ void MovementAIComponent::SetVelocity(const NiPoint3& value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
|
auto* simplePhysicsComponent = m_ParentEntity->GetComponent<SimplePhysicsComponent>();
|
||||||
|
|
||||||
if (simplePhysicsComponent != nullptr) {
|
if (simplePhysicsComponent != nullptr) {
|
||||||
simplePhysicsComponent->SetVelocity(value);
|
simplePhysicsComponent->SetVelocity(value);
|
||||||
|
@ -57,7 +57,7 @@ void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIniti
|
|||||||
|
|
||||||
MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::string& pathName) : Component(parent) {
|
MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::string& pathName) : Component(parent) {
|
||||||
m_MoverSubComponentType = eMoverSubComponentType::mover;
|
m_MoverSubComponentType = eMoverSubComponentType::mover;
|
||||||
m_MoverSubComponent = new MoverSubComponent(m_OwningEntity->GetDefaultPosition());
|
m_MoverSubComponent = new MoverSubComponent(m_ParentEntity->GetDefaultPosition());
|
||||||
m_PathName = GeneralUtils::ASCIIToUTF16(pathName);
|
m_PathName = GeneralUtils::ASCIIToUTF16(pathName);
|
||||||
m_Path = dZoneManager::Instance()->GetZone()->GetPath(pathName);
|
m_Path = dZoneManager::Instance()->GetZone()->GetPath(pathName);
|
||||||
m_NoAutoStart = false;
|
m_NoAutoStart = false;
|
||||||
@ -133,7 +133,7 @@ void MovingPlatformComponent::SetMovementState(eMovementPlatformState value) {
|
|||||||
|
|
||||||
subComponent->mState = value;
|
subComponent->mState = value;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint) {
|
void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint) {
|
||||||
@ -147,7 +147,7 @@ void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MovingPlatformComponent::StartPathing() {
|
void MovingPlatformComponent::StartPathing() {
|
||||||
//GameMessages::SendStartPathing(m_OwningEntity);
|
//GameMessages::SendStartPathing(m_ParentEntity);
|
||||||
m_PathingStopped = false;
|
m_PathingStopped = false;
|
||||||
|
|
||||||
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
||||||
@ -167,14 +167,14 @@ void MovingPlatformComponent::StartPathing() {
|
|||||||
|
|
||||||
targetPosition = nextWaypoint.position;
|
targetPosition = nextWaypoint.position;
|
||||||
} else {
|
} else {
|
||||||
subComponent->mPosition = m_OwningEntity->GetPosition();
|
subComponent->mPosition = m_ParentEntity->GetPosition();
|
||||||
subComponent->mSpeed = 1.0f;
|
subComponent->mSpeed = 1.0f;
|
||||||
subComponent->mWaitTime = 2.0f;
|
subComponent->mWaitTime = 2.0f;
|
||||||
|
|
||||||
targetPosition = m_OwningEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
targetPosition = m_ParentEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
m_ParentEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
||||||
SetMovementState(eMovementPlatformState::Moving);
|
SetMovementState(eMovementPlatformState::Moving);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -182,19 +182,19 @@ void MovingPlatformComponent::StartPathing() {
|
|||||||
|
|
||||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
m_ParentEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnWaypointReached(m_OwningEntity, subComponent->mNextWaypointIndex);
|
script->OnWaypointReached(m_ParentEntity, subComponent->mNextWaypointIndex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(travelNext, [this] {
|
m_ParentEntity->AddCallbackTimer(travelNext, [this] {
|
||||||
ContinuePathing();
|
ContinuePathing();
|
||||||
});
|
});
|
||||||
|
|
||||||
//GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
//GameMessages::SendPlatformResync(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovingPlatformComponent::ContinuePathing() {
|
void MovingPlatformComponent::ContinuePathing() {
|
||||||
@ -222,17 +222,17 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
|
|
||||||
targetPosition = nextWaypoint.position;
|
targetPosition = nextWaypoint.position;
|
||||||
} else {
|
} else {
|
||||||
subComponent->mPosition = m_OwningEntity->GetPosition();
|
subComponent->mPosition = m_ParentEntity->GetPosition();
|
||||||
subComponent->mSpeed = 1.0f;
|
subComponent->mSpeed = 1.0f;
|
||||||
subComponent->mWaitTime = 2.0f;
|
subComponent->mWaitTime = 2.0f;
|
||||||
|
|
||||||
targetPosition = m_OwningEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
targetPosition = m_ParentEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
||||||
|
|
||||||
pathSize = 1;
|
pathSize = 1;
|
||||||
behavior = PathBehavior::Loop;
|
behavior = PathBehavior::Loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_OwningEntity->GetLOT() == 9483) {
|
if (m_ParentEntity->GetLOT() == 9483) {
|
||||||
behavior = PathBehavior::Bounce;
|
behavior = PathBehavior::Bounce;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -242,7 +242,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
subComponent->mCurrentWaypointIndex = pathSize;
|
subComponent->mCurrentWaypointIndex = pathSize;
|
||||||
switch (behavior) {
|
switch (behavior) {
|
||||||
case PathBehavior::Once:
|
case PathBehavior::Once:
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case PathBehavior::Bounce:
|
case PathBehavior::Bounce:
|
||||||
@ -271,7 +271,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
subComponent->mCurrentWaypointIndex = 1;
|
subComponent->mCurrentWaypointIndex = 1;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
//GameMessages::SendPlatformResync(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
if (subComponent->mCurrentWaypointIndex == subComponent->mDesiredWaypointIndex) {
|
if (subComponent->mCurrentWaypointIndex == subComponent->mDesiredWaypointIndex) {
|
||||||
// TODO: Send event?
|
// TODO: Send event?
|
||||||
@ -280,35 +280,35 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OwningEntity->CancelCallbackTimers();
|
m_ParentEntity->CancelCallbackTimers();
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
m_ParentEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
||||||
SetMovementState(eMovementPlatformState::Moving);
|
SetMovementState(eMovementPlatformState::Moving);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
||||||
|
|
||||||
if (m_OwningEntity->GetLOT() == 9483) {
|
if (m_ParentEntity->GetLOT() == 9483) {
|
||||||
travelTime += 20;
|
travelTime += 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
m_ParentEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnWaypointReached(m_OwningEntity, subComponent->mNextWaypointIndex);
|
script->OnWaypointReached(m_ParentEntity, subComponent->mNextWaypointIndex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(travelNext, [this] {
|
m_ParentEntity->AddCallbackTimer(travelNext, [this] {
|
||||||
ContinuePathing();
|
ContinuePathing();
|
||||||
});
|
});
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovingPlatformComponent::StopPathing() {
|
void MovingPlatformComponent::StopPathing() {
|
||||||
//m_OwningEntity->CancelCallbackTimers();
|
//m_ParentEntity->CancelCallbackTimers();
|
||||||
|
|
||||||
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
||||||
|
|
||||||
@ -318,9 +318,9 @@ void MovingPlatformComponent::StopPathing() {
|
|||||||
subComponent->mDesiredWaypointIndex = -1;
|
subComponent->mDesiredWaypointIndex = -1;
|
||||||
subComponent->mShouldStopAtDesiredWaypoint = false;
|
subComponent->mShouldStopAtDesiredWaypoint = false;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
//GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
//GameMessages::SendPlatformResync(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovingPlatformComponent::SetSerialized(bool value) {
|
void MovingPlatformComponent::SetSerialized(bool value) {
|
||||||
@ -338,10 +338,10 @@ void MovingPlatformComponent::SetNoAutoStart(const bool value) {
|
|||||||
void MovingPlatformComponent::WarpToWaypoint(size_t index) {
|
void MovingPlatformComponent::WarpToWaypoint(size_t index) {
|
||||||
const auto& waypoint = m_Path->pathWaypoints[index];
|
const auto& waypoint = m_Path->pathWaypoints[index];
|
||||||
|
|
||||||
m_OwningEntity->SetPosition(waypoint.position);
|
m_ParentEntity->SetPosition(waypoint.position);
|
||||||
m_OwningEntity->SetRotation(waypoint.rotation);
|
m_ParentEntity->SetRotation(waypoint.rotation);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MovingPlatformComponent::GetLastWaypointIndex() const {
|
size_t MovingPlatformComponent::GetLastWaypointIndex() const {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "CharacterComponent.h"
|
#include "CharacterComponent.h"
|
||||||
|
|
||||||
MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent) : Component(parent) {
|
MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent) : Component(parent) {
|
||||||
m_OwningEntity = parent;
|
m_ParentEntity = parent;
|
||||||
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_OwningEntity->GetVar<std::u16string>(u"MultiZoneIDs"));
|
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_ParentEntity->GetVar<std::u16string>(u"MultiZoneIDs"));
|
||||||
std::stringstream ss(zoneString);
|
std::stringstream ss(zoneString);
|
||||||
for (int i; ss >> i;) {
|
for (int i; ss >> i;) {
|
||||||
m_LUPWorlds.push_back(i);
|
m_LUPWorlds.push_back(i);
|
||||||
@ -21,11 +21,11 @@ void MultiZoneEntranceComponent::OnUse(Entity* originator) {
|
|||||||
if (!rocket) return;
|
if (!rocket) return;
|
||||||
|
|
||||||
// the LUP world menu is just the property menu, the client knows how to handle it
|
// the LUP world menu is just the property menu, the client knows how to handle it
|
||||||
GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress());
|
GameMessages::SendPropertyEntranceBegin(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) {
|
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) {
|
||||||
auto* rocketLaunchpadControlComponent = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>();
|
auto* rocketLaunchpadControlComponent = m_ParentEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||||
if (!rocketLaunchpadControlComponent) return;
|
if (!rocketLaunchpadControlComponent) return;
|
||||||
|
|
||||||
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
|
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
|
||||||
|
@ -173,7 +173,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* movementAIComponent = m_OwningEntity->GetComponent<MovementAIComponent>();
|
auto* movementAIComponent = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||||
|
|
||||||
if (movementAIComponent != nullptr) {
|
if (movementAIComponent != nullptr) {
|
||||||
movementAIComponent->Stop();
|
movementAIComponent->Stop();
|
||||||
@ -181,7 +181,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
|
|
||||||
inventoryComponent->DespawnPet();
|
inventoryComponent->DespawnPet();
|
||||||
|
|
||||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||||
int32_t imaginationCost = 0;
|
int32_t imaginationCost = 0;
|
||||||
|
|
||||||
std::string buildFile;
|
std::string buildFile;
|
||||||
@ -189,7 +189,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
if (cached == buildCache.end()) {
|
if (cached == buildCache.end()) {
|
||||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||||
"SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;");
|
"SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;");
|
||||||
query.bind(1, (int)m_OwningEntity->GetLOT());
|
query.bind(1, (int)m_ParentEntity->GetLOT());
|
||||||
|
|
||||||
auto result = query.execQuery();
|
auto result = query.execQuery();
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
if (data.timeLimit <= 0) data.timeLimit = 60;
|
if (data.timeLimit <= 0) data.timeLimit = 60;
|
||||||
imaginationCost = data.imaginationCost;
|
imaginationCost = data.imaginationCost;
|
||||||
|
|
||||||
buildCache[m_OwningEntity->GetLOT()] = data;
|
buildCache[m_ParentEntity->GetLOT()] = data;
|
||||||
|
|
||||||
result.finalize();
|
result.finalize();
|
||||||
} else {
|
} else {
|
||||||
@ -245,13 +245,13 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto petPosition = m_OwningEntity->GetPosition();
|
auto petPosition = m_ParentEntity->GetPosition();
|
||||||
|
|
||||||
auto originatorPosition = originator->GetPosition();
|
auto originatorPosition = originator->GetPosition();
|
||||||
|
|
||||||
m_OwningEntity->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition));
|
m_ParentEntity->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition));
|
||||||
|
|
||||||
float interactionDistance = m_OwningEntity->GetVar<float>(u"interaction_distance");
|
float interactionDistance = m_ParentEntity->GetVar<float>(u"interaction_distance");
|
||||||
|
|
||||||
if (interactionDistance <= 0) {
|
if (interactionDistance <= 0) {
|
||||||
interactionDistance = 15;
|
interactionDistance = 15;
|
||||||
@ -259,7 +259,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
|
|
||||||
auto position = originatorPosition;
|
auto position = originatorPosition;
|
||||||
|
|
||||||
NiPoint3 forward = NiQuaternion::LookAt(m_OwningEntity->GetPosition(), originator->GetPosition()).GetForwardVector();
|
NiPoint3 forward = NiQuaternion::LookAt(m_ParentEntity->GetPosition(), originator->GetPosition()).GetForwardVector();
|
||||||
forward.y = 0;
|
forward.y = 0;
|
||||||
|
|
||||||
if (dpWorld::Instance().IsLoaded()) {
|
if (dpWorld::Instance().IsLoaded()) {
|
||||||
@ -268,7 +268,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
|
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
|
||||||
|
|
||||||
while (std::abs(y - petPosition.y) > 4 && interactionDistance > 10) {
|
while (std::abs(y - petPosition.y) > 4 && interactionDistance > 10) {
|
||||||
const NiPoint3 forward = m_OwningEntity->GetRotation().GetForwardVector();
|
const NiPoint3 forward = m_ParentEntity->GetRotation().GetForwardVector();
|
||||||
|
|
||||||
attempt = originatorPosition + forward * interactionDistance;
|
attempt = originatorPosition + forward * interactionDistance;
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
|
|
||||||
GameMessages::SendNotifyPetTamingMinigame(
|
GameMessages::SendNotifyPetTamingMinigame(
|
||||||
originator->GetObjectID(),
|
originator->GetObjectID(),
|
||||||
m_OwningEntity->GetObjectID(),
|
m_ParentEntity->GetObjectID(),
|
||||||
LWOOBJID_EMPTY,
|
LWOOBJID_EMPTY,
|
||||||
true,
|
true,
|
||||||
ePetTamingNotifyType::BEGIN,
|
ePetTamingNotifyType::BEGIN,
|
||||||
@ -298,7 +298,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
GameMessages::SendNotifyPetTamingMinigame(
|
GameMessages::SendNotifyPetTamingMinigame(
|
||||||
m_OwningEntity->GetObjectID(),
|
m_ParentEntity->GetObjectID(),
|
||||||
LWOOBJID_EMPTY,
|
LWOOBJID_EMPTY,
|
||||||
originator->GetObjectID(),
|
originator->GetObjectID(),
|
||||||
true,
|
true,
|
||||||
@ -314,17 +314,17 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
m_Tamer = originator->GetObjectID();
|
m_Tamer = originator->GetObjectID();
|
||||||
SetStatus(5);
|
SetStatus(5);
|
||||||
|
|
||||||
currentActivities.insert_or_assign(m_Tamer, m_OwningEntity->GetObjectID());
|
currentActivities.insert_or_assign(m_Tamer, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
// Notify the start of a pet taming minigame
|
// Notify the start of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, originator, ePetTamingNotifyType::BEGIN);
|
script->OnNotifyPetTamingMinigame(m_ParentEntity, originator, ePetTamingNotifyType::BEGIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::Update(float deltaTime) {
|
void PetComponent::Update(float deltaTime) {
|
||||||
if (m_StartPosition == NiPoint3::ZERO) {
|
if (m_StartPosition == NiPoint3::ZERO) {
|
||||||
m_StartPosition = m_OwningEntity->GetPosition();
|
m_StartPosition = m_ParentEntity->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Owner == LWOOBJID_EMPTY) {
|
if (m_Owner == LWOOBJID_EMPTY) {
|
||||||
@ -344,7 +344,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
if (m_Timer <= 0) {
|
if (m_Timer <= 0) {
|
||||||
Wander();
|
Wander();
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_Timer = 5;
|
m_Timer = 5;
|
||||||
@ -357,13 +357,13 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
auto* owner = GetOwner();
|
auto* owner = GetOwner();
|
||||||
|
|
||||||
if (owner == nullptr) {
|
if (owner == nullptr) {
|
||||||
m_OwningEntity->Kill();
|
m_ParentEntity->Kill();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_MovementAI == nullptr) {
|
if (m_MovementAI == nullptr) {
|
||||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
m_MovementAI = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||||
if (!m_MovementAI) return;
|
if (!m_MovementAI) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,9 +381,9 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
m_MovementAI->Stop();
|
m_MovementAI->Stop();
|
||||||
|
|
||||||
if (m_TresureTime <= 0) {
|
if (m_TresureTime <= 0) {
|
||||||
m_OwningEntity->SetOwnerOverride(m_Owner);
|
m_ParentEntity->SetOwnerOverride(m_Owner);
|
||||||
|
|
||||||
tresure->Smash(m_OwningEntity->GetObjectID());
|
tresure->Smash(m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
m_Interaction = LWOOBJID_EMPTY;
|
m_Interaction = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
float distance = Vector3::DistanceSquared(position, switchPosition);
|
float distance = Vector3::DistanceSquared(position, switchPosition);
|
||||||
if (distance < 3 * 3) {
|
if (distance < 3 * 3) {
|
||||||
m_Interaction = closestSwitch->GetParentEntity()->GetObjectID();
|
m_Interaction = closestSwitch->GetParentEntity()->GetObjectID();
|
||||||
closestSwitch->EntityEnter(m_OwningEntity);
|
closestSwitch->EntityEnter(m_ParentEntity);
|
||||||
} else if (distance < 20 * 20) {
|
} else if (distance < 20 * 20) {
|
||||||
haltDistance = 1;
|
haltDistance = 1;
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
if (closestTresure != nullptr) {
|
if (closestTresure != nullptr) {
|
||||||
// Skeleton Dragon Pat special case for bone digging
|
// Skeleton Dragon Pat special case for bone digging
|
||||||
if (closestTresure->GetLOT() == 12192 && m_OwningEntity->GetLOT() != 13067) {
|
if (closestTresure->GetLOT() == 12192 && m_ParentEntity->GetLOT() != 13067) {
|
||||||
goto skipTresure;
|
goto skipTresure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||||
|
|
||||||
if (cached == buildCache.end()) return;
|
if (cached == buildCache.end()) return;
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||||
|
|
||||||
if (cached == buildCache.end()) {
|
if (cached == buildCache.end()) {
|
||||||
return;
|
return;
|
||||||
@ -546,7 +546,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
|
|
||||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendPetResponse(m_Tamer, m_OwningEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress());
|
GameMessages::SendPetResponse(m_Tamer, m_ParentEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress());
|
||||||
|
|
||||||
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>();
|
||||||
|
|
||||||
@ -564,13 +564,13 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
std::string petName = tamer->GetCharacter()->GetName();
|
std::string petName = tamer->GetCharacter()->GetName();
|
||||||
petName += "'s Pet";
|
petName += "'s Pet";
|
||||||
|
|
||||||
GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_OwningEntity->GetLOT(), tamer->GetSystemAddress());
|
GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_ParentEntity->GetLOT(), tamer->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendRegisterPetID(m_Tamer, m_OwningEntity->GetObjectID(), tamer->GetSystemAddress());
|
GameMessages::SendRegisterPetID(m_Tamer, m_ParentEntity->GetObjectID(), tamer->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress());
|
GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress());
|
||||||
|
|
||||||
inventoryComponent->AddItem(m_OwningEntity->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
inventoryComponent->AddItem(m_ParentEntity->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||||
auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
|
auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
|
||||||
|
|
||||||
if (item == nullptr) {
|
if (item == nullptr) {
|
||||||
@ -579,7 +579,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
|
|
||||||
DatabasePet databasePet{};
|
DatabasePet databasePet{};
|
||||||
|
|
||||||
databasePet.lot = m_OwningEntity->GetLOT();
|
databasePet.lot = m_ParentEntity->GetLOT();
|
||||||
databasePet.moderationState = 1;
|
databasePet.moderationState = 1;
|
||||||
databasePet.name = petName;
|
databasePet.name = petName;
|
||||||
|
|
||||||
@ -602,14 +602,14 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Triggers the catch a pet missions
|
// Triggers the catch a pet missions
|
||||||
if (petFlags.find(m_OwningEntity->GetLOT()) != petFlags.end()) {
|
if (petFlags.find(m_ParentEntity->GetLOT()) != petFlags.end()) {
|
||||||
tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_OwningEntity->GetLOT()), true);
|
tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_ParentEntity->GetLOT()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* missionComponent = tamer->GetComponent<MissionComponent>();
|
auto* missionComponent = tamer->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
if (missionComponent != nullptr) {
|
if (missionComponent != nullptr) {
|
||||||
missionComponent->Progress(eMissionTaskType::PET_TAMING, m_OwningEntity->GetLOT());
|
missionComponent->Progress(eMissionTaskType::PET_TAMING, m_ParentEntity->GetLOT());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatus(1);
|
SetStatus(1);
|
||||||
@ -660,18 +660,18 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
|||||||
//Save our pet's new name to the db:
|
//Save our pet's new name to the db:
|
||||||
SetPetNameForModeration(GeneralUtils::UTF16ToWTF8(name));
|
SetPetNameForModeration(GeneralUtils::UTF16ToWTF8(name));
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
std::u16string u16name = GeneralUtils::UTF8ToUTF16(m_Name);
|
std::u16string u16name = GeneralUtils::UTF8ToUTF16(m_Name);
|
||||||
std::u16string u16ownerName = GeneralUtils::UTF8ToUTF16(m_OwnerName);
|
std::u16string u16ownerName = GeneralUtils::UTF8ToUTF16(m_OwnerName);
|
||||||
GameMessages::SendSetPetName(m_Tamer, u16name, m_DatabaseId, tamer->GetSystemAddress());
|
GameMessages::SendSetPetName(m_Tamer, u16name, m_DatabaseId, tamer->GetSystemAddress());
|
||||||
GameMessages::SendSetPetName(m_Tamer, u16name, LWOOBJID_EMPTY, tamer->GetSystemAddress());
|
GameMessages::SendSetPetName(m_Tamer, u16name, LWOOBJID_EMPTY, tamer->GetSystemAddress());
|
||||||
GameMessages::SendPetNameChanged(m_OwningEntity->GetObjectID(), m_ModerationStatus, u16name, u16ownerName, UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendPetNameChanged(m_ParentEntity->GetObjectID(), m_ModerationStatus, u16name, u16ownerName, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
GameMessages::SendSetPetNameModerated(m_Tamer, m_DatabaseId, m_ModerationStatus, tamer->GetSystemAddress());
|
GameMessages::SendSetPetNameModerated(m_Tamer, m_DatabaseId, m_ModerationStatus, tamer->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendNotifyPetTamingMinigame(
|
GameMessages::SendNotifyPetTamingMinigame(
|
||||||
m_Tamer,
|
m_Tamer,
|
||||||
m_OwningEntity->GetObjectID(),
|
m_ParentEntity->GetObjectID(),
|
||||||
m_Tamer,
|
m_Tamer,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::SUCCESS,
|
ePetTamingNotifyType::SUCCESS,
|
||||||
@ -681,7 +681,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
|||||||
UNASSIGNED_SYSTEM_ADDRESS
|
UNASSIGNED_SYSTEM_ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
auto* modelEntity = EntityManager::Instance()->GetEntity(m_ModelId);
|
auto* modelEntity = EntityManager::Instance()->GetEntity(m_ModelId);
|
||||||
|
|
||||||
@ -694,8 +694,8 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
|||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
// Notify the end of a pet taming minigame
|
// Notify the end of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::SUCCESS);
|
script->OnNotifyPetTamingMinigame(m_ParentEntity, tamer, ePetTamingNotifyType::SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +712,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
|||||||
|
|
||||||
GameMessages::SendNotifyPetTamingMinigame(
|
GameMessages::SendNotifyPetTamingMinigame(
|
||||||
m_Tamer,
|
m_Tamer,
|
||||||
m_OwningEntity->GetObjectID(),
|
m_ParentEntity->GetObjectID(),
|
||||||
m_Tamer,
|
m_Tamer,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::QUIT,
|
ePetTamingNotifyType::QUIT,
|
||||||
@ -724,7 +724,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
|||||||
|
|
||||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
currentActivities.erase(m_Tamer);
|
currentActivities.erase(m_Tamer);
|
||||||
|
|
||||||
@ -732,16 +732,16 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
|||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
// Notify the end of a pet taming minigame
|
// Notify the end of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::QUIT);
|
script->OnNotifyPetTamingMinigame(m_ParentEntity, tamer, ePetTamingNotifyType::QUIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::StartTimer() {
|
void PetComponent::StartTimer() {
|
||||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||||
|
|
||||||
if (cached == buildCache.end()) {
|
if (cached == buildCache.end()) {
|
||||||
return;
|
return;
|
||||||
@ -763,7 +763,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
|||||||
|
|
||||||
GameMessages::SendNotifyPetTamingMinigame(
|
GameMessages::SendNotifyPetTamingMinigame(
|
||||||
m_Tamer,
|
m_Tamer,
|
||||||
m_OwningEntity->GetObjectID(),
|
m_ParentEntity->GetObjectID(),
|
||||||
m_Tamer,
|
m_Tamer,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::FAILED,
|
ePetTamingNotifyType::FAILED,
|
||||||
@ -775,7 +775,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
|||||||
|
|
||||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
currentActivities.erase(m_Tamer);
|
currentActivities.erase(m_Tamer);
|
||||||
|
|
||||||
@ -783,16 +783,16 @@ void PetComponent::ClientFailTamingMinigame() {
|
|||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
// Notify the end of a pet taming minigame
|
// Notify the end of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::FAILED);
|
script->OnNotifyPetTamingMinigame(m_ParentEntity, tamer, ePetTamingNotifyType::FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::Wander() {
|
void PetComponent::Wander() {
|
||||||
if (!m_MovementAI) m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
if (!m_MovementAI) m_MovementAI = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||||
|
|
||||||
if (m_MovementAI == nullptr || !m_MovementAI->AtFinalWaypoint()) {
|
if (m_MovementAI == nullptr || !m_MovementAI->AtFinalWaypoint()) {
|
||||||
return;
|
return;
|
||||||
@ -882,18 +882,18 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
|
|||||||
|
|
||||||
GameMessages::SendMarkInventoryItemAsActive(m_Owner, true, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
GameMessages::SendMarkInventoryItemAsActive(m_Owner, true, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
||||||
|
|
||||||
activePets[m_Owner] = m_OwningEntity->GetObjectID();
|
activePets[m_Owner] = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
m_Timer = 3;
|
m_Timer = 3;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true);
|
owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true);
|
||||||
|
|
||||||
if (registerPet) {
|
if (registerPet) {
|
||||||
GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_OwningEntity->GetLOT(), owner->GetSystemAddress());
|
GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_ParentEntity->GetLOT(), owner->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendRegisterPetID(m_Owner, m_OwningEntity->GetObjectID(), owner->GetSystemAddress());
|
GameMessages::SendRegisterPetID(m_Owner, m_ParentEntity->GetObjectID(), owner->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendRegisterPetDBID(m_Owner, m_DatabaseId, owner->GetSystemAddress());
|
GameMessages::SendRegisterPetDBID(m_Owner, m_DatabaseId, owner->GetSystemAddress());
|
||||||
}
|
}
|
||||||
@ -920,7 +920,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
|
|||||||
if (!fromTaming) playerDestroyableComponent->Imagine(-1);
|
if (!fromTaming) playerDestroyableComponent->Imagine(-1);
|
||||||
|
|
||||||
// Set this to a variable so when this is called back from the player the timer doesn't fire off.
|
// Set this to a variable so when this is called back from the player the timer doesn't fire off.
|
||||||
m_OwningEntity->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() {
|
m_ParentEntity->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() {
|
||||||
if (!playerDestroyableComponent) {
|
if (!playerDestroyableComponent) {
|
||||||
Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent");
|
Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent");
|
||||||
return;
|
return;
|
||||||
@ -940,13 +940,13 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::Deactivate() {
|
void PetComponent::Deactivate() {
|
||||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
|
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
|
||||||
|
|
||||||
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
||||||
|
|
||||||
activePets.erase(m_Owner);
|
activePets.erase(m_Owner);
|
||||||
|
|
||||||
m_OwningEntity->Kill();
|
m_ParentEntity->Kill();
|
||||||
|
|
||||||
auto* owner = GetOwner();
|
auto* owner = GetOwner();
|
||||||
|
|
||||||
@ -986,7 +986,7 @@ void PetComponent::Command(NiPoint3 position, LWOOBJID source, int32_t commandTy
|
|||||||
|
|
||||||
if (commandType == 1) {
|
if (commandType == 1) {
|
||||||
// Emotes
|
// Emotes
|
||||||
GameMessages::SendPlayEmote(m_OwningEntity->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendPlayEmote(m_ParentEntity->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
} else if (commandType == 3) {
|
} else if (commandType == 3) {
|
||||||
// Follow me, ???
|
// Follow me, ???
|
||||||
} else if (commandType == 6) {
|
} else if (commandType == 6) {
|
||||||
@ -1075,7 +1075,7 @@ PetComponent* PetComponent::GetActivePet(LWOOBJID owner) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* PetComponent::GetParentEntity() const {
|
Entity* PetComponent::GetParentEntity() const {
|
||||||
return m_OwningEntity;
|
return m_ParentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
PetComponent::~PetComponent() {
|
PetComponent::~PetComponent() {
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
#include "dpShapeSphere.h"
|
#include "dpShapeSphere.h"
|
||||||
|
|
||||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
||||||
m_Position = m_OwningEntity->GetDefaultPosition();
|
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||||
m_Rotation = m_OwningEntity->GetDefaultRotation();
|
m_Rotation = m_ParentEntity->GetDefaultRotation();
|
||||||
m_Scale = m_OwningEntity->GetDefaultScale();
|
m_Scale = m_ParentEntity->GetDefaultScale();
|
||||||
m_dpEntity = nullptr;
|
m_dpEntity = nullptr;
|
||||||
|
|
||||||
m_EffectInfoDirty = false;
|
m_EffectInfoDirty = false;
|
||||||
@ -47,17 +47,17 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
m_IsDirectional = false;
|
m_IsDirectional = false;
|
||||||
m_Direction = NiPoint3(); // * m_DirectionalMultiplier
|
m_Direction = NiPoint3(); // * m_DirectionalMultiplier
|
||||||
|
|
||||||
if (m_OwningEntity->GetVar<bool>(u"create_physics")) {
|
if (m_ParentEntity->GetVar<bool>(u"create_physics")) {
|
||||||
CreatePhysics();
|
CreatePhysics();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_OwningEntity->GetVar<bool>(u"respawnVol")) {
|
if (m_ParentEntity->GetVar<bool>(u"respawnVol")) {
|
||||||
m_IsRespawnVolume = true;
|
m_IsRespawnVolume = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_IsRespawnVolume) {
|
if (m_IsRespawnVolume) {
|
||||||
{
|
{
|
||||||
auto respawnString = std::stringstream(m_OwningEntity->GetVarAsString(u"rspPos"));
|
auto respawnString = std::stringstream(m_ParentEntity->GetVarAsString(u"rspPos"));
|
||||||
|
|
||||||
std::string segment;
|
std::string segment;
|
||||||
std::vector<std::string> seglist;
|
std::vector<std::string> seglist;
|
||||||
@ -70,7 +70,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto respawnString = std::stringstream(m_OwningEntity->GetVarAsString(u"rspRot"));
|
auto respawnString = std::stringstream(m_ParentEntity->GetVarAsString(u"rspRot"));
|
||||||
|
|
||||||
std::string segment;
|
std::string segment;
|
||||||
std::vector<std::string> seglist;
|
std::vector<std::string> seglist;
|
||||||
@ -84,7 +84,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HF - RespawnPoints. Legacy respawn entity.
|
// HF - RespawnPoints. Legacy respawn entity.
|
||||||
if (m_OwningEntity->GetLOT() == 4945) {
|
if (m_ParentEntity->GetLOT() == 4945) {
|
||||||
m_IsRespawnVolume = true;
|
m_IsRespawnVolume = true;
|
||||||
m_RespawnPos = m_Position;
|
m_RespawnPos = m_Position;
|
||||||
m_RespawnRot = m_Rotation;
|
m_RespawnRot = m_Rotation;
|
||||||
@ -133,7 +133,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_OwningEntity->GetLOT() == 4945) // HF - RespawnPoints
|
if (m_ParentEntity->GetLOT() == 4945) // HF - RespawnPoints
|
||||||
{
|
{
|
||||||
m_IsRespawnVolume = true;
|
m_IsRespawnVolume = true;
|
||||||
m_RespawnPos = m_Position;
|
m_RespawnPos = m_Position;
|
||||||
@ -145,7 +145,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
|
|
||||||
if (!m_HasCreatedPhysics) {
|
if (!m_HasCreatedPhysics) {
|
||||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||||
auto componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||||
|
|
||||||
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
|
|
||||||
//temp test
|
//temp test
|
||||||
if (info->physicsAsset == "miscellaneous\\misc_phys_10x1x5.hkx") {
|
if (info->physicsAsset == "miscellaneous\\misc_phys_10x1x5.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 10.0f, 5.0f, 1.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 5.0f, 1.0f);
|
||||||
|
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
@ -167,7 +167,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
||||||
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
|
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
|
||||||
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
||||||
|
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
@ -175,49 +175,49 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
|
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") {
|
} else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 10.0f, 25.0f, 1.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 25.0f, 1.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") {
|
} else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 20.0f, 20.0f, 20.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 20.0f, 20.0f, 20.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") {
|
} else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
|
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f);
|
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
|
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f);
|
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
|
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
|
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 4.5f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 4.5f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx"){
|
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx"){
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_Position.y -= (111.467964f * m_Scale) / 2;
|
m_Position.y -= (111.467964f * m_Scale) / 2;
|
||||||
@ -227,7 +227,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str());
|
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str());
|
||||||
|
|
||||||
//add fallback cube:
|
//add fallback cube:
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 2.0f, 2.0f, 2.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 2.0f, 2.0f, 2.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
@ -255,14 +255,14 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
|||||||
float width = 0.0f; //aka "radius"
|
float width = 0.0f; //aka "radius"
|
||||||
float height = 0.0f;
|
float height = 0.0f;
|
||||||
|
|
||||||
if (m_OwningEntity->HasVar(u"primitiveModelType")) {
|
if (m_ParentEntity->HasVar(u"primitiveModelType")) {
|
||||||
type = m_OwningEntity->GetVar<int32_t>(u"primitiveModelType");
|
type = m_ParentEntity->GetVar<int32_t>(u"primitiveModelType");
|
||||||
x = m_OwningEntity->GetVar<float>(u"primitiveModelValueX");
|
x = m_ParentEntity->GetVar<float>(u"primitiveModelValueX");
|
||||||
y = m_OwningEntity->GetVar<float>(u"primitiveModelValueY");
|
y = m_ParentEntity->GetVar<float>(u"primitiveModelValueY");
|
||||||
z = m_OwningEntity->GetVar<float>(u"primitiveModelValueZ");
|
z = m_ParentEntity->GetVar<float>(u"primitiveModelValueZ");
|
||||||
} else {
|
} else {
|
||||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||||
auto componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||||
|
|
||||||
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
|||||||
boxSize = NiPoint3(width, height, width);
|
boxSize = NiPoint3(width, height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), boxSize);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), boxSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,7 +358,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
//Process enter events
|
//Process enter events
|
||||||
for (auto en : m_dpEntity->GetNewObjects()) {
|
for (auto en : m_dpEntity->GetNewObjects()) {
|
||||||
m_OwningEntity->OnCollisionPhantom(en->GetObjectID());
|
m_ParentEntity->OnCollisionPhantom(en->GetObjectID());
|
||||||
|
|
||||||
//If we are a respawn volume, inform the client:
|
//If we are a respawn volume, inform the client:
|
||||||
if (m_IsRespawnVolume) {
|
if (m_IsRespawnVolume) {
|
||||||
@ -374,7 +374,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
//Process exit events
|
//Process exit events
|
||||||
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
||||||
m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
m_ParentEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) {
|
|||||||
void PhantomPhysicsComponent::SpawnVertices() {
|
void PhantomPhysicsComponent::SpawnVertices() {
|
||||||
if (!m_dpEntity) return;
|
if (!m_dpEntity) return;
|
||||||
|
|
||||||
std::cout << m_OwningEntity->GetObjectID() << std::endl;
|
std::cout << m_ParentEntity->GetObjectID() << std::endl;
|
||||||
auto box = static_cast<dpShapeBox*>(m_dpEntity->GetShape());
|
auto box = static_cast<dpShapeBox*>(m_dpEntity->GetShape());
|
||||||
for (auto vert : box->GetVertices()) {
|
for (auto vert : box->GetVertices()) {
|
||||||
std::cout << vert.x << ", " << vert.y << ", " << vert.z << std::endl;
|
std::cout << vert.x << ", " << vert.y << ", " << vert.z << std::endl;
|
||||||
@ -400,7 +400,7 @@ void PhantomPhysicsComponent::SpawnVertices() {
|
|||||||
info.lot = 33;
|
info.lot = 33;
|
||||||
info.pos = vert;
|
info.pos = vert;
|
||||||
info.spawner = nullptr;
|
info.spawner = nullptr;
|
||||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||||
info.spawnerNodeID = 0;
|
info.spawnerNodeID = 0;
|
||||||
|
|
||||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "PlayerForcedMovementComponent.h"
|
#include "PlayerForcedMovementComponent.h"
|
||||||
|
|
||||||
PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : Component(parent) {
|
PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : Component(parent) {
|
||||||
m_OwningEntity = parent;
|
m_ParentEntity = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {}
|
PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent) {
|
PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent) {
|
||||||
m_Possessor = LWOOBJID_EMPTY;
|
m_Possessor = LWOOBJID_EMPTY;
|
||||||
CDItemComponent item = Inventory::FindItemComponent(m_OwningEntity->GetLOT());
|
CDItemComponent item = Inventory::FindItemComponent(m_ParentEntity->GetLOT());
|
||||||
m_AnimationFlag = static_cast<eAnimationFlags>(item.animationFlag);
|
m_AnimationFlag = static_cast<eAnimationFlags>(item.animationFlag);
|
||||||
|
|
||||||
// Get the possession Type from the CDClient
|
// Get the possession Type from the CDClient
|
||||||
@ -44,12 +44,12 @@ void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
|
|||||||
|
|
||||||
void PossessableComponent::Dismount() {
|
void PossessableComponent::Dismount() {
|
||||||
SetPossessor(LWOOBJID_EMPTY);
|
SetPossessor(LWOOBJID_EMPTY);
|
||||||
if (m_ItemSpawned) m_OwningEntity->ScheduleKillAfterUpdate();
|
if (m_ItemSpawned) m_ParentEntity->ScheduleKillAfterUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PossessableComponent::OnUse(Entity* originator) {
|
void PossessableComponent::OnUse(Entity* originator) {
|
||||||
auto* possessor = originator->GetComponent<PossessorComponent>();
|
auto* possessor = originator->GetComponent<PossessorComponent>();
|
||||||
if (possessor) {
|
if (possessor) {
|
||||||
possessor->Mount(m_OwningEntity);
|
possessor->Mount(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ PossessorComponent::~PossessorComponent() {
|
|||||||
auto* possessable = mount->GetComponent<PossessableComponent>();
|
auto* possessable = mount->GetComponent<PossessableComponent>();
|
||||||
if (possessable) {
|
if (possessable) {
|
||||||
if (possessable->GetIsItemSpawned()) {
|
if (possessable->GetIsItemSpawned()) {
|
||||||
GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_OwningEntity->GetSystemAddress());
|
GameMessages::SendMarkInventoryItemAsActive(m_ParentEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_ParentEntity->GetSystemAddress());
|
||||||
}
|
}
|
||||||
possessable->Dismount();
|
possessable->Dismount();
|
||||||
}
|
}
|
||||||
@ -42,23 +42,23 @@ void PossessorComponent::Mount(Entity* mount) {
|
|||||||
// Don't do anything if we are busy dismounting
|
// Don't do anything if we are busy dismounting
|
||||||
if (GetIsDismounting() || !mount) return;
|
if (GetIsDismounting() || !mount) return;
|
||||||
|
|
||||||
GameMessages::SendSetMountInventoryID(m_OwningEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendSetMountInventoryID(m_ParentEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||||
if (possessableComponent) {
|
if (possessableComponent) {
|
||||||
possessableComponent->SetPossessor(m_OwningEntity->GetObjectID());
|
possessableComponent->SetPossessor(m_ParentEntity->GetObjectID());
|
||||||
SetPossessable(mount->GetObjectID());
|
SetPossessable(mount->GetObjectID());
|
||||||
SetPossessableType(possessableComponent->GetPossessionType());
|
SetPossessableType(possessableComponent->GetPossessionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent) characterComponent->SetIsRacing(true);
|
if (characterComponent) characterComponent->SetIsRacing(true);
|
||||||
|
|
||||||
// GM's to send
|
// GM's to send
|
||||||
GameMessages::SendSetJetPackMode(m_OwningEntity, false);
|
GameMessages::SendSetJetPackMode(m_ParentEntity, false);
|
||||||
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress());
|
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_ParentEntity->GetSystemAddress());
|
||||||
GameMessages::SendSetStunned(m_OwningEntity->GetObjectID(), eStateChangeType::PUSH, m_OwningEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
GameMessages::SendSetStunned(m_ParentEntity->GetObjectID(), eStateChangeType::PUSH, m_ParentEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
EntityManager::Instance()->SerializeEntity(mount);
|
EntityManager::Instance()->SerializeEntity(mount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,12 +73,12 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
|
|||||||
possessableComponent->SetPossessor(LWOOBJID_EMPTY);
|
possessableComponent->SetPossessor(LWOOBJID_EMPTY);
|
||||||
if (forceDismount) possessableComponent->ForceDepossess();
|
if (forceDismount) possessableComponent->ForceDepossess();
|
||||||
}
|
}
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
EntityManager::Instance()->SerializeEntity(mount);
|
EntityManager::Instance()->SerializeEntity(mount);
|
||||||
|
|
||||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent) characterComponent->SetIsRacing(false);
|
if (characterComponent) characterComponent->SetIsRacing(false);
|
||||||
}
|
}
|
||||||
// Make sure we don't have wacky controls
|
// Make sure we don't have wacky controls
|
||||||
GameMessages::SendSetPlayerControlScheme(m_OwningEntity, eControlScheme::SCHEME_A);
|
GameMessages::SendSetPlayerControlScheme(m_ParentEntity, eControlScheme::SCHEME_A);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "eObjectBits.h"
|
#include "eObjectBits.h"
|
||||||
#include "eGameMasterLevel.h"
|
#include "eGameMasterLevel.h"
|
||||||
|
|
||||||
PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entity* parent) : Component(parent) {
|
PropertyEntranceComponent::PropertyEntranceComponent(Entity* parent, uint32_t componentID) : Component(parent) {
|
||||||
this->propertyQueries = {};
|
this->propertyQueries = {};
|
||||||
|
|
||||||
auto table = CDClientManager::Instance().GetTable<CDPropertyEntranceComponentTable>();
|
auto table = CDClientManager::Instance().GetTable<CDPropertyEntranceComponentTable>();
|
||||||
@ -32,7 +32,7 @@ void PropertyEntranceComponent::OnUse(Entity* entity) {
|
|||||||
auto* rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity);
|
auto* rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity);
|
||||||
if (!rocket) return;
|
if (!rocket) return;
|
||||||
|
|
||||||
GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), entity->GetSystemAddress());
|
GameMessages::SendPropertyEntranceBegin(m_ParentEntity->GetObjectID(), entity->GetSystemAddress());
|
||||||
|
|
||||||
AMFArrayValue args;
|
AMFArrayValue args;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index,
|
|||||||
cloneId = query[index].CloneId;
|
cloneId = query[index].CloneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* launcher = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>();
|
auto* launcher = m_ParentEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||||
|
|
||||||
if (launcher == nullptr) {
|
if (launcher == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -330,5 +330,5 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
delete propertiesLeft;
|
delete propertiesLeft;
|
||||||
propertiesLeft = nullptr;
|
propertiesLeft = nullptr;
|
||||||
|
|
||||||
GameMessages::SendPropertySelectQuery(m_OwningEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr);
|
GameMessages::SendPropertySelectQuery(m_ParentEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
class PropertyEntranceComponent : public Component {
|
class PropertyEntranceComponent : public Component {
|
||||||
public:
|
public:
|
||||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
|
||||||
explicit PropertyEntranceComponent(uint32_t componentID, Entity* parent);
|
explicit PropertyEntranceComponent(Entity* parent, uint32_t componentID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an OnUse request for some other entity, rendering the property browse menu
|
* Handles an OnUse request for some other entity, rendering the property browse menu
|
||||||
|
@ -206,7 +206,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
|||||||
std::string name = zone->GetZoneName();
|
std::string name = zone->GetZoneName();
|
||||||
std::string description = "";
|
std::string description = "";
|
||||||
|
|
||||||
auto prop_path = zone->GetPath(m_OwningEntity->GetVarAsString(u"propertyName"));
|
auto prop_path = zone->GetPath(m_ParentEntity->GetVarAsString(u"propertyName"));
|
||||||
|
|
||||||
if (prop_path){
|
if (prop_path){
|
||||||
if (!prop_path->property.displayName.empty()) name = prop_path->property.displayName;
|
if (!prop_path->property.displayName.empty()) name = prop_path->property.displayName;
|
||||||
@ -395,7 +395,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
|||||||
|
|
||||||
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
||||||
|
|
||||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_OwningEntity->GetObjectID(), 14, originalRotation);
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_ParentEntity->GetObjectID(), 14, originalRotation);
|
||||||
|
|
||||||
GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId);
|
GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId);
|
||||||
|
|
||||||
@ -783,7 +783,7 @@ PropertyManagementComponent* PropertyManagementComponent::Instance() {
|
|||||||
|
|
||||||
void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author) {
|
void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author) {
|
||||||
if (author == LWOOBJID_EMPTY) {
|
if (author == LWOOBJID_EMPTY) {
|
||||||
author = m_OwningEntity->GetObjectID();
|
author = m_ParentEntity->GetObjectID();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||||
@ -861,7 +861,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
|
|||||||
|
|
||||||
void PropertyManagementComponent::OnUse(Entity* originator) {
|
void PropertyManagementComponent::OnUse(Entity* originator) {
|
||||||
OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS);
|
OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
GameMessages::SendOpenPropertyManagment(m_OwningEntity->GetObjectID(), originator->GetSystemAddress());
|
GameMessages::SendOpenPropertyManagment(m_ParentEntity->GetObjectID(), originator->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyManagementComponent::SetOwnerId(const LWOOBJID value) {
|
void PropertyManagementComponent::SetOwnerId(const LWOOBJID value) {
|
||||||
|
@ -21,7 +21,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) {
|
|||||||
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
|
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
|
||||||
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!");
|
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!");
|
||||||
|
|
||||||
GameMessages::SendOpenPropertyVendor(m_OwningEntity->GetObjectID(), originator->GetSystemAddress());
|
GameMessages::SendOpenPropertyVendor(m_ParentEntity->GetObjectID(), originator->GetSystemAddress());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) {
|
|||||||
void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) {
|
void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) {
|
||||||
if (PropertyManagementComponent::Instance() == nullptr) return;
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
||||||
|
|
||||||
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_OwningEntity->GetObjectID());
|
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_ParentEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
|
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
|
||||||
@ -41,11 +41,11 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendPropertyRentalResponse(m_OwningEntity->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
GameMessages::SendPropertyRentalResponse(m_ParentEntity->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
||||||
|
|
||||||
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
||||||
|
|
||||||
controller->OnFireEventServerSide(m_OwningEntity, "propertyRented");
|
controller->OnFireEventServerSide(m_ParentEntity, "propertyRented");
|
||||||
|
|
||||||
PropertyManagementComponent::Instance()->SetOwner(originator);
|
PropertyManagementComponent::Instance()->SetOwner(originator);
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ ProximityMonitorComponent::~ProximityMonitorComponent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::string& name) {
|
void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::string& name) {
|
||||||
dpEntity* en = new dpEntity(m_OwningEntity->GetObjectID(), proxRadius);
|
dpEntity* en = new dpEntity(m_ParentEntity->GetObjectID(), proxRadius);
|
||||||
en->SetPosition(m_OwningEntity->GetPosition());
|
en->SetPosition(m_ParentEntity->GetPosition());
|
||||||
|
|
||||||
dpWorld::Instance().AddEntity(en);
|
dpWorld::Instance().AddEntity(en);
|
||||||
m_ProximitiesData.insert(std::make_pair(name, en));
|
m_ProximitiesData.insert(std::make_pair(name, en));
|
||||||
@ -34,7 +34,7 @@ void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::
|
|||||||
|
|
||||||
void ProximityMonitorComponent::SetProximityRadius(dpEntity* entity, const std::string& name) {
|
void ProximityMonitorComponent::SetProximityRadius(dpEntity* entity, const std::string& name) {
|
||||||
dpWorld::Instance().AddEntity(entity);
|
dpWorld::Instance().AddEntity(entity);
|
||||||
entity->SetPosition(m_OwningEntity->GetPosition());
|
entity->SetPosition(m_ParentEntity->GetPosition());
|
||||||
m_ProximitiesData.insert(std::make_pair(name, entity));
|
m_ProximitiesData.insert(std::make_pair(name, entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,12 +66,12 @@ void ProximityMonitorComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
//Process enter events
|
//Process enter events
|
||||||
for (auto* en : prox.second->GetNewObjects()) {
|
for (auto* en : prox.second->GetNewObjects()) {
|
||||||
m_OwningEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER");
|
m_ParentEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process exit events
|
//Process exit events
|
||||||
for (auto* en : prox.second->GetRemovedObjects()) {
|
for (auto* en : prox.second->GetRemovedObjects()) {
|
||||||
m_OwningEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE");
|
m_ParentEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,13 +132,13 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
|||||||
info.lot = 8092;
|
info.lot = 8092;
|
||||||
info.pos = startPosition;
|
info.pos = startPosition;
|
||||||
info.rot = startRotation;
|
info.rot = startRotation;
|
||||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
auto* carEntity =
|
auto* carEntity =
|
||||||
EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
|
EntityManager::Instance()->CreateEntity(info, nullptr, m_ParentEntity);
|
||||||
|
|
||||||
// Make the vehicle a child of the racing controller.
|
// Make the vehicle a child of the racing controller.
|
||||||
m_OwningEntity->AddChild(carEntity);
|
m_ParentEntity->AddChild(carEntity);
|
||||||
|
|
||||||
auto* destroyableComponent = carEntity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = carEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
@ -205,17 +205,17 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
|||||||
|
|
||||||
EntityManager::Instance()->ConstructEntity(carEntity);
|
EntityManager::Instance()->ConstructEntity(carEntity);
|
||||||
EntityManager::Instance()->SerializeEntity(player);
|
EntityManager::Instance()->SerializeEntity(player);
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
GameMessages::SendRacingSetPlayerResetInfo(
|
GameMessages::SendRacingSetPlayerResetInfo(
|
||||||
m_OwningEntity->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1,
|
m_ParentEntity->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
const auto playerID = player->GetObjectID();
|
const auto playerID = player->GetObjectID();
|
||||||
|
|
||||||
// Reset the player to the start position during downtime, in case something
|
// Reset the player to the start position during downtime, in case something
|
||||||
// went wrong.
|
// went wrong.
|
||||||
m_OwningEntity->AddCallbackTimer(1, [this, playerID]() {
|
m_ParentEntity->AddCallbackTimer(1, [this, playerID]() {
|
||||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||||
|
|
||||||
if (player == nullptr) {
|
if (player == nullptr) {
|
||||||
@ -223,14 +223,14 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendRacingResetPlayerToLastReset(
|
GameMessages::SendRacingResetPlayerToLastReset(
|
||||||
m_OwningEntity->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS);
|
m_ParentEntity->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
});
|
});
|
||||||
|
|
||||||
GameMessages::SendSetJetPackMode(player, false);
|
GameMessages::SendSetJetPackMode(player, false);
|
||||||
|
|
||||||
// Set the vehicle's state.
|
// Set the vehicle's state.
|
||||||
GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(),
|
GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(),
|
||||||
m_OwningEntity->GetObjectID(),
|
m_ParentEntity->GetObjectID(),
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
GameMessages::SendVehicleSetWheelLockState(carEntity->GetObjectID(), false,
|
GameMessages::SendVehicleSetWheelLockState(carEntity->GetObjectID(), false,
|
||||||
@ -253,7 +253,7 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
|||||||
if (racingPlayer.playerID != player->GetObjectID()) {
|
if (racingPlayer.playerID != player->GetObjectID()) {
|
||||||
if (racingPlayer.playerLoaded) {
|
if (racingPlayer.playerLoaded) {
|
||||||
GameMessages::SendRacingPlayerLoaded(
|
GameMessages::SendRacingPlayerLoaded(
|
||||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||||
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,11 +263,11 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
|||||||
racingPlayer.playerLoaded = true;
|
racingPlayer.playerLoaded = true;
|
||||||
|
|
||||||
GameMessages::SendRacingPlayerLoaded(
|
GameMessages::SendRacingPlayerLoaded(
|
||||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||||
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RacingControlComponent::OnRequestDie(Entity* player) {
|
void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||||
@ -300,15 +300,15 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
|||||||
|
|
||||||
// Respawn the player in 2 seconds, as was done in live. Not sure if this value is in a setting somewhere else...
|
// Respawn the player in 2 seconds, as was done in live. Not sure if this value is in a setting somewhere else...
|
||||||
vehicle->AddCallbackTimer(2.0f, [=]() {
|
vehicle->AddCallbackTimer(2.0f, [=]() {
|
||||||
if (!vehicle || !this->m_OwningEntity) return;
|
if (!vehicle || !this->m_ParentEntity) return;
|
||||||
GameMessages::SendRacingResetPlayerToLastReset(
|
GameMessages::SendRacingResetPlayerToLastReset(
|
||||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
GameMessages::SendVehicleStopBoost(vehicle, player->GetSystemAddress(), true);
|
GameMessages::SendVehicleStopBoost(vehicle, player->GetSystemAddress(), true);
|
||||||
|
|
||||||
GameMessages::SendRacingSetPlayerResetInfo(
|
GameMessages::SendRacingSetPlayerResetInfo(
|
||||||
m_OwningEntity->GetObjectID(), racingPlayer.lap,
|
m_ParentEntity->GetObjectID(), racingPlayer.lap,
|
||||||
racingPlayer.respawnIndex, player->GetObjectID(),
|
racingPlayer.respawnIndex, player->GetObjectID(),
|
||||||
racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1,
|
racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
@ -326,12 +326,12 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GameMessages::SendRacingSetPlayerResetInfo(
|
GameMessages::SendRacingSetPlayerResetInfo(
|
||||||
m_OwningEntity->GetObjectID(), racingPlayer.lap,
|
m_ParentEntity->GetObjectID(), racingPlayer.lap,
|
||||||
racingPlayer.respawnIndex, player->GetObjectID(),
|
racingPlayer.respawnIndex, player->GetObjectID(),
|
||||||
racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1,
|
racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
GameMessages::SendRacingResetPlayerToLastReset(
|
GameMessages::SendRacingResetPlayerToLastReset(
|
||||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,11 +375,11 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
|
|||||||
// Calculate the score, different loot depending on player count
|
// Calculate the score, different loot depending on player count
|
||||||
const auto score = m_LoadedPlayers * 10 + data->finished;
|
const auto score = m_LoadedPlayers * 10 + data->finished;
|
||||||
|
|
||||||
LootGenerator::Instance().GiveActivityLoot(player, m_OwningEntity, m_ActivityID, score);
|
LootGenerator::Instance().GiveActivityLoot(player, m_ParentEntity, m_ActivityID, score);
|
||||||
|
|
||||||
// Giving rewards
|
// Giving rewards
|
||||||
GameMessages::SendNotifyRacingClient(
|
GameMessages::SendNotifyRacingClient(
|
||||||
m_OwningEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"",
|
m_ParentEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"",
|
||||||
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
@ -409,7 +409,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
|
|||||||
|
|
||||||
// Exiting race
|
// Exiting race
|
||||||
GameMessages::SendNotifyRacingClient(
|
GameMessages::SendNotifyRacingClient(
|
||||||
m_OwningEntity->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
|
m_ParentEntity->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
|
||||||
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||||
@ -617,7 +617,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
|||||||
// Setup for racing
|
// Setup for racing
|
||||||
if (m_StartTimer == 0) {
|
if (m_StartTimer == 0) {
|
||||||
GameMessages::SendNotifyRacingClient(
|
GameMessages::SendNotifyRacingClient(
|
||||||
m_OwningEntity->GetObjectID(), 1, 0, LWOOBJID_EMPTY, u"",
|
m_ParentEntity->GetObjectID(), 1, 0, LWOOBJID_EMPTY, u"",
|
||||||
LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS);
|
LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
for (const auto& player : m_RacingPlayers) {
|
for (const auto& player : m_RacingPlayers) {
|
||||||
@ -700,14 +700,14 @@ void RacingControlComponent::Update(float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the race
|
// Start the race
|
||||||
GameMessages::SendActivityStart(m_OwningEntity->GetObjectID(),
|
GameMessages::SendActivityStart(m_ParentEntity->GetObjectID(),
|
||||||
UNASSIGNED_SYSTEM_ADDRESS);
|
UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
m_Started = true;
|
m_Started = true;
|
||||||
|
|
||||||
Game::logger->Log("RacingControlComponent", "Starting race");
|
Game::logger->Log("RacingControlComponent", "Starting race");
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
m_StartTime = std::time(nullptr);
|
m_StartTime = std::time(nullptr);
|
||||||
}
|
}
|
||||||
@ -738,7 +738,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
|||||||
// If the player is this far below the map, safe to assume they should
|
// If the player is this far below the map, safe to assume they should
|
||||||
// be smashed by death plane
|
// be smashed by death plane
|
||||||
if (vehiclePosition.y < -500) {
|
if (vehiclePosition.y < -500) {
|
||||||
GameMessages::SendDie(vehicle, m_OwningEntity->GetObjectID(),
|
GameMessages::SendDie(vehicle, m_ParentEntity->GetObjectID(),
|
||||||
LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0,
|
LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0,
|
||||||
true, false, 0);
|
true, false, 0);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t component
|
|||||||
RailActivatorComponent::~RailActivatorComponent() = default;
|
RailActivatorComponent::~RailActivatorComponent() = default;
|
||||||
|
|
||||||
void RailActivatorComponent::OnUse(Entity* originator) {
|
void RailActivatorComponent::OnUse(Entity* originator) {
|
||||||
auto* rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>();
|
auto* rebuildComponent = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||||
if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED)
|
if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
|||||||
|
|
||||||
const auto originatorID = originator->GetObjectID();
|
const auto originatorID = originator->GetObjectID();
|
||||||
|
|
||||||
m_OwningEntity->AddCallbackTimer(animationLength, [originatorID, this]() {
|
m_ParentEntity->AddCallbackTimer(animationLength, [originatorID, this]() {
|
||||||
auto* originator = EntityManager::Instance()->GetEntity(originatorID);
|
auto* originator = EntityManager::Instance()->GetEntity(originatorID);
|
||||||
|
|
||||||
if (originator == nullptr) {
|
if (originator == nullptr) {
|
||||||
@ -78,7 +78,7 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
|||||||
m_loopSound, m_StopSound, originator->GetSystemAddress(),
|
m_loopSound, m_StopSound, originator->GetSystemAddress(),
|
||||||
m_PathStart, m_PathDirection, m_DamageImmune, m_NoAggro, m_NotifyArrived,
|
m_PathStart, m_PathDirection, m_DamageImmune, m_NoAggro, m_NotifyArrived,
|
||||||
m_ShowNameBillboard, m_CameraLocked, m_CollisionEnabled, m_UseDB, m_ComponentID,
|
m_ShowNameBillboard, m_CameraLocked, m_CollisionEnabled, m_UseDB, m_ComponentID,
|
||||||
m_OwningEntity->GetObjectID());
|
m_ParentEntity->GetObjectID());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
|
|||||||
|
|
||||||
GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart,
|
GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart,
|
||||||
originator->GetSystemAddress(), m_ComponentID,
|
originator->GetSystemAddress(), m_ComponentID,
|
||||||
m_OwningEntity->GetObjectID());
|
m_ParentEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) {
|
|||||||
true, true, true, true, true, true, true
|
true, true, true, true, true, true, true
|
||||||
);
|
);
|
||||||
|
|
||||||
auto* rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>();
|
auto* rebuildComponent = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||||
|
|
||||||
if (rebuildComponent != nullptr) {
|
if (rebuildComponent != nullptr) {
|
||||||
// Set back reset time
|
// Set back reset time
|
||||||
|
@ -33,14 +33,14 @@ RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) {
|
|||||||
|
|
||||||
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
|
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
|
||||||
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
|
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
|
||||||
auto positionAsVector = GeneralUtils::SplitString(m_OwningEntity->GetVarAsString(u"rebuild_activators"), 0x1F);
|
auto positionAsVector = GeneralUtils::SplitString(m_ParentEntity->GetVarAsString(u"rebuild_activators"), 0x1F);
|
||||||
if (positionAsVector.size() == 3 &&
|
if (positionAsVector.size() == 3 &&
|
||||||
GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) &&
|
GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) &&
|
||||||
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
|
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
|
||||||
GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) {
|
GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) {
|
||||||
} else {
|
} else {
|
||||||
Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_OwningEntity->GetLOT());
|
Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_ParentEntity->GetLOT());
|
||||||
m_ActivatorPosition = m_OwningEntity->GetPosition();
|
m_ActivatorPosition = m_ParentEntity->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpawnActivator();
|
SpawnActivator();
|
||||||
@ -58,7 +58,7 @@ RebuildComponent::~RebuildComponent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
if (!m_OwningEntity->GetComponent<DestroyableComponent>()) {
|
if (!m_ParentEntity->GetComponent<DestroyableComponent>()) {
|
||||||
if (bIsInitialUpdate) {
|
if (bIsInitialUpdate) {
|
||||||
outBitStream->Write(false);
|
outBitStream->Write(false);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ void RebuildComponent::Update(float deltaTime) {
|
|||||||
else {
|
else {
|
||||||
m_SoftTimer = 5.0f;
|
m_SoftTimer = 5.0f;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
switch (m_State) {
|
switch (m_State) {
|
||||||
@ -128,7 +128,7 @@ void RebuildComponent::Update(float deltaTime) {
|
|||||||
SpawnActivator();
|
SpawnActivator();
|
||||||
m_TimeBeforeDrain = 0;
|
m_TimeBeforeDrain = 0;
|
||||||
|
|
||||||
auto* spawner = m_OwningEntity->GetSpawner();
|
auto* spawner = m_ParentEntity->GetSpawner();
|
||||||
const bool isSmashGroup = spawner != nullptr ? spawner->GetIsSpawnSmashGroup() : false;
|
const bool isSmashGroup = spawner != nullptr ? spawner->GetIsSpawnSmashGroup() : false;
|
||||||
|
|
||||||
if (isSmashGroup) {
|
if (isSmashGroup) {
|
||||||
@ -139,13 +139,13 @@ void RebuildComponent::Update(float deltaTime) {
|
|||||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||||
m_ShowResetEffect = true;
|
m_ShowResetEffect = true;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||||
m_Builder = LWOOBJID_EMPTY;
|
m_Builder = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
GameMessages::SendDieNoImplCode(m_ParentEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||||
|
|
||||||
ResetRebuild(false);
|
ResetRebuild(false);
|
||||||
}
|
}
|
||||||
@ -163,13 +163,13 @@ void RebuildComponent::Update(float deltaTime) {
|
|||||||
if (!m_ShowResetEffect) {
|
if (!m_ShowResetEffect) {
|
||||||
m_ShowResetEffect = true;
|
m_ShowResetEffect = true;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Timer >= m_ResetTime) {
|
if (m_Timer >= m_ResetTime) {
|
||||||
|
|
||||||
GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
GameMessages::SendDieNoImplCode(m_ParentEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||||
|
|
||||||
ResetRebuild(false);
|
ResetRebuild(false);
|
||||||
}
|
}
|
||||||
@ -225,13 +225,13 @@ void RebuildComponent::Update(float deltaTime) {
|
|||||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||||
m_ShowResetEffect = true;
|
m_ShowResetEffect = true;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||||
m_Builder = LWOOBJID_EMPTY;
|
m_Builder = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
GameMessages::SendDieNoImplCode(m_ParentEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||||
|
|
||||||
ResetRebuild(false);
|
ResetRebuild(false);
|
||||||
}
|
}
|
||||||
@ -260,16 +260,16 @@ void RebuildComponent::SpawnActivator() {
|
|||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
|
|
||||||
info.lot = 6604;
|
info.lot = 6604;
|
||||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||||
info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_OwningEntity->GetPosition() : m_ActivatorPosition;
|
info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_ParentEntity->GetPosition() : m_ActivatorPosition;
|
||||||
|
|
||||||
m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
|
m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_ParentEntity);
|
||||||
if (m_Activator) {
|
if (m_Activator) {
|
||||||
m_ActivatorId = m_Activator->GetObjectID();
|
m_ActivatorId = m_Activator->GetObjectID();
|
||||||
EntityManager::Instance()->ConstructEntity(m_Activator);
|
EntityManager::Instance()->ConstructEntity(m_Activator);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,25 +405,25 @@ void RebuildComponent::StartRebuild(Entity* user) {
|
|||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(user);
|
EntityManager::Instance()->SerializeEntity(user);
|
||||||
|
|
||||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::BUILDING, user->GetObjectID());
|
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::BUILDING, user->GetObjectID());
|
||||||
GameMessages::SendEnableRebuild(m_OwningEntity, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
GameMessages::SendEnableRebuild(m_ParentEntity, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||||
|
|
||||||
m_State = eRebuildState::BUILDING;
|
m_State = eRebuildState::BUILDING;
|
||||||
m_StateDirty = true;
|
m_StateDirty = true;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
auto* movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>();
|
auto* movingPlatform = m_ParentEntity->GetComponent<MovingPlatformComponent>();
|
||||||
if (movingPlatform != nullptr) {
|
if (movingPlatform != nullptr) {
|
||||||
movingPlatform->OnRebuildInitilized();
|
movingPlatform->OnRebuildInitilized();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnRebuildStart(m_OwningEntity, user);
|
script->OnRebuildStart(m_ParentEntity, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity))
|
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity))
|
||||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||||
for (const auto& cb : m_RebuildStateCallbacks)
|
for (const auto& cb : m_RebuildStateCallbacks)
|
||||||
cb(m_State);
|
cb(m_State);
|
||||||
}
|
}
|
||||||
@ -445,10 +445,10 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(user);
|
EntityManager::Instance()->SerializeEntity(user);
|
||||||
|
|
||||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::COMPLETED, user->GetObjectID());
|
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::COMPLETED, user->GetObjectID());
|
||||||
GameMessages::SendPlayFXEffect(m_OwningEntity, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
GameMessages::SendPlayFXEffect(m_ParentEntity, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||||
GameMessages::SendEnableRebuild(m_OwningEntity, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
GameMessages::SendEnableRebuild(m_ParentEntity, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
|
|
||||||
m_State = eRebuildState::COMPLETED;
|
m_State = eRebuildState::COMPLETED;
|
||||||
@ -456,7 +456,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
m_Timer = 0.0f;
|
m_Timer = 0.0f;
|
||||||
m_DrainedImagination = 0;
|
m_DrainedImagination = 0;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
// Removes extra item requirements, isn't live accurate.
|
// Removes extra item requirements, isn't live accurate.
|
||||||
// In live, all items were removed at the start of the quickbuild, then returned if it was cancelled.
|
// In live, all items were removed at the start of the quickbuild, then returned if it was cancelled.
|
||||||
@ -468,7 +468,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
DespawnActivator();
|
DespawnActivator();
|
||||||
|
|
||||||
// Set owner override so that entities smashed by this quickbuild will result in the builder getting rewards.
|
// Set owner override so that entities smashed by this quickbuild will result in the builder getting rewards.
|
||||||
m_OwningEntity->SetOwnerOverride(user->GetObjectID());
|
m_ParentEntity->SetOwnerOverride(user->GetObjectID());
|
||||||
|
|
||||||
auto* builder = GetBuilder();
|
auto* builder = GetBuilder();
|
||||||
|
|
||||||
@ -486,13 +486,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
auto* missionComponent = builder->GetComponent<MissionComponent>();
|
auto* missionComponent = builder->GetComponent<MissionComponent>();
|
||||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
|
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
|
||||||
}
|
}
|
||||||
LootGenerator::Instance().DropActivityLoot(builder, m_OwningEntity, m_ActivityId, 1);
|
LootGenerator::Instance().DropActivityLoot(builder, m_ParentEntity, m_ActivityId, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify scripts
|
// Notify scripts
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnRebuildComplete(m_OwningEntity, user);
|
script->OnRebuildComplete(m_ParentEntity, user);
|
||||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify subscribers
|
// Notify subscribers
|
||||||
@ -501,9 +501,9 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
for (const auto& callback : m_RebuildCompleteCallbacks)
|
for (const auto& callback : m_RebuildCompleteCallbacks)
|
||||||
callback(user);
|
callback(user);
|
||||||
|
|
||||||
m_OwningEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user);
|
m_ParentEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user);
|
||||||
|
|
||||||
auto* movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>();
|
auto* movingPlatform = m_ParentEntity->GetComponent<MovingPlatformComponent>();
|
||||||
if (movingPlatform != nullptr) {
|
if (movingPlatform != nullptr) {
|
||||||
movingPlatform->OnCompleteRebuild();
|
movingPlatform->OnCompleteRebuild();
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
auto* character = user->GetCharacter();
|
auto* character = user->GetCharacter();
|
||||||
|
|
||||||
if (character != nullptr) {
|
if (character != nullptr) {
|
||||||
const auto flagNumber = m_OwningEntity->GetVar<int32_t>(u"quickbuild_single_build_player_flag");
|
const auto flagNumber = m_ParentEntity->GetVar<int32_t>(u"quickbuild_single_build_player_flag");
|
||||||
|
|
||||||
if (flagNumber != 0) {
|
if (flagNumber != 0) {
|
||||||
character->SetPlayerFlag(flagNumber, true);
|
character->SetPlayerFlag(flagNumber, true);
|
||||||
@ -525,14 +525,14 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
|||||||
Entity* builder = GetBuilder();
|
Entity* builder = GetBuilder();
|
||||||
|
|
||||||
if (m_State == eRebuildState::BUILDING && builder) {
|
if (m_State == eRebuildState::BUILDING && builder) {
|
||||||
GameMessages::SendEnableRebuild(m_OwningEntity, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
GameMessages::SendEnableRebuild(m_ParentEntity, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
RenderComponent::PlayAnimation(builder, u"rebuild-fail");
|
RenderComponent::PlayAnimation(builder, u"rebuild-fail");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY);
|
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY);
|
||||||
|
|
||||||
m_State = eRebuildState::RESETTING;
|
m_State = eRebuildState::RESETTING;
|
||||||
m_StateDirty = true;
|
m_StateDirty = true;
|
||||||
@ -541,15 +541,15 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
|||||||
m_ShowResetEffect = false;
|
m_ShowResetEffect = false;
|
||||||
m_DrainedImagination = 0;
|
m_DrainedImagination = 0;
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity))
|
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity))
|
||||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||||
for (const auto& cb : m_RebuildStateCallbacks)
|
for (const auto& cb : m_RebuildStateCallbacks)
|
||||||
cb(m_State);
|
cb(m_State);
|
||||||
|
|
||||||
m_OwningEntity->ScheduleKillAfterUpdate();
|
m_ParentEntity->ScheduleKillAfterUpdate();
|
||||||
|
|
||||||
if (m_Activator) {
|
if (m_Activator) {
|
||||||
m_Activator->ScheduleKillAfterUpdate();
|
m_Activator->ScheduleKillAfterUpdate();
|
||||||
@ -564,24 +564,24 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR
|
|||||||
const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY;
|
const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY;
|
||||||
|
|
||||||
// Notify the client that a state has changed
|
// Notify the client that a state has changed
|
||||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::INCOMPLETE, entityID);
|
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::INCOMPLETE, entityID);
|
||||||
GameMessages::SendEnableRebuild(m_OwningEntity, false, true, false, failReason, m_Timer, entityID);
|
GameMessages::SendEnableRebuild(m_ParentEntity, false, true, false, failReason, m_Timer, entityID);
|
||||||
|
|
||||||
// Now terminate any interaction with the rebuild
|
// Now terminate any interaction with the rebuild
|
||||||
GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||||
GameMessages::SendTerminateInteraction(m_OwningEntity->GetObjectID(), eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
GameMessages::SendTerminateInteraction(m_ParentEntity->GetObjectID(), eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
// Now update the component itself
|
// Now update the component itself
|
||||||
m_State = eRebuildState::INCOMPLETE;
|
m_State = eRebuildState::INCOMPLETE;
|
||||||
m_StateDirty = true;
|
m_StateDirty = true;
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity))
|
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity))
|
||||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||||
for (const auto& cb : m_RebuildStateCallbacks)
|
for (const auto& cb : m_RebuildStateCallbacks)
|
||||||
cb(m_State);
|
cb(m_State);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
|
@ -141,7 +141,7 @@ void RenderComponent::Update(const float deltaTime) {
|
|||||||
void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& effectType, const std::string& name, const LWOOBJID secondary, const float priority, const float scale, const bool serialize) {
|
void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& effectType, const std::string& name, const LWOOBJID secondary, const float priority, const float scale, const bool serialize) {
|
||||||
RemoveEffect(name);
|
RemoveEffect(name);
|
||||||
|
|
||||||
GameMessages::SendPlayFXEffect(m_OwningEntity, effectId, effectType, name, secondary, priority, scale, serialize);
|
GameMessages::SendPlayFXEffect(m_ParentEntity, effectId, effectType, name, secondary, priority, scale, serialize);
|
||||||
|
|
||||||
auto* effect = AddEffect(effectId, name, effectType);
|
auto* effect = AddEffect(effectId, name, effectType);
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& e
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderComponent::StopEffect(const std::string& name, const bool killImmediate) {
|
void RenderComponent::StopEffect(const std::string& name, const bool killImmediate) {
|
||||||
GameMessages::SendStopFXEffect(m_OwningEntity, killImmediate, name);
|
GameMessages::SendStopFXEffect(m_ParentEntity, killImmediate, name);
|
||||||
|
|
||||||
RemoveEffect(name);
|
RemoveEffect(name);
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
|
||||||
RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
||||||
m_Position = m_OwningEntity->GetDefaultPosition();
|
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||||
m_Rotation = m_OwningEntity->GetDefaultRotation();
|
m_Rotation = m_ParentEntity->GetDefaultRotation();
|
||||||
m_IsDirty = true;
|
m_IsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
|
|||||||
|
|
||||||
SetSelectedMapId(originator->GetObjectID(), zone);
|
SetSelectedMapId(originator->GetObjectID(), zone);
|
||||||
|
|
||||||
GameMessages::SendFireEventClientSide(m_OwningEntity->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
|
GameMessages::SendFireEventClientSide(m_ParentEntity->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
|
||||||
|
|
||||||
GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
@ -89,12 +89,12 @@ void RocketLaunchpadControlComponent::OnUse(Entity* originator) {
|
|||||||
// instead we let their OnUse handlers do their things
|
// instead we let their OnUse handlers do their things
|
||||||
// which components of an Object have their OnUse called when using them
|
// which components of an Object have their OnUse called when using them
|
||||||
// so we don't need to call it here
|
// so we don't need to call it here
|
||||||
auto* propertyEntrance = m_OwningEntity->GetComponent<PropertyEntranceComponent>();
|
auto* propertyEntrance = m_ParentEntity->GetComponent<PropertyEntranceComponent>();
|
||||||
if (propertyEntrance) {
|
if (propertyEntrance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* multiZoneEntranceComponent = m_OwningEntity->GetComponent<MultiZoneEntranceComponent>();
|
auto* multiZoneEntranceComponent = m_ParentEntity->GetComponent<MultiZoneEntranceComponent>();
|
||||||
if (multiZoneEntranceComponent) {
|
if (multiZoneEntranceComponent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyableComponent) {
|
if (destroyableComponent) {
|
||||||
// check for LMIs and set the loot LMIs
|
// check for LMIs and set the loot LMIs
|
||||||
@ -137,11 +137,11 @@ void ScriptedActivityComponent::PlayerJoin(Entity* player) {
|
|||||||
instance->AddParticipant(player);
|
instance->AddParticipant(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
||||||
if (!m_OwningEntity->HasComponent(eReplicaComponentType::QUICK_BUILD))
|
if (!m_ParentEntity->HasComponent(eReplicaComponentType::QUICK_BUILD))
|
||||||
GameMessages::SendMatchResponse(player, player->GetSystemAddress(), 0); // tell the client they joined a lobby
|
GameMessages::SendMatchResponse(player, player->GetSystemAddress(), 0); // tell the client they joined a lobby
|
||||||
LobbyPlayer* newLobbyPlayer = new LobbyPlayer();
|
LobbyPlayer* newLobbyPlayer = new LobbyPlayer();
|
||||||
newLobbyPlayer->entityID = player->GetObjectID();
|
newLobbyPlayer->entityID = player->GetObjectID();
|
||||||
@ -304,7 +304,7 @@ bool ScriptedActivityComponent::HasLobby() const {
|
|||||||
bool ScriptedActivityComponent::IsValidActivity(Entity* player) {
|
bool ScriptedActivityComponent::IsValidActivity(Entity* player) {
|
||||||
// Makes it so that scripted activities with an unimplemented map cannot be joined
|
// Makes it so that scripted activities with an unimplemented map cannot be joined
|
||||||
/*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) {
|
/*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) {
|
||||||
if (m_OwningEntity->GetLOT() == 4860) {
|
if (m_ParentEntity->GetLOT() == 4860) {
|
||||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
missionComponent->CompleteMission(229);
|
missionComponent->CompleteMission(229);
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActivityInstance* ScriptedActivityComponent::NewInstance() {
|
ActivityInstance* ScriptedActivityComponent::NewInstance() {
|
||||||
auto* instance = new ActivityInstance(m_OwningEntity, m_ActivityInfo);
|
auto* instance = new ActivityInstance(m_ParentEntity, m_ActivityInfo);
|
||||||
m_Instances.push_back(instance);
|
m_Instances.push_back(instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) {
|
|||||||
m_ActivityPlayers[i] = nullptr;
|
m_ActivityPlayers[i] = nullptr;
|
||||||
|
|
||||||
m_ActivityPlayers.erase(m_ActivityPlayers.begin() + i);
|
m_ActivityPlayers.erase(m_ActivityPlayers.begin() + i);
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID player
|
|||||||
return data;
|
return data;
|
||||||
|
|
||||||
m_ActivityPlayers.push_back(new ActivityPlayer{ playerID, {} });
|
m_ActivityPlayers.push_back(new ActivityPlayer{ playerID, {} });
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
|
|
||||||
return GetActivityPlayerData(playerID);
|
return GetActivityPlayerData(playerID);
|
||||||
}
|
}
|
||||||
@ -480,7 +480,7 @@ void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t ind
|
|||||||
data->values[std::min(index, (uint32_t)9)] = value;
|
data->values[std::min(index, (uint32_t)9)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptedActivityComponent::PlayerRemove(LWOOBJID playerID) {
|
void ScriptedActivityComponent::PlayerRemove(LWOOBJID playerID) {
|
||||||
@ -576,7 +576,7 @@ void ActivityInstance::RewardParticipant(Entity* participant) {
|
|||||||
maxCoins = currencyTable[0].maxvalue;
|
maxCoins = currencyTable[0].maxvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LootGenerator::Instance().DropLoot(participant, m_OwningEntity, activityRewards[0].LootMatrixIndex, minCoins, maxCoins);
|
LootGenerator::Instance().DropLoot(participant, m_ParentEntity, activityRewards[0].LootMatrixIndex, minCoins, maxCoins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
class ActivityInstance {
|
class ActivityInstance {
|
||||||
public:
|
public:
|
||||||
ActivityInstance(Entity* parent, CDActivities activityInfo) { m_OwningEntity = parent; m_ActivityInfo = activityInfo; };
|
ActivityInstance(Entity* parent, CDActivities activityInfo) { m_ParentEntity = parent; m_ActivityInfo = activityInfo; };
|
||||||
//~ActivityInstance();
|
//~ActivityInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +86,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* The entity that owns this activity (the entity that has the ScriptedActivityComponent)
|
* The entity that owns this activity (the entity that has the ScriptedActivityComponent)
|
||||||
*/
|
*/
|
||||||
Entity* m_OwningEntity;
|
Entity* m_ParentEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the participants of this activity
|
* All the participants of this activity
|
||||||
|
@ -14,7 +14,7 @@ void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams
|
|||||||
void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryParams& params) {
|
void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryParams& params) {
|
||||||
m_DynamicParams = params;
|
m_DynamicParams = params;
|
||||||
m_Dirty = true;
|
m_Dirty = true;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const {
|
void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const {
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
|
||||||
SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* parent) : Component(parent) {
|
SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, uint32_t componentID) : Component(parent) {
|
||||||
m_Position = m_OwningEntity->GetDefaultPosition();
|
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||||
m_Rotation = m_OwningEntity->GetDefaultRotation();
|
m_Rotation = m_ParentEntity->GetDefaultRotation();
|
||||||
m_IsDirty = true;
|
m_IsDirty = true;
|
||||||
|
|
||||||
const auto& climbable_type = m_OwningEntity->GetVar<std::u16string>(u"climbable");
|
const auto& climbable_type = m_ParentEntity->GetVar<std::u16string>(u"climbable");
|
||||||
if (climbable_type == u"wall") {
|
if (climbable_type == u"wall") {
|
||||||
SetClimbableType(eClimbableType::CLIMBABLE_TYPE_WALL);
|
SetClimbableType(eClimbableType::CLIMBABLE_TYPE_WALL);
|
||||||
} else if (climbable_type == u"ladder") {
|
} else if (climbable_type == u"ladder") {
|
||||||
|
@ -30,7 +30,7 @@ class SimplePhysicsComponent : public Component {
|
|||||||
public:
|
public:
|
||||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
|
||||||
|
|
||||||
SimplePhysicsComponent(uint32_t componentID, Entity* parent);
|
SimplePhysicsComponent(Entity* parent, uint32_t componentID);
|
||||||
~SimplePhysicsComponent() override;
|
~SimplePhysicsComponent() override;
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
|
@ -32,9 +32,9 @@ ProjectileSyncEntry::ProjectileSyncEntry() {
|
|||||||
std::unordered_map<uint32_t, uint32_t> SkillComponent::m_skillBehaviorCache = {};
|
std::unordered_map<uint32_t, uint32_t> SkillComponent::m_skillBehaviorCache = {};
|
||||||
|
|
||||||
bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream* bitStream, const LWOOBJID target, uint32_t skillID) {
|
bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream* bitStream, const LWOOBJID target, uint32_t skillID) {
|
||||||
auto* context = new BehaviorContext(this->m_OwningEntity->GetObjectID());
|
auto* context = new BehaviorContext(this->m_ParentEntity->GetObjectID());
|
||||||
|
|
||||||
context->caster = m_OwningEntity->GetObjectID();
|
context->caster = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
context->skillID = skillID;
|
context->skillID = skillID;
|
||||||
|
|
||||||
@ -130,11 +130,11 @@ void SkillComponent::RegisterPlayerProjectile(const LWOOBJID projectileId, Behav
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkillComponent::Update(const float deltaTime) {
|
void SkillComponent::Update(const float deltaTime) {
|
||||||
if (!m_OwningEntity->HasComponent(eReplicaComponentType::BASE_COMBAT_AI) && m_OwningEntity->GetLOT() != 1) {
|
if (!m_ParentEntity->HasComponent(eReplicaComponentType::BASE_COMBAT_AI) && m_ParentEntity->GetLOT() != 1) {
|
||||||
CalculateUpdate(deltaTime);
|
CalculateUpdate(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_OwningEntity->IsPlayer()) {
|
if (m_ParentEntity->IsPlayer()) {
|
||||||
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
|
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ void SkillComponent::Reset() {
|
|||||||
|
|
||||||
void SkillComponent::Interrupt() {
|
void SkillComponent::Interrupt() {
|
||||||
// TODO: need to check immunities on the destroyable component, but they aren't implemented
|
// TODO: need to check immunities on the destroyable component, but they aren't implemented
|
||||||
auto* combat = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
auto* combat = m_ParentEntity->GetComponent<BaseCombatAIComponent>();
|
||||||
if (combat != nullptr && combat->GetStunImmune()) return;
|
if (combat != nullptr && combat->GetStunImmune()) return;
|
||||||
|
|
||||||
for (const auto& behavior : this->m_managedBehaviors) {
|
for (const auto& behavior : this->m_managedBehaviors) {
|
||||||
@ -201,7 +201,7 @@ void SkillComponent::Interrupt() {
|
|||||||
behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second);
|
behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second);
|
||||||
}
|
}
|
||||||
behavior.second->endEntries.clear();
|
behavior.second->endEntries.clear();
|
||||||
if (m_OwningEntity->IsPlayer()) continue;
|
if (m_ParentEntity->IsPlayer()) continue;
|
||||||
behavior.second->Interrupt();
|
behavior.second->Interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,9 +256,9 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
|||||||
|
|
||||||
auto* behavior = Behavior::CreateBehavior(behaviorId);
|
auto* behavior = Behavior::CreateBehavior(behaviorId);
|
||||||
|
|
||||||
auto* context = new BehaviorContext(originatorOverride != LWOOBJID_EMPTY ? originatorOverride : this->m_OwningEntity->GetObjectID(), true);
|
auto* context = new BehaviorContext(originatorOverride != LWOOBJID_EMPTY ? originatorOverride : this->m_ParentEntity->GetObjectID(), true);
|
||||||
|
|
||||||
context->caster = m_OwningEntity->GetObjectID();
|
context->caster = m_ParentEntity->GetObjectID();
|
||||||
|
|
||||||
context->skillID = skillId;
|
context->skillID = skillId;
|
||||||
|
|
||||||
@ -268,8 +268,8 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
|||||||
|
|
||||||
behavior->Calculate(context, bitStream, { target, 0 });
|
behavior->Calculate(context, bitStream, { target, 0 });
|
||||||
|
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||||
script->OnSkillCast(m_OwningEntity, skillId);
|
script->OnSkillCast(m_ParentEntity, skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context->foundTarget) {
|
if (!context->foundTarget) {
|
||||||
@ -305,7 +305,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
|||||||
RakNet::BitStream message;
|
RakNet::BitStream message;
|
||||||
|
|
||||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||||
message.Write(this->m_OwningEntity->GetObjectID());
|
message.Write(this->m_ParentEntity->GetObjectID());
|
||||||
start.Serialize(&message);
|
start.Serialize(&message);
|
||||||
|
|
||||||
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
@ -431,14 +431,14 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
|
|||||||
DoClientProjectileImpact projectileImpact;
|
DoClientProjectileImpact projectileImpact;
|
||||||
|
|
||||||
projectileImpact.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
projectileImpact.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
||||||
projectileImpact.i64OwnerID = this->m_OwningEntity->GetObjectID();
|
projectileImpact.i64OwnerID = this->m_ParentEntity->GetObjectID();
|
||||||
projectileImpact.i64OrgID = entry.id;
|
projectileImpact.i64OrgID = entry.id;
|
||||||
projectileImpact.i64TargetID = entry.branchContext.target;
|
projectileImpact.i64TargetID = entry.branchContext.target;
|
||||||
|
|
||||||
RakNet::BitStream message;
|
RakNet::BitStream message;
|
||||||
|
|
||||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||||
message.Write(this->m_OwningEntity->GetObjectID());
|
message.Write(this->m_ParentEntity->GetObjectID());
|
||||||
projectileImpact.Serialize(&message);
|
projectileImpact.Serialize(&message);
|
||||||
|
|
||||||
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
|
@ -76,7 +76,7 @@ void SoundTriggerComponent::ActivateMusicCue(const std::string& name) {
|
|||||||
-1.0f
|
-1.0f
|
||||||
});
|
});
|
||||||
dirty = true;
|
dirty = true;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +88,6 @@ void SoundTriggerComponent::DeactivateMusicCue(const std::string& name) {
|
|||||||
if (musicCue != this->musicCues.end()) {
|
if (musicCue != this->musicCues.end()) {
|
||||||
this->musicCues.erase(musicCue);
|
this->musicCues.erase(musicCue);
|
||||||
dirty = true;
|
dirty = true;
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ std::vector<SwitchComponent*> SwitchComponent::petSwitches;
|
|||||||
SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) {
|
SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) {
|
||||||
m_Active = false;
|
m_Active = false;
|
||||||
|
|
||||||
m_ResetTime = m_OwningEntity->GetVarAs<int32_t>(u"switch_reset_time");
|
m_ResetTime = m_ParentEntity->GetVarAs<int32_t>(u"switch_reset_time");
|
||||||
|
|
||||||
m_Rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
|
m_Rebuild = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchComponent::~SwitchComponent() {
|
SwitchComponent::~SwitchComponent() {
|
||||||
@ -43,10 +43,10 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
|||||||
if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return;
|
if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return;
|
||||||
}
|
}
|
||||||
m_Active = true;
|
m_Active = true;
|
||||||
if (!m_OwningEntity) return;
|
if (!m_ParentEntity) return;
|
||||||
m_OwningEntity->TriggerEvent(eTriggerEventType::ACTIVATED, entity);
|
m_ParentEntity->TriggerEvent(eTriggerEventType::ACTIVATED, entity);
|
||||||
|
|
||||||
const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name");
|
const auto grpName = m_ParentEntity->GetVarAsString(u"grp_name");
|
||||||
|
|
||||||
if (!grpName.empty()) {
|
if (!grpName.empty()) {
|
||||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||||
@ -59,11 +59,11 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
|||||||
m_Timer = m_ResetTime;
|
m_Timer = m_ResetTime;
|
||||||
|
|
||||||
if (m_PetBouncer != nullptr) {
|
if (m_PetBouncer != nullptr) {
|
||||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
||||||
RenderComponent::PlayAnimation(m_OwningEntity, u"engaged");
|
RenderComponent::PlayAnimation(m_ParentEntity, u"engaged");
|
||||||
m_PetBouncer->SetPetBouncerEnabled(true);
|
m_PetBouncer->SetPetBouncerEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -79,10 +79,10 @@ void SwitchComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
if (m_Timer <= 0.0f) {
|
if (m_Timer <= 0.0f) {
|
||||||
m_Active = false;
|
m_Active = false;
|
||||||
if (!m_OwningEntity) return;
|
if (!m_ParentEntity) return;
|
||||||
m_OwningEntity->TriggerEvent(eTriggerEventType::DEACTIVATED, m_OwningEntity);
|
m_ParentEntity->TriggerEvent(eTriggerEventType::DEACTIVATED, m_ParentEntity);
|
||||||
|
|
||||||
const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name");
|
const auto grpName = m_ParentEntity->GetVarAsString(u"grp_name");
|
||||||
|
|
||||||
if (!grpName.empty()) {
|
if (!grpName.empty()) {
|
||||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||||
@ -95,14 +95,14 @@ void SwitchComponent::Update(float deltaTime) {
|
|||||||
if (m_PetBouncer != nullptr) {
|
if (m_PetBouncer != nullptr) {
|
||||||
m_PetBouncer->SetPetBouncerEnabled(false);
|
m_PetBouncer->SetPetBouncerEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* SwitchComponent::GetParentEntity() const {
|
Entity* SwitchComponent::GetParentEntity() const {
|
||||||
return m_OwningEntity;
|
return m_ParentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
||||||
@ -110,7 +110,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_OwningEntity->GetPosition(), position);
|
float distance = Vector3::DistanceSquared(petSwitch->m_ParentEntity->GetPosition(), position);
|
||||||
|
|
||||||
if (closest == nullptr || distance < closestDistance) {
|
if (closest == nullptr || distance < closestDistance) {
|
||||||
closestDistance = distance;
|
closestDistance = distance;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
|
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
|
||||||
m_OwningEntity = parent;
|
m_ParentEntity = parent;
|
||||||
m_Trigger = nullptr;
|
m_Trigger = nullptr;
|
||||||
|
|
||||||
std::vector<std::string> tokens = GeneralUtils::SplitString(triggerInfo, ':');
|
std::vector<std::string> tokens = GeneralUtils::SplitString(triggerInfo, ':');
|
||||||
@ -116,7 +116,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity
|
|||||||
HandleCastSkill(targetEntity, command->args);
|
HandleCastSkill(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::DISPLAY_ZONE_SUMMARY:
|
case eTriggerCommandType::DISPLAY_ZONE_SUMMARY:
|
||||||
GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_OwningEntity->GetObjectID());
|
GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_ParentEntity->GetObjectID());
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_PHYSICS_VOLUME_EFFECT:
|
case eTriggerCommandType::SET_PHYSICS_VOLUME_EFFECT:
|
||||||
HandleSetPhysicsVolumeEffect(targetEntity, argArray);
|
HandleSetPhysicsVolumeEffect(targetEntity, argArray);
|
||||||
@ -164,7 +164,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity
|
|||||||
std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* command, Entity* optionalTarget) {
|
std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* command, Entity* optionalTarget) {
|
||||||
std::vector<Entity*> entities = {};
|
std::vector<Entity*> entities = {};
|
||||||
|
|
||||||
if (command->target == "self") entities.push_back(m_OwningEntity);
|
if (command->target == "self") entities.push_back(m_ParentEntity);
|
||||||
else if (command->target == "zone") { /*TODO*/ }
|
else if (command->target == "zone") { /*TODO*/ }
|
||||||
else if (command->target == "target" && optionalTarget) entities.push_back(optionalTarget);
|
else if (command->target == "target" && optionalTarget) entities.push_back(optionalTarget);
|
||||||
else if (command->target == "targetTeam" && optionalTarget) {
|
else if (command->target == "targetTeam" && optionalTarget) {
|
||||||
@ -185,14 +185,14 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
|
|||||||
|
|
||||||
void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(targetEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(targetEntity)) {
|
||||||
script->OnFireEventServerSide(targetEntity, m_OwningEntity, args, 0, 0, 0);
|
script->OnFireEventServerSide(targetEntity, m_ParentEntity, args, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
||||||
uint32_t killType;
|
uint32_t killType;
|
||||||
GeneralUtils::TryParse<uint32_t>(args, killType);
|
GeneralUtils::TryParse<uint32_t>(args, killType);
|
||||||
targetEntity->Smash(m_OwningEntity->GetObjectID(), static_cast<eKillType>(killType));
|
targetEntity->Smash(m_ParentEntity->GetObjectID(), static_cast<eKillType>(killType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
||||||
@ -237,7 +237,7 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std:
|
|||||||
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){
|
||||||
if (argArray.size() < 3) return;
|
if (argArray.size() < 3) return;
|
||||||
|
|
||||||
auto* phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>();
|
auto* phantomPhysicsComponent = m_ParentEntity->GetComponent<PhantomPhysicsComponent>();
|
||||||
if (!phantomPhysicsComponent) {
|
if (!phantomPhysicsComponent) {
|
||||||
Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
|
Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
|
||||||
return;
|
return;
|
||||||
@ -249,12 +249,12 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
|
|||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), direction);
|
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), direction);
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){
|
||||||
auto* phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>();
|
auto* phantomPhysicsComponent = m_ParentEntity->GetComponent<PhantomPhysicsComponent>();
|
||||||
if (!phantomPhysicsComponent) {
|
if (!phantomPhysicsComponent) {
|
||||||
Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!");
|
Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!");
|
||||||
return;
|
return;
|
||||||
@ -265,7 +265,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
|||||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(forceMultiplier);
|
phantomPhysicsComponent->SetDirectionalMultiplier(forceMultiplier);
|
||||||
|
|
||||||
auto triggerPos = m_OwningEntity->GetPosition();
|
auto triggerPos = m_ParentEntity->GetPosition();
|
||||||
auto targetPos = targetEntity->GetPosition();
|
auto targetPos = targetEntity->GetPosition();
|
||||||
|
|
||||||
// normalize the vectors to get the direction
|
// normalize the vectors to get the direction
|
||||||
@ -274,7 +274,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
|||||||
NiPoint3 direction = delta / length;
|
NiPoint3 direction = delta / length;
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
||||||
@ -284,11 +284,11 @@ void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::str
|
|||||||
}
|
}
|
||||||
float time = 0.0;
|
float time = 0.0;
|
||||||
GeneralUtils::TryParse<float>(argArray.at(1), time);
|
GeneralUtils::TryParse<float>(argArray.at(1), time);
|
||||||
m_OwningEntity->AddTimer(argArray.at(0), time);
|
m_ParentEntity->AddTimer(argArray.at(0), time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){
|
||||||
m_OwningEntity->CancelTimer(args);
|
m_ParentEntity->CancelTimer(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector<std::string> argArray) {
|
void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
|
@ -24,8 +24,8 @@ void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VendorComponent::OnUse(Entity* originator) {
|
void VendorComponent::OnUse(Entity* originator) {
|
||||||
GameMessages::SendVendorOpenWindow(m_OwningEntity, originator->GetSystemAddress());
|
GameMessages::SendVendorOpenWindow(m_ParentEntity, originator->GetSystemAddress());
|
||||||
GameMessages::SendVendorStatusUpdate(m_OwningEntity, originator->GetSystemAddress());
|
GameMessages::SendVendorStatusUpdate(m_ParentEntity, originator->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
float VendorComponent::GetBuyScalar() const {
|
float VendorComponent::GetBuyScalar() const {
|
||||||
@ -50,12 +50,12 @@ std::map<LOT, int>& VendorComponent::GetInventory() {
|
|||||||
|
|
||||||
bool VendorComponent::HasCraftingStation() {
|
bool VendorComponent::HasCraftingStation() {
|
||||||
// As far as we know, only Umami has a crafting station
|
// As far as we know, only Umami has a crafting station
|
||||||
return m_OwningEntity->GetLOT() == 13800;
|
return m_ParentEntity->GetLOT() == 13800;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VendorComponent::RefreshInventory(bool isCreation) {
|
void VendorComponent::RefreshInventory(bool isCreation) {
|
||||||
//Custom code for Max vanity NPC
|
//Custom code for Max vanity NPC
|
||||||
if (m_OwningEntity->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) {
|
if (m_ParentEntity->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) {
|
||||||
if (!isCreation) return;
|
if (!isCreation) return;
|
||||||
m_Inventory.insert({ 11909, 0 }); //Top hat w frog
|
m_Inventory.insert({ 11909, 0 }); //Top hat w frog
|
||||||
m_Inventory.insert({ 7785, 0 }); //Flash bulb
|
m_Inventory.insert({ 7785, 0 }); //Flash bulb
|
||||||
@ -97,7 +97,7 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Because I want a vendor to sell these cameras
|
//Because I want a vendor to sell these cameras
|
||||||
if (m_OwningEntity->GetLOT() == 13569) {
|
if (m_ParentEntity->GetLOT() == 13569) {
|
||||||
auto randomCamera = GeneralUtils::GenerateRandomNumber<int32_t>(0, 2);
|
auto randomCamera = GeneralUtils::GenerateRandomNumber<int32_t>(0, 2);
|
||||||
|
|
||||||
switch (randomCamera) {
|
switch (randomCamera) {
|
||||||
@ -116,15 +116,15 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Callback timer to refresh this inventory.
|
// Callback timer to refresh this inventory.
|
||||||
m_OwningEntity->AddCallbackTimer(m_RefreshTimeSeconds, [this]() {
|
m_ParentEntity->AddCallbackTimer(m_RefreshTimeSeconds, [this]() {
|
||||||
RefreshInventory();
|
RefreshInventory();
|
||||||
});
|
});
|
||||||
GameMessages::SendVendorStatusUpdate(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendVendorStatusUpdate(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VendorComponent::SetupConstants() {
|
void VendorComponent::SetupConstants() {
|
||||||
auto* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
auto* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||||
int componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::VENDOR);
|
int componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::VENDOR);
|
||||||
|
|
||||||
auto* vendorComponentTable = CDClientManager::Instance().GetTable<CDVendorComponentTable>();
|
auto* vendorComponentTable = CDClientManager::Instance().GetTable<CDVendorComponentTable>();
|
||||||
std::vector<CDVendorComponent> vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); });
|
std::vector<CDVendorComponent> vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); });
|
||||||
|
@ -19,7 +19,7 @@ ScriptComponent::~ScriptComponent() {
|
|||||||
|
|
||||||
void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
if (bIsInitialUpdate) {
|
if (bIsInitialUpdate) {
|
||||||
const auto& networkSettings = m_OwningEntity->GetNetworkSettings();
|
const auto& networkSettings = m_ParentEntity->GetNetworkSettings();
|
||||||
auto hasNetworkSettings = !networkSettings.empty();
|
auto hasNetworkSettings = !networkSettings.empty();
|
||||||
outBitStream->Write(hasNetworkSettings);
|
outBitStream->Write(hasNetworkSettings);
|
||||||
|
|
||||||
@ -52,5 +52,5 @@ void ScriptComponent::SetScript(const std::string& scriptName) {
|
|||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
m_Script = CppScripts::GetScript(m_OwningEntity, scriptName);
|
m_Script = CppScripts::GetScript(m_ParentEntity, scriptName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user