Skip to content

Commit d900619

Browse files
committed
Merge branch 'specialupdown' into staging
2 parents 128cdc3 + 8c34c5a commit d900619

File tree

9 files changed

+27
-166
lines changed

9 files changed

+27
-166
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ sound files are found in `fortress/sound/hitaudio/` and `fortress/sound/announc
9494
* `+special2` Same as `special2`, but also has `+rj` for Soldier and Pyro.
9595
* `specialup` Engineer: `cmd sentry rotate -15`, Spy: `cmd disguise prev`.
9696
* `specialdown` Engineer: `cmd sentry rotate 15`, Spy: `cmd disguise next`.
97+
* `zoomin` and `zoomout` commands that adjust sens with zoom. 5 levels.
9798
* `setinfo hold_grens` for press and hold `+grenade1` and `+grenade2`
9899
* `setinfo hold_fiegn` for press and hold feigning
99100
* `setinfo hold_detpack` for press and hold detpack

csqc/main.qc

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = {
113113
registercommand("specialup");
114114
registercommand("specialdown");
115115

116+
registercommand("zoomin");
117+
registercommand("zoomout");
118+
116119
registercommand("+slot");
117120
registercommand("-slot");
118121

@@ -289,6 +292,14 @@ void Slot_Keyup(float slot) {
289292
localcmd("-attack\n");
290293
}
291294

295+
void ZoomIn() {
296+
zoom_scale = min(zoom_scale + 1, 5);
297+
}
298+
299+
void ZoomOut() {
300+
zoom_scale = max(zoom_scale - 1, 1);
301+
}
302+
292303
void W_ChangeToSlotAlternate(string opt1, string opt2, string opt3, string opt4);
293304

294305
noref float(string cmd) CSQC_ConsoleCommand = {
@@ -300,6 +311,9 @@ noref float(string cmd) CSQC_ConsoleCommand = {
300311
switch(argv(0)) {
301312
case "specialup":
302313
switch (WP_PlayerClass()) {
314+
case PC_SNIPER:
315+
ZoomIn();
316+
break;
303317
case PC_SPY:
304318
localcmd("cmd disguise prev\n");
305319
break;
@@ -310,13 +324,13 @@ noref float(string cmd) CSQC_ConsoleCommand = {
310324
localcmd("cmd sentry rotate 15\n");
311325
}
312326
break;
313-
default:
314-
zoom_scale = min(zoom_scale + 1, 5);
315-
break;
316327
}
317328
break;
318329
case "specialdown":
319330
switch (WP_PlayerClass()) {
331+
case PC_SNIPER:
332+
ZoomOut();
333+
break;
320334
case PC_SPY:
321335
localcmd("cmd disguise next\n");
322336
break;
@@ -327,11 +341,14 @@ noref float(string cmd) CSQC_ConsoleCommand = {
327341
localcmd("cmd sentry rotate -15\n");
328342
}
329343
break;
330-
default:
331-
zoom_scale = max(zoom_scale - 1, 1);
332-
break;
333344
}
334345
break;
346+
case "zoomin":
347+
ZoomIn();
348+
break;
349+
case "zoomout":
350+
ZoomOut();
351+
break;
335352
case "+slot":
336353
Slot_Keydown(stof(argv(1)));
337354
break;

share/defs.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@ struct Slot { int id; };
446446
#define TF_SCAN_ENEMY 43 // Scout: Toggle scanning of enemies
447447
#define TF_SCAN_FRIENDLY 44 // Scout: Toggle scanning of friendlies
448448
#define TF_SCAN_SOUND 45 // Scout: Toggle scanner sound
449-
#define TF_ZOOMTOGGLE 46 // Sniper: Toggle zoom mode on/off
450-
#define TF_ZOOMIN 47 // Sniper: Zoom in (while zoom mode is on)
451-
#define TF_ZOOMOUT 48 // Sniper: Zoom out (while zoom mode is on)
449+
// 46
450+
// 47
451+
// 48
452452
#define TF_DEMOMAN_DETPACK 49 // Demoman: Bring up detpack menu
453453
#define TF_DETPACK 50 // Demoman: Detpack Pre-Impulse
454454
#define TF_DETPACK_STOP 51 // Demoman: Impulse to stop setting detpack
@@ -1609,9 +1609,6 @@ TFAlias client_aliases[] = {
16091609
{"scansound", TF_SCAN_SOUND},
16101610
{"scanf", TF_SCAN_FRIENDLY},
16111611
{"scane", TF_SCAN_ENEMY},
1612-
{"zoomtoggle", TF_ZOOMTOGGLE},
1613-
{"zoomin", TF_ZOOMIN},
1614-
{"zoomout", TF_ZOOMOUT},
16151612
{"detpipe", TF_PB_DETONATE},
16161613
{"+det5", TF_DETPACK_5},
16171614
{"-det5", TF_DETPACK_STOP},

ssqc/client.qc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ entity(float ino) Finditem;
5050
void (entity Item, entity AP, entity Goal) tfgoalitem_GiveToPlayer;
5151

5252
void () CTF_FlagCheck;
53-
void (entity pl) Sniper_ZoomReset;
5453
void () StartTimer;
5554
void () StopTimer;
5655
void () StartQuadRound;
@@ -1759,8 +1758,6 @@ void () ClientKill = {
17591758
}
17601759
}
17611760

1762-
Sniper_ZoomReset(self);
1763-
17641761
set_suicide_frame();
17651762
self.modelindex = modelindex_player;
17661763

@@ -2042,7 +2039,6 @@ void (entity p) SetVoteParams = {
20422039
p.th_pain = player_pain;
20432040
p.th_die = PlayerDie;
20442041
p.height = 0;
2045-
Sniper_ZoomReset(p);
20462042

20472043
p.deadflag = 0;
20482044
p.pausetime = 0;
@@ -2276,7 +2272,6 @@ void () PutClientInServer = {
22762272
self.th_pain = player_pain;
22772273
self.th_die = PlayerDie;
22782274
self.height = 0;
2279-
Sniper_ZoomReset(self);
22802275

22812276
self.deadflag = 0;
22822277
self.pausetime = 0;
@@ -3875,8 +3870,6 @@ string (entity pe_target, entity pe_attacker, float pf_deathmsg) GetDeathMessage
38753870
void (entity targ, entity attacker) ClientObituary = {
38763871
local string deathstring;
38773872

3878-
Sniper_ZoomReset(targ);
3879-
38803873
if (cb_prematch)
38813874
return;
38823875

ssqc/help.qc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ void () Help_ShowSniper = {
6767
sprint(self, PRINT_HIGH, Q"\sf\s - Throw Flare\n");
6868
sprint(self, PRINT_HIGH, Q"\smouse2\s - Prime/throw Hand Grenade\n");
6969
sprint(self, PRINT_HIGH, "\nClass aliases for Sniper:\n");
70-
sprint(self, PRINT_HIGH, Q"\szoomtoggle\s - Toggle zoom mode\n");
7170
sprint(self, PRINT_HIGH, Q"\szoomin\s - Zoom in (for adjusting zoom while in zoom mode)\n");
7271
sprint(self, PRINT_HIGH, Q"\szoomout\s - Zoom out (for adjusting zoom while in zoom mode)\n");
73-
sprint(self, PRINT_HIGH, "\nSettings for Sniper:\n");
74-
sprint(self, PRINT_HIGH, Q"\szf \"fov\"\s - The default zoom fov which zoomtoggle zooms to (default 30)\n");
75-
sprint(self, PRINT_HIGH, Q"\szs \"fov\"\s - The fov increments/decrements used by zoomin/zoomout (default 20)\n");
7672
sprint(self, PRINT_HIGH, "Usage: setinfo <setting> <value>\n");
7773
};
7874

ssqc/qw.qc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,11 @@ float remote_client_time();
5353
.float is_button_feigning; // TRUE for a SPY if they're feigning death with +feign or +special
5454
.float feign_next_damage; // TRUE for a SPY if they're going to feign death on next damage
5555
.float is_unabletospy; // TRUE for a SPY if they can't go undercover
56-
.float is_zooming; // TRUE for a SNIPER if they're currently zoomed in
5756
.float has_throwngren; // TRUE for a player that has thrown a grenade (won't get a free suicide)
5857
.float has_changedteam; // TRUE for a player that has changed team
5958
.float has_changedclass; // TRUE for a player that has changed class
6059
.float has_disconnected; // TRUE if the player has disconnected
6160
.float has_menutimer; // TRUE if the player has an active menu timer
62-
.float default_sensitivity; // Player's default (non-zoomed) sensitivity
63-
.float default_fov; // Player's default (non-zoomed) fov
64-
.float current_fov; // Player's current field of view
65-
.float zoom_level; // Start zooming to this fov next frame
66-
.float zoom_fov; // The default fov to zoom in to when pressing special button
67-
.float zoom_last; // The last used zoom fov by the player - zoom to this when toggling zoom
6861
.float has_voted_map; // Map option that player voted for
6962
.float spawn_time; // Time when player spawned
7063
.float menu_time; // Time when vote map menu was first issued

ssqc/sniper.qc

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,119 +2,6 @@
22
// Functions for the SNIPER class and associated weaponry
33
//========================================================
44

5-
void (float zoom_to) Sniper_Zoom = {
6-
self.default_fov = stof(infokey(self, "df"));
7-
self.default_sensitivity = stof(infokey(self, "ds"));
8-
self.zoom_fov = stof(infokey(self, "zf"));
9-
10-
if (self.default_fov == 0)
11-
return;
12-
13-
if (zoom_to >= self.default_fov)
14-
Sniper_ZoomReset(self);
15-
else if (zoom_to != self.current_fov) {
16-
if (zoom_to < self.default_fov)
17-
self.zoom_last = zoom_to;
18-
self.current_fov = zoom_to;
19-
stuffcmd(self, "fov ");
20-
stuffcmd(self, ftos(zoom_to));
21-
stuffcmd(self, "\n");
22-
23-
if (self.default_sensitivity > 0) {
24-
stuffcmd(self, "sensitivity ");
25-
stuffcmd(self, ftos(self.default_sensitivity * zoom_to / self.default_fov));
26-
stuffcmd(self, "\n");
27-
}
28-
}
29-
};
30-
31-
void (entity pl) Sniper_ZoomReset = {
32-
pl.default_sensitivity = stof(infokey(pl, "ds"));
33-
pl.default_fov = stof(infokey(pl, "df"));
34-
35-
pl.is_zooming = 0;
36-
37-
if (pl.default_fov > 0) {
38-
pl.current_fov = pl.default_fov;
39-
stuffcmd(pl, "fov ");
40-
stuffcmd(pl, ftos(pl.default_fov));
41-
stuffcmd(pl, "\n");
42-
}
43-
44-
if (pl.default_sensitivity > 0) {
45-
stuffcmd(pl, "sensitivity ");
46-
stuffcmd(pl, ftos(pl.default_sensitivity));
47-
stuffcmd(pl, "\n");
48-
}
49-
};
50-
51-
void () Sniper_ZoomToggle = {
52-
local float magnification = 0;
53-
local float zoom_to = 0;
54-
55-
if (self.playerclass != PC_SNIPER)
56-
return;
57-
58-
self.default_fov = stof(infokey(self, "df"));
59-
self.default_sensitivity = stof(infokey(self, "ds"));
60-
self.zoom_fov = stof(infokey(self, "zf"));
61-
62-
if (self.default_fov == 0) {
63-
sprint(self, PRINT_HIGH, "Use \"setinfo df <fov>\" to set default fov to use sniper zoom. Use \"setinfo ds <sensitivity>\" to set default sensitivity for sensitivity scaling.\n");
64-
return;
65-
}
66-
67-
if (self.is_zooming) {
68-
self.is_zooming = 0;
69-
zoom_to = self.default_fov;
70-
sprint(self, PRINT_HIGH, "Zoomed out\n");
71-
} else {
72-
self.is_zooming = 1;
73-
if (self.zoom_last && self.zoom_last < self.default_fov)
74-
zoom_to = self.zoom_last;
75-
else if (self.zoom_fov)
76-
zoom_to = self.zoom_fov;
77-
else
78-
zoom_to = 30;
79-
80-
magnification = floor(self.default_fov / zoom_to);
81-
sprint(self, PRINT_HIGH, ftos(magnification), "x zoom\n");
82-
}
83-
84-
Sniper_Zoom(zoom_to);
85-
};
86-
87-
void (float zoom_in) Sniper_ZoomAdjust = {
88-
local float zoom_to = 0;
89-
local float zoom_steps = 0;
90-
91-
if (self.playerclass != PC_SNIPER || !self.is_zooming)
92-
return;
93-
94-
zoom_steps = stof(infokey(self, "zs"));
95-
if (!zoom_steps)
96-
zoom_steps = 5;
97-
98-
if (self.default_fov == 0) {
99-
sprint(self, PRINT_HIGH, "Use \"setinfo df <fov>\" to set default fov to use sniper zoom. Use \"setinfo ds <sensitivity>\" to set default sensitivity for sensitivity scaling.\n");
100-
return;
101-
}
102-
103-
if (zoom_in)
104-
zoom_to = self.current_fov - zoom_steps;
105-
else
106-
zoom_to = self.current_fov + zoom_steps;
107-
108-
if (zoom_to <= 10)
109-
zoom_to = 10;
110-
else if (zoom_to >= self.default_fov)
111-
zoom_to = self.default_fov;
112-
113-
self.zoom_last = zoom_to;
114-
115-
Sniper_Zoom(zoom_to);
116-
};
117-
1185
void () SniperSight_Update = {
1196
local vector org;
1207

ssqc/tfort.qc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ void () UseSpecialSkill = {
4848
case PC_SCOUT:
4949
self.impulse = TF_DASH;
5050
break;
51-
case PC_SNIPER:
52-
self.impulse = TF_ZOOMTOGGLE;
53-
break;
5451
case PC_DEMOMAN:
5552
self.impulse = TF_PB_DETONATE;
5653
break;

ssqc/weapons.qc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,11 @@ void () PipebombTouch;
3030

3131
void () SniperSight_Create;
3232

33-
void (float zoom_to) Sniper_Zoom;
34-
3533
void () Help_Show;
3634
void () TeamFortress_Inventory;
3735
void () TeamFortress_SaveMe;
3836
void (entity pe_player, float f_type) CF_Identify;
3937
void () TeamFortress_ReloadNext;
40-
void () Sniper_ZoomToggle;
41-
void (float zoom_in) Sniper_ZoomAdjust;
4238
void () TeamFortress_StatusQuery;
4339
void () CF_Scout_Dash;
4440
void () CF_Spy_DisguiseStop;
@@ -2552,22 +2548,6 @@ void () W_WeaponFrame = {
25522548
}
25532549
}
25542550

2555-
if (self.playerclass == PC_SNIPER) {
2556-
if (self.impulse == TF_SPECIAL_SKILL || self.impulse == TF_ZOOMTOGGLE) {
2557-
Sniper_ZoomToggle();
2558-
self.impulse = 0;
2559-
return;
2560-
} else if (self.impulse == TF_ZOOMIN || (self.is_zooming && self.impulse == TF_WEAPPREV)) {
2561-
Sniper_ZoomAdjust(1);
2562-
self.impulse = 0;
2563-
return;
2564-
} else if (self.impulse == TF_ZOOMOUT || (self.is_zooming && self.impulse == TF_WEAPNEXT)) {
2565-
Sniper_ZoomAdjust(0);
2566-
self.impulse = 0;
2567-
return;
2568-
}
2569-
}
2570-
25712551
// whitelist of commands that can be used even when reloading
25722552
switch (self.impulse)
25732553
{

0 commit comments

Comments
 (0)