Skip to content

Build better #1336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
946e906
WIP sentry preview
drzel Apr 29, 2024
6c1fd61
Refactor
drzel Apr 29, 2024
dea4ba5
Don't show crosshair while previewing sentry
drzel Apr 29, 2024
6ac9d0e
Barely working but really naster sentry preview rotation
drzel Apr 29, 2024
77636fd
WIP pass sentry rotation offset to cmd build sentry
drzel Apr 29, 2024
ad73938
Remove green colormod for valid sentry
drzel Apr 30, 2024
07dff8e
Allow building in the air
drzel Apr 30, 2024
d768db1
Don't show sentry preview if player has sentry
drzel Apr 30, 2024
230abad
Fix unlimited sentries, don't show preview without enough ammo, remov…
drzel Apr 30, 2024
befe34d
Actually build the gun
drzel Apr 30, 2024
444259d
No sentry preview in prematch
drzel Apr 30, 2024
35f2738
Stop sentry preview on death
drzel Apr 30, 2024
f2faaf1
Remove debug statement
drzel Apr 30, 2024
00d6b99
Don't try to preview sentry when dead
drzel Apr 30, 2024
ee979ba
Fix mismatch in CheckArea entity bounding boxes
drzel Apr 30, 2024
8779758
Dismantle at close range for still building sentry should return all …
drzel Apr 30, 2024
e16314f
Print how many more cells are needed
drzel Apr 30, 2024
59a07b2
Don't immediately fire gun if cancelling sentry preview while rotating
drzel Apr 30, 2024
6f1fc4e
Don't spawn entities every frame
drzel Apr 30, 2024
829ed8c
Move sentry preview up in CSQC_UpdateView order
drzel Apr 30, 2024
15858a4
Don't close sentry if gun doesn't fit
drzel Apr 30, 2024
0d1785d
Stop preview if building
drzel Apr 30, 2024
9ce0a43
First pass at mouse rotate
drzel May 2, 2024
3bd8bb9
Error go away
drzel May 2, 2024
b09d3b6
WIP do cool things with dimensions, don't send model string, it's alr…
drzel May 2, 2024
e558f1b
Play sound, don't allow rotate when already rotating
drzel May 3, 2024
d88b4d5
Add sentry rotation options, range indicator
drzel May 11, 2024
3cc82c8
refactor
drzel May 13, 2024
d358020
Allow gun placement on z axis, part 1: preview
drzel May 13, 2024
54ea3f8
Lock only mouse y axis when rotating sentry
drzel May 14, 2024
13aec92
Merge branch 'master' into build-better
drzel May 14, 2024
8475cc8
Allow player to build more intuitively
drzel May 14, 2024
4698bd7
Refactor
drzel May 15, 2024
d52f409
Merge master
drzel Jul 10, 2024
6f4f58b
Fix init of sentry
drzel Jul 10, 2024
e2ccab3
Use seperate preview model
drzel Sep 12, 2024
b876769
Remove the traceline requirement of a sentry
drzel Sep 12, 2024
98c394e
Comment out mouse rotate for now
drzel Sep 12, 2024
e82717a
make sentry rotating feel nicer
drzel Sep 14, 2024
bec58b3
Support mousewheel rotation of sentry preview
drzel Sep 14, 2024
a40ff36
Clean up some old rotate stuff
drzel Sep 14, 2024
da5c514
Remove debug statements
drzel Sep 14, 2024
db33eea
Send rotate commands to server if no preview
drzel Sep 14, 2024
52a42c9
More encompassing message
drzel Sep 14, 2024
6cb97a2
You should still be able to rotate sentry while menu is up
drzel Sep 14, 2024
e24f5fb
make sentry preview a bit more transparent
drzel Sep 15, 2024
d5f0cc5
Clean up
drzel Sep 15, 2024
b3b5016
Refactor / remove unneeded temp ents
drzel Sep 16, 2024
4f3da26
Simplify
drzel Sep 16, 2024
4257be9
Don't det building sentry when detting disp
drzel Sep 17, 2024
56e910f
Use pre-existing Engy BUILD_ defines
drzel Sep 17, 2024
5990a5d
Predicted player shouldn't prevent gun build
drzel Sep 29, 2024
8e5da39
WIP
drzel Oct 13, 2024
f5d9d48
Use a tracebox to simplify sentry location
drzel Oct 16, 2024
6a1753a
Make building more flexible
drzel Oct 17, 2024
8300424
Smooth rotation with high ping
drzel Oct 17, 2024
6d6b301
Handle rotating sentry base
drzel Oct 17, 2024
83f58ab
Don't allow client side rotation when not in range
drzel Oct 17, 2024
457ed6c
Temp fix for sentry falling into world before proper fix
drzel Nov 12, 2024
cdf011b
fo_forward_facing_sentry option
drzel Nov 12, 2024
70ab88f
Fix clockwise/anticlockwise
drzel Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions csqc/csextradefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ float vote_selected_index;
float vote_list_offset;
entity current_vote;
string vote_list_filter;
float oldbuttons;
float zoomed_in;
float pick_up_time;
float flag_team;
Expand Down Expand Up @@ -866,6 +867,7 @@ struct {
DEFCVAR_FLOAT(fo_fte_hud, 0);
DEFCVAR_FLOAT(fo_legacy_sbar, 0);
DEFCVAR_FLOAT(fo_csjumpsounds, 1);
DEFCVAR_FLOAT(fo_forward_facing_sentry, 0);

struct GameState {
float localentnum;
Expand Down
1 change: 1 addition & 0 deletions csqc/csprogs.src
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ profile.qc
../share/classes.qc
../share/animate.qc
../share/mcp_precache.qc
../share/engineer.qc
weapon_predict.qc
pmove.qc
tfx.qc
Expand Down
3 changes: 3 additions & 0 deletions csqc/events.qc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ void() CSQC_Parse_Event = {
flag_team = readfloat();
pick_up_time = time;
break;
case MSG_BUILDING:
SentryPreviewStop();
break;
case MSG_FLAG_DROP:
pick_up_time = FALSE;
break;
Expand Down
3 changes: 1 addition & 2 deletions csqc/input.qc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent = {
}
return TRUE;
}
}
}
case IE_KEYUP:
switch (scanx) {
case K_ESCAPE:
Expand All @@ -117,7 +117,6 @@ float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent = {
return TRUE;
}
break;
default:
}
}

Expand Down
182 changes: 171 additions & 11 deletions csqc/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ void FO_Hud_Init();
float InFluid(vector point);
float CalculateWaterLevel();
void RenderHitTexts();
entity sentry_preview;
entity sentry_preview_range_sphere;
float sentry_preview_offset;
float previewing_sentry;
float prevent_firing;
float sentry_fits;

void GetSelf() = {
self = findfloat(world, entnum, player_localentnum);
Expand Down Expand Up @@ -58,7 +64,6 @@ float RemoveFromSlotHistory(float slot) {
}
}


static void BindAlias(TFAlias* tfa) {
if (tfa->impulse == 0 && tfa->cmd == "") // Some aliases are !csqc-only
return;
Expand Down Expand Up @@ -90,7 +95,6 @@ void ClientSettings_Check();
noref void(float apiver, string enginename, float enginever) CSQC_Init = {
print("CSQC Started\n");

// precache_model("progs/weapons/v_rock.mdl");

// for (float i = 0; i < HudIcons.length; i++) {
// precache_pic(HudIcons[i].icon);
Expand All @@ -106,6 +110,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = {
FO_Predict_Init();
CsGrenTimer::Init();

registercommand("specialup");
registercommand("specialdown");

registercommand("+slot");
registercommand("-slot");

Expand Down Expand Up @@ -180,6 +187,19 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = {
FO_Menu_Game(TRUE);

pengine.view_mask = MASK_VIEWMODEL; // Start with engine models.

precache_model("progs/turrpreview.mdl");
sentry_preview = spawn();
setmodel(sentry_preview, "progs/turrpreview.mdl");
setsize(sentry_preview, '-16 -16 0', '16 16 48');
sentry_preview.alpha = 0.25;

precache_model("progs/sphere.mdl");
sentry_preview_range_sphere = spawn();
setmodel(sentry_preview_range_sphere, "progs/sphere.mdl");
sentry_preview_range_sphere.scale = 1000;
sentry_preview_range_sphere.alpha = 0.02;

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

Expand All @@ -199,11 +219,50 @@ void PMD_DrawGraphs(float width);

DEFCVAR_FLOAT(fov, 90);

void SentryPreviewStart() {
if (CVARF(fo_forward_facing_sentry)) {
sentry_preview_offset = 0;
} else {
sentry_preview_offset = 180;
}

sentry_preview.angles_y = input_angles_y;
sentry_preview.drawmask = MASK_ENGINE;

local vector sphere_colormod = '1 1 1';
switch (team_no) {
case 1:
sphere_colormod = '0 0.4 1';
break;
case 2:
sphere_colormod = '1 0 0';
break;
case 3:
sphere_colormod = '1 1 0';
break;
case 4:
sphere_colormod = '0 1 0';
break;
}

sentry_preview_range_sphere.colormod = sphere_colormod * 4;
sentry_preview_range_sphere.drawmask = MASK_ENGINE;

previewing_sentry = TRUE;
prevent_firing = TRUE;
}

void SentryPreviewStop() {
previewing_sentry = FALSE;
sentry_preview.drawmask = 0;
sentry_preview_range_sphere.drawmask = 0;
}

noref void(float width, float height, float menushown) CSQC_UpdateView = {
float fts = perf_start_sample(&frame_timing);
clearscene();
setproperty(VF_DRAWWORLD, 1); // we want to draw our world!
setproperty(VF_DRAWCROSSHAIR, 1); // we want to draw our crosshair!

FO_CussView();

if (zoomed_in)
Expand All @@ -221,6 +280,34 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = {
if (PM_Enabled())
PM_UpdateView();

if (previewing_sentry) {
if (game_state.is_alive) {
} else {
}
}

if (previewing_sentry) {
if (!game_state.is_alive) {
SentryPreviewStop();
} else {
}
makevectors(view_angles);
local vector v_forward_sentry;
v_forward_sentry.z = (normalize(v_forward) * 64).z;
v_forward_z = 0;
local vector xy_pos = normalize(v_forward) * 64;
v_forward_sentry.x = xy_pos.x;
v_forward_sentry.y = xy_pos.y;

sentry_preview.origin = PM_Org() + v_forward_sentry;
sentry_fits = PlaceSentry(sentry_preview, PM_Org());
sentry_preview.colormod = sentry_fits ? '1 1 1' : '0.5 0.2 0.2';
sentry_preview_range_sphere.origin = sentry_preview.origin;
sentry_preview.angles_y = anglemod(view_angles_y + sentry_preview_offset);
} else {
setproperty(VF_DRAWCROSSHAIR, 1); // we want to draw our crosshair!
}

renderscene();

FO_CussCrosshair(width, height);
Expand Down Expand Up @@ -261,6 +348,32 @@ noref float(string cmd) CSQC_ConsoleCommand = {
local float grentype;

switch(argv(0)) {
case "specialup":
switch (WP_PlayerClass()) {
case PC_ENGINEER:
if (previewing_sentry) {
sentry_preview_offset = anglemod(sentry_preview_offset - 15);
} else if (vlen(PM_Org() - sentry_pos) < ENG_BUILDING_DISMANTLE_DISTANCE) {
update_sentry_angles = time + 0.55;
sentry_angles_y = anglemod(sentry_angles_y - 15);
localcmd(sprintf("cmd sentry angle %f\n", sentry_angles_y));
}
break;
}
break;
case "specialdown":
switch (WP_PlayerClass()) {
case PC_ENGINEER:
if (previewing_sentry) {
sentry_preview_offset = anglemod(sentry_preview_offset + 15);
} else if (vlen(PM_Org() - sentry_pos) < ENG_BUILDING_DISMANTLE_DISTANCE) {
update_sentry_angles = time + 0.55;
sentry_angles_y = anglemod(sentry_angles_y + 15);
localcmd(sprintf("cmd sentry angle %f\n", sentry_angles_y));
}
break;
}
break;
case "+slot":
Slot_Keydown(stof(argv(1)));
break;
Expand Down Expand Up @@ -531,11 +644,11 @@ static vector FO_Conc_Offset() {
float i, rot = 0;

if (!IsClownMode(CLOWN_CONC)) {
table = conc_curve;
len = conc_curve.length;
table = conc_curve;
len = conc_curve.length;
} else {
table = clown_curve;
len = clown_curve.length;
table = clown_curve;
len = clown_curve.length;
}

for (i = 0; i < len - 1; i++) {
Expand Down Expand Up @@ -633,7 +746,7 @@ void FO_ApplyCussInput() {
float modify_forward = TRUE;

if ((!pmove_onground && (fo_config.fo_concuss & FOC_EASY_AIR)) ||
(pmove_onground && (fo_config.fo_concuss & FOC_EASY_GROUND)))
(pmove_onground && (fo_config.fo_concuss & FOC_EASY_GROUND)))
modify_forward = input_buttons & BUTTON0;

if (modify_forward) {
Expand All @@ -646,13 +759,60 @@ void FO_ApplyCussInput() {
void PM_InputFrame();

noref void CSQC_Input_Frame() {
local float changed_buttons = input_buttons ^ oldbuttons;
oldbuttons = input_buttons;

local float keydowns = changed_buttons & input_buttons;
local float keyups = changed_buttons & ~input_buttons;

Sync_GameState();

// Intercept rocket jump;
// Intercept rocket jump
if ((WP_PlayerClass() == PC_SOLDIER || WP_PlayerClass() == PC_PYRO) &&
(input_buttons & BUTTON4))
(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) {
if (input_buttons & BUTTON4) {
if (keydowns & BUTTON4) {
if (!previewing_sentry) {
SentryPreviewStart();
} else {
SentryPreviewStop();
}
}

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 (input_buttons & BUTTON0) {
input_buttons = input_buttons - BUTTON0;
}
}

}

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

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

// Handle zoom
float prev_zoomed_in = zoomed_in;
if (WP_PlayerClass() == PC_SNIPER)
Expand Down Expand Up @@ -753,7 +913,7 @@ float FoLogin(string token, float print_error) {
}

if (token == "") {
if (print_error)
if (print_error)
print("Token required: Please sign-up at fortressone.org and follow the instructions to generate your login token.\n");
return FALSE;
}
Expand Down
10 changes: 6 additions & 4 deletions csqc/menu.qc
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,11 @@ var fo_menu FO_MENU_BUILD = {
};
var fo_menu FO_MENU_SENTRY_MAINTAIN = {
[0,0], [300,200], "Sentry Gun", FO_MENU_FLAG_CENTER | FO_MENU_FLAG_SHOW_SHORTCUTS, {
{"1","Anticlockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate 45\n");Menu_Cancel();},MENU_BUTTON},
{"1","Anticlockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate -45\n");Menu_Cancel();},MENU_BUTTON},
{"2","180 Degrees","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate 180\n");Menu_Cancel();},MENU_BUTTON},
{"3","Clockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate -45\n");Menu_Cancel();},MENU_BUTTON},
{"3","Clockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate 45\n");Menu_Cancel();},MENU_BUTTON},
MenuSpacer,
/* {"4","With Mouse","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate mouse\n");Menu_Cancel();},MENU_BUTTON}, */
{"5","Nothing","","",FO_MENU_STATE_NORMAL,{Menu_Cancel();},MENU_BUTTON},
}, 5, TRUE, {
if(vlen(PM_Org() - sentry_pos) > ENG_BUILDING_MAINT_DISTANCE) {
Expand All @@ -339,10 +340,11 @@ var fo_menu FO_MENU_SENTRY_MAINTAIN = {

var fo_menu FO_MENU_SENTRY_ROTATE = {
[0,0], [300,200], "Rotate Sentry Gun", FO_MENU_FLAG_CENTER | FO_MENU_FLAG_SHOW_SHORTCUTS, {
{"1","Anticlockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate 45\n");Menu_Cancel();},MENU_BUTTON},
{"1","Anticlockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate -45\n");Menu_Cancel();},MENU_BUTTON},
{"2","180 Degrees","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate 180\n");Menu_Cancel();},MENU_BUTTON},
{"3","Clockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate -45\n");Menu_Cancel();},MENU_BUTTON},
{"3","Clockwise","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate 45\n");Menu_Cancel();},MENU_BUTTON},
MenuSpacer,
/* {"4","With Mouse","","",FO_MENU_STATE_NORMAL,{localcmd("cmd sentry rotate mouse\n");Menu_Cancel();},MENU_BUTTON}, */
{"5","Nothing","","",FO_MENU_STATE_NORMAL,{Menu_Cancel();},MENU_BUTTON},
}, 5, TRUE, {
if(vlen(PM_Org() - sentry_pos) > ENG_BUILDING_MAINT_DISTANCE) {
Expand Down
Loading