Skip to content

Commit

Permalink
Disguise next and previous
Browse files Browse the repository at this point in the history
  • Loading branch information
drzel committed Sep 15, 2024
1 parent c32243d commit 10ff5a4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ sound files are found in `fortress/sound/hitaudio/` and `fortress/sound/announc
* New buttons (not impulses):
* `+special` Scout: `dash`, Demoman: `detpipe`, Medic: `aura`, Hwguy: `lock`, Pyro: `airblast`, Spy: `+feign`, Engineer: `toggledispenser`.
* `+special2` Same as `special2`, but also has `+rj` for Soldier and Pyro.
* `specialup` Engineer: `cmd sentry rotate -15`, Spy: `cmd disguise prev`.
* `specialdown` Engineer: `cmd sentry rotate 15`, Spy: `cmd disguise next`.
* `setinfo hold_grens` for press and hold `+grenade1` and `+grenade2`
* `setinfo hold_fiegn` for press and hold feigning
* `setinfo hold_detpack` for press and hold detpack
Expand Down
2 changes: 1 addition & 1 deletion csqc/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ noref float(string cmd) CSQC_ConsoleCommand = {
case "specialup":
switch (WP_PlayerClass()) {
case PC_SPY:
localcmd("cmd disguise next\n");
localcmd("cmd disguise prev\n");
break;
case PC_ENGINEER:
if (previewing_sentry) {
Expand Down
6 changes: 5 additions & 1 deletion ssqc/commands.qc
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,11 @@ float (string arg1, string arg2, string arg3, string arg4) ParseCmds = {
}
if (arg2) {
if(arg2 == "next") {
FO_Spy_DisguiseNext(self);
FO_Spy_DisguiseCycle(self, 1);
break;
}
if(arg2 == "prev") {
FO_Spy_DisguiseCycle(self, -1);
break;
}
if(arg2 == "last") {
Expand Down
44 changes: 28 additions & 16 deletions ssqc/spy.qc
Original file line number Diff line number Diff line change
Expand Up @@ -452,35 +452,47 @@ void (entity player, float is_user) FO_Spy_DisguiseLast = {
CF_Spy_ChangeSkin(player, player.last_selected_skin, is_user);
};

void (entity spy) FO_Spy_DisguiseNext = {
void FO_Spy_DisguiseCycle(entity spy, float direction) {
local float current_skin = spy.disguise_skin;
local entity te;

if (spy.disguised_as != world) {
te = self.disguised_as;

if (!current_skin) {
te = find(world, classname, "player");
while (te != world) {
if (te.team_no != spy.team_no && te.skin != spy.disguised_as.skin) {
if (te.team_no != spy.team_no && te.skin) {
CF_Spy_DisguiseStop();
Menu_Spy_Skin_Input(te.skin);
spy.disguised_as = te;
spy.disguise_skin = te.skin;
return;
}
te = find(te, classname, "player");
}
}
} else {
local float next_skin = current_skin + direction;

te = find(world, classname, "player");
while (te != world) {
if (te.team_no != spy.team_no && te.skin != spy.disguise_skin) {
CF_Spy_DisguiseStop();
Menu_Spy_Skin_Input(te.skin);
spy.disguised_as = te;
return;
while (next_skin != current_skin) {
te = find(world, classname, "player");
while (te != world) {
if (te.skin == next_skin && te.team_no != spy.team_no) {
CF_Spy_DisguiseStop();
Menu_Spy_Skin_Input(te.skin);
spy.disguise_skin = te.skin;
return;
}
te = find(te, classname, "player");
}

next_skin += direction;

if (next_skin > 9) {
next_skin = 1;
} else if (next_skin < 1) {
next_skin = 9;
}
}
te = find(te, classname, "player");
}

spy.disguised_as = world;
sprint(spy, PRINT_HIGH, "No enemies to disguise as!\n");
}

void (entity player, float is_user) FO_Spy_DisguiseLastSpawned = {
Expand Down

0 comments on commit 10ff5a4

Please sign in to comment.