Skip to content

Commit

Permalink
Merge pull request #1325 from drzel/improved-flag-pickup-notification
Browse files Browse the repository at this point in the history
Improved flag pickup notification
  • Loading branch information
drzel authored Apr 26, 2024
2 parents 95c7c2b + 791abcc commit e2a2d98
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 85 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ sound files are found in `fortress/sound/hitaudio/` and `fortress/sound/announc
* Server option for making all walls block EMP. Off by default. `localinfo walls_block_emp 1` or `localinfo wbe 1`. (SPAWNFLAG_BLOCK_EMP 4096 will work regardless)
* Server option for setting detpack to solid (blocking). Off by default. `localinfo solid_detpack 1` or `localinfo sdp 1`.
* Server option for overriding map class restrictions (except civilian). `serverinfo override_mapclasses 1` or `serverinfo omc 1`.
* Option for maximum grenades for all classes. `localinfo max_gren1_<class> <number>`, short `localinfo mg1_<classnum> <number>`. Works for gren1s and gren2s. Eg `localinfo max_gren1_scout 0` to remove caltrops or `localinfo mg2_9 2` to reduce max EMPs to 2.
* Option for maximum grenades for all classes. `localinfo max_gren1_<class> <number>`, short `localinfo mg1_<classnum> <number>`. Works for gren1s and gren2s. Eg `localinfo max_gren1_scout 0` to remove caltrops or `localinfo mg2_9 2` to reduce max EMPs to 2. Set to -1 for default.
* Option to fully restock player's clip and finish reload immediately if in progress. `localinfo stock_reload 1` (`localinfo srd 1`) will trigger only on flag capture (with stock_on_cap enabled). `2` will trigger whenever any tfgoal gives you the appropriate ammo.
* Option for statusbar flaginfo. `setinfo sbflaginfo 1` (default). Setting it to `2` will skip the tf tips on respawn and show flag info all the time.
* Admin system created to allow for easy setup of pub/clan/quad/duel games, kick players etc `localinfo adminpwd <password>` and `cmd adminpwd <password>; wait; adminmenu`
Expand All @@ -177,6 +177,7 @@ sound files are found in `fortress/sound/hitaudio/` and `fortress/sound/announc
* Keys and flags glow their colour.
* Option to adjust conussion grenade effect time in seconds. `localinfo cussgrentime`.
* Option to fully restock player on cap. `localinfo stock_on_cap on`.
* Option to strip ammo and grens from defenders within 1500 units of cap point when flag is capped. `localinfo cap_strip 1`.
* Option for packs to fully restock health and armor of player. `localinfo stockfull on`.
* Automatic server-side mvd recording of clan matches. Requires `localinfo serverdemo on`.
* Map vote (4 random maps + current map) during last few minutes of game (shown for newly spawned or toggled with /togglevote).
Expand Down
4 changes: 3 additions & 1 deletion csqc/csextradefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ float vote_list_offset;
entity current_vote;
string vote_list_filter;
float zoomed_in;
float pick_up_time;
float flag_team;

float slot_history[MAX_SLOT_HISTORY_SIZE];
float slot_history_top, slot_under_stack;
Expand Down Expand Up @@ -412,7 +414,7 @@ enum PanelID:float {
HUDP_GRENTIMER,
HUDP_MOTD,
HUDP_GAME_MODE,
HUDP_READY,
HUDP_NOTIFICATION,
HUDP_HEALTH,
HUDP_FACE,
HUDP_AMMO,
Expand Down
4 changes: 4 additions & 0 deletions csqc/events.qc
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ void() CSQC_Parse_Event = {
local float weapon = readfloat();
FO_ReloadSound(weapon);
break;
case MSG_FLAG_PICKUP:
flag_team = readfloat();
pick_up_time = time;
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion csqc/hud.qc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void FO_Hud_Editor_LoadDefaultSettings()
getHudPanel(HUDP_GAME_MODE)->Position = [width - getHudPanel(HUDP_GAME_MODE)->FillSize.x, 30];
getHudPanel(HUDP_GAME_MODE)->Orientation = FO_HUD_INSERT_AFTER;
getHudPanel(HUDP_MOTD)->Position = [(width / 2) - (getHudPanel(HUDP_MOTD)->FillSize.x / 2), 30];
getHudPanel(HUDP_READY)->Position = [(width / 2) - (getHudPanel(HUDP_READY)->FillSize.x / 2), 30];
getHudPanel(HUDP_NOTIFICATION)->Position = [(width / 2) - (getHudPanel(HUDP_NOTIFICATION)->FillSize.x / 2), 30];
getHudPanel(HUDP_MENU_HINT)->Position = [(width / 2) - (getHudPanel(HUDP_MENU)->FillSize.x / 2), 80];
getHudPanel(HUDP_MENU_HINT)->Orientation = FO_HUD_INSERT_MIDDLE;
getHudPanel(HUDP_MENU)->Position = [(width / 2) - (getHudPanel(HUDP_MENU)->FillSize.x / 2), 120];
Expand Down
2 changes: 1 addition & 1 deletion csqc/hud_helpers.qc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void FO_Hud_InitSystemPanels() {
if (panel->System) {
switch (panel->id) {
case HUDP_MOTD:
case HUDP_READY:
case HUDP_NOTIFICATION:
FO_Hud_ShowPanel(i);
break;

Expand Down
49 changes: 46 additions & 3 deletions csqc/status.qc
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void(PanelID panelid, string text) drawGameModePanel = {
}
}

void(PanelID panelid, string text) drawReadyPanel = {
void(PanelID panelid, string text) drawNotificationPanel = {
FO_Hud_Panel* panel = getHudPanel(panelid);

vector position = getPanelPosition(panel);
Expand All @@ -520,7 +520,7 @@ void(PanelID panelid, string text) drawReadyPanel = {
local float pos_aligned;
local string message = "";
if (fo_hud_editor) {
message = "Ready Status";
message = "Notification panel";
if (hud_panel(panelid, position, size, 0.3, panel.Display)) {
// click event
}
Expand Down Expand Up @@ -606,6 +606,49 @@ void(PanelID panelid, string text) drawReadyPanel = {
}
}
}
} else if (pick_up_time && time < pick_up_time + 1.5) {
local vector alert_text_size = MENU_TEXT_MEDIUM * panel.Scale;
local vector alert_text_position;
alert_text_position.y = ScreenSize.y / 3;
alert_text_position.x = (ScreenSize.x / 2) - (size.x / 2);

local string flag_team_str = "the";
local vector menu_text_color = MENU_TEXT_4;

switch(flag_team) {
case 1:
flag_team_str = "blue's";
menu_text_color = MENU_TEXT_BLUE_FO;
break;
case 2:
flag_team_str = "red's";
menu_text_color = MENU_TEXT_RED_FO;
break;
case 3:
flag_team_str = "yellow's";
menu_text_color = MENU_TEXT_YELLOW_FO;
break;
case 4:
flag_team_str = "green's";
menu_text_color = MENU_TEXT_GREEN_FO;
break;
}

local string alert_text_message = sprintf("You got %s flag!", flag_team_str);

pos_aligned = GetTextAlignOffset(
alert_text_position.x,
size.x,
padding,
alert_text_message,
alert_text_size.x,
panel.Orientation
);

HRC_drawstring(
[pos_aligned, alert_text_position.y],
alert_text_message, alert_text_size, menu_text_color, 1, 0
);
}
}
if(message) {
Expand Down Expand Up @@ -1110,7 +1153,7 @@ var FO_Hud_Panel Hud_Panels[] = {
{HUDP_GRENTIMER, "grentimer", FO_HUD_GRENTIMER_NAME, '100 110', '26 26', 1,0,1,0,0, drawGrenTimerPanel, {return "";}},
{HUDP_MOTD, "motd", FO_HUD_MOTD_NAME, '150 100', '100 24', 1,0,1,0,0, drawMOTDPanel, {return SBAR.MOTD;}},
{HUDP_GAME_MODE, "gamemode", FO_HUD_GAME_MODE_NAME, '100 140', '100 10', 1,0,1,0,0, drawGameModePanel, {return "";}},
{HUDP_READY, "ready", FO_HUD_READY_NAME, '10 100', '100 10', 2,0,1,FO_HUD_INSERT_MIDDLE, 1, drawReadyPanel, {return SBAR.Hint;}},
{HUDP_NOTIFICATION, "notification", FO_HUD_NOTIFICATION_NAME, '10 100', '100 10', 2,0,1,FO_HUD_INSERT_MIDDLE, 1, drawNotificationPanel, {return SBAR.Hint;}},
{HUDP_HEALTH, "health", FO_HUD_HEALTH_NAME, '-22 -2', '72 24', 1,0,1,0,0, drawHealthArmourTextPanel, {return ftos(getstatf(STAT_HEALTH));}, 0, 34},
{HUDP_FACE, "face", FO_HUD_FACE_NAME, '-70 -2', '24 24', 1,0,1,0,0, drawFacePanel, {return "";}, 0, 34},
{HUDP_AMMO, "ammo", FO_HUD_AMMO_NAME, '90 -2', '72 24', 1,0,1,0,0, drawAmmoTextPanel, {return ftos(WP_CurrentAmmo());}, 0, 34},
Expand Down
1 change: 1 addition & 0 deletions share/commondefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const float SERVER_FRAME_MS = SERVER_FRAME_DT * 1000.0;
#define MSG_LOGIN 26
#define MSG_HITFLAG 27
#define MSG_RELOADSOUND 28
#define MSG_FLAG_PICKUP 29

#define FLAGINFO_HOME 1
#define FLAGINFO_CARRIED 2
Expand Down
13 changes: 6 additions & 7 deletions share/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ enum {
#define PC_DEMOMAN_GRENADE_INIT_1 4
#define PC_DEMOMAN_GRENADE_INIT_2 4
#define PC_DEMOMAN_GRENADE_MAX_1 4
#define PC_DEMOMAN_GRENADE_MAX_2 4
#define PC_DEMOMAN_GRENADE_MAX_2 1
#define PC_DEMOMAN_TF_ITEMS 0

// Class Details for COMBAT MEDIC
Expand All @@ -1003,7 +1003,7 @@ enum {
#define PC_MEDIC_GRENADE_INIT_1 3
#define PC_MEDIC_GRENADE_INIT_2 3
#define PC_MEDIC_GRENADE_MAX_1 4
#define PC_MEDIC_GRENADE_MAX_2 3
#define PC_MEDIC_GRENADE_MAX_2 2
#define PC_MEDIC_TF_ITEMS 0
#define PC_MEDIC_REGEN_TIME 3 // Number of seconds between each regen.
#define PC_MEDIC_REGEN_AMOUNT 2 // Amount of health regenerated each regen.
Expand Down Expand Up @@ -1043,7 +1043,6 @@ enum {
#define PC_HVYWEAP_TF_ITEMS 0
#define PC_HVYWEAP_CELL_FIRE 7


// Class Details for PYRO
#define PC_PYRO_SKIN 21
#define PC_PYRO_MAXHEALTH 100
Expand All @@ -1065,7 +1064,7 @@ enum {
#define PC_PYRO_GRENADE_INIT_1 1
#define PC_PYRO_GRENADE_INIT_2 4
#define PC_PYRO_GRENADE_MAX_1 4
#define PC_PYRO_GRENADE_MAX_2 4
#define PC_PYRO_GRENADE_MAX_2 1
#define PC_PYRO_TF_ITEMS 0
#define PC_PYRO_AIRBLAST_RANGE 400
#define PC_PYRO_AIRBLAST_CELLS 55
Expand Down Expand Up @@ -1100,7 +1099,7 @@ enum {
#define PC_SPY_GRENADE_INIT_1 2
#define PC_SPY_GRENADE_INIT_2 2
#define PC_SPY_GRENADE_MAX_1 4
#define PC_SPY_GRENADE_MAX_2 2
#define PC_SPY_GRENADE_MAX_2 1
#define PC_SPY_TF_ITEMS 0
#define PC_SPY_CELL_REGEN_TIME 5
#define PC_SPY_CELL_REGEN_AMOUNT 1
Expand Down Expand Up @@ -1129,7 +1128,7 @@ enum {
#define PC_ENGINEER_GRENADE_INIT_1 2
#define PC_ENGINEER_GRENADE_INIT_2 2
#define PC_ENGINEER_GRENADE_MAX_1 4
#define PC_ENGINEER_GRENADE_MAX_2 4
#define PC_ENGINEER_GRENADE_MAX_2 2
#define PC_ENGINEER_TF_ITEMS 0
#define PC_ENGINEER_RAILSPEED 1500

Expand Down Expand Up @@ -1396,7 +1395,7 @@ enum {
#define FO_HUD_MOTD_NAME "MOTD"
#define FO_HUD_MENU_HINT_NAME "Menu Hints"
#define FO_HUD_GAME_MODE_NAME "Game Mode"
#define FO_HUD_READY_NAME "Ready Status"
#define FO_HUD_NOTIFICATION_NAME "Notification"
#define FO_HUD_SHOWSCORES_NAME "Show Scores"
#define FO_HUD_MAP_MENU_NAME "Map Menu"
#define FO_HUD_HEALTH_NAME "Health"
Expand Down
Loading

0 comments on commit e2a2d98

Please sign in to comment.