-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 62544f5
Showing
14 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin | ||
obj | ||
.vs | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net4.8</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>10</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>Libs\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="com.rlabrecque.steamworks.net"> | ||
<HintPath>Libs\com.rlabrecque.steamworks.net.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.API"> | ||
<HintPath>Libs\Rocket.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.Core"> | ||
<HintPath>Libs\Rocket.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.Unturned"> | ||
<HintPath>Libs\Rocket.Unturned.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>Libs\UnityEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>Libs\UnityEngine.CoreModule.dll</HintPath> | ||
<Aliases>UnityEngineCoreModule</Aliases> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34728.123 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodModeArea", "GodModeArea.csproj", "{D1823CED-91A4-4A22-8D9A-BB70B78290E9}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D1823CED-91A4-4A22-8D9A-BB70B78290E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D1823CED-91A4-4A22-8D9A-BB70B78290E9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D1823CED-91A4-4A22-8D9A-BB70B78290E9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D1823CED-91A4-4A22-8D9A-BB70B78290E9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {8EBB3434-0B21-46CB-96AC-EFD8B1564733} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Rocket.API; | ||
|
||
namespace GodModeArea | ||
{ | ||
public class GodModeAreaConfiguration : IRocketPluginConfiguration | ||
{ | ||
public List<GodModeAreas> GodModeAreas = new(); | ||
public int GodModeTickrate = 100; | ||
public int GodModeMillisecondsExitDelay = 5000; | ||
public bool GodModeDefaultValue = false; | ||
public bool DebugExtended = false; | ||
public void LoadDefaults() | ||
{ | ||
GodModeAreas = new() | ||
{ | ||
new() | ||
{ | ||
X1 = 431.41, | ||
X2 = 440.92, | ||
Y1 = 51.00, | ||
Y2 = 54.00, | ||
Z1 = 437.25, | ||
Z2 = 447.05 | ||
} | ||
}; | ||
} | ||
} | ||
public class GodModeAreas | ||
{ | ||
public double X1; | ||
public double Y1; | ||
public double Z1; | ||
public double X2; | ||
public double Y2; | ||
public double Z2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
extern alias UnityEngineCoreModule; | ||
using Rocket.API.Collections; | ||
using Rocket.Core.Logging; | ||
using Rocket.Core.Plugins; | ||
using Rocket.Core.Utils; | ||
using Rocket.Unturned.Chat; | ||
using Rocket.Unturned.Player; | ||
using SDG.Unturned; | ||
using UnityCoreModule = UnityEngineCoreModule.UnityEngine; | ||
|
||
namespace GodModeArea | ||
{ | ||
public class GodModeAreaPlugin : RocketPlugin<GodModeAreaConfiguration> | ||
{ | ||
public static readonly Dictionary<string, bool> PlayerOnGodMode = new(); | ||
public override void LoadPlugin() | ||
{ | ||
base.LoadPlugin(); | ||
// Instanciating the player events | ||
Rocket.Unturned.U.Events.OnPlayerConnected += OnPlayerConnected; | ||
Rocket.Unturned.U.Events.OnPlayerDisconnected += OnPlayerDisconnected; | ||
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerUpdatePosition += PositionUpdate; | ||
Logger.Log("GodModeArea by LeandroTheDev"); | ||
} | ||
|
||
private void PositionUpdate(UnturnedPlayer player, UnityCoreModule.Vector3 position) | ||
{ | ||
// Debug | ||
if (Configuration.Instance.DebugExtended) | ||
Logger.Log($"Player: {player.DisplayName}, Mode: {player.GodMode}, Position {player.Position}"); | ||
// Execute the tickrate for the player only if his exist in god mode context | ||
if (PlayerOnGodMode.TryGetValue(player.Id, out _)) | ||
{ | ||
foreach (GodModeAreas area in Configuration.Instance.GodModeAreas) | ||
{ | ||
// Verify X position | ||
if (position.x < area.X1 || position.x > area.X2) | ||
{ | ||
// Remove the player from godmode | ||
if (PlayerOnGodMode[player.Id]) RemovePlayerFromGodMode(player); | ||
return; | ||
} | ||
// Verify Y position | ||
else if (position.y < area.Y1 || position.y > area.Y2) | ||
{ | ||
// Remove the player from godmode | ||
if (PlayerOnGodMode[player.Id]) RemovePlayerFromGodMode(player); | ||
return; | ||
} | ||
// Verifiy Z position | ||
else if (position.z < area.Z1 || position.z > area.Z2) | ||
{ | ||
// Remove the player from godmode | ||
if (PlayerOnGodMode[player.Id]) RemovePlayerFromGodMode(player); | ||
return; | ||
} | ||
} | ||
if (!player.GodMode) | ||
{ | ||
player.GodMode = true; | ||
PlayerOnGodMode[player.Id] = true; | ||
} | ||
} | ||
} | ||
|
||
|
||
private void OnPlayerConnected(UnturnedPlayer player) | ||
{ | ||
// Add the default value for new player | ||
player.GodMode = Configuration.Instance.GodModeDefaultValue; | ||
PlayerOnGodMode.Add(player.Id, Configuration.Instance.GodModeDefaultValue); | ||
} | ||
|
||
private void OnPlayerDisconnected(UnturnedPlayer player) | ||
{ | ||
// Clear Variables | ||
PlayerOnGodMode.Remove(player.Id); | ||
} | ||
|
||
private void RemovePlayerFromGodMode(UnturnedPlayer player) | ||
{ | ||
// Informate the player the are exiting the zone | ||
UnturnedChat.Say(player, Translate("Exiting_God_Mode", Math.Round(Configuration.Instance.GodModeMillisecondsExitDelay / 1000.0)), Palette.COLOR_R); | ||
|
||
// Remove the player from the list | ||
PlayerOnGodMode[player.Id] = false; | ||
|
||
// After delay disable the god mode | ||
Task.Delay(Configuration.Instance.GodModeMillisecondsExitDelay).ContinueWith((_) => | ||
{ | ||
// If player back to the god mode again just cancel | ||
if (PlayerOnGodMode[player.Id]) return; | ||
// Inform the player | ||
TaskDispatcher.QueueOnMainThread(() => | ||
{ | ||
UnturnedChat.Say(player, Translate("No_Longer_God_Mode"), Palette.COLOR_R); | ||
// Remove god mod | ||
player.GodMode = false; | ||
}); | ||
}); | ||
} | ||
|
||
public override TranslationList DefaultTranslations => new() | ||
{ | ||
{ "Exiting_God_Mode", "Exiting zone, you have {0} seconds of invulnerability" }, | ||
{ "No_Longer_God_Mode", "You are now vulnerable!" }, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FREE TO MODIFY PUBLIC LICENSE | ||
February 2024 | ||
|
||
Copyright (C) 2024 Leandro Schmidt <leandro.schmidt.profissional@gmail.com> | ||
|
||
Anyone has free access to the contents to modify or | ||
produce similar content, as long as the name is | ||
different from the original. | ||
|
||
FREE TO MODIFY PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, | ||
DISTRIBUTION AND MODIFICATION | ||
|
||
0. Free to Modify. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# God Mode Area | ||
Creates a fully configurable area, players in that area will become god mode, if player exit will lose, configurable timer to lose after exiting area. |