Skip to content

Commit

Permalink
Refactored awards, server msg in general, match formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
darkshade9 committed Aug 30, 2024
1 parent 3756694 commit 0bfcf2c
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/action/a_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ void Cmd_Pickup_f(edict_t* ent)

// 5 minute timer
if(message_timer_check(300)) {
lc_discord_webhook(msg, SERVER_MSG);
lc_discord_webhook(msg, SERVER_MSG, AWARD_NONE);
gi.cprintf(ent, PRINT_HIGH, "Pickup request sent.\n");
} else {
gi.cprintf(ent, PRINT_HIGH, "It is too early to send another request, please wait.\n");
Expand Down
2 changes: 1 addition & 1 deletion src/action/a_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void SendScores(void)
LogEndMatchStats(); // Generates end of match stats
}
#if AQTION_CURL
lc_discord_webhook(MM_MATCH_END_MSG, MATCH_END_MSG);
lc_discord_webhook(MM_MATCH_END_MSG, MATCH_END_MSG, AWARD_NONE);
#endif
#endif
// Stats: Reset roundNum
Expand Down
22 changes: 14 additions & 8 deletions src/action/a_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,12 @@ qboolean CheckTimelimit( void )
CenterPrintAll( "3 MINUTES LEFT..." );
gi.sound( &g_edicts[0], CHAN_VOICE | CHAN_NO_PHS_ADD, gi.soundindex("tng/3_minutes.wav"), 1.0, ATTN_NONE, 0.0 );
timewarning = 1;
#if AQTION_CURL
if (!game.time_warning) {
lc_discord_webhook(MM_3_MIN_WARN, SERVER_MSG, AWARD_NONE);
game.time_warning = true;
}
#endif
}
}
// Deathmatch and Team Deathmatch warnings
Expand All @@ -2573,14 +2579,14 @@ qboolean CheckTimelimit( void )
CenterPrintAll( "3 MINUTES LEFT..." );
gi.sound( &g_edicts[0], CHAN_VOICE | CHAN_NO_PHS_ADD, gi.soundindex("tng/3_minutes.wav"), 1.0, ATTN_NONE, 0.0 );
timewarning = 1;
#if AQTION_CURL
if (!game.time_warning) {
lc_discord_webhook(MM_3_MIN_WARN, SERVER_MSG, AWARD_NONE);
game.time_warning = true;
}
#endif
}
}
#if AQTION_CURL
else if ( use_warnings->value && matchmode->value ){
if( timelimit->value > 5 && level.matchTime >= ((timelimit->value - 5) * 60) && !during_countdown)
lc_discord_webhook(MM_FIVE_MIN_WARN, FIVE_MIN_WARN);
}
#endif
}

return false;
Expand Down Expand Up @@ -2994,7 +3000,7 @@ int CheckTeamRules (void)
}
#if AQTION_CURL
if (game.roundNum == 0) // Only announce on game start, so match pauses don't send the msg
lc_discord_webhook(buf, MATCH_START_MSG);
lc_discord_webhook(buf, MATCH_START_MSG, AWARD_NONE);
#endif

CenterPrintAll( buf );
Expand Down Expand Up @@ -3907,7 +3913,7 @@ void TallyEndOfLevelTeamScores (void)
LogEndMatchStats(); // Generates end of match logs
}
#if AQTION_CURL
lc_discord_webhook(TP_MATCH_END_MSG, MATCH_END_MSG);
lc_discord_webhook(TP_MATCH_END_MSG, MATCH_END_MSG, AWARD_NONE);
#endif
#endif
// Stats: Reset roundNum
Expand Down
2 changes: 1 addition & 1 deletion src/action/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ void Cmd_Say_f (edict_t * ent, qboolean team, qboolean arg0, qboolean partner_ms

// Send message to Discord -- this must come before the newline add or it screws up formatting in-game
#if AQTION_CURL
lc_discord_webhook(text, CHAT_MSG);
lc_discord_webhook(text, CHAT_MSG, AWARD_NONE);
#endif

Q_strncatz(text, "\n", sizeof(text));
Expand Down
19 changes: 10 additions & 9 deletions src/action/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,15 @@ typedef enum {
SERVER_MSG = BIT(5), // 32
MATCH_START_MSG = BIT(6), // 64
MATCH_END_MSG = BIT(7), // 128
FIVE_MIN_WARN = BIT(8), // 256
NOTIFY_MAX = BIT(9) // 512 (enable all)
NOTIFY_MAX = BIT(8) // 256 (enable all)
} Discord_Notifications;

// Default messages
#define MM_MATCH_END_MSG "Matchmode Results"
#define TP_MATCH_END_MSG "Teamplay Results"
#define DM_MATCH_END_MSG "Deathmatch Results"
#define MM_FIVE_MIN_WARN "5 minutes remaining in the map"
#define MM_3_MIN_WARN "3 minutes remaining in the map"
#define TP_MATCH_START_MSG "Match is about to begin!"
#define TP_MATCH_END_MSG "Match has ended!"

//deadflag
#define DEAD_NO 0
Expand Down Expand Up @@ -809,6 +808,11 @@ typedef struct
char* bot_file_path[MAX_QPATH];
int used_bot_personalities;
#endif

#if AQTION_CURL
// Discord Webhook limits
qboolean time_warning;
#endif
}
game_locals_t;

Expand Down Expand Up @@ -1047,6 +1051,7 @@ typedef enum {

// Awards
typedef enum {
AWARD_NONE,
ACCURACY,
IMPRESSIVE,
EXCELLENT,
Expand Down Expand Up @@ -1326,10 +1331,6 @@ extern cvar_t *esp_debug; // Enable or disable debug mode (very spammy)
// 2023
extern cvar_t *use_killcounts; // Adjust how kill streaks are counted
extern cvar_t *am; // Enable or disable Attract Mode (ltk bots)
extern cvar_t *am_newnames; // Enable or disable new names for Attract Mode (ltk bots)
extern cvar_t *am_botcount; // Number of bots in Attract Mode
extern cvar_t *am_delay; // Delay between bot spawns after players leave in Attract Mode (not implemented)
extern cvar_t *am_team; // Set which team the bots will join in Attract Mode
extern cvar_t *zoom_comp; // Enable or disable zoom compensation
extern cvar_t *item_kit_mode; // Enable or disable item kit mode
extern cvar_t *gun_dualmk23_enhance; // Enable or disable enhanced dual mk23s (laser + silencer)
Expand Down Expand Up @@ -2935,6 +2936,6 @@ void FireTimedMessages(void);
void lc_shutdown_function(void);
qboolean lc_init_function(void);
void lc_once_per_gameframe(void);
void lc_discord_webhook(char* message, Discord_Notifications msgtype);
void lc_discord_webhook(char* message, Discord_Notifications msgtype, Awards awardtype);
void lc_start_request_function(request_t* request);
#endif
4 changes: 0 additions & 4 deletions src/action/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,6 @@ cvar_t *g_spawn_items;
// 2023
cvar_t *use_killcounts; // Display kill counts in console to clients on frag
cvar_t *am; // Attract mode toggle
cvar_t *am_newnames; // Attract mode new names, use new LTK bot names
cvar_t *am_botcount; // Attract mode botcount, how many bots at minimum at all times
cvar_t *am_delay; // Attract mode delay, unused at the moment
cvar_t *am_team; // Attract mode team, which team do you want the bots to join
cvar_t *zoom_comp; // Compensates zoom-in frames with ping (high ping = fewer frames)
cvar_t *item_kit_mode; // Toggles item kit mode
cvar_t *gun_dualmk23_enhance; // Enables laser sight for dual mk23 pistols
Expand Down
10 changes: 5 additions & 5 deletions src/action/p_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void Announce_Reward(edict_t *ent, int rewardType) {
ent->client->resp.awardstats[rewardType]++;

#if AQTION_CURL
lc_discord_webhook(buf, AWARD_MSG);
lc_discord_webhook(buf, AWARD_MSG, rewardType);
#endif

CenterPrintAll(buf);
Expand Down Expand Up @@ -1181,7 +1181,7 @@ void ClientObituary(edict_t * self, edict_t * inflictor, edict_t * attacker)
PrintDeathMessage(death_msg, self);
//Using discord webhook for death messaging
#if AQTION_CURL
lc_discord_webhook(death_msg, DEATH_MSG);
lc_discord_webhook(death_msg, DEATH_MSG, AWARD_NONE);
#endif
IRC_printf(IRC_T_KILL, death_msg);
AddKilledPlayer(self->client->attacker, self);
Expand Down Expand Up @@ -1216,7 +1216,7 @@ void ClientObituary(edict_t * self, edict_t * inflictor, edict_t * attacker)
sprintf( death_msg, "%s %s\n", self->client->pers.netname, message );
//Using discord webhook for death messaging
#if AQTION_CURL
lc_discord_webhook(death_msg, DEATH_MSG);
lc_discord_webhook(death_msg, DEATH_MSG, AWARD_NONE);
#endif
PrintDeathMessage(death_msg, self );
IRC_printf( IRC_T_DEATH, death_msg );
Expand Down Expand Up @@ -1572,7 +1572,7 @@ void ClientObituary(edict_t * self, edict_t * inflictor, edict_t * attacker)
PrintDeathMessage(death_msg, self);
//Using discord webhook for death messaging
#if AQTION_CURL
lc_discord_webhook(death_msg, DEATH_MSG);
lc_discord_webhook(death_msg, DEATH_MSG, AWARD_NONE);
#endif
IRC_printf(IRC_T_KILL, death_msg);
AddKilledPlayer(attacker, self);
Expand Down Expand Up @@ -1620,7 +1620,7 @@ void ClientObituary(edict_t * self, edict_t * inflictor, edict_t * attacker)
PrintDeathMessage(death_msg, self);
//Using discord webhook for death messaging
#if AQTION_CURL
lc_discord_webhook(death_msg, DEATH_MSG);
lc_discord_webhook(death_msg, DEATH_MSG, AWARD_NONE);
#endif
IRC_printf(IRC_T_DEATH, death_msg);

Expand Down
2 changes: 1 addition & 1 deletion src/action/p_hud.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void BeginIntermission(edict_t *targ)
}
#if AQTION_CURL
if(!teamplay->value)
lc_discord_webhook(DM_MATCH_END_MSG, MATCH_END_MSG);
lc_discord_webhook(DM_MATCH_END_MSG, MATCH_END_MSG, AWARD_NONE);
#endif
#endif

Expand Down
Loading

0 comments on commit 0bfcf2c

Please sign in to comment.