From f77251c9b6d2b0d20e7141eb51aff6f23b2b3c4c Mon Sep 17 00:00:00 2001 From: Kai-Li Date: Tue, 14 Nov 2023 20:59:38 +0100 Subject: [PATCH] GAME: Add player scores for countering a balloon also changed: - Assist bonus from 1 to 2 - Counter bonus from 2 to 1 --- code/game/g_local.h | 1 + code/game/g_team.h | 6 +++--- code/game/g_trigger.c | 20 ++++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/code/game/g_local.h b/code/game/g_local.h index 691e4066f..8af6610cf 100644 --- a/code/game/g_local.h +++ b/code/game/g_local.h @@ -99,6 +99,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define SCORE_BONUS_DEFENSE_S "defense" #define SCORE_BONUS_RECOVERY_S "recovery" #define SCORE_BONUS_CAPTURE_S "capture" +#define SCORE_BONUS_COUNTER_S "counter" #define SCORE_BONUS_CAPTURE_TEAM_S "capture_team" #define SCORE_BONUS_ASSIST_CAPTURE_S "assist_capture" #define SCORE_BONUS_ASSIST_RETURN_S "assist_return" diff --git a/code/game/g_team.h b/code/game/g_team.h index c41712c29..74f1c9b67 100644 --- a/code/game/g_team.h +++ b/code/game/g_team.h @@ -35,9 +35,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define CTF_FRAG_CARRIER_ASSIST_BONUS 2 // award for fragging a flag carrier if a capture happens almost immediately #define BB_CAPTURE_BONUS 5 // what you get for capturing a balloon -#define BB_DESTROY_BONUS 2 // what you get for destroying a balloon -#define BB_DEFENSE_BONUS 1 // what you get for defending a balloon -#define BB_ASSIST_BONUS 1 // what you get for assisting in capturing a balloon (PadAce) +#define BB_COUNTER_BONUS 1 // what you get for countering a balloon +#define BB_DEFENSE_BONUS 1 // what you get for defending a balloon (PadHero) +#define BB_ASSIST_BONUS 2 // what you get for assisting in capturing a balloon (PadAce) #define CTF_TARGET_PROTECT_RADIUS 1000 // the radius around an object being defended where a target will be worth extra frags #define CTF_ATTACKER_PROTECT_RADIUS 1000 // the radius around an object being defended where an attacker will get extra frags when making kills diff --git a/code/game/g_trigger.c b/code/game/g_trigger.c index dee8bd9b6..5b29fdf72 100644 --- a/code/game/g_trigger.c +++ b/code/game/g_trigger.c @@ -603,7 +603,7 @@ static int FirstPlayerAtBalloon(const gentity_t *balloon, team_t team) { return clientNum; } -static void AddPersPlayerScores(gentity_t *balloon, team_t team) { +static void AddCaptureBalloonScores(gentity_t *balloon, team_t team) { int i, firstAtBalloon = FirstPlayerAtBalloon(balloon, team); for (i = 0; i < level.maxclients; i++) { @@ -627,6 +627,19 @@ static void AddPersPlayerScores(gentity_t *balloon, team_t team) { } } +static void AddCounterBalloonScores(gentity_t *balloon, team_t team) { + int i; + + for (i = 0; i < level.maxclients; i++) { + if ((level.clients[i].sess.sessionTeam == team) && (IsPlayerAtBalloon(i, balloon))) { + gentity_t *ent = (g_entities + i); + + // all players at balloon receive counter points + AddScore(ent, ent->r.currentOrigin, BB_COUNTER_BONUS, SCORE_BONUS_COUNTER_S); + } + } +} + #define BALLOON_FULLY_RAISED_FRAME 11 static void ThinkBalloonzone(gentity_t *self) { @@ -666,7 +679,7 @@ static void ThinkBalloonzone(gentity_t *self) { // TODO: Give more points for capturing than for owning? // Need to test balance! AddTeamScore(self->s.pos.trBase, tteam, (BalloonScore() * 2), SCORE_BONUS_CAPTURE_S); - AddPersPlayerScores(self, tteam); + AddCaptureBalloonScores(self, tteam); trap_SendServerCommand(-1, va("mp \"%s captured by %s Team\"", msg, TeamName(tteam))); } @@ -710,8 +723,7 @@ static void ThinkBalloonzone(gentity_t *self) { self->target_ent->s.frame = 0; level.balloonState[self->count] = '0'; trap_SetConfigstring(CS_BALLOONS, level.balloonState); - - // TODO: Also give players//&team points for destroying a balloon? + AddCounterBalloonScores(self, OtherTeam(tteam)); trap_SendServerCommand(-1, va("mp \"%s destroyed by %s Team\"", msg, TeamName(OtherTeam(tteam)))); }