mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-12 19:28:21 +00:00
Merge remote-tracking branch 'upstream/main' into ServerShutdown
This commit is contained in:
commit
5d0de99390
@ -488,6 +488,7 @@ enum GAME_MSG : unsigned short {
|
||||
GAME_MSG_MATCH_UPDATE = 1310,
|
||||
GAME_MSG_MODULE_ASSEMBLY_DB_DATA_FOR_CLIENT = 1131,
|
||||
GAME_MSG_MODULE_ASSEMBLY_QUERY_DATA = 1132,
|
||||
GAME_MSG_CHANGE_IDLE_FLAGS = 1338,
|
||||
GAME_MSG_VEHICLE_ADD_PASSIVE_BOOST_ACTION = 1340,
|
||||
GAME_MSG_VEHICLE_REMOVE_PASSIVE_BOOST_ACTION = 1341,
|
||||
GAME_MSG_VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION = 1342,
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
enum class eAnimationFlags : uint32_t {
|
||||
IDLE_INVALID = 0, // made up, for internal use!!!
|
||||
IDLE_NONE = 0,
|
||||
IDLE_BASIC,
|
||||
IDLE_SWIM,
|
||||
IDLE_CARRY,
|
||||
|
@ -2,11 +2,16 @@
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "EntityManager.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
uint32_t handle;
|
||||
uint32_t handle{};
|
||||
|
||||
bitStream->Read(handle);
|
||||
if (!bitStream->Read(handle)) {
|
||||
Game::logger->Log("AirMovementBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
}
|
||||
@ -17,14 +22,20 @@ void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream*
|
||||
bitStream->Write(handle);
|
||||
}
|
||||
|
||||
void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) {
|
||||
uint32_t behaviorId;
|
||||
void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
uint32_t behaviorId{};
|
||||
|
||||
bit_stream->Read(behaviorId);
|
||||
if (!bitStream->Read(behaviorId)) {
|
||||
Game::logger->Log("AirMovementBehavior", "Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
LWOOBJID target;
|
||||
LWOOBJID target{};
|
||||
|
||||
bit_stream->Read(target);
|
||||
if (!bitStream->Read(target)) {
|
||||
Game::logger->Log("AirMovementBehavior", "Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
auto* behavior = CreateBehavior(behaviorId);
|
||||
|
||||
@ -32,7 +43,7 @@ void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bit_
|
||||
branch.target = target;
|
||||
}
|
||||
|
||||
behavior->Handle(context, bit_stream, branch);
|
||||
behavior->Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void AirMovementBehavior::Load() {
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Sync(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
};
|
||||
|
@ -9,11 +9,16 @@
|
||||
#include "BehaviorContext.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
uint32_t targetCount;
|
||||
uint32_t targetCount{};
|
||||
|
||||
bitStream->Read(targetCount);
|
||||
if (!bitStream->Read(targetCount)) {
|
||||
Game::logger->Log("AreaOfEffectBehavior", "Unable to read targetCount from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetCount > this->m_maxTargets) {
|
||||
return;
|
||||
@ -24,9 +29,12 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
|
||||
targets.reserve(targetCount);
|
||||
|
||||
for (auto i = 0u; i < targetCount; ++i) {
|
||||
LWOOBJID target;
|
||||
LWOOBJID target{};
|
||||
|
||||
bitStream->Read(target);
|
||||
if (!bitStream->Read(target)) {
|
||||
Game::logger->Log("AreaOfEffectBehavior", "failed to read in target %i from bitStream, aborting target Handle!", i);
|
||||
return;
|
||||
};
|
||||
|
||||
targets.push_back(target);
|
||||
}
|
||||
|
@ -5,9 +5,12 @@
|
||||
#include "dLogger.h"
|
||||
|
||||
void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
uint32_t handle;
|
||||
uint32_t handle{};
|
||||
|
||||
bitStream->Read(handle);
|
||||
if (!bitStream->Read(handle)) {
|
||||
Game::logger->Log("AttackDelayBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
for (auto i = 0u; i < this->m_numIntervals; ++i) {
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "SpeedBehavior.h"
|
||||
#include "DamageReductionBehavior.h"
|
||||
#include "JetPackBehavior.h"
|
||||
#include "ChangeIdleFlagsBehavior.h"
|
||||
|
||||
//CDClient includes
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
@ -196,7 +197,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
|
||||
behavior = new SkillCastFailedBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_IMITATION_SKUNK_STINK: break;
|
||||
case BehaviorTemplates::BEHAVIOR_CHANGE_IDLE_FLAGS: break;
|
||||
case BehaviorTemplates::BEHAVIOR_CHANGE_IDLE_FLAGS:
|
||||
behavior = new ChangeIdleFlagsBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_APPLY_BUFF:
|
||||
behavior = new ApplyBuffBehavior(behaviorId);
|
||||
break;
|
||||
|
@ -12,6 +12,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"BuffBehavior.cpp"
|
||||
"CarBoostBehavior.cpp"
|
||||
"ChainBehavior.cpp"
|
||||
"ChangeIdleFlagsBehavior.cpp"
|
||||
"ChangeOrientationBehavior.cpp"
|
||||
"ChargeUpBehavior.cpp"
|
||||
"ClearTargetBehavior.cpp"
|
||||
|
@ -4,14 +4,19 @@
|
||||
#include "dLogger.h"
|
||||
|
||||
void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
uint32_t chain_index;
|
||||
uint32_t chainIndex{};
|
||||
|
||||
bitStream->Read(chain_index);
|
||||
if (!bitStream->Read(chainIndex)) {
|
||||
Game::logger->Log("ChainBehavior", "Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
chain_index--;
|
||||
chainIndex--;
|
||||
|
||||
if (chain_index < this->m_behaviors.size()) {
|
||||
this->m_behaviors.at(chain_index)->Handle(context, bitStream, branch);
|
||||
if (chainIndex < this->m_behaviors.size()) {
|
||||
this->m_behaviors.at(chainIndex)->Handle(context, bitStream, branch);
|
||||
} else {
|
||||
Game::logger->Log("ChainBehavior", "chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream->GetNumberOfUnreadBits());
|
||||
}
|
||||
}
|
||||
|
||||
|
37
dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp
Normal file
37
dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
#include "ChangeIdleFlagsBehavior.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
|
||||
void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
||||
if (!target) return;
|
||||
|
||||
GameMessages::SendChangeIdleFlags(target, m_FlagsOn, m_FlagsOff, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
if (branch.duration > 0.0f) {
|
||||
context->RegisterTimerBehavior(this, branch);
|
||||
} else if (branch.start > 0) {
|
||||
context->RegisterEndBehavior(this, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeIdleFlagsBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void ChangeIdleFlagsBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
||||
if (!target) return;
|
||||
// flip on and off to end behavior
|
||||
GameMessages::SendChangeIdleFlags(target, m_FlagsOff, m_FlagsOn, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
void ChangeIdleFlagsBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
End(context, branch, second);
|
||||
}
|
||||
|
||||
void ChangeIdleFlagsBehavior::Load() {
|
||||
m_FlagsOff = static_cast<eAnimationFlags>(GetInt("flags_off", 0));
|
||||
m_FlagsOn = static_cast<eAnimationFlags>(GetInt("flags_on", 0));
|
||||
}
|
23
dGame/dBehaviors/ChangeIdleFlagsBehavior.h
Normal file
23
dGame/dBehaviors/ChangeIdleFlagsBehavior.h
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
#pragma once
|
||||
#include "Behavior.h"
|
||||
#include "eAninmationFlags.h"
|
||||
|
||||
class ChangeIdleFlagsBehavior final : public Behavior {
|
||||
public:
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
explicit ChangeIdleFlagsBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
|
||||
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||
void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
eAnimationFlags m_FlagsOff;
|
||||
eAnimationFlags m_FlagsOn;
|
||||
};
|
@ -1,12 +1,16 @@
|
||||
#include "ChargeUpBehavior.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
uint32_t handle;
|
||||
uint32_t handle{};
|
||||
|
||||
bitStream->Read(handle);
|
||||
if (!bitStream->Read(handle)) {
|
||||
Game::logger->Log("ChargeUpBehavior", "Unable to read handle from bitStream, aborting Handle! variable_type");
|
||||
return;
|
||||
};
|
||||
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
}
|
||||
|
@ -3,23 +3,34 @@
|
||||
#include "BehaviorContext.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t handle;
|
||||
bitStream->Read(handle);
|
||||
uint32_t handle{};
|
||||
if (!bitStream->Read(handle)) {
|
||||
Game::logger->Log("ForceMovementBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
}
|
||||
|
||||
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
uint32_t next;
|
||||
bitStream->Read(next);
|
||||
uint32_t next{};
|
||||
if (!bitStream->Read(next)) {
|
||||
Game::logger->Log("ForceMovementBehavior", "Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
LWOOBJID target;
|
||||
bitStream->Read(target);
|
||||
LWOOBJID target{};
|
||||
if (!bitStream->Read(target)) {
|
||||
Game::logger->Log("ForceMovementBehavior", "Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
|
||||
branch.target = target;
|
||||
auto* behavior = CreateBehavior(next);
|
||||
|
@ -11,7 +11,10 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
if (branch.target != context->originator) {
|
||||
bool unknown = false;
|
||||
|
||||
bitStream->Read(unknown);
|
||||
if (!bitStream->Read(unknown)) {
|
||||
Game::logger->Log("InterruptBehavior", "Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
if (unknown) return;
|
||||
}
|
||||
@ -19,7 +22,10 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
if (!this->m_interruptBlock) {
|
||||
bool unknown = false;
|
||||
|
||||
bitStream->Read(unknown);
|
||||
if (!bitStream->Read(unknown)) {
|
||||
Game::logger->Log("InterruptBehavior", "Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
if (unknown) return;
|
||||
}
|
||||
@ -28,7 +34,10 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
{
|
||||
bool unknown = false;
|
||||
|
||||
bitStream->Read(unknown);
|
||||
if (!bitStream->Read(unknown)) {
|
||||
Game::logger->Log("InterruptBehavior", "Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
if (branch.target == context->originator) return;
|
||||
|
@ -6,11 +6,16 @@
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
bool unknown;
|
||||
bool unknown{};
|
||||
|
||||
bitStream->Read(unknown);
|
||||
if (!bitStream->Read(unknown)) {
|
||||
Game::logger->Log("KnockbackBehavior", "Unable to read unknown from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
|
@ -13,9 +13,11 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t movementType;
|
||||
|
||||
bitStream->Read(movementType);
|
||||
uint32_t movementType{};
|
||||
if (!bitStream->Read(movementType)) {
|
||||
Game::logger->Log("MovementSwitchBehavior", "Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
switch (movementType) {
|
||||
case 1:
|
||||
@ -55,4 +57,3 @@ void MovementSwitchBehavior::Load() {
|
||||
|
||||
this->m_jumpAction = GetAction("jump_action");
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,12 @@
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
|
||||
void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
LWOOBJID target;
|
||||
LWOOBJID target{};
|
||||
|
||||
bitStream->Read(target);
|
||||
if (!bitStream->Read(target)) {
|
||||
Game::logger->Log("ProjectileAttackBehavior", "Unable to read target from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
|
||||
@ -30,15 +33,21 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
|
||||
|
||||
if (m_useMouseposit) {
|
||||
NiPoint3 targetPosition = NiPoint3::ZERO;
|
||||
bitStream->Read(targetPosition);
|
||||
if (!bitStream->Read(targetPosition)) {
|
||||
Game::logger->Log("ProjectileAttackBehavior", "Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
||||
|
||||
for (auto i = 0u; i < this->m_projectileCount; ++i) {
|
||||
LWOOBJID projectileId;
|
||||
LWOOBJID projectileId{};
|
||||
|
||||
bitStream->Read(projectileId);
|
||||
if (!bitStream->Read(projectileId)) {
|
||||
Game::logger->Log("ProjectileAttackBehavior", "Unable to read projectileId from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
branch.target = target;
|
||||
branch.isProjectile = true;
|
||||
@ -98,7 +107,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
||||
for (auto i = 0u; i < this->m_projectileCount; ++i) {
|
||||
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
|
||||
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED);
|
||||
|
||||
bitStream->Write(id);
|
||||
|
||||
|
@ -14,8 +14,11 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
|
||||
return;
|
||||
}
|
||||
|
||||
bool blocked;
|
||||
bitStream->Read(blocked);
|
||||
bool blocked{};
|
||||
if (!bitStream->Read(blocked)) {
|
||||
Game::logger->Log("StunBehavior", "Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
|
@ -10,7 +10,10 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
auto state = true;
|
||||
|
||||
if (this->m_imagination > 0 || !this->m_isEnemyFaction) {
|
||||
bitStream->Read(state);
|
||||
if (!bitStream->Read(state)) {
|
||||
Game::logger->Log("SwitchBehavior", "Unable to read state from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
@ -25,7 +28,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
return;
|
||||
}
|
||||
|
||||
Game::logger->Log("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
|
||||
Game::logger->LogDebug("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
|
||||
|
||||
if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination)) {
|
||||
this->m_actionTrue->Handle(context, bitStream, branch);
|
||||
|
@ -9,10 +9,12 @@
|
||||
#include "EntityManager.h"
|
||||
|
||||
|
||||
void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) {
|
||||
float value;
|
||||
void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
float value{};
|
||||
|
||||
bit_stream->Read(value);
|
||||
if (!bitStream->Read(value)) {
|
||||
Game::logger->Log("SwitchMultipleBehavior", "Unable to read value from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
};
|
||||
|
||||
uint32_t trigger = 0;
|
||||
|
||||
@ -30,10 +32,10 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
||||
|
||||
auto* behavior = this->m_behaviors.at(trigger).second;
|
||||
|
||||
behavior->Handle(context, bit_stream, branch);
|
||||
behavior->Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void SwitchMultipleBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) {
|
||||
void SwitchMultipleBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,16 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
bool hit = false;
|
||||
|
||||
bitStream->Read(hit);
|
||||
if (!bitStream->Read(hit)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read hit from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
};
|
||||
|
||||
if (this->m_checkEnv) {
|
||||
bool blocked = false;
|
||||
|
||||
bitStream->Read(blocked);
|
||||
if (!bitStream->Read(blocked)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
};
|
||||
|
||||
if (blocked) {
|
||||
this->m_blockedAction->Handle(context, bitStream, branch);
|
||||
@ -37,7 +41,9 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
if (hit) {
|
||||
uint32_t count = 0;
|
||||
|
||||
bitStream->Read(count);
|
||||
if (!bitStream->Read(count)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read count from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
};
|
||||
|
||||
if (count > m_maxTargets && m_maxTargets > 0) {
|
||||
count = m_maxTargets;
|
||||
@ -46,9 +52,11 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
std::vector<LWOOBJID> targets;
|
||||
|
||||
for (auto i = 0u; i < count; ++i) {
|
||||
LWOOBJID id;
|
||||
LWOOBJID id{};
|
||||
|
||||
bitStream->Read(id);
|
||||
if (!bitStream->Read(id)) {
|
||||
Game::logger->Log("TacArcBehavior", "Unable to read id from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
};
|
||||
|
||||
targets.push_back(id);
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
|
||||
outBitStream->Write(m_Possessor != LWOOBJID_EMPTY);
|
||||
if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor);
|
||||
|
||||
outBitStream->Write(m_AnimationFlag != eAnimationFlags::IDLE_INVALID);
|
||||
if (m_AnimationFlag != eAnimationFlags::IDLE_INVALID) outBitStream->Write(m_AnimationFlag);
|
||||
outBitStream->Write(m_AnimationFlag != eAnimationFlags::IDLE_NONE);
|
||||
if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream->Write(m_AnimationFlag);
|
||||
|
||||
outBitStream->Write(m_ImmediatelyDepossess);
|
||||
m_ImmediatelyDepossess = false; // reset flag
|
||||
|
@ -109,7 +109,7 @@ private:
|
||||
* @brief What animaiton flag to use
|
||||
*
|
||||
*/
|
||||
eAnimationFlags m_AnimationFlag = eAnimationFlags::IDLE_INVALID;
|
||||
eAnimationFlags m_AnimationFlag = eAnimationFlags::IDLE_NONE;
|
||||
|
||||
/**
|
||||
* @brief Should this be immediately depossessed
|
||||
|
@ -181,17 +181,11 @@ void SkillComponent::Reset() {
|
||||
}
|
||||
|
||||
void SkillComponent::Interrupt() {
|
||||
if (m_Parent->IsPlayer()) return;
|
||||
|
||||
// TODO: need to check immunities on the destroyable component, but they aren't implemented
|
||||
auto* combat = m_Parent->GetComponent<BaseCombatAIComponent>();
|
||||
if (combat != nullptr && combat->GetStunImmune()) return;
|
||||
|
||||
if (combat != nullptr && combat->GetStunImmune()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& behavior : this->m_managedBehaviors) {
|
||||
behavior.second->Interrupt();
|
||||
}
|
||||
for (const auto& behavior : this->m_managedBehaviors) behavior.second->Interrupt();
|
||||
}
|
||||
|
||||
void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, BehaviorContext* context, const BehaviorBranchContext& branch, const LOT lot, const float maxTime,
|
||||
|
@ -3922,6 +3922,18 @@ void GameMessages::SendDisplayChatBubble(LWOOBJID objectId, const std::u16string
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
|
||||
void GameMessages::SendChangeIdleFlags(LWOOBJID objectId, eAnimationFlags FlagsOn, eAnimationFlags FlagsOff, const SystemAddress& sysAddr) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(objectId);
|
||||
bitStream.Write(GAME_MSG::GAME_MSG_CHANGE_IDLE_FLAGS);
|
||||
bitStream.Write(FlagsOff);
|
||||
bitStream.Write(FlagsOn);
|
||||
|
||||
SEND_PACKET_BROADCAST;
|
||||
}
|
||||
// Mounts
|
||||
|
||||
void GameMessages::SendSetMountInventoryID(Entity* entity, const LWOOBJID& objectID, const SystemAddress& sysAddr) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "TradingManager.h"
|
||||
#include "LeaderboardManager.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
#include "eAninmationFlags.h"
|
||||
|
||||
class NiQuaternion;
|
||||
class User;
|
||||
@ -373,6 +374,15 @@ namespace GameMessages {
|
||||
|
||||
void SendDisplayChatBubble(LWOOBJID objectId, const std::u16string& text, const SystemAddress& sysAddr);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param objectId ID of the entity to set idle flags
|
||||
* @param FlagsOn Flag to turn on
|
||||
* @param FlagsOff Flag to turn off
|
||||
*/
|
||||
void SendChangeIdleFlags(LWOOBJID objectId, eAnimationFlags FlagsOn, eAnimationFlags FlagsOff, const SystemAddress& sysAddr);
|
||||
|
||||
// Mounts
|
||||
/**
|
||||
* @brief Set the Inventory LWOOBJID of the mount
|
||||
|
@ -722,7 +722,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
|
||||
Game::logger->Log("SGCannon", "Player has %d equipped items", equippedItems.size());
|
||||
|
||||
auto skillID = constants.cannonSkill;
|
||||
auto coolDown = constants.cannonRefireRate;
|
||||
auto cooldown = constants.cannonRefireRate;
|
||||
|
||||
auto* selfInventoryComponent = self->GetComponent<InventoryComponent>();
|
||||
|
||||
@ -738,7 +738,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
|
||||
|
||||
// TODO: Equip items
|
||||
skillID = constants.cannonSuperChargeSkill;
|
||||
coolDown = 400;
|
||||
cooldown = 400;
|
||||
} else {
|
||||
selfInventoryComponent->UpdateSlot("greeble_r", { ObjectIDManager::GenerateRandomObjectID(), 0, 0, 0 });
|
||||
selfInventoryComponent->UpdateSlot("greeble_l", { ObjectIDManager::GenerateRandomObjectID(), 0, 0, 0 });
|
||||
@ -761,7 +761,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cooldown = 800;
|
||||
self->SetVar<uint32_t>(NumberOfChargesVariable, 0);
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
|
||||
|
||||
properties.cannonFOV = 58.6f;
|
||||
properties.cannonVelocity = 129.0;
|
||||
properties.cannonRefireRate = 800;
|
||||
properties.cannonRefireRate = cooldown;
|
||||
properties.cannonMinDistance = 30;
|
||||
properties.cannonTimeout = -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user