Skip to content

Commit 10ff5a4

Browse files
committed
Disguise next and previous
1 parent c32243d commit 10ff5a4

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ sound files are found in `fortress/sound/hitaudio/` and `fortress/sound/announc
9292
* New buttons (not impulses):
9393
* `+special` Scout: `dash`, Demoman: `detpipe`, Medic: `aura`, Hwguy: `lock`, Pyro: `airblast`, Spy: `+feign`, Engineer: `toggledispenser`.
9494
* `+special2` Same as `special2`, but also has `+rj` for Soldier and Pyro.
95+
* `specialup` Engineer: `cmd sentry rotate -15`, Spy: `cmd disguise prev`.
96+
* `specialdown` Engineer: `cmd sentry rotate 15`, Spy: `cmd disguise next`.
9597
* `setinfo hold_grens` for press and hold `+grenade1` and `+grenade2`
9698
* `setinfo hold_fiegn` for press and hold feigning
9799
* `setinfo hold_detpack` for press and hold detpack

csqc/main.qc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ noref float(string cmd) CSQC_ConsoleCommand = {
332332
case "specialup":
333333
switch (WP_PlayerClass()) {
334334
case PC_SPY:
335-
localcmd("cmd disguise next\n");
335+
localcmd("cmd disguise prev\n");
336336
break;
337337
case PC_ENGINEER:
338338
if (previewing_sentry) {

ssqc/commands.qc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,11 @@ float (string arg1, string arg2, string arg3, string arg4) ParseCmds = {
519519
}
520520
if (arg2) {
521521
if(arg2 == "next") {
522-
FO_Spy_DisguiseNext(self);
522+
FO_Spy_DisguiseCycle(self, 1);
523+
break;
524+
}
525+
if(arg2 == "prev") {
526+
FO_Spy_DisguiseCycle(self, -1);
523527
break;
524528
}
525529
if(arg2 == "last") {

ssqc/spy.qc

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -452,35 +452,47 @@ void (entity player, float is_user) FO_Spy_DisguiseLast = {
452452
CF_Spy_ChangeSkin(player, player.last_selected_skin, is_user);
453453
};
454454

455-
void (entity spy) FO_Spy_DisguiseNext = {
455+
void FO_Spy_DisguiseCycle(entity spy, float direction) {
456+
local float current_skin = spy.disguise_skin;
456457
local entity te;
457458

458-
if (spy.disguised_as != world) {
459-
te = self.disguised_as;
460-
459+
if (!current_skin) {
460+
te = find(world, classname, "player");
461461
while (te != world) {
462-
if (te.team_no != spy.team_no && te.skin != spy.disguised_as.skin) {
462+
if (te.team_no != spy.team_no && te.skin) {
463463
CF_Spy_DisguiseStop();
464464
Menu_Spy_Skin_Input(te.skin);
465-
spy.disguised_as = te;
465+
spy.disguise_skin = te.skin;
466466
return;
467467
}
468468
te = find(te, classname, "player");
469469
}
470-
}
470+
} else {
471+
local float next_skin = current_skin + direction;
471472

472-
te = find(world, classname, "player");
473-
while (te != world) {
474-
if (te.team_no != spy.team_no && te.skin != spy.disguise_skin) {
475-
CF_Spy_DisguiseStop();
476-
Menu_Spy_Skin_Input(te.skin);
477-
spy.disguised_as = te;
478-
return;
473+
while (next_skin != current_skin) {
474+
te = find(world, classname, "player");
475+
while (te != world) {
476+
if (te.skin == next_skin && te.team_no != spy.team_no) {
477+
CF_Spy_DisguiseStop();
478+
Menu_Spy_Skin_Input(te.skin);
479+
spy.disguise_skin = te.skin;
480+
return;
481+
}
482+
te = find(te, classname, "player");
483+
}
484+
485+
next_skin += direction;
486+
487+
if (next_skin > 9) {
488+
next_skin = 1;
489+
} else if (next_skin < 1) {
490+
next_skin = 9;
491+
}
479492
}
480-
te = find(te, classname, "player");
481493
}
482494

483-
spy.disguised_as = world;
495+
sprint(spy, PRINT_HIGH, "No enemies to disguise as!\n");
484496
}
485497

486498
void (entity player, float is_user) FO_Spy_DisguiseLastSpawned = {

0 commit comments

Comments
 (0)