-
Notifications
You must be signed in to change notification settings - Fork 31
Add cg_damagePlums #56
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,9 @@ DECLARE_EVENT( EV_TAUNT_NO ), | |
| DECLARE_EVENT( EV_TAUNT_FOLLOWME ), | ||
| DECLARE_EVENT( EV_TAUNT_GETFLAG ), | ||
| DECLARE_EVENT( EV_TAUNT_GUARDBASE ), | ||
| DECLARE_EVENT( EV_TAUNT_PATROL ) | ||
| DECLARE_EVENT( EV_TAUNT_PATROL ), | ||
|
|
||
| DECLARE_EVENT( EV_DAMAGEPLUM ) // damage plum | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, I've come up with a way to keep network compatibility!
0001-fix-don-t-introduce-new-event-reuse-EV_SCOREPLUM.patch patch textFrom 0cefcfcdc83db1ad2f9c263362ca704dca69cd40 Mon Sep 17 00:00:00 2001
From: WofWca <wofwca@protonmail.com>
Date: Sun, 1 Feb 2026 18:52:10 +0400
Subject: [PATCH] fix: don't introduce new event, reuse EV_SCOREPLUM
This fixes inability to play back demos that were recorded
in the new version on a client that doesn't know
about the `EV_DAMAGEPLUM` event. See
https://github.com/ec-/baseq3a/pull/56#issuecomment-3772877175.
This will display damage plums as score plums in older clients.
---
code/cgame/cg_event.c | 10 +++++-----
code/game/bg_events.h | 4 +---
code/game/bg_public.h | 1 +
code/game/g_combat.c | 3 ++-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/code/cgame/cg_event.c b/code/cgame/cg_event.c
index 15390dcb..fe33a047 100644
--- a/code/cgame/cg_event.c
+++ b/code/cgame/cg_event.c
@@ -960,11 +960,11 @@ void CG_EntityEvent( centity_t *cent, vec3_t position, int entityNum ) {
#endif
case EV_SCOREPLUM:
- CG_ScorePlum( cent->currentState.otherEntityNum, cent->lerpOrigin, cent->currentState.time );
- break;
-
- case EV_DAMAGEPLUM:
- CG_DamagePlum( cent->lerpOrigin, cent->currentState.time );
+ if (cent->currentState.eventParm & SCOREPLUM_IS_DAMAGEPLUM) {
+ CG_DamagePlum( cent->lerpOrigin, cent->currentState.time );
+ } else {
+ CG_ScorePlum( cent->currentState.otherEntityNum, cent->lerpOrigin, cent->currentState.time );
+ }
break;
//
diff --git a/code/game/bg_events.h b/code/game/bg_events.h
index 27d74e09..b9e0b2ce 100644
--- a/code/game/bg_events.h
+++ b/code/game/bg_events.h
@@ -108,9 +108,7 @@ DECLARE_EVENT( EV_TAUNT_NO ),
DECLARE_EVENT( EV_TAUNT_FOLLOWME ),
DECLARE_EVENT( EV_TAUNT_GETFLAG ),
DECLARE_EVENT( EV_TAUNT_GUARDBASE ),
-DECLARE_EVENT( EV_TAUNT_PATROL ),
-
-DECLARE_EVENT( EV_DAMAGEPLUM ) // damage plum
+DECLARE_EVENT( EV_TAUNT_PATROL )
#ifdef EVENT_ENUMS
, DECLARE_EVENT( EV_MAX )
diff --git a/code/game/bg_public.h b/code/game/bg_public.h
index c5374159..af02efe6 100644
--- a/code/game/bg_public.h
+++ b/code/game/bg_public.h
@@ -355,6 +355,7 @@ typedef enum {
#undef EVENT_ENUMS
} entity_event_t;
+#define SCOREPLUM_IS_DAMAGEPLUM 0x01
typedef enum {
GTS_RED_CAPTURE,
diff --git a/code/game/g_combat.c b/code/game/g_combat.c
index 4639789a..9156bc84 100644
--- a/code/game/g_combat.c
+++ b/code/game/g_combat.c
@@ -36,13 +36,14 @@ void DamagePlum( gentity_t *attacker, vec3_t origin, int damage ) {
return;
}
- plum = G_TempEntity( origin, EV_DAMAGEPLUM );
+ plum = G_TempEntity( origin, EV_SCOREPLUM );
// only send this temp entity to the attacker
plum->r.svFlags |= SVF_SINGLECLIENT;
plum->r.singleClient = attacker->s.number;
//
plum->s.otherEntityNum = attacker->s.number;
plum->s.time = damage;
+ plum->s.eventParm = SCOREPLUM_IS_DAMAGEPLUM;
}
/*
--
2.41.0
Maybe one should consider hiding them completely, e.g. by providing an out-of-range
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Solid idea. I've stopped pushing over here but implemented in https://github.com/ernie/trinity (which has adopted the quake live style font, as well) |
||
|
|
||
| #ifdef EVENT_ENUMS | ||
| , DECLARE_EVENT( EV_MAX ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,27 @@ void ScorePlum( gentity_t *ent, vec3_t origin, int score ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plum->s.time = score; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ============ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DamagePlum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ============ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void DamagePlum( gentity_t *attacker, vec3_t origin, int damage ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gentity_t *plum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( !attacker || !attacker->client || !attacker->client->pers.damagePlums) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plum = G_TempEntity( origin, EV_DAMAGEPLUM ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // only send this temp entity to the attacker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plum->r.svFlags |= SVF_SINGLECLIENT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plum->r.singleClient = attacker->s.number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plum->s.otherEntityNum = attacker->s.number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plum->s.time = damage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that you followed the example of baseq3a/code/cgame/cg_playerstate.c Lines 483 to 527 in aa8dac0
This would also allow to use the option even if the server doesn't support it. Maybe I'm micro-optimizing here, but I think that we should expect the "damage" events to take up a significant portion of the traffic?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They don’t seem to be appreciably noisy in my testing, but that’s helped by aggregating damage during server frames and sending just one. My initial try was to do exactly what you said re: estimating the damage client side. I ran into issues with things like splash damage, though, because the client doesn’t know the split of damage per player hit. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ============ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AddScore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -805,6 +826,8 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int asave; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int knockback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qboolean found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef MISSIONPACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vec3_t bouncedir, impactpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1018,6 +1041,24 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attacker->client->damage.amount += take + asave; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( !OnSameTeam( targ, attacker ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // accumulate damage per target for damage plums | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| found = qfalse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for ( i = 0; i < attacker->client->damagePlumCount; i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( attacker->client->damagePlums[i].clientNum == targ->s.number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attacker->client->damagePlums[i].damage += take + asave; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| found = qtrue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( !found && attacker->client->damagePlumCount < MAX_CLIENTS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attacker->client->damagePlums[attacker->client->damagePlumCount].clientNum = targ->s.number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attacker->client->damagePlums[attacker->client->damagePlumCount].damage = take + asave; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VectorCopy( targ->r.currentOrigin, attacker->client->damagePlums[attacker->client->damagePlumCount].origin ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attacker->client->damagePlums[attacker->client->damagePlumCount].origin[2] += 24; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attacker->client->damagePlumCount++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // add to the damage inflicted on a player this frame | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There really is a lot of common code between
CG_AddScorePlumand this. Maybe some could be factored out?Although maybe not, the original code is also full of copy-paste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my thinking. It’s weird but also follows the style of the original