Skip to content

Commit

Permalink
feat: bring back teleporter commands
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Oct 5, 2024
1 parent 22422e6 commit 9b204e4
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 34 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,34 @@ The complete feature set includes the following.
- Anti-kick
- Anti-flash
- Auto-reconnect
- Always sane
- Always lightweight
- Always show HUD
- Always keep items on teleport
- Build anywhere
- Connection spoofing
- Clear vision
- Crosshair
- ESP
- Enemy possession with abilities
- Grab through walls
- Instant interact
- Infinite stamina
- Infinite scan range
- Infinite ammo
- Infinite charge
- Infinite grab distance
- Infinite item usage
- Infinite item deposit
- Grab through walls
- Pocket any item
- Instant interact
- No/fake reload
- No item usage cooldown
- No lobby refresh delay
- No build constraints
- No character limit
- No pan limits
- Always sane
- Always lightweight
- Always show HUD
- Always keep items on teleport
- Enemy possession with abilities
- Notify teammate's death
- Pocket any item
- Stable Zap gun
- Clear vision
- Crosshair
- ESP
- [Commands](#commands)
- [Binds](#binds)

Expand All @@ -97,7 +98,10 @@ The complete feature set includes the following.
| Teleport outside entrance | `/exit` |
| Teleport inside entrance | `/enter` |
| Teleport to a player | `/tp <player>` |
| Teleport player to player | `/tp <player> <player>` |
| Teleport to a location | `/tp <x> <y> <z>` |
| Teleport player to a location | `/tp <player> <x> <y> <z>` |
| Teleports the player to hell | `/void <player>` |
| Teleport back to ship | `/home <player?>` |
| Teleport enemies to player | `/mob <player>` |
| Inverse teleport a player | `/random <player>` |
Expand Down
8 changes: 4 additions & 4 deletions lc-hax/Scripts/Commands/KillCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class KillCommand : ICommand {

Result KillSelf() {
Helper.LocalPlayer?.KillPlayer();
return new Result(true);
return new Result { Success = true };
}

Result KillTargetPlayer(string[] args) {
Expand All @@ -17,17 +17,17 @@ Result KillTargetPlayer(string[] args) {
}

targetPlayer.KillPlayer();
return new Result(true);
return new Result { Success = true };
}

Result KillAllPlayers() {
Helper.Players?.ForEach(player => player.KillPlayer());
return new Result(true);
return new Result { Success = true };
}

Result KillAllEnemies() {
Helper.Enemies.ForEach(Helper.Kill);
return new Result(true);
return new Result { Success = true };
}

void HandleResult(Result result) {
Expand Down
37 changes: 33 additions & 4 deletions lc-hax/Scripts/Commands/TeleportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GameNetcodeStuff;

[Command("tp")]
class TeleportCommand : ICommand {
class TeleportCommand : ITeleporter, ICommand {
Vector3? GetCoordinates(string[] args) {
bool isValidX = float.TryParse(args[0], out float x);
bool isValidY = float.TryParse(args[1], out float y);
Expand All @@ -22,7 +22,7 @@ Result TeleportToPlayer(string[] args) {
}

currentPlayer.TeleportPlayer(targetPlayer.transform.position);
return new Result(true);
return new Result { Success = true };
}

Result TeleportToPosition(string[] args) {
Expand All @@ -33,22 +33,51 @@ Result TeleportToPosition(string[] args) {
}

Helper.LocalPlayer?.TeleportPlayer(coordinates.Value);
return new Result(true);
return new Result { Success = true };
}

Result TeleportPlayerToPosition(PlayerControllerB player, Vector3 position) {
this.PrepareToTeleport(this.TeleportPlayerToPositionLater(player, position));
return new Result { Success = true };
}

Result TeleportPlayerToPosition(string[] args) {
if (Helper.GetPlayer(args[0]) is not PlayerControllerB player) {
return new Result { Message = "Player not found!" };
}

Vector3? coordinates = this.GetCoordinates(args[1..]);

return coordinates is null
? new Result { Message = "Invalid coordinates!" }
: this.TeleportPlayerToPosition(player, coordinates.Value);
}

Result TeleportPlayerToPlayer(string[] args) {
PlayerControllerB? sourcePlayer = Helper.GetPlayer(args[0]);
PlayerControllerB? targetPlayer = Helper.GetPlayer(args[1]);
return sourcePlayer is null || targetPlayer is null
? new Result { Message = "Player not found!" }
: this.TeleportPlayerToPosition(sourcePlayer, targetPlayer.transform.position);
}

public async Task Execute(string[] args, CancellationToken cancellationToken) {
if (args.Length is 0) {
Chat.Print("Usages:",
"tp <player>",
"tp <x> <y> <z>"
"tp <player> <player>",
"tp <x> <y> <z>",
"tp <player> <x> <y> <z>"
);

return;
}

Result result = args.Length switch {
1 => this.TeleportToPlayer(args),
2 => this.TeleportPlayerToPlayer(args),
3 => this.TeleportToPosition(args),
4 => this.TeleportPlayerToPosition(args),
_ => new Result { Message = "Invalid arguments!" }
};

Expand Down
16 changes: 1 addition & 15 deletions lc-hax/Scripts/Commands/Unlockable/HomeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GameNetcodeStuff;

[Command("home")]
class HomeCommand : ICommand {
class HomeCommand : ITeleporter, ICommand {
ShipTeleporter? Teleporter => Helper.ShipTeleporters.First(
teleporter => teleporter is not null && !teleporter.isInverseTeleporter
);
Expand All @@ -23,20 +23,6 @@ Action TeleportPlayerToBaseLater(PlayerControllerB targetPlayer) => () => {
.Init(teleporter.PressTeleportButtonServerRpc);
};

bool TeleporterExists() {
HaxObjects.Instance?.ShipTeleporters?.Renew();
return this.Teleporter is not null;
}

void PrepareToTeleport(Action action) {
Helper.BuyUnlockable(Unlockable.TELEPORTER);
Helper.ReturnUnlockable(Unlockable.TELEPORTER);

Helper.CreateComponent<WaitForBehaviour>()
.SetPredicate(this.TeleporterExists)
.Init(action);
}

public async Task Execute(string[] args, CancellationToken cancellationToken) {
if (Helper.StartOfRound is not StartOfRound startOfRound) return;
if (args.Length is 0) {
Expand Down
23 changes: 23 additions & 0 deletions lc-hax/Scripts/Commands/VoidCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Threading;
using System.Threading.Tasks;
using GameNetcodeStuff;

[Command("void")]
class VoidCommand : ITeleporter, ICommand {
public async Task Execute(string[] args, CancellationToken cancellationToken) {
if (args.Length is 0) {
Chat.Print("Usage: /void <player>");
return;
}

if (Helper.GetActivePlayer(args[0]) is not PlayerControllerB player) {
Chat.Print("Player not found!");
return;
}

this.PrepareToTeleport(this.TeleportPlayerToPositionLater(
player,
player.playersManager.notSpawnedPosition.position
));
}
}
72 changes: 72 additions & 0 deletions lc-hax/Scripts/Mixins/ITeleporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using UnityEngine;
using GameNetcodeStuff;

public interface ITeleporter { }

public static class ITeleporterMixin {
public static ShipTeleporter? GetTeleporter(this ITeleporter _) =>
Helper.ShipTeleporters.First(teleporter => teleporter is not null && !teleporter.isInverseTeleporter);

public static bool TeleporterExists(this ITeleporter self) {
HaxObjects.Instance?.ShipTeleporters?.Renew();
return self.GetTeleporter();
}

public static void PrepareToTeleport(this ITeleporter self, Action action) {
Helper.BuyUnlockable(Unlockable.TELEPORTER);
Helper.ReturnUnlockable(Unlockable.TELEPORTER);
Helper.CreateComponent<WaitForBehaviour>()
.SetPredicate(self.TeleporterExists)
.Init(action);
}

public static Action PlaceAndTeleport(
this ITeleporter self,
PlayerControllerB player,
Vector3 position
) => () => {
HaxObjects.Instance?.ShipTeleporters?.Renew();
if (self.GetTeleporter() is not ShipTeleporter teleporter) {
Chat.Print("ShipTeleporter not found!");
return;
}
Transform newTransform = player.transform.Copy();
newTransform.transform.position = position;
Vector3 rotationOffset = new(-90.0f, 0.0f, 0.0f);
Vector3 positionOffset = new(0.0f, 1.6f, 0.0f);
ObjectPlacement<Transform, ShipTeleporter> teleporterPlacement = new() {
TargetObject = newTransform,
GameObject = teleporter,
PositionOffset = positionOffset,
RotationOffset = rotationOffset
};
ObjectPlacement<Transform, ShipTeleporter> previousTeleporterPlacement = new() {
TargetObject = teleporter.transform.Copy(),
GameObject = teleporter,
PositionOffset = positionOffset,
RotationOffset = rotationOffset
};
Helper.CreateComponent<TransientBehaviour>()
.Init(_ => Helper.PlaceObjectAtPosition(teleporterPlacement), 5.0f)
.Dispose(() => Helper.PlaceObjectAtPosition(previousTeleporterPlacement));
teleporter.PressTeleportButtonServerRpc();
};

public static Action TeleportPlayerToPositionLater(
this ITeleporter self,
PlayerControllerB player,
Vector3 position
) => () => {
Helper.SwitchRadarTarget(player);
Helper.CreateComponent<WaitForBehaviour>()
.SetPredicate(_ => Helper.IsRadarTarget(player.playerClientId))
.Init(self.PlaceAndTeleport(player, position));
};
}

0 comments on commit 9b204e4

Please sign in to comment.