mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 01:38:20 +00:00
Add change idle flags behavior and GM (#871)
* update naming for animation flag enum value 0 * Add change idle flags behaviors and GM * default to 0 when none is given
This commit is contained in:
parent
32f8bda538
commit
631365b7f7
@ -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,
|
||||
|
@ -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"
|
||||
|
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;
|
||||
};
|
@ -28,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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user