Skip to content

Commit

Permalink
GAME: Add player scores for countering a balloon
Browse files Browse the repository at this point in the history
also changed:
- Assist bonus from 1 to 2
- Counter bonus from 2 to 1
  • Loading branch information
kai-li-wop committed Nov 14, 2023
1 parent d2c84e1 commit f77251c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions code/game/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions code/game/g_team.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions code/game/g_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)));
}
Expand Down Expand Up @@ -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))));
}
Expand Down

0 comments on commit f77251c

Please sign in to comment.