2022-08-06 03:01:59 +00:00
|
|
|
#pragma once
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "Behavior.h"
|
|
|
|
|
|
|
|
class BasicAttackBehavior final : public Behavior
|
|
|
|
{
|
|
|
|
public:
|
2022-07-28 13:39:57 +00:00
|
|
|
explicit BasicAttackBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-12-28 22:04:37 +00:00
|
|
|
/**
|
|
|
|
* @brief Reads a 16bit short from the bitStream and when the actual behavior handling finishes with all of its branches, the bitStream
|
|
|
|
* is then offset to after the allocated bits for this stream.
|
2023-11-12 11:53:03 +00:00
|
|
|
*
|
2022-12-28 22:04:37 +00:00
|
|
|
*/
|
2024-02-27 07:25:44 +00:00
|
|
|
void DoHandleBehavior(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch);
|
2022-12-28 22:04:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Handles a client initialized Basic Attack Behavior cast to be deserialized and verified on the server.
|
2023-11-12 11:53:03 +00:00
|
|
|
*
|
|
|
|
* @param context The Skill's Behavior context. All behaviors in the same tree share the same context
|
2022-12-28 22:04:37 +00:00
|
|
|
* @param bitStream The bitStream to deserialize. BitStreams will always check their bounds before reading in a behavior
|
|
|
|
* and will fail gracefully if an overread is detected.
|
|
|
|
* @param branch The context of this specific branch of the Skill Behavior. Changes based on which branch you are going down.
|
|
|
|
*/
|
2024-02-27 07:25:44 +00:00
|
|
|
void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-12-28 22:04:37 +00:00
|
|
|
/**
|
|
|
|
* @brief Writes a 16bit short to the bitStream and when the actual behavior calculation finishes with all of its branches, the number
|
|
|
|
* of bits used is then written to where the 16bit short initially was.
|
2023-11-12 11:53:03 +00:00
|
|
|
*
|
2022-12-28 22:04:37 +00:00
|
|
|
*/
|
2024-02-27 07:25:44 +00:00
|
|
|
void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-12-28 22:04:37 +00:00
|
|
|
/**
|
|
|
|
* @brief Calculates a server initialized Basic Attack Behavior cast to be serialized to the client
|
2023-11-12 11:53:03 +00:00
|
|
|
*
|
2022-12-28 22:04:37 +00:00
|
|
|
* @param context The Skill's Behavior context. All behaviors in the same tree share the same context
|
|
|
|
* @param bitStream The bitStream to serialize to.
|
|
|
|
* @param branch The context of this specific branch of the Skill Behavior. Changes based on which branch you are going down.
|
|
|
|
*/
|
2024-02-27 07:25:44 +00:00
|
|
|
void DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch);
|
2022-12-28 22:04:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Loads this Behaviors parameters from the database. For this behavior specifically:
|
|
|
|
* max and min damage will always be the same. If min is less than max, they are both set to max.
|
|
|
|
* If an action is not in the database, then no action is taken for that result.
|
2023-11-12 11:53:03 +00:00
|
|
|
*
|
2022-12-28 22:04:37 +00:00
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void Load() override;
|
2022-12-16 06:10:58 +00:00
|
|
|
private:
|
2023-11-12 11:53:03 +00:00
|
|
|
bool m_DontApplyImmune;
|
|
|
|
|
2022-12-16 06:10:58 +00:00
|
|
|
uint32_t m_MinDamage;
|
|
|
|
|
|
|
|
uint32_t m_MaxDamage;
|
|
|
|
|
|
|
|
Behavior* m_OnSuccess;
|
|
|
|
|
|
|
|
Behavior* m_OnFailArmor;
|
2022-12-28 22:04:37 +00:00
|
|
|
|
|
|
|
Behavior* m_OnFailImmune;
|
|
|
|
|
|
|
|
Behavior* m_OnFailBlocked;
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|