mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
The client only simulates knockbacks on the character it controls (LWOControllablePhysComponent::msgKnockback); enemies and NPCs are drawn where the server puts them, so a knockback on them did nothing and scripts stunned them instead. MovementAIComponent::Knockback now flies the object the way the client flies its character: a vector longer than 5 lifts it 0.5, throws it with that velocity under WorldConfig gravity (times its gravity scale) until it lands on the navmesh, no sooner than 250ms later; a shorter one moves it by the vector. Walls taller than a step stop sideways motion, the landing is put back onto the navmesh, and pathing and the combat AI wait until it lands (destinations set mid air are walked to afterwards). Position and velocity go out in the normal serialization every tick. KnockbackBehavior builds the vector like the client's Cast (strength capped at 300, angle as elevation, relative, caster and ignore_self) and knocks back server moved targets that aren't immune, both when the server casts and when a client's skill hits. The blocked bit it writes now also answers for the target's knockback immunity, so a player whose client hasn't caught up with a Personal Fortress isn't knocked out of it. The AM shield generators knock enemies back like live instead of stunning them. Fixes #257 Refs #185 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
908 B
C++
37 lines
908 B
C++
#pragma once
|
|
#include "Behavior.h"
|
|
|
|
class Entity;
|
|
|
|
class KnockbackBehavior final : public Behavior
|
|
{
|
|
public:
|
|
/*
|
|
* Inherited
|
|
*/
|
|
|
|
float m_strength;
|
|
float m_angle;
|
|
bool m_relative;
|
|
uint32_t m_time;
|
|
bool m_ignoreSelf;
|
|
bool m_caster;
|
|
|
|
|
|
explicit KnockbackBehavior(const uint32_t behaviorID) : Behavior(behaviorID) {
|
|
}
|
|
|
|
void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override;
|
|
|
|
void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override;
|
|
|
|
void Load() override;
|
|
|
|
private:
|
|
/**
|
|
* Knocks back the target if the server moves it. Players knock themselves back on their own client when it
|
|
* runs the skill; enemies and NPCs are only drawn where the server puts them, so the server flies them.
|
|
*/
|
|
void KnockbackServerObject(BehaviorContext* context, const BehaviorBranchContext& branch) const;
|
|
};
|