Skip to content

Commit

Permalink
Merge branch 'build-better' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
drzel committed Oct 17, 2024
2 parents 8c0b26b + 6a1753a commit a0c71b2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 99 deletions.
90 changes: 47 additions & 43 deletions csqc/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = {
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");
Expand Down Expand Up @@ -223,6 +224,40 @@ void PMD_DrawGraphs(float width);

DEFCVAR_FLOAT(fov, 90);

void SentryPreviewStart() {
sentry_preview_offset = 0;
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();
Expand All @@ -246,6 +281,16 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = {
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;
Expand All @@ -255,6 +300,8 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = {
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 {
Expand Down Expand Up @@ -734,40 +781,6 @@ void FO_ApplyCussInput() {

void PM_InputFrame();

void SentryPreviewStart() {
sentry_preview_offset = 0;
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 CSQC_Input_Frame() {
local float changed_buttons = input_buttons ^ oldbuttons;
oldbuttons = input_buttons;
Expand Down Expand Up @@ -894,15 +907,6 @@ void _Sync_ServerCommandFrame() {

CsGrenTimer::UpdateSoundStack();
UpdateTeamColorCrosshair();

if (previewing_sentry) {
if (game_state.is_alive) {
sentry_fits = CheckArea(sentry_preview, player_localentnum);
sentry_preview.colormod = sentry_fits ? '1 1 1' : '0.5 0.2 0.2';
} else {
SentryPreviewStop();
}
}
}


Expand Down
73 changes: 18 additions & 55 deletions share/engineer.qc
Original file line number Diff line number Diff line change
@@ -1,59 +1,22 @@
float (entity obj, float builder) CheckArea = {
local vector src;
local vector end;
local float pos;
local entity te;
float PlaceSentry(entity sentry, vector builder_org) {
tracebox(sentry.origin, sentry.mins, sentry.maxs, sentry.origin, MOVE_NORMAL, sentry);

pos = pointcontents(obj.origin);
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
return (0);
}
src_x = (obj.origin_x) + 24;
src_y = (obj.origin_y) + 24;
src_z = (obj.origin_z);
pos = pointcontents(src);
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
return (0);
}
end_x = (obj.origin_x) - 16;
end_y = (obj.origin_y) - 16;
end_z = (obj.origin_z);
traceline(src, end, 1, obj);
if (trace_fraction != 1) {
return (0);
}
pos = pointcontents(end);
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
return (0);
}
src_x = (obj.origin_x) - 16;
src_y = (obj.origin_y) + 16;
src_z = (obj.origin_z);
pos = pointcontents(src);
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
return (0);
}
end_x = (obj.origin_x) + 16;
end_y = (obj.origin_y) - 16;
end_z = (obj.origin_z);
traceline(src, end, 1, obj);
if (trace_fraction != 1) {
return (0);
}
pos = pointcontents(end);
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
return (0);
}
/* traceline(builder.origin, obj.origin, 1, builder); */
/* if (trace_fraction != 1) { */
/* return (0); */
/* } */
if (trace_inopen)
return (1);

local vector start = sentry.origin;
start_z = builder_org_z + 64;

tracebox(start, sentry.mins, sentry.maxs, sentry.origin, MOVE_NORMAL, sentry);

te = findradius(obj.origin, 64);
if (te != world) {
if !(te.movetype == MOVETYPE_WALK && builder && num_for_edict(te.owner) == builder) {
return (0);
if (trace_fraction < 1.0) {
tracebox(trace_endpos, sentry.mins, sentry.maxs, trace_endpos, MOVE_NORMAL, sentry);

if (trace_inopen) {
sentry.origin = trace_endpos;
return (1);
}
}
return (1);
};

return (0);
}
2 changes: 1 addition & 1 deletion ssqc/engineer.qc
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ void (float objtobuild, float offset) TeamFortress_Build = {
self.sentry_ticks = 0;
}

if (!CheckArea(newmis, 0)) {
if (!PlaceSentry(newmis, self.origin)) {
sprint(self, PRINT_HIGH, "You can't build here\n");
dremove(newmis);
return;
Expand Down

0 comments on commit a0c71b2

Please sign in to comment.