From e46bbe99c08a4c274f56f0613d3ac8a1beddd435 Mon Sep 17 00:00:00 2001 From: ATFGK <62204605+ATFGK@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:27:42 +0800 Subject: [PATCH] Pvp with no team (#2851) * Update TShockConfig.cs * Update TShock.cs * Update GetDataHandlers.cs * Update changelog.md * Update GetDataHandlers.cs * Update changelog.md * Update changelog.md * Update changelog.md --- TShockAPI/Configuration/TShockConfig.cs | 4 ++-- TShockAPI/GetDataHandlers.cs | 5 +++-- TShockAPI/TShock.cs | 2 +- docs/changelog.md | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index efeeae86..79c374b2 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -113,8 +113,8 @@ namespace TShockAPI.Configuration [Description("Enables never ending invasion events. You still need to start the event, such as with the /invade command.")] public bool InfiniteInvasion; - /// Sets the PvP mode. Valid types are: "normal", "always", "disabled". - [Description("Sets the PvP mode. Valid types are: \"normal\", \"always\" and \"disabled\".")] + /// Sets the PvP mode. Valid types are: "normal", "always", "pvpwithnoteam", "disabled". + [Description("Sets the PvP mode. Valid types are: \"normal\", \"always\", \"pvpwithnoteam\" and \"disabled\".")] public string PvPMode = "normal"; /// Prevents tiles from being placed within SpawnProtectionRadius of the default spawn. diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 0aa2dce6..9ce1a5a2 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3092,7 +3092,7 @@ namespace TShockAPI } string pvpMode = TShock.Config.Settings.PvPMode.ToLowerInvariant(); - if (pvpMode == "disabled" || pvpMode == "always" || (DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) + if (pvpMode == "disabled" || pvpMode == "always" || pvpMode == "pvpwithnoteam" || (DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) { TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTogglePvp rejected fastswitch {0}", args.Player.Name)); args.Player.SendData(PacketTypes.TogglePvp, "", id); @@ -3349,7 +3349,8 @@ namespace TShockAPI if (id != args.Player.Index) return true; - if ((DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) + string pvpMode = TShock.Config.Settings.PvPMode.ToLowerInvariant(); + if (pvpMode == "pvpwithnoteam" || (DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) { args.Player.SendData(PacketTypes.PlayerTeam, "", id); TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerTeam rejected team fastswitch {0}", args.Player.Name)); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 2eb53c97..a1531931 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1676,7 +1676,7 @@ namespace TShockAPI player.SendFileTextAsMessage(FileTools.MotdPath); string pvpMode = Config.Settings.PvPMode.ToLowerInvariant(); - if (pvpMode == "always") + if (pvpMode == "always" || pvpMode == "pvpwithnoteam") { player.TPlayer.hostile = true; player.SendData(PacketTypes.TogglePvp, "", player.Index); diff --git a/docs/changelog.md b/docs/changelog.md index 6bb0c295..5789aad6 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,6 +78,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. --> ## Upcoming changes +* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team.(@CelestialAnarchy, #2617, @ATFGK) * Corrected and updated deserialization of the following packets (@ATFGK): * `ProjectileNew`: Read the third `AI` value. * Before this change, it was previously possible for the projectile damage limit to falsely trigger, such as when using the Terra Balde and Fire Gauntlet together. @@ -102,6 +103,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Allowed the Hellfire (`OnFire3`) buff. (@drunderscore) + ## TShock 5.1.3 * Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef)