mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
Add speedbase readling and writing to the level prograssion component and impli proper character versions for fixes (#856)
* Add speed base readling and writing to the level prograssion component Add retroactive fix to the world transfer TODO: see about versioning charxml fixes to make them not run every time * version all current changes * cleanup speed behavior add calculate for future use in scripts make < 1 speed multiplier possible tested wormholer and it plays anims correctly * cap the lower end of the speed multiplier until the ending the behavior on hit properly works * address feedback add emun for character version make set ignore multipliers consistent in speed behavior switch case for char version upgrades * remove the ability to stack speed boosts * update value on level ups
This commit is contained in:
@@ -7,85 +7,44 @@
|
||||
|
||||
|
||||
void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
if (m_AffectsCaster) {
|
||||
branch.target = context->caster;
|
||||
}
|
||||
if (m_AffectsCaster) branch.target = context->caster;
|
||||
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (target == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!target) return;
|
||||
|
||||
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
if (!controllablePhysicsComponent) return;
|
||||
|
||||
if (controllablePhysicsComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
|
||||
|
||||
controllablePhysicsComponent->SetSpeedMultiplier(current + ((m_RunSpeed - 500.0f) / 500.0f));
|
||||
|
||||
controllablePhysicsComponent->AddSpeedboost(m_RunSpeed);
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
|
||||
if (branch.duration > 0.0f) {
|
||||
context->RegisterTimerBehavior(this, branch);
|
||||
} else if (branch.start > 0) {
|
||||
controllablePhysicsComponent->SetIgnoreMultipliers(true);
|
||||
|
||||
context->RegisterEndBehavior(this, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void SpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (target == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllablePhysicsComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
|
||||
|
||||
controllablePhysicsComponent->SetSpeedMultiplier(current - ((m_RunSpeed - 500.0f) / 500.0f));
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
void SpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void SpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (target == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!target) return;
|
||||
|
||||
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
if (!controllablePhysicsComponent) return;
|
||||
|
||||
if (controllablePhysicsComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
|
||||
|
||||
controllablePhysicsComponent->SetIgnoreMultipliers(false);
|
||||
|
||||
controllablePhysicsComponent->SetSpeedMultiplier(current - ((m_RunSpeed - 500.0f) / 500.0f));
|
||||
|
||||
controllablePhysicsComponent->RemoveSpeedboost(m_RunSpeed);
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
}
|
||||
|
||||
void SpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
End(context, branch, second);
|
||||
}
|
||||
|
||||
void SpeedBehavior::Load() {
|
||||
m_RunSpeed = GetFloat("run_speed");
|
||||
|
||||
if (m_RunSpeed < 500.0f) {
|
||||
m_RunSpeed = 500.0f;
|
||||
}
|
||||
|
||||
m_AffectsCaster = GetBoolean("affects_caster");
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@ public:
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Calculate(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;
|
||||
|
Reference in New Issue
Block a user