Skip to content

Commit

Permalink
Reset accumulatedDamage #808 (#867)
Browse files Browse the repository at this point in the history
add variable damageCooldownTicks to Actor, in UpdateActorState reset Actor's accumulatedDamage if thier damageCooldownTicks is greater than one second
  • Loading branch information
Hrvt2 authored Dec 6, 2024
1 parent 4992b43 commit 38ae30a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cdogs/actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions src/cdogs/actors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 38ae30a

Please sign in to comment.