Skip to content

Commit f5d9d48

Browse files
committed
Use a tracebox to simplify sentry location
1 parent 8e5da39 commit f5d9d48

File tree

3 files changed

+12
-59
lines changed

3 files changed

+12
-59
lines changed

csqc/main.qc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void adjustEntityAboveGround(entity ent) {
230230
tracebox(startPos, ent.mins, ent.maxs, endPos, MOVE_NORMAL, ent);
231231

232232
// Move the entity up to be 1 unit above the ground
233-
ent.origin[2] = trace_endpos[2] - (ent.mins[2] - ent.maxs[2]) + 1; // 1 unit above the ground
233+
ent.origin[2] = trace_endpos[2] + 1; // 1 unit above the ground
234234
}
235235

236236
noref void(float width, float height, float menushown) CSQC_UpdateView = {
@@ -265,7 +265,7 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = {
265265
v_forward_sentry.y = xy_pos.y;
266266

267267
sentry_preview.origin = PM_Org() + v_forward_sentry;
268-
adjustEntityAboveGround(sentry_preview);
268+
/* adjustEntityAboveGround(sentry_preview); */
269269
sentry_preview_range_sphere.origin = sentry_preview.origin;
270270
sentry_preview.angles_y = anglemod(view_angles_y + sentry_preview_offset);
271271
} else {
@@ -879,7 +879,7 @@ void _Sync_ServerCommandFrame() {
879879

880880
if (previewing_sentry) {
881881
if (game_state.is_alive) {
882-
sentry_fits = CheckArea(sentry_preview, player_localentnum);
882+
sentry_fits = CheckArea(sentry_preview, edict_num(player_localentnum));
883883
sentry_preview.colormod = sentry_fits ? '1 1 1' : '0.5 0.2 0.2';
884884
} else {
885885
SentryPreviewStop();

share/engineer.qc

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,12 @@
1-
float (entity obj, float builder) CheckArea = {
2-
local vector src;
3-
local vector end;
4-
local float pos;
5-
local entity te;
1+
float (entity obj, entity builder) CheckArea = {
2+
vector start, end;
3+
start = obj.origin;
4+
end = start;
5+
tracebox(start, obj.mins, obj.maxs, end, MOVE_NORMAL, builder);
66

7-
pos = pointcontents(obj.origin);
8-
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
7+
if (trace_inopen) {
8+
return (1);
9+
} else {
910
return (0);
1011
}
11-
src_x = (obj.origin_x) + 24;
12-
src_y = (obj.origin_y) + 24;
13-
src_z = (obj.origin_z);
14-
pos = pointcontents(src);
15-
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
16-
return (0);
17-
}
18-
end_x = (obj.origin_x) - 16;
19-
end_y = (obj.origin_y) - 16;
20-
end_z = (obj.origin_z);
21-
traceline(src, end, 1, obj);
22-
if (trace_fraction != 1) {
23-
return (0);
24-
}
25-
pos = pointcontents(end);
26-
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
27-
return (0);
28-
}
29-
src_x = (obj.origin_x) - 16;
30-
src_y = (obj.origin_y) + 16;
31-
src_z = (obj.origin_z);
32-
pos = pointcontents(src);
33-
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
34-
return (0);
35-
}
36-
end_x = (obj.origin_x) + 16;
37-
end_y = (obj.origin_y) - 16;
38-
end_z = (obj.origin_z);
39-
traceline(src, end, 1, obj);
40-
if (trace_fraction != 1) {
41-
return (0);
42-
}
43-
pos = pointcontents(end);
44-
if ((pos == CONTENT_SOLID) || (pos == CONTENT_SKY)) {
45-
return (0);
46-
}
47-
/* traceline(builder.origin, obj.origin, 1, builder); */
48-
/* if (trace_fraction != 1) { */
49-
/* return (0); */
50-
/* } */
51-
52-
te = findradius(obj.origin, 64);
53-
if (te != world) {
54-
if !(te.movetype == MOVETYPE_WALK && builder && num_for_edict(te.owner) == builder) {
55-
return (0);
56-
}
57-
}
58-
return (1);
5912
};

ssqc/engineer.qc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ void (float objtobuild, float offset) TeamFortress_Build = {
612612
self.sentry_ticks = 0;
613613
}
614614

615-
if (!CheckArea(newmis, 0)) {
615+
if (!CheckArea(newmis, self)) {
616616
sprint(self, PRINT_HIGH, "You can't build here\n");
617617
dremove(newmis);
618618
return;

0 commit comments

Comments
 (0)