From 05fdd3c679bfe92dbd16b935734ed7c797ee1437 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Mon, 3 Jul 2023 16:47:38 +0200 Subject: [PATCH] chat_command_ufo_mode 1.0.0 --- chat_commands/README.md | 23 +++++ chat_commands/chat_command_ufo_mode.gsc | 117 ++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 chat_commands/chat_command_ufo_mode.gsc diff --git a/chat_commands/README.md b/chat_commands/README.md index ba450b9..31980b3 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -255,6 +255,29 @@ Prints how to use the `commands` and the `help command` commands in the player's |---| | 1 | +## chat_command_ufo_mode.gsc + +Toggles whether the targeted player can use the ufo mode or not. +This allows the player to fly around the map by holding the melee button and, if death barrier protection is on, to get out of map without dying. + +The death barrier protection is on by default. +In ZM it will remove the death barriers for the entire team. +In MP it will put the player in god mode until disabling UFO mode (running the command again). +If the player had god mode from the god mode chat command he will keep the god mode. + +| # | Argument | Mandatory | +|---|---|---| +| 1 | The name of the player to toggle ufo mode for | :white_check_mark: | + +| Examples | +|---| +| `!ufomode me` | +| `!ufomode Resxt` | + +| Permission level | +|---| +| 3 | + ## chat_command_unfair_aimbot.gsc Toggles unfair aimbot on the targeted player. diff --git a/chat_commands/chat_command_ufo_mode.gsc b/chat_commands/chat_command_ufo_mode.gsc new file mode 100644 index 0000000..87290a1 --- /dev/null +++ b/chat_commands/chat_command_ufo_mode.gsc @@ -0,0 +1,117 @@ +#include scripts\chat_commands; + +Init() +{ + // change to false to disable death barrier protection + // in ZM: no death barrier for all players during the entire game + // in MP: constant god mode for the player who's in UFO mode until toggling ufo off + level.chat_commands_protect_from_death_barriers = true; + + if (level.chat_commands_protect_from_death_barriers && !IsMultiplayerMode()) + { + level.player_out_of_playable_area_monitor = false; + } + + CreateCommand(level.chat_commands["ports"], "ufomode", "function", ::UfoModeCommand, 3, array("default_help_one_player"), array("ufo")); +} + + + +/* Command section */ + +UfoModeCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = ToggleUfoMode(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +ToggleUfoMode(playerName) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + commandName = "ufo"; + + ToggleStatus(commandName, "Ufo Mode", player); + + if (GetStatus(commandName, player)) + { + player thread DoUfoMode(); + player thread ThreadUfoMode(); + } + else + { + player notify("chat_commands_ufo_mode_off"); + + if (IsMultiplayerMode() && !GetStatus("god", player)) + { + self DisableInvulnerability(); + } + } +} + +ThreadUfoMode() +{ + self endon("disconnect"); + self endon("chat_commands_ufo_mode_off"); + + for(;;) + { + self waittill("spawned_player"); + + self DoUfoMode(); + } +} + +DoUfoMode() +{ + self endon("disconnect"); + self endon("death"); + self endon("chat_commands_ufo_mode_off"); + + if (level.chat_commands_protect_from_death_barriers && IsMultiplayerMode()) + { + self EnableInvulnerability(); + } + + self.fly = 0; + UFO = Spawn("script_model", self.origin); + + for(;;) + { + if(self MeleeButtonPressed()) + { + self PlayerLinkTo(UFO); + self.fly = 1; + } + else + { + self Unlink(); + self.fly = 0; + } + if(self.fly == 1) + { + fly = self.origin + VectorScale(AnglesToForward(self GetPlayerAngles()), 20); + UFO MoveTo(fly, .01); + } + + wait 0.05; + } +} \ No newline at end of file