Skip to content

Commit

Permalink
Merge branch 'specialupdown' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
drzel committed Sep 18, 2024
2 parents b2dfa3c + 43d3771 commit a9e0adf
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 77 deletions.
2 changes: 1 addition & 1 deletion csqc/csextradefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ float vote_list_offset;
entity current_vote;
string vote_list_filter;
float oldbuttons;
float zoomed_in;
float zoom_scale;
float pick_up_time;
float flag_team;

Expand Down
6 changes: 6 additions & 0 deletions csqc/events.qc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ void() CSQC_Parse_Event = {
last_id_time = time;
SBAR.Identify = readstring();
break;
case MSG_PLAYER_DIE:
zoom_scale = 1;
break;
case MSG_PLAYER_SPAWN:
zoom_scale = 1;
break;
case MSG_GRENPRIMED:
float entno = readentitynum();
float grentype = readbyte();
Expand Down
102 changes: 56 additions & 46 deletions csqc/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = {
sentry_preview_range_sphere.scale = 1000;
sentry_preview_range_sphere.alpha = 0.02;

zoom_scale = 1;

print("CSQC initialization finished\n");
};

Expand All @@ -225,8 +227,8 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = {

FO_CussView();

if (zoomed_in)
setviewprop(VF_AFOV, CVARF(fov)/3);
setviewprop(VF_AFOV, CVARF(fov)/zoom_scale);
setsensitivityscaler(1/zoom_scale);

// Draw original sbar, viewsize honoured automatically.
if (!CVARF(fo_fte_hud) || CVARF(fo_legacy_sbar))
Expand Down Expand Up @@ -308,6 +310,9 @@ noref float(string cmd) CSQC_ConsoleCommand = {
localcmd("cmd sentry rotate 15\n");
}
break;
default:
zoom_scale = min(zoom_scale + 1, 5);
break;
}
break;
case "specialdown":
Expand All @@ -322,6 +327,9 @@ noref float(string cmd) CSQC_ConsoleCommand = {
localcmd("cmd sentry rotate -15\n");
}
break;
default:
zoom_scale = max(zoom_scale - 1, 1);
break;
}
break;
case "+slot":
Expand Down Expand Up @@ -752,61 +760,63 @@ noref void CSQC_Input_Frame() {

Sync_GameState();

// Intercept rocket jump
if ((WP_PlayerClass() == PC_SOLDIER || WP_PlayerClass() == PC_PYRO) &&
(input_buttons & BUTTON4))
input_buttons |= BUTTON0 | BUTTON2;

if (WP_PlayerClass() == PC_ENGINEER) {
// Intercept sentry build
if (!getstatf(STAT_HAS_SENTRY) && getstatf(STAT_CELLS) >= 130 && game_state.is_alive && !prematch) {
switch (WP_PlayerClass()) {
case PC_SNIPER:
if (keydowns & BUTTON3) {
if (zoom_scale == 1) {
zoom_scale = 3;
} else {
zoom_scale = 1;
}
}
break;
case PC_SOLDIER:
case PC_PYRO:
// Intercept rocket jump
if (input_buttons & BUTTON4) {
if (keydowns & BUTTON4) {
if (!previewing_sentry) {
SentryPreviewStart();
} else {
SentryPreviewStop();
input_buttons |= BUTTON0 | BUTTON2;
}
break;
case PC_ENGINEER:
// Intercept sentry build
if (!getstatf(STAT_HAS_SENTRY) && getstatf(STAT_CELLS) >= 130 && game_state.is_alive && !prematch) {
if (input_buttons & BUTTON4) {
if (keydowns & BUTTON4) {
if (!previewing_sentry) {
SentryPreviewStart();
} else {
SentryPreviewStop();
}
}
}

input_buttons = input_buttons - BUTTON4;
}
input_buttons = input_buttons - BUTTON4;
}

if (previewing_sentry) {
if (keydowns & BUTTON0) {
if (sentry_fits) {
localcmd(sprintf("cmd build sentry %f\n", anglemod(180 + sentry_preview_offset)));
SentryPreviewStop();
} else {
print("Can't build here\n");
if (previewing_sentry) {
if (keydowns & BUTTON0) {
if (sentry_fits) {
localcmd(sprintf("cmd build sentry %f\n", anglemod(180 + sentry_preview_offset)));
SentryPreviewStop();
} else {
print("Can't build here\n");
}
}
}

if (input_buttons & BUTTON0) {
input_buttons = input_buttons - BUTTON0;
if (input_buttons & BUTTON0) {
input_buttons = input_buttons - BUTTON0;
}
}
}

}

if (prevent_firing && !previewing_sentry && (keyups & BUTTON0)) {
prevent_firing = FALSE;
}

if (prevent_firing) {
input_buttons &= ~BUTTON0;
}
break;
}

// Handle zoom
float prev_zoomed_in = zoomed_in;
if (WP_PlayerClass() == PC_SNIPER)
zoomed_in = input_buttons & BUTTON3;
else
zoomed_in = 0;
if (prevent_firing && !previewing_sentry && (keyups & BUTTON0)) {
prevent_firing = FALSE;
}

if (prev_zoomed_in != zoomed_in)
setsensitivityscaler(zoomed_in ? 1/3 : 1);
if (prevent_firing) {
input_buttons &= ~BUTTON0;
}

PM_InputFrame();
FO_ApplyCussInput();
Expand Down
62 changes: 32 additions & 30 deletions share/commondefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -185,37 +185,39 @@ const float SERVER_FRAME_MS = SERVER_FRAME_DT * 1000.0;
#define GAMEMODE_DUEL 4
#define GAMEMODE_VOTE 8

#define MSG_FLAGINFOINIT 1
#define MSG_FLAGINFO 2

#define MSG_SBAR 4
#define MSG_GRENPRIMED 5
#define MSG_CLIENT_MENU 6
#define MSG_TEAMS_UPDATE 7
#define MSG_CLASSES_UPDATE 8
#define MSG_SENTRY_POS 9
#define MSG_DISPENSER_POS 10
#define MSG_FLAGINFOINIT 1
#define MSG_FLAGINFO 2
// 3
#define MSG_SBAR 4
#define MSG_GRENPRIMED 5
#define MSG_CLIENT_MENU 6
#define MSG_TEAMS_UPDATE 7
#define MSG_CLASSES_UPDATE 8
#define MSG_SENTRY_POS 9
#define MSG_DISPENSER_POS 10
#define MSG_SERVER_ADMIN_INFO 11
#define MSG_CAPTAINS 12
#define MSG_MOTD 13
#define MSG_PREMATCH 14
#define MSG_GRENTHROWN 15
#define MSG_ID 16
#define MSG_TEAM_SCORES 17
#define MSG_VOTE_MAPS 18
#define MSG_VOTE_UPDATE 19
#define MSG_VOTE_MAP_ADD 20
#define MSG_VOTE_MAP_DELETE 21
#define MSG_PAUSE 22
#define MSG_UNPAUSE 23
#define MSG_TFX_GRENTIMER 24
#define MSG_QUAD_ROUND_BEGIN 25
#define MSG_LOGIN 26
#define MSG_HITFLAG 27
#define MSG_RELOADSOUND 28
#define MSG_FLAG_PICKUP 29
#define MSG_FLAG_DROP 30
#define MSG_BUILDING 31
#define MSG_CAPTAINS 12
#define MSG_MOTD 13
#define MSG_PREMATCH 14
#define MSG_GRENTHROWN 15
#define MSG_ID 16
#define MSG_TEAM_SCORES 17
#define MSG_VOTE_MAPS 18
#define MSG_VOTE_UPDATE 19
#define MSG_VOTE_MAP_ADD 20
#define MSG_VOTE_MAP_DELETE 21
#define MSG_PAUSE 22
#define MSG_UNPAUSE 23
#define MSG_TFX_GRENTIMER 24
#define MSG_QUAD_ROUND_BEGIN 25
#define MSG_LOGIN 26
#define MSG_HITFLAG 27
#define MSG_RELOADSOUND 28
#define MSG_FLAG_PICKUP 29
#define MSG_FLAG_DROP 30
#define MSG_BUILDING 31
#define MSG_PLAYER_DIE 32
#define MSG_PLAYER_SPAWN 33

#define FLAGINFO_HOME 1
#define FLAGINFO_CARRIED 2
Expand Down
2 changes: 2 additions & 0 deletions ssqc/client.qc
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,8 @@ void (float all_dimensions) SetDimensions = {
};

void () PutClientInServer = {
UpdateClientPlayerSpawn(self);

if (fo_login_required && self.fo_login == string_null)
UpdateClient_Login(self);

Expand Down
2 changes: 2 additions & 0 deletions ssqc/player.qc
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ void () GibPlayer = {
};

void () PlayerDie = {
UpdateClientPlayerDie(self);

self.spawn_gen += 1;
self.last_death_ctime = self.client_time;

Expand Down
20 changes: 20 additions & 0 deletions ssqc/status.qc
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,26 @@ string GetSBClassInfo(entity pl, float csqcactive)
return st1;
}

void UpdateClientPlayerDie(entity pl) {
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
return;

msg_entity = pl;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, MSG_PLAYER_DIE);
multicast('0 0 0', MULTICAST_ONE_NOSPECS);
}

void UpdateClientPlayerSpawn(entity pl) {
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
return;

msg_entity = pl;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, MSG_PLAYER_SPAWN);
multicast('0 0 0', MULTICAST_ONE_NOSPECS);
}

void UpdateClientBuilding(entity pl) {
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
return;
Expand Down

0 comments on commit a9e0adf

Please sign in to comment.