Skip to content

Commit

Permalink
Don't display score's points for AIs
Browse files Browse the repository at this point in the history
Score's toasts, such as "3 HIT COMBO" will still be displayed.
  • Loading branch information
Nopey committed Jan 13, 2025
1 parent 4da429a commit 37c089f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
13 changes: 7 additions & 6 deletions src/game/scenes/arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ void arena_har_take_hit_hook(int hittee, af_move *move, scene *scene) {
if(h->state == STATE_RECOIL) {
DEBUG("COMBO!");
}
chr_score_hit(score, move->points);
bool no_points = is_demoplay(scene->gs) || !game_state_get_player(scene->gs, hitter)->selectable;
chr_score_hit(score, no_points ? 0 : move->points);
chr_score_interrupt(otherscore, object_get_pos(hit_har));
}

Expand Down Expand Up @@ -1116,13 +1117,13 @@ void arena_render_overlay(scene *scene) {
lang_get((player[1]->pilot->har_id) + 31));
}

// dont render total score in demo play
bool render_totalscore = !is_demoplay(scene->gs);
// Render score stuff
chr_score_render(game_player_get_score(player[0]));
chr_score_render(game_player_get_score(player[0]), render_totalscore);

// Do not render player 2 score in 1 player mode
if(game_player_get_selectable(player[1])) {
chr_score_render(game_player_get_score(player[1]));
}
// Do not render player 2 total score in 1 player mode
chr_score_render(game_player_get_score(player[1]), render_totalscore && game_player_get_selectable(player[1]));

// render ping, if player is networked
if(player[0]->ctrl->type == CTRL_TYPE_NETWORK) {
Expand Down
35 changes: 21 additions & 14 deletions src/game/utils/score.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,26 @@ void chr_score_tick(chr_score *score) {
}
}

void chr_score_render(chr_score *score) {
// Render all texts in list to right spot
char tmp[50];
score_format(score->score, tmp, 50);

void chr_score_render(chr_score *score, bool render_total_points) {
text_settings tconf_score;
text_defaults(&tconf_score);
tconf_score.font = FONT_SMALL;
tconf_score.cforeground = TEXT_COLOR;
tconf_score.shadow = TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM;

if(score->direction == OBJECT_FACE_RIGHT) {
text_render(&tconf_score, TEXT_DEFAULT, score->x, score->y, 200, 6, tmp);
if(render_total_points) {
char tmp[50];
score_format(score->score, tmp, 50);

} else {
int s2len = strlen(tmp) * font_small.w;
text_render(&tconf_score, TEXT_DEFAULT, score->x - s2len, score->y, 200, 6, tmp);
if(score->direction == OBJECT_FACE_RIGHT) {
text_render(&tconf_score, TEXT_DEFAULT, score->x, score->y, 200, 6, tmp);
} else {
int s2len = strlen(tmp) * font_small.w;
text_render(&tconf_score, TEXT_DEFAULT, score->x - s2len, score->y, 200, 6, tmp);
}
}

// Render all texts in list to right spot
iterator it;
score_text *t;
int lastage = -1;
Expand Down Expand Up @@ -252,8 +253,11 @@ int chr_score_interrupt(chr_score *score, vec2i pos) {
if(score->consecutive_hits > 3) {
char *text = omf_calloc(64, 1);
ret = 1;
int len = snprintf(text, 64, "%d consecutive hits ", score->consecutive_hits);
score_format(score->consecutive_hit_score, text + len, 64 - len);
int len = snprintf(text, 64, "%d consecutive hits", score->consecutive_hits);
if(score->consecutive_hit_score > 0) {
text[len++] = ' ';
score_format(score->consecutive_hit_score, text + len, 64 - len);
}
// XXX hardcode the y coordinate for now
chr_score_add(score, text, score->consecutive_hit_score, vec2i_create(pos.x, 130), 1.0f);
}
Expand All @@ -268,8 +272,11 @@ int chr_score_end_combo(chr_score *score, vec2i pos) {
if(score->combo_hits > 1) {
char *text = omf_calloc(64, 1);
ret = 1;
int len = snprintf(text, 64, "%d hit combo ", score->combo_hits);
score_format(score->combo_hit_score * 4, text + len, 64 - len);
int len = snprintf(text, 64, "%d hit combo", score->combo_hits);
if(score->combo_hit_score > 0) {
text[len++] = ' ';
score_format(score->combo_hit_score * 4, text + len, 64 - len);
}
// XXX hardcode the y coordinate for now
chr_score_add(score, text, score->combo_hit_score * 4, vec2i_create(pos.x, 130), 1.0f);
}
Expand Down
3 changes: 2 additions & 1 deletion src/game/utils/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "game/protos/object.h"
#include "utils/list.h"
#include "video/surface.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -43,7 +44,7 @@ void chr_score_set_pos(chr_score *score, int x, int y, int direction);
unsigned int chr_score_get_num_texts(chr_score *score);
void chr_score_free(chr_score *score);
void chr_score_tick(chr_score *score);
void chr_score_render(chr_score *score);
void chr_score_render(chr_score *score, bool render_total_points);
int chr_score_onscreen(chr_score *score);

void chr_score_hit(chr_score *score, int points);
Expand Down

0 comments on commit 37c089f

Please sign in to comment.