Skip to content

Commit 83e919a

Browse files
committed
Merge build better
2 parents c6e188f + 457ed6c commit 83e919a

File tree

5 files changed

+79
-18
lines changed

5 files changed

+79
-18
lines changed

csqc/main.qc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,10 @@ noref float(string cmd) CSQC_ConsoleCommand = {
367367
case PC_ENGINEER:
368368
if (previewing_sentry) {
369369
sentry_preview_offset = anglemod(sentry_preview_offset - 15);
370-
} else {
371-
localcmd("cmd sentry rotate 15\n");
370+
} else if (vlen(PM_Org() - sentry_pos) < ENG_BUILDING_DISMANTLE_DISTANCE) {
371+
update_sentry_angles = time + 0.55;
372+
sentry_angles_y = anglemod(sentry_angles_y - 15);
373+
localcmd(sprintf("cmd sentry angle %f\n", sentry_angles_y));
372374
}
373375
break;
374376
}
@@ -384,8 +386,10 @@ noref float(string cmd) CSQC_ConsoleCommand = {
384386
case PC_ENGINEER:
385387
if (previewing_sentry) {
386388
sentry_preview_offset = anglemod(sentry_preview_offset + 15);
387-
} else {
388-
localcmd("cmd sentry rotate -15\n");
389+
} else if (vlen(PM_Org() - sentry_pos) < ENG_BUILDING_DISMANTLE_DISTANCE) {
390+
update_sentry_angles = time + 0.55;
391+
sentry_angles_y = anglemod(sentry_angles_y + 15);
392+
localcmd(sprintf("cmd sentry angle %f\n", sentry_angles_y));
389393
}
390394
break;
391395
}

csqc/tfx.qc

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
.float teamno;
44
static entity local_player;
55
static float shader_team[2], shader_flag, shader_over_outline;
6+
float update_sentry_angles;
7+
float sentry_angles_y;
68

79
enum {
810
TeamNone = 0,
@@ -270,6 +272,36 @@ float UpdateFlag(float isnew) {
270272
return TRUE;
271273
}
272274

275+
float UpdateSentry(float isnew) {
276+
if (isnew) {
277+
sentry_angles_y = self.angles_y;
278+
} else {
279+
if (update_sentry_angles > time) {
280+
self.angles_y = sentry_angles_y;
281+
} else {
282+
sentry_angles_y = self.angles_y;
283+
}
284+
}
285+
286+
return TRUE;
287+
}
288+
289+
float UpdateSentryBase(float isnew) {
290+
if (isnew) {
291+
sentry_angles_y = self.angles_y;
292+
} else {
293+
if (!SBAR.SentryLevel && SBAR.IsBuilding) {
294+
if (update_sentry_angles > time) {
295+
self.angles_y = sentry_angles_y;
296+
} else {
297+
sentry_angles_y = self.angles_y;
298+
}
299+
}
300+
}
301+
302+
return TRUE;
303+
}
304+
273305
void TFxGrenTimerUpdate(float ent_num, float expiry) {
274306
EntHash* he = EntGet(ent_num);
275307
he->grentimer_expires = expiry;
@@ -316,8 +348,9 @@ void TF_Init() {
316348

317349
shader_over_outline = shaderforname(rnds("over_outline"), "{ sort 7 }");
318350
#endif
319-
320351
deltalisten("progs/ff_flag.mdl", UpdateFlag, 0);
321352
deltalisten("progs/tf_flag.mdl", UpdateFlag, 0);
322353
deltalisten("progs/tf_stan.mdl", UpdateFlag, 0);
354+
deltalisten("progs/turrgun.mdl", UpdateSentry, 0);
355+
deltalisten("progs/turrbase.mdl", UpdateSentryBase, 0);
323356
}

ssqc/commands.qc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,24 @@ float (string arg1, string arg2, string arg3, string arg4) ParseCmds = {
782782
}
783783
ent.nextthink = time + 0.5;
784784
break;
785+
} else if (arg2 == "angle") {
786+
farg3 = stof(arg3);
787+
if (!ent.real_owner.has_sentry || ent.real_owner != self
788+
|| self.classname != "player" || ent == world) {
789+
sprint(self, PRINT_HIGH, "Sentry detection issue!\n");
790+
break;
791+
}
792+
ent.angles_y = farg3;
793+
ent.waitmin = rint(ent.angles_y - 50);
794+
ent.waitmin = anglemod(ent.waitmin);
795+
ent.waitmax = rint(ent.angles_y + 50);
796+
ent.waitmax = anglemod(ent.waitmax);
797+
if (ent.waitmin > ent.waitmax) {
798+
ent.waitmin = ent.waitmax;
799+
ent.waitmax = anglemod(ent.angles_y - 50);
800+
}
801+
ent.nextthink = time + 0.5;
802+
break;
785803
}
786804
sprint(self, PRINT_HIGH, "Invalid choice.\n");
787805
} else {

ssqc/engineer.qc

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

615+
setsize(newmis, tmp1, tmp2);
616+
615617
if (!PlaceSentry(newmis, self.origin)) {
616618
sprint(self, PRINT_HIGH, "You can't build here\n");
617619
dremove(newmis);
@@ -626,6 +628,11 @@ void (float objtobuild, float offset) TeamFortress_Build = {
626628
}
627629

628630
UpdateClientBuilding(self);
631+
632+
if (objtobuild == BUILD_SENTRYGUN) {
633+
UpdateClient_Sentry(self, newmis);
634+
}
635+
629636
self.is_building = objtobuild;
630637
if (!engineer_move) {
631638
self.immune_to_check = time + 5;
@@ -647,7 +654,6 @@ void (float objtobuild, float offset) TeamFortress_Build = {
647654
newmis.movetype = 6;
648655
newmis.solid = 2;
649656
FO_SetModel(newmis, newmis.mdl);
650-
setsize(newmis, tmp1, tmp2);
651657
setorigin(newmis, newmis.origin);
652658
newmis.flags = newmis.flags - (newmis.flags & 512);
653659

@@ -929,18 +935,6 @@ void () DispenserThink = {
929935
self.nextthink = time + 0.3;
930936
};
931937

932-
void UpdateClient_Sentry(entity pl, entity sent) = {
933-
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
934-
return;
935-
msg_entity = pl;
936-
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
937-
WriteByte(MSG_MULTICAST, MSG_SENTRY_POS);
938-
WriteFloat(MSG_MULTICAST, sent.origin.x);
939-
WriteFloat(MSG_MULTICAST, sent.origin.y);
940-
WriteFloat(MSG_MULTICAST, sent.origin.z);
941-
multicast('0 0 0', MULTICAST_ONE_NOSPECS);
942-
}
943-
944938
void UpdateClient_Dispenser(entity pl, entity disp) = {
945939
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
946940
return;

ssqc/status.qc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,18 @@ void UpdateClientBuilding(entity pl) {
787787
multicast('0 0 0', MULTICAST_ONE_NOSPECS);
788788
}
789789

790+
void UpdateClient_Sentry(entity pl, entity sent) = {
791+
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
792+
return;
793+
msg_entity = pl;
794+
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
795+
WriteByte(MSG_MULTICAST, MSG_SENTRY_POS);
796+
WriteFloat(MSG_MULTICAST, sent.origin.x);
797+
WriteFloat(MSG_MULTICAST, sent.origin.y);
798+
WriteFloat(MSG_MULTICAST, sent.origin.z);
799+
multicast('0 0 0', MULTICAST_ONE_NOSPECS);
800+
}
801+
790802
void UpdateClientReloadSound(entity pl, float weapon) {
791803
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
792804
return;

0 commit comments

Comments
 (0)