New weapon, two new attacks

This commit is contained in:
Vladislav Khorev committed 2026-11-26 00:35:41 +06:00
1 parent 60e84c077c
commit 722e5eb5ed
24 files changed
+650 -76

No files matched your search

+35 -10
View File
@@ -16,6 +16,7 @@ namespace FRG {
constexpr float VISIBLE_RANGE = 6.f;
// Distance at which a character starts attacking its target.
constexpr float kAttackRange = 1.25f;
constexpr float kJumpAttackRange = 5.0f;
// How close the player must be to a peaceful NPC to start a conversation.
constexpr float kNpcTalkDistance = 1.35f;
@@ -29,11 +30,12 @@ enum class AnimationState {
WALK = 1,
STAND_TO_ACTION = 2,
ACTION_ATTACK = 3,
ACTION_ATTACK_2 = 4,
ACTION_IDLE = 5,
ACTION_TO_STAND = 6,
ACTION_TO_DEATH = 7,
DEATH_IDLE = 8,
ACTION_IDLE = 4,
ACTION_TO_STAND = 5,
ACTION_TO_DEATH = 6,
DEATH_IDLE = 7,
ACTION_ATTACK_JUMP = 8,
ACTION_ATTACK_POWER = 9,
};
@@ -83,6 +85,22 @@ public:
AnimationState currentState = AnimationState::STAND;
float attack_cooldown = 0.f;
// Jump attack is selected by an ordinary hostile-target command, but all
// timing and movement are authoritative simulation state.
bool jumpAttackUnlocked = false;
bool jumpAttackPending = false;
bool jumpAttackActive = false;
bool jumpAttackImpactConsumed = false;
int jumpAttackCooldownTicks = 0;
int jumpAttackAnimationSubframe = 0; // 1000 units per animation frame.
std::string jumpAttackTargetId;
Vec3fp jumpAttackStartPosition;
Vec3fp jumpAttackLandingPosition;
bool powerAttackPending = false;
int powerAttackCooldownTicks = 0;
std::string powerAttackTargetId;
// Weapon visibility toggle (changes during animation)
bool showWeapon = true;
@@ -99,11 +117,11 @@ public:
// Frame counts are immutable metadata copied from loaded clips during
// character construction. Simulation advances animationFrame itself.
float animationFrame = 0.0f;
std::array<int, 9> animationStartFrames = {{0, 0, 0, 0, 0, 0, 0, 0, 0}};
std::array<int, 9> animationFrameCounts = {{1, 1, 1, 1, 1, 1, 1, 1, 1}};
std::array<float, 9> animationPlaybackRates = {{
std::array<int, 10> animationStartFrames = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
std::array<int, 10> animationFrameCounts = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
std::array<float, 10> animationPlaybackRates = {{
1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f}};
1.0f, 1.0f, 1.0f, 1.0f, 1.0f}};
// --- Movement / visual parameters ---
fp walkSpeed = static_cast<fp>(3.0f);
@@ -157,8 +175,12 @@ public:
const LocationNetworkState& location);
void forceReplan(const LocationNetworkState& location);
void stopAndRotateToTarget(std::string characterId);
void leaveBattleState();
void resetPlayerAfterDeath();
void tryAttackCombo();
bool tryPowerAttack(const std::string& targetId);
bool reserveJumpAttack(const std::string& targetId);
void cancelPendingJumpAttack();
void beginJumpAttack(const Vec3fp& landingPosition);
void setHp(float newHp);
CharacterUpdateEvents update(std::int64_t deltaMs, const CharacterUpdateContext& context);
void setAnimationMetadata(AnimationState state, int startFrame, int frameCount);
@@ -189,6 +211,8 @@ struct CharacterUpdateContext {
struct CharacterUpdateEvents {
bool attackImpact = false;
bool jumpAttackImpact = false;
bool powerAttackImpact = false;
bool deathAnimationComplete = false;
bool navigationRequested = false;
bool forceNavigationReplan = false;
@@ -197,6 +221,7 @@ struct CharacterUpdateEvents {
std::string arrivedCallbackName;
std::string attackTargetId;
Vec3fp attackDirection;
float attackDamage = 10.f;
};
} // namespace FRG