Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset accumulatedDamage #808 #867

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cdogs/actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
#define GRIMACE_MELEE_TICKS 19
#define DAMAGE_TEXT_DISTANCE_RESET_THRESHOLD (ACTOR_W / 2)
#define FOOTPRINT_MAX 8
#define GAME_TICKS_PER_SECOND 60 // Assuming 60 ticks per second for accumulatedDamage reset
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the game is 70FPS
please use FPS_FRAMELIMIT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as advised


CArray gPlayerIds;

Expand Down Expand Up @@ -142,6 +143,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 1 second of ticks passed
actor->damageCooldownTicks += ticks;
if (actor->accumulatedDamage)
{
if (actor->damageCooldownTicks >= GAME_TICKS_PER_SECOND)
{
actor->accumulatedDamage = 0;
actor->damageCooldownTicks = 0;
}
}
}

actor->slideLock = MAX(0, actor->slideLock - ticks);
Expand Down Expand Up @@ -2206,6 +2218,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
Loading