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 Sep 14, 2024
2 parents c980919 + db33eea commit 7e5c257
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 198 deletions.
27 changes: 0 additions & 27 deletions csqc/events.qc
Original file line number Diff line number Diff line change
Expand Up @@ -362,33 +362,6 @@ void() CSQC_Parse_Event = {
case MSG_BUILDING:
SentryPreviewStop();
break;
case MSG_SENTRY_ROTATE:
sentry_rotate.drawmask = MASK_ENGINE;

local vector origin = getentity(readentitynum(), GE_ORIGINANDVECTORS);
setorigin(sentry_rotate, origin);
sentry_rotate.angles = vectoangles(v_forward);
sentry_rotate.frame = readfloat();
rotating_sentry = TRUE;
break;
case MSG_SENTRY_ROTATE_BY:
local vector origin = getentity(readentitynum(), GE_ORIGINANDVECTORS);
sentry_rotate.frame = readfloat();
local float offset = readfloat() * -1;

if (!rotating_sentry) {
rotating_sentry = TRUE;
setorigin(sentry_rotate, origin);
sentry_rotate.angles = vectoangles(v_forward);
sentry_rotate.angles_y += offset;
sentry_rotate.drawmask = MASK_ENGINE;
}

sentry_rotate.angles_y += offset;
break;
case MSG_SENTRY_DIE:
SentryRotateStop();
break;
case MSG_FLAG_DROP:
pick_up_time = FALSE;
break;
Expand Down
11 changes: 1 addition & 10 deletions csqc/input.qc
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,8 @@ float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent = {
}
break;
case IE_MOUSEDELTA:
if (rotating_sentry) {
sentry_rotate.angles_y = anglemod(sentry_rotate.angles_y + scanx * rotating_sensitivity * -1);
}

if (rotating_preview) {
sentry_preview.angles_y = anglemod(sentry_preview.angles_y + scanx * rotating_sensitivity);
sentry_preview_offset = (sentry_preview_offset + scanx * rotating_sensitivity);
}

if (previewing_sentry) {
sentry_preview.angles_y = anglemod(input_angles_y + (180 - sentry_preview_offset));
sentry_preview.angles_y = anglemod(input_angles_y + (sentry_preview_offset + 180));
}
default:
}
Expand Down
77 changes: 23 additions & 54 deletions csqc/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ float CalculateWaterLevel();
void RenderHitTexts();
entity sentry_preview;
entity sentry_preview_range_sphere;
entity sentry_rotate;
entity temp_sentry;
entity temp_self;
float sentry_preview_offset;
float previewing_sentry;
float rotating_preview;
float rotating_preview_y;
float rotating_sentry;
float rotating_sentry_y;
float rotating_sensitivity = 0.25;
float prevent_firing;
float sentry_fits;

Expand Down Expand Up @@ -231,10 +225,6 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = {
sentry_preview_range_sphere.scale = 1000;
sentry_preview_range_sphere.alpha = 0.02;

precache_model("progs/turrgun.mdl");
sentry_rotate = spawn();
setmodel(sentry_rotate, "progs/turrgun.mdl");

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

Expand Down Expand Up @@ -295,10 +285,6 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = {
temp_sentry.origin = sentry_preview.origin;
local vector v_forward_range = normalize(v_forward) * 1024;
sentry_preview_range_sphere.origin = sentry_preview.origin;

if (rotating_preview) {
setviewprop(VF_CL_VIEWANGLES_Y, rotating_preview_y);
}
} else {
setproperty(VF_DRAWCROSSHAIR, 1); // we want to draw our crosshair!
}
Expand Down Expand Up @@ -346,16 +332,26 @@ noref float(string cmd) CSQC_ConsoleCommand = {
case "specialup":
switch (WP_PlayerClass()) {
case PC_ENGINEER:
if (previewing_sentry) {
sentry_preview.angles_y -= 15;
sentry_preview_offset -= 15;
} else {
localcmd("cmd sentry rotate 15\n");
}
break;
}
localcmd("specialup\n");
break;
case "specialdown":
switch (WP_PlayerClass()) {
case PC_ENGINEER:
if (previewing_sentry) {
sentry_preview.angles_y += 15;
sentry_preview_offset += 15;
} else {
localcmd("cmd sentry rotate -15\n");
}
break;
}
localcmd("specialdown\n");
break;
case "+slot":
Slot_Keydown(stof(argv(1)));
Expand Down Expand Up @@ -767,22 +763,15 @@ void SentryPreviewStart() {
sentry_preview_range_sphere.drawmask = MASK_ENGINE;

previewing_sentry = TRUE;
prevent_firing = TRUE;
}

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

void SentryRotateStop() {
rotating_sentry = FALSE;
rotating_sentry_y = 0;
sentry_rotate.drawmask = 0;
}

noref void CSQC_Input_Frame() {
local float changed_buttons = input_buttons ^ oldbuttons;
oldbuttons = input_buttons;
Expand All @@ -799,23 +788,13 @@ noref void CSQC_Input_Frame() {

if (WP_PlayerClass() == PC_ENGINEER) {
// Intercept sentry build
if (rotating_sentry) {
if (keyups & BUTTON0) {
localcmd(sprintf("cmd sentry rotate mouse %f\n", sentry_rotate.angles_y));
SentryRotateStop();
}
input_buttons &= ~BUTTON0;
} else if (!getstatf(STAT_HAS_SENTRY) && getstatf(STAT_CELLS) >= 130 && game_state.is_alive && !prematch) {
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();

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

Expand All @@ -824,18 +803,11 @@ noref void CSQC_Input_Frame() {

if (previewing_sentry) {
if (keydowns & BUTTON0) {
rotating_preview_y = input_angles_y;
rotating_preview = TRUE;
}

if (keyups & BUTTON0) {
if (sentry_fits) {
localcmd(sprintf("cmd build sentry %f\n", -1 * sentry_preview_offset));
localcmd(sprintf("cmd build sentry %f\n", sentry_preview_offset));
SentryPreviewStop();
} else {
print("Not enough room to build here\n");
rotating_preview_y = 0;
rotating_preview = FALSE;
print("Can't build here\n");
}
}

Expand All @@ -844,13 +816,14 @@ noref void CSQC_Input_Frame() {
}
}

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

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

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

Expand Down Expand Up @@ -927,10 +900,6 @@ void _Sync_ServerCommandFrame() {
if (!game_state.is_alive) {
if (previewing_sentry)
SentryPreviewStop();

if (rotating_sentry) {
SentryRotateStop();
}
}

sentry_fits = CheckArea(temp_sentry, temp_self);
Expand Down
3 changes: 0 additions & 3 deletions share/commondefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ const float SERVER_FRAME_MS = SERVER_FRAME_DT * 1000.0;
#define MSG_FLAG_PICKUP 29
#define MSG_FLAG_DROP 30
#define MSG_BUILDING 31
#define MSG_SENTRY_ROTATE 32
#define MSG_SENTRY_DIE 33
#define MSG_SENTRY_ROTATE_BY 34

#define FLAGINFO_HOME 1
#define FLAGINFO_CARRIED 2
Expand Down
42 changes: 1 addition & 41 deletions ssqc/commands.qc
Original file line number Diff line number Diff line change
Expand Up @@ -740,23 +740,6 @@ float (string arg1, string arg2, string arg3, string arg4) ParseCmds = {
break;
}

/* if (arg2 && arg2 == "rotate" && arg3 && arg3 == "mouse" && arg4) { */
/* if (self.rotating_sentry == world) */
/* break; */

/* self.dimension_see = (self.dimension_see & ~DMN_GHOST) | DMN_HIDDEN; */

/* local entity rs = self.rotating_sentry; */
/* rs.dimension_seen = (rs.dimension_seen & ~(DMN_HIDDEN | DMN_GHOST)) | DMN_NOFLASH; */
/* farg4 = stof(arg4); */
/* rs.angles_y = farg4; */
/* rs.waitmin = anglemod(farg4 - 50); */
/* rs.waitmax = anglemod(farg4 + 50); */
/* FO_Sound(self, CHAN_ITEM, "weapons/turridle.wav", 1, ATTN_NORM); */
/* self.rotating_sentry = world; */
/* break; */
/* } */

//find sentry first
ent = findradius(self.origin, ENG_BUILDING_MAINT_DISTANCE);
while (ent) {
Expand All @@ -767,19 +750,6 @@ float (string arg1, string arg2, string arg3, string arg4) ParseCmds = {
ent = ent.chain;
}

/* if (arg2 && arg2 == "rotate" && arg3 && arg3 == "mwheel" && arg4) { */
/* if (!arg4) */
/* break; */

/* farg4 = stof(arg4); */
/* self.dimension_see = (self.dimension_see & ~DMN_HIDDEN) | DMN_GHOST; */
/* ent.dimension_seen = (ent.dimension_seen & ~DMN_NOFLASH) | DMN_HIDDEN | DMN_GHOST; */
/* if (self.rotating_sentry == world) */
/* self.rotating_sentry = ent; */
/* UpdateClientSentryRotateBy(self, self.rotating_sentry, farg4); */
/* break; */
/* } */

if (!ent) {
sprint(self, PRINT_HIGH, "No sentry in range\n");
break;
Expand All @@ -793,17 +763,7 @@ float (string arg1, string arg2, string arg3, string arg4) ParseCmds = {
sprint(self, PRINT_HIGH, "Sentry detection issue!\n");
break;
}
/* if (arg3 == "mouse" && !arg4) { */
/* if (!self.rotating_sentry == world) */
/* break; */

/* self.dimension_see = (self.dimension_see & ~DMN_HIDDEN) | DMN_GHOST; */
/* ent.dimension_seen = (ent.dimension_seen & ~DMN_NOFLASH) | DMN_HIDDEN | DMN_GHOST; */
/* self.rotating_sentry = ent; */
/* UpdateClientSentryRotate(self, ent); */
/* break; */
/* } */
ent.angles_y += farg3;
ent.angles_y -= farg3;
ent.waitmin = rint(ent.angles_y - 50);
ent.waitmin = anglemod(ent.waitmin);
ent.waitmax = rint(ent.angles_y + 50);
Expand Down
4 changes: 0 additions & 4 deletions ssqc/player.qc
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,6 @@ void () GibPlayer = {
};

void () PlayerDie = {
local entity rs = self.rotating_sentry;
rs.dimension_seen = (rs.dimension_seen & ~(DMN_HIDDEN | DMN_GHOST)) | DMN_NOFLASH;
self.rotating_sentry = world;

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

Expand Down
1 change: 0 additions & 1 deletion ssqc/qw.qc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ float coop;
.float has_dispenser; // TRUE for an ENGINEER if he has a dispenser
.float has_sentry; // TRUE for an ENGINEER if he has a sentry
.entity sentry_ent; // Contains sentry gun entity
.entity rotating_sentry; // Contains sentry gun currently being rotated

.float real_frags; // Used to store the players frags when TeamFrags is On

Expand Down
3 changes: 0 additions & 3 deletions ssqc/sentry.qc
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,6 @@ void () Sentry_Die = {
stuffcmd(self.real_owner, "play misc/chink.wav\n");
local entity ro = self.real_owner;
ro.has_sentry = 0;
ro.dimension_see = (ro.dimension_see & ~DMN_GHOST) | DMN_HIDDEN;
UpdateClientSentryDie(ro);
ro.rotating_sentry = world;

self.tfstate = self.tfstate | TFSTATE_RESPAWN_READY;
self.think = Sentry_Explode;
Expand Down
55 changes: 0 additions & 55 deletions ssqc/status.qc
Original file line number Diff line number Diff line change
Expand Up @@ -767,61 +767,6 @@ void UpdateClientBuilding(entity pl) {
multicast('0 0 0', MULTICAST_ONE_NOSPECS);
}

/* void UpdateClientSentryRotate(entity pl, entity sentry) { */
/* if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE)) */
/* return; */

/* msg_entity = pl; */
/* WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); */
/* WriteByte(MSG_MULTICAST, MSG_SENTRY_ROTATE); */
/* WriteEntity(MSG_MULTICAST, sentry); */

/* local float frame_no; */
/* if (sentry.frame >= 6) { */
/* frame_no = 6; */
/* } else if (sentry.frame >= 3) { */
/* frame_no = 3; */
/* } else { */
/* frame_no = 0; */
/* } */

/* WriteFloat(MSG_MULTICAST, frame_no); */
/* multicast('0 0 0', MULTICAST_ONE_NOSPECS); */
/* } */

/* void UpdateClientSentryRotateBy(entity pl, entity sentry, float offset) { */
/* if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE)) */
/* return; */

/* msg_entity = pl; */
/* WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); */
/* WriteByte(MSG_MULTICAST, MSG_SENTRY_ROTATE_BY); */
/* WriteEntity(MSG_MULTICAST, sentry); */

/* local float frame_no; */
/* if (sentry.frame >= 6) { */
/* frame_no = 6; */
/* } else if (sentry.frame >= 3) { */
/* frame_no = 3; */
/* } else { */
/* frame_no = 0; */
/* } */

/* WriteFloat(MSG_MULTICAST, frame_no); */
/* WriteFloat(MSG_MULTICAST, offset); */
/* multicast('0 0 0', MULTICAST_ONE_NOSPECS); */
/* } */

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

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

void UpdateClientReloadSound(entity pl, float weapon) {
if(!infokeyf(pl, INFOKEY_P_CSQCACTIVE))
return;
Expand Down

0 comments on commit 7e5c257

Please sign in to comment.