Skip to content

Commit

Permalink
feat: introduce experimental fall command
Browse files Browse the repository at this point in the history
- makes a player fall through the ground
  • Loading branch information
winstxnhdw committed Mar 4, 2024
1 parent 72a4a47 commit 4d7200c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lc-hax/Scripts/Commands/FallCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

using GameNetcodeStuff;
using Hax;
using UnityEngine;

[Command("fall")]
class FallCommand : ICommand {
public void Execute(StringArray args) {
if (Helper.LocalPlayer is not PlayerControllerB localPlayer) return;
if (args.Length is 0) {
Chat.Print("Usage: /fall <player>");
return;
}

if (Helper.Enemies.First() is not EnemyAI enemy) {
Chat.Print("An enemy must have spawned to use this command!");
return;
}

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

enemy.ChangeEnemyOwnerServerRpc(localPlayer.actualClientId);
enemy.serverPosition = enemy.serverPosition == Vector3.positiveInfinity
? targetPlayer.transform.position
: Vector3.positiveInfinity;

Helper.ShortDelay(() =>
enemy.ChangeEnemyOwnerServerRpc(targetPlayer.actualClientId)
);
}
}

0 comments on commit 4d7200c

Please sign in to comment.