mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
@@ -15,7 +15,7 @@ void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
if (buffComponent == nullptr) return;
|
||||
|
||||
buffComponent->ApplyBuff(m_BuffId, m_Duration, context->originator, addImmunity, cancelOnDamaged, cancelOnDeath,
|
||||
cancelOnLogout, cancelonRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
||||
cancelOnLogout, cancelonRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone, m_ApplyOnTeammates);
|
||||
}
|
||||
|
||||
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||
@@ -45,4 +45,5 @@ void ApplyBuffBehavior::Load() {
|
||||
cancelOnUi = GetBoolean("cancel_on_ui");
|
||||
cancelOnUnequip = GetBoolean("cancel_on_unequip");
|
||||
cancelOnZone = GetBoolean("cancel_on_zone");
|
||||
m_ApplyOnTeammates = GetBoolean("apply_on_teammates");
|
||||
}
|
||||
|
@@ -31,4 +31,6 @@ public:
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
private:
|
||||
bool m_ApplyOnTeammates;
|
||||
};
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include "Logger.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
|
@@ -22,7 +22,6 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
||||
if (entity->IsPlayer() && !this->m_DontApplyImmune) {
|
||||
const float immunityTime = Game::zoneManager->GetWorldConfig()->globalImmunityTime;
|
||||
destroyableComponent->SetDamageCooldownTimer(immunityTime);
|
||||
LOG_DEBUG("Target targetEntity %llu took damage, setting damage cooldown timer to %f s", branch.target, immunityTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,11 +187,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet
|
||||
return;
|
||||
}
|
||||
|
||||
const float immunityTime = Game::zoneManager->GetWorldConfig()->globalImmunityTime;
|
||||
LOG_DEBUG("Damage cooldown timer currently %f s", destroyableComponent->GetDamageCooldownTimer());
|
||||
|
||||
const bool isImmune = (destroyableComponent->IsImmune()) || (destroyableComponent->IsCooldownImmune());
|
||||
|
||||
const bool isImmune = destroyableComponent->IsImmune() || destroyableComponent->IsCooldownImmune();
|
||||
bitStream->Write(isImmune);
|
||||
|
||||
if (isImmune) {
|
||||
@@ -219,8 +214,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet
|
||||
|
||||
//Handle player damage cooldown
|
||||
if (isSuccess && targetEntity->IsPlayer() && !this->m_DontApplyImmune) {
|
||||
destroyableComponent->SetDamageCooldownTimer(immunityTime);
|
||||
LOG_DEBUG("Target targetEntity %llu took damage, setting damage cooldown timer to %f s", branch.target, immunityTime);
|
||||
destroyableComponent->SetDamageCooldownTimer(Game::zoneManager->GetWorldConfig()->globalImmunityTime);
|
||||
}
|
||||
|
||||
eBasicAttackSuccessTypes successState = eBasicAttackSuccessTypes::FAILIMMUNE;
|
||||
|
@@ -64,6 +64,7 @@
|
||||
#include "FallSpeedBehavior.h"
|
||||
#include "ChangeIdleFlagsBehavior.h"
|
||||
#include "DarkInspirationBehavior.h"
|
||||
#include "ConsumeItemBehavior.h"
|
||||
|
||||
//CDClient includes
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
@@ -200,7 +201,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
|
||||
case BehaviorTemplates::BEHAVIOR_SKILL_EVENT:
|
||||
behavior = new SkillEventBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_CONSUME_ITEM: break;
|
||||
case BehaviorTemplates::BEHAVIOR_CONSUME_ITEM:
|
||||
behavior = new ConsumeItemBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_SKILL_CAST_FAILED:
|
||||
behavior = new SkillCastFailedBehavior(behaviorId);
|
||||
break;
|
||||
@@ -365,11 +368,11 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
||||
|
||||
if (!type.empty()) {
|
||||
typeQuery.bind(1, typeString.c_str());
|
||||
typeQuery.bind(2, (int)effectId);
|
||||
typeQuery.bind(2, static_cast<int>(effectId));
|
||||
|
||||
result = typeQuery.execQuery();
|
||||
} else {
|
||||
idQuery.bind(1, (int)effectId);
|
||||
idQuery.bind(1, static_cast<int>(effectId));
|
||||
|
||||
result = idQuery.execQuery();
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include "DestroyableComponent.h"
|
||||
#include "EchoSyncSkill.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "TeamManager.h"
|
||||
#include "eConnectionType.h"
|
||||
@@ -249,7 +249,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) {
|
||||
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);
|
||||
|
||||
if (!clientInitalized) {
|
||||
echo.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
||||
echo.sBitStream.assign(reinterpret_cast<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
|
||||
|
||||
// Write message
|
||||
RakNet::BitStream message;
|
||||
@@ -412,8 +412,8 @@ bool BehaviorContext::CheckTargetingRequirements(const Entity* target) const {
|
||||
if (!target) return false;
|
||||
|
||||
// ignore quickbuilds that aren't completed
|
||||
auto* targetQuickbuildComponent = target->GetComponent<RebuildComponent>();
|
||||
if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != eRebuildState::COMPLETED) return false;
|
||||
auto* targetQuickbuildComponent = target->GetComponent<QuickBuildComponent>();
|
||||
if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != eQuickBuildState::COMPLETED) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"ChangeOrientationBehavior.cpp"
|
||||
"ChargeUpBehavior.cpp"
|
||||
"ClearTargetBehavior.cpp"
|
||||
"ConsumeItemBehavior.cpp"
|
||||
"DamageAbsorptionBehavior.cpp"
|
||||
"DamageReductionBehavior.cpp"
|
||||
"DarkInspirationBehavior.cpp"
|
||||
@@ -53,4 +54,9 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"TargetCasterBehavior.cpp"
|
||||
"TauntBehavior.cpp"
|
||||
"VentureVisionBehavior.cpp"
|
||||
"VerifyBehavior.cpp" PARENT_SCOPE)
|
||||
"VerifyBehavior.cpp")
|
||||
|
||||
add_library(dBehaviors STATIC ${DGAME_DBEHAVIORS_SOURCES})
|
||||
target_link_libraries(dBehaviors PUBLIC dPhysics)
|
||||
target_include_directories(dBehaviors PUBLIC ".")
|
||||
target_precompile_headers(dBehaviors REUSE_FROM dGameBase)
|
||||
|
31
dGame/dBehaviors/ConsumeItemBehavior.cpp
Normal file
31
dGame/dBehaviors/ConsumeItemBehavior.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "ConsumeItemBehavior.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto action_to_cast = m_ActionNotConsumed;
|
||||
if (this->m_ConsumeLOT != -1) {
|
||||
auto caster = Game::entityManager->GetEntity(context->caster);
|
||||
if (!caster) return;
|
||||
|
||||
auto inventoryComponent = caster->GetComponent<InventoryComponent>();
|
||||
if (!inventoryComponent) return;
|
||||
|
||||
if (inventoryComponent->RemoveItem(this->m_ConsumeLOT, this->m_NumToConsume, eInventoryType::INVALID, false, true)){
|
||||
action_to_cast = m_ActionConsumed;
|
||||
}
|
||||
}
|
||||
if(action_to_cast) action_to_cast->Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void ConsumeItemBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void ConsumeItemBehavior::Load() {
|
||||
this->m_ConsumeLOT = GetInt("consume_lot", -1);
|
||||
this->m_NumToConsume = GetInt("num_to_consume", 1);
|
||||
this->m_ActionNotConsumed = GetAction("action_not_consumed");
|
||||
this->m_ActionConsumed = GetAction("action_consumed");
|
||||
}
|
17
dGame/dBehaviors/ConsumeItemBehavior.h
Normal file
17
dGame/dBehaviors/ConsumeItemBehavior.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "Behavior.h"
|
||||
|
||||
class ConsumeItemBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
explicit ConsumeItemBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
LOT m_ConsumeLOT;
|
||||
uint32_t m_NumToConsume;
|
||||
Behavior* m_ActionNotConsumed;
|
||||
Behavior* m_ActionConsumed;
|
||||
};
|
@@ -38,10 +38,12 @@ void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit
|
||||
}
|
||||
|
||||
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);
|
||||
this->m_WarningEffectID = GetInt("warning_effect_id", -1);
|
||||
this->m_Airspeed = GetFloat("airspeed", 10);
|
||||
this->m_MaxAirspeed = GetFloat("max_airspeed", 15);
|
||||
this->m_VerticalVelocity = GetFloat("vertical_velocity", 1);
|
||||
this->m_EnableHover = GetBoolean("enable_hover", false);
|
||||
|
||||
// TODO: Implement proper jetpack checks, so we can set this default to false
|
||||
this->m_BypassChecks = GetBoolean("bypass_checks", true);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
#include "ObjectIDManager.h"
|
||||
#include "eObjectBits.h"
|
||||
|
||||
void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
@@ -106,7 +106,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
||||
const auto maxTime = this->m_maxDistance / this->m_projectileSpeed;
|
||||
|
||||
for (auto i = 0u; i < this->m_projectileCount; ++i) {
|
||||
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
|
||||
auto id = static_cast<LWOOBJID>(ObjectIDManager::GenerateObjectID());
|
||||
|
||||
GeneralUtils::SetBit(id, eObjectBits::SPAWNED);
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "Entity.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
@@ -53,10 +53,10 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
|
||||
entity->SetOwnerOverride(context->originator);
|
||||
|
||||
// Unset the flag to reposition the player, this makes it harder to glitch out of the map
|
||||
auto* rebuildComponent = entity->GetComponent<RebuildComponent>();
|
||||
auto* quickBuildComponent = entity->GetComponent<QuickBuildComponent>();
|
||||
|
||||
if (rebuildComponent != nullptr) {
|
||||
rebuildComponent->SetRepositionPlayer(false);
|
||||
if (quickBuildComponent != nullptr) {
|
||||
quickBuildComponent->SetRepositionPlayer(false);
|
||||
}
|
||||
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
|
@@ -42,7 +42,7 @@ void SwitchMultipleBehavior::Load() {
|
||||
"(select bP2.value FROM BehaviorParameter bP2 WHERE bP2.behaviorID = ?1 AND bP2.parameterID LIKE 'value %' "
|
||||
"AND replace(bP1.parameterID, 'behavior ', '') = replace(bP2.parameterID, 'value ', '')) as value "
|
||||
"FROM BehaviorParameter bP1 WHERE bP1.behaviorID = ?1 AND bP1.parameterID LIKE 'behavior %';");
|
||||
query.bind(1, (int)this->m_behaviorId);
|
||||
query.bind(1, static_cast<int>(this->m_behaviorId));
|
||||
|
||||
auto result = query.execQuery();
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include "BehaviorContext.h"
|
||||
#include "BaseCombatAIComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -104,7 +104,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
|
||||
const auto casterPosition = self->GetPosition();
|
||||
|
||||
auto reference = self->GetPosition(); //+ m_offset;
|
||||
auto reference = self->GetPosition() + m_offset;
|
||||
|
||||
targets.clear();
|
||||
|
||||
@@ -114,46 +114,34 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
context->FilterTargets(validTargets, this->m_ignoreFactionList, this->m_includeFactionList, this->m_targetSelf, this->m_targetEnemy, this->m_targetFriend, this->m_targetTeam);
|
||||
|
||||
for (auto validTarget : validTargets) {
|
||||
if (targets.size() >= this->m_maxTargets) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (std::find(targets.begin(), targets.end(), validTarget) != targets.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targets.size() >= this->m_maxTargets) break;
|
||||
if (std::find(targets.begin(), targets.end(), validTarget) != targets.end()) continue;
|
||||
if (validTarget->GetIsDead()) continue;
|
||||
|
||||
const auto otherPosition = validTarget->GetPosition();
|
||||
const auto targetPos = validTarget->GetPosition();
|
||||
|
||||
const auto heightDifference = std::abs(otherPosition.y - casterPosition.y);
|
||||
|
||||
/*if (otherPosition.y > reference.y && heightDifference > this->m_upperBound || otherPosition.y < reference.y && heightDifference > this->m_lowerBound)
|
||||
{
|
||||
// make sure we aren't too high or low in comparison to the targer
|
||||
const auto heightDifference = std::abs(reference.y - targetPos.y);
|
||||
if (targetPos.y > reference.y && heightDifference > this->m_upperBound || targetPos.y < reference.y && heightDifference > this->m_lowerBound)
|
||||
continue;
|
||||
}*/
|
||||
|
||||
const auto forward = self->GetRotation().GetForwardVector();
|
||||
|
||||
// forward is a normalized vector of where the caster is facing.
|
||||
// otherPosition is the position of the target.
|
||||
// targetPos is the position of the target.
|
||||
// reference is the position of the caster.
|
||||
// If we cast a ray forward from the caster, does it come within m_farWidth of the target?
|
||||
|
||||
const auto distance = Vector3::Distance(reference, otherPosition);
|
||||
const auto distance = Vector3::Distance(reference, targetPos);
|
||||
|
||||
if (m_method == 2) {
|
||||
NiPoint3 rayPoint = casterPosition + forward * distance;
|
||||
|
||||
if (m_farWidth > 0 && Vector3::DistanceSquared(rayPoint, otherPosition) > this->m_farWidth * this->m_farWidth) {
|
||||
if (m_farWidth > 0 && Vector3::DistanceSquared(rayPoint, targetPos) > this->m_farWidth * this->m_farWidth)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
auto normalized = (reference - otherPosition) / distance;
|
||||
|
||||
auto normalized = (reference - targetPos) / distance;
|
||||
const float degreeAngle = std::abs(Vector3::Angle(forward, normalized) * (180 / 3.14) - 180);
|
||||
|
||||
if (distance >= this->m_minRange && this->m_maxRange >= distance && degreeAngle <= 2 * this->m_angle) {
|
||||
targets.push_back(validTarget);
|
||||
}
|
||||
@@ -167,33 +155,26 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
});
|
||||
|
||||
const auto hit = !targets.empty();
|
||||
|
||||
bitStream->Write(hit);
|
||||
|
||||
if (this->m_checkEnv) {
|
||||
const auto blocked = false; // TODO
|
||||
|
||||
bitStream->Write(blocked);
|
||||
}
|
||||
|
||||
if (hit) {
|
||||
if (combatAi != nullptr) {
|
||||
combatAi->LookAt(targets[0]->GetPosition());
|
||||
}
|
||||
if (combatAi) combatAi->LookAt(targets[0]->GetPosition());
|
||||
|
||||
context->foundTarget = true; // We want to continue with this behavior
|
||||
|
||||
const auto count = static_cast<uint32_t>(targets.size());
|
||||
|
||||
bitStream->Write(count);
|
||||
|
||||
for (auto* target : targets) {
|
||||
bitStream->Write(target->GetObjectID());
|
||||
}
|
||||
|
||||
for (auto* target : targets) {
|
||||
branch.target = target->GetObjectID();
|
||||
|
||||
this->m_action->Calculate(context, bitStream, branch);
|
||||
}
|
||||
} else {
|
||||
@@ -214,8 +195,8 @@ void TacArcBehavior::Load() {
|
||||
GetFloat("offset_z", 0.0f)
|
||||
);
|
||||
this->m_method = GetInt("method", 1);
|
||||
this->m_upperBound = GetFloat("upper_bound", 4.4f);
|
||||
this->m_lowerBound = GetFloat("lower_bound", 0.4f);
|
||||
this->m_upperBound = std::abs(GetFloat("upper_bound", 4.4f));
|
||||
this->m_lowerBound = std::abs(GetFloat("lower_bound", 0.4f));
|
||||
this->m_usePickedTarget = GetBoolean("use_picked_target", false);
|
||||
this->m_useTargetPostion = GetBoolean("use_target_position", false);
|
||||
this->m_checkEnv = GetBoolean("check_env", false);
|
||||
|
Reference in New Issue
Block a user