From 38ae30a1a8c7a79d8884d3a50d24beebbd737f9f Mon Sep 17 00:00:00 2001 From: Hrvt2 Date: Fri, 6 Dec 2024 04:23:50 +0100 Subject: [PATCH] Reset accumulatedDamage #808 (#867) add variable damageCooldownTicks to Actor, in UpdateActorState reset Actor's accumulatedDamage if thier damageCooldownTicks is greater than one second --- src/cdogs/actors.c | 12 ++++++++++++ src/cdogs/actors.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/cdogs/actors.c b/src/cdogs/actors.c index dccf6cad9..446409624 100644 --- a/src/cdogs/actors.c +++ b/src/cdogs/actors.c @@ -142,6 +142,17 @@ void UpdateActorState(TActor *actor, int ticks) } actor->petrified = MAX(0, actor->petrified - ticks); actor->confused = MAX(0, actor->confused - ticks); + + // Reset accumulated damage if FPS_FRAMELIMIT passed since taking damage + actor->damageCooldownTicks += ticks; + if (actor->accumulatedDamage) + { + if (actor->damageCooldownTicks >= FPS_FRAMELIMIT) + { + actor->accumulatedDamage = 0; + actor->damageCooldownTicks = 0; + } + } } actor->slideLock = MAX(0, actor->slideLock - ticks); @@ -2206,6 +2217,7 @@ void ActorHit(const NThingDamage d) } CA_FOREACH_END() a->accumulatedDamage = damage; + a->damageCooldownTicks = 0; GameEvent s = GameEventNew(GAME_EVENT_ADD_PARTICLE); s.u.AddParticle.Class = diff --git a/src/cdogs/actors.h b/src/cdogs/actors.h index ed15b8468..ac69268c5 100644 --- a/src/cdogs/actors.h +++ b/src/cdogs/actors.h @@ -154,6 +154,7 @@ typedef struct Actor int slideLock; // For damage text int accumulatedDamage; + int damageCooldownTicks; // Facial expression when melee or taking damage int grimaceCounter;