mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
implement jetpack behavior and remove hardcoded jetpacks (#411)
This commit is contained in:
parent
1e01423a93
commit
f6558aa31e
@ -40,13 +40,13 @@ std::string CDBehaviorParameterTable::GetName(void) const {
|
|||||||
return "BehaviorParameter";
|
return "BehaviorParameter";
|
||||||
}
|
}
|
||||||
|
|
||||||
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name)
|
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue)
|
||||||
{
|
{
|
||||||
size_t hash = 0;
|
size_t hash = 0;
|
||||||
GeneralUtils::hash_combine(hash, behaviorID);
|
GeneralUtils::hash_combine(hash, behaviorID);
|
||||||
GeneralUtils::hash_combine(hash, name);
|
GeneralUtils::hash_combine(hash, name);
|
||||||
|
|
||||||
// Search for specific perameter
|
// Search for specific parameter
|
||||||
const auto& it = m_Entries.find(hash);
|
const auto& it = m_Entries.find(hash);
|
||||||
if (it != m_Entries.end()) {
|
if (it != m_Entries.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -55,7 +55,7 @@ float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::s
|
|||||||
// Check if this behavior has already been checked
|
// Check if this behavior has already been checked
|
||||||
const auto& itChecked = m_Entries.find(behaviorID);
|
const auto& itChecked = m_Entries.find(behaviorID);
|
||||||
if (itChecked != m_Entries.end()) {
|
if (itChecked != m_Entries.end()) {
|
||||||
return itChecked->second;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CDCLIENT_CACHE_ALL
|
#ifndef CDCLIENT_CACHE_ALL
|
||||||
@ -86,5 +86,5 @@ float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::s
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,5 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::string GetName(void) const override;
|
std::string GetName(void) const override;
|
||||||
|
|
||||||
float GetEntry(const uint32_t behaviorID, const std::string& name);
|
float GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
||||||
};
|
};
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "SkillEventBehavior.h"
|
#include "SkillEventBehavior.h"
|
||||||
#include "SpeedBehavior.h"
|
#include "SpeedBehavior.h"
|
||||||
#include "DamageReductionBehavior.h"
|
#include "DamageReductionBehavior.h"
|
||||||
|
#include "JetPackBehavior.h"
|
||||||
|
|
||||||
//CDClient includes
|
//CDClient includes
|
||||||
#include "CDBehaviorParameterTable.h"
|
#include "CDBehaviorParameterTable.h"
|
||||||
@ -183,7 +184,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
|||||||
case BehaviorTemplates::BEHAVIOR_BUFF:
|
case BehaviorTemplates::BEHAVIOR_BUFF:
|
||||||
behavior = new BuffBehavior(behaviorId);
|
behavior = new BuffBehavior(behaviorId);
|
||||||
break;
|
break;
|
||||||
case BehaviorTemplates::BEHAVIOR_JETPACK: break;
|
case BehaviorTemplates::BEHAVIOR_JETPACK:
|
||||||
|
behavior = new JetPackBehavior(behaviorId);
|
||||||
|
break;
|
||||||
case BehaviorTemplates::BEHAVIOR_SKILL_EVENT:
|
case BehaviorTemplates::BEHAVIOR_SKILL_EVENT:
|
||||||
behavior = new SkillEventBehavior(behaviorId);
|
behavior = new SkillEventBehavior(behaviorId);
|
||||||
break;
|
break;
|
||||||
@ -455,21 +458,21 @@ Behavior::Behavior(const uint32_t behaviorId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float Behavior::GetFloat(const std::string& name) const
|
float Behavior::GetFloat(const std::string& name, const float defaultValue) const
|
||||||
{
|
{
|
||||||
return BehaviorParameterTable->GetEntry(this->m_behaviorId, name);
|
return BehaviorParameterTable->GetEntry(this->m_behaviorId, name, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Behavior::GetBoolean(const std::string& name) const
|
bool Behavior::GetBoolean(const std::string& name, const bool defaultValue) const
|
||||||
{
|
{
|
||||||
return GetFloat(name) > 0;
|
return GetFloat(name, defaultValue) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t Behavior::GetInt(const std::string& name) const
|
int32_t Behavior::GetInt(const std::string& name, const int defaultValue) const
|
||||||
{
|
{
|
||||||
return static_cast<int32_t>(GetFloat(name));
|
return static_cast<int32_t>(GetFloat(name, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ public:
|
|||||||
* Behavior parameters
|
* Behavior parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float GetFloat(const std::string& name) const;
|
float GetFloat(const std::string& name, const float defaultValue = 0) const;
|
||||||
|
|
||||||
bool GetBoolean(const std::string& name) const;
|
bool GetBoolean(const std::string& name, const bool defaultValue = false) const;
|
||||||
|
|
||||||
int32_t GetInt(const std::string& name) const;
|
int32_t GetInt(const std::string& name, const int32_t defaultValue = 0) const;
|
||||||
|
|
||||||
Behavior* GetAction(const std::string& name) const;
|
Behavior* GetAction(const std::string& name) const;
|
||||||
|
|
||||||
|
29
dGame/dBehaviors/JetPackBehavior.cpp
Normal file
29
dGame/dBehaviors/JetPackBehavior.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "JetPackBehavior.h"
|
||||||
|
|
||||||
|
#include "BehaviorBranchContext.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
|
||||||
|
void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
|
GameMessages::SendSetJetPackMode(entity, true, this->m_BypassChecks, this->m_EnableHover, this->m_effectId, this->m_Airspeed, this->m_MaxAirspeed, this->m_VerticalVelocity, this->m_WarningEffectID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JetPackBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
|
GameMessages::SendSetJetPackMode(entity, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
|
Handle(context, bit_stream, branch);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JetPackBehavior::Load() {
|
||||||
|
this->m_WarningEffectID = GetInt("warning_effect_id");
|
||||||
|
this->m_Airspeed = GetFloat("airspeed");
|
||||||
|
this->m_MaxAirspeed = GetFloat("max_airspeed");
|
||||||
|
this->m_VerticalVelocity = GetFloat("vertical_velocity");
|
||||||
|
this->m_EnableHover = GetBoolean("enable_hover");
|
||||||
|
this->m_BypassChecks = GetBoolean("bypass_checks", true);
|
||||||
|
}
|
28
dGame/dBehaviors/JetPackBehavior.h
Normal file
28
dGame/dBehaviors/JetPackBehavior.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Behavior.h"
|
||||||
|
|
||||||
|
class JetPackBehavior final : public Behavior
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int32_t m_WarningEffectID;
|
||||||
|
float m_Airspeed;
|
||||||
|
float m_MaxAirspeed;
|
||||||
|
float m_VerticalVelocity;
|
||||||
|
bool m_EnableHover;
|
||||||
|
bool m_BypassChecks = true; // from what I can tell this defaulted true in live
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inherited
|
||||||
|
*/
|
||||||
|
|
||||||
|
explicit JetPackBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
|
void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
|
void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
|
void Load() override;
|
||||||
|
};
|
@ -1000,10 +1000,6 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks)
|
|||||||
{
|
{
|
||||||
set->OnEquip(lot);
|
set->OnEquip(lot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lot == 1727) GameMessages::SendSetJetpackMode(m_Parent, false, true, false);
|
|
||||||
if (lot == 7292) GameMessages::SendSetJetpackMode(m_Parent, true, true, false);
|
|
||||||
if (lot == 14442) GameMessages::SendSetJetpackMode(m_Parent, false, true, true);
|
|
||||||
|
|
||||||
if (item->GetInfo().isBOE)
|
if (item->GetInfo().isBOE)
|
||||||
{
|
{
|
||||||
@ -1042,10 +1038,6 @@ void InventoryComponent::UnEquipItem(Item* item)
|
|||||||
set->OnUnEquip(lot);
|
set->OnUnEquip(lot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lot == 1727) GameMessages::SendSetJetpackMode(m_Parent, false, false, false);
|
|
||||||
if (lot == 7292) GameMessages::SendSetJetpackMode(m_Parent, true, false, false);
|
|
||||||
if (lot == 14442) GameMessages::SendSetJetpackMode(m_Parent, false, false, true);
|
|
||||||
|
|
||||||
RemoveBuff(item->GetLot());
|
RemoveBuff(item->GetLot());
|
||||||
|
|
||||||
RemoveItemSkills(item->GetLot());
|
RemoveItemSkills(item->GetLot());
|
||||||
|
@ -257,7 +257,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity *player,
|
|||||||
m_Parent->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS);
|
m_Parent->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
});
|
});
|
||||||
|
|
||||||
GameMessages::SendSetJetpackMode(player, false, false, false);
|
GameMessages::SendSetJetPackMode(player, false);
|
||||||
|
|
||||||
// Set the vehicle's state.
|
// Set the vehicle's state.
|
||||||
GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(),
|
GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(),
|
||||||
|
@ -105,9 +105,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
|||||||
auto items = inv->GetEquippedItems();
|
auto items = inv->GetEquippedItems();
|
||||||
for (auto pair : items) {
|
for (auto pair : items) {
|
||||||
const auto item = pair.second;
|
const auto item = pair.second;
|
||||||
if (item.lot == 1727) GameMessages::SendSetJetpackMode(entity, false, true, false);
|
|
||||||
if (item.lot == 7292) GameMessages::SendSetJetpackMode(entity, true, true, false);
|
|
||||||
if (item.lot == 14442) GameMessages::SendSetJetpackMode(entity, false, true, true);
|
|
||||||
|
|
||||||
inv->AddItemSkills(item.lot);
|
inv->AddItemSkills(item.lot);
|
||||||
}
|
}
|
||||||
|
@ -872,19 +872,14 @@ void GameMessages::SendSetEmoteLockState(Entity* entity, bool bLock, int emoteID
|
|||||||
SEND_PACKET
|
SEND_PACKET
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::SendSetJetpackMode(Entity* entity, bool bDoHover, bool bUse, bool bIsJamessterPhysics) {
|
void GameMessages::SendSetJetPackMode(Entity* entity, bool use, bool bypassChecks, bool doHover, int effectID, float airspeed, float maxAirspeed, float verticalVelocity, int warningEffectID) {
|
||||||
int effectID = 167;
|
/* historical jamesster jetpack values
|
||||||
int iWarningEffectID = -1;
|
|
||||||
float fAirspeed = 25;
|
|
||||||
float fMaxAirspeed = 25;
|
|
||||||
float fVertVel = 2;
|
|
||||||
bool bBypassChecks = true;
|
|
||||||
|
|
||||||
if (bIsJamessterPhysics) {
|
if (bIsJamessterPhysics) {
|
||||||
fAirspeed = 75;
|
fAirspeed = 75;
|
||||||
fMaxAirspeed = 75;
|
fMaxAirspeed = 75;
|
||||||
fVertVel = 15;
|
fVertVel = 15;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
CBITSTREAM
|
CBITSTREAM
|
||||||
CMSGHEADER
|
CMSGHEADER
|
||||||
@ -892,24 +887,24 @@ void GameMessages::SendSetJetpackMode(Entity* entity, bool bDoHover, bool bUse,
|
|||||||
bitStream.Write(entity->GetObjectID());
|
bitStream.Write(entity->GetObjectID());
|
||||||
bitStream.Write(uint16_t(GAME_MSG_SET_JET_PACK_MODE));
|
bitStream.Write(uint16_t(GAME_MSG_SET_JET_PACK_MODE));
|
||||||
|
|
||||||
bitStream.Write(bBypassChecks);
|
bitStream.Write(bypassChecks);
|
||||||
bitStream.Write(bDoHover);
|
bitStream.Write(doHover);
|
||||||
bitStream.Write(bUse);
|
bitStream.Write(use);
|
||||||
|
|
||||||
bitStream.Write(effectID != -1);
|
bitStream.Write(effectID != -1);
|
||||||
if (effectID != -1) bitStream.Write(effectID);
|
if (effectID != -1) bitStream.Write(effectID);
|
||||||
|
|
||||||
bitStream.Write(fAirspeed != 10);
|
bitStream.Write(airspeed != 10);
|
||||||
if (fAirspeed != 10) bitStream.Write(fAirspeed);
|
if (airspeed != 10) bitStream.Write(airspeed);
|
||||||
|
|
||||||
bitStream.Write(fMaxAirspeed != 15);
|
bitStream.Write(maxAirspeed != 15);
|
||||||
if (fMaxAirspeed != 15) bitStream.Write(fMaxAirspeed);
|
if (maxAirspeed != 15) bitStream.Write(maxAirspeed);
|
||||||
|
|
||||||
bitStream.Write(fVertVel != 1);
|
bitStream.Write(verticalVelocity != 1);
|
||||||
if (fVertVel != 1) bitStream.Write(fVertVel);
|
if (verticalVelocity != 1) bitStream.Write(verticalVelocity);
|
||||||
|
|
||||||
bitStream.Write(iWarningEffectID != -1);
|
bitStream.Write(warningEffectID != -1);
|
||||||
if (iWarningEffectID != -1) bitStream.Write(iWarningEffectID);
|
if (warningEffectID != -1) bitStream.Write(warningEffectID);
|
||||||
|
|
||||||
SEND_PACKET_BROADCAST
|
SEND_PACKET_BROADCAST
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace GameMessages {
|
|||||||
void SendSetInventorySize(Entity* entity, int invType, int size);
|
void SendSetInventorySize(Entity* entity, int invType, int size);
|
||||||
|
|
||||||
void SendSetEmoteLockState(Entity* entity, bool bLock, int emoteID);
|
void SendSetEmoteLockState(Entity* entity, bool bLock, int emoteID);
|
||||||
void SendSetJetpackMode(Entity* entity, bool bDoHover, bool bUse, bool bIsJamessterPhysics);
|
void SendSetJetPackMode(Entity* entity, bool use, bool bypassChecks = false, bool doHover = false, int effectID = -1, float airspeed = 10, float maxAirspeed = 15, float verticalVelocity = 1, int warningEffectID = -1);
|
||||||
void SendResurrect(Entity* entity);
|
void SendResurrect(Entity* entity);
|
||||||
void SendStop2DAmbientSound(Entity* entity, bool force, std::string audioGUID, bool result = false);
|
void SendStop2DAmbientSound(Entity* entity, bool force, std::string audioGUID, bool result = false);
|
||||||
void SendPlay2DAmbientSound(Entity* entity, std::string audioGUID, bool result = false);
|
void SendPlay2DAmbientSound(Entity* entity, std::string audioGUID, bool result = false);
|
||||||
|
Loading…
Reference in New Issue
Block a user