Skip to content

Commit

Permalink
2.0.0 full release
Browse files Browse the repository at this point in the history
  • Loading branch information
Rabek009 committed Sep 27, 2024
1 parent 9d15eba commit 4a0ab9c
Show file tree
Hide file tree
Showing 28 changed files with 708 additions and 540 deletions.
7 changes: 4 additions & 3 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public partial class Main : BasePlugin
public static bool GameStarted;
public static float Timer;

public static ConfigEntry<bool> ModdedProtocol { get; private set; }
public static ConfigEntry<bool> UnlockFPS { get; private set; }
public static ConfigEntry<bool> ShowFPS { get; private set; }
public static ConfigEntry<bool> DarkTheme { get; private set; }
Expand Down Expand Up @@ -62,7 +61,7 @@ public partial class Main : BasePlugin
public static Dictionary<byte, float> ProtectCooldowns;
public static Dictionary<byte, float> OptionProtectCooldowns;

public const string CurrentVersion = "2.0.0 beta6.9";
public const string CurrentVersion = "2.0.0";
public bool isDev = CurrentVersion.Contains("dev");
public bool isBeta = CurrentVersion.Contains("beta");

Expand All @@ -80,7 +79,6 @@ public override void Load()
Preset9 = Config.Bind("Preset Name Options", "Preset9", "Preset 9");
Preset10 = Config.Bind("Preset Name Options", "Preset10", "Preset 10");

ModdedProtocol = Config.Bind("Client Options", "ModdedProtocol", true);
UnlockFPS = Config.Bind("Client Options", "UnlockFPS", true);
ShowFPS = Config.Bind("Client Options", "ShowFPS", true);
DarkTheme = Config.Bind("Client Options", "DarkTheme", false);
Expand All @@ -101,6 +99,7 @@ public override void Load()
DeathrunGamemode.instance = null;
BaseWarsGamemode.instance = null;
FreezeTagGamemode.instance = null;
ColorWarsGamemode.instance = null;

GameStarted = false;
Timer = 0f;
Expand Down Expand Up @@ -183,6 +182,7 @@ public static void Postfix(PlayerControl __instance)
DeathrunGamemode.instance = null;
BaseWarsGamemode.instance = null;
FreezeTagGamemode.instance = null;
ColorWarsGamemode.instance = null;

Timer = 0f;
StandardColors = new Dictionary<byte, byte>();
Expand Down Expand Up @@ -250,6 +250,7 @@ public enum Gamemodes
Deathrun,
BaseWars,
FreezeTag,
ColorWars,
All = int.MaxValue,
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/AntiCheat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static bool PlayerControlReceiveRpc(PlayerControl pc, byte callId, Messag
return true;
}
if (target2 == null) break;
if (CustomGamemode.Instance.Gamemode is Gamemodes.BombTag or Gamemodes.BattleRoyale or Gamemodes.PaintBattle or Gamemodes.KillOrDie or Gamemodes.Jailbreak or Gamemodes.BaseWars) break;
if (CustomGamemode.Instance.Gamemode is Gamemodes.BombTag or Gamemodes.BattleRoyale or Gamemodes.PaintBattle or Gamemodes.KillOrDie or Gamemodes.Jailbreak or Gamemodes.BaseWars or Gamemodes.ColorWars) break;
var targetRole = Main.DesyncRoles.ContainsKey((target2.PlayerId, pc.PlayerId)) ? Main.DesyncRoles[(target2.PlayerId, pc.PlayerId)] : Main.StandardRoles[target2.PlayerId];
if (!pc.GetSelfRole().IsImpostor())
{
Expand Down
62 changes: 59 additions & 3 deletions Modules/CustomOptionsHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void WaitOptionsLoad()

public static readonly string[] gameModes =
{
"Classic", "Hide And Seek", "Shift And Seek", "Bomb Tag", "Random Items", "Battle Royale", "Speedrun", "Paint Battle", "Kill Or Die", "Zombies", "Jailbreak", "Deathrun", "Base Wars", "Freeze Tag"
"Classic", "Hide And Seek", "Shift And Seek", "Bomb Tag", "Random Items", "Battle Royale", "Speedrun", "Paint Battle", "Kill Or Die", "Zombies", "Jailbreak", "Deathrun", "Base Wars", "Freeze Tag", "Color Wars"
};

public static readonly string[] speedrunBodyTypes =
Expand Down Expand Up @@ -188,7 +188,7 @@ public static void WaitOptionsLoad()
public static OptionItem Lives;
public static OptionItem LivesVisibleToOthers;
public static OptionItem ArrowToNearestPlayer;
public static OptionItem GracePeriod;
public static OptionItem BrGracePeriod;

//Speedrun
public static OptionItem Speedrun;
Expand Down Expand Up @@ -309,6 +309,22 @@ public static void WaitOptionsLoad()
public static OptionItem UnfreezeRadius;
public static OptionItem TaskCompleteTimeDuringFreeze;
public static OptionItem ShowDangerMeter;

//Color wars
public static OptionItem Leaders;
public static OptionItem LeadersAmount;
public static OptionItem LeaderLives;
public static OptionItem LivesVisibleToEnemies;
public static OptionItem LeaderCooldown;
public static OptionItem CwGracePeriod;
public static OptionItem Players;
public static OptionItem PlayerKillCooldown;
public static OptionItem PlayerCanRespawn;
public static OptionItem CwRespawnCooldown;
public static OptionItem ArrowToLeader;
public static OptionItem ArrowToNearestEnemyLeader;
public static OptionItem NonTeamSpeed;
public static OptionItem NonTeamVision;

//Additional gamemodes
public static OptionItem RandomSpawn;
Expand Down Expand Up @@ -688,7 +704,7 @@ public static void Load()
.SetGamemode(Gamemodes.BattleRoyale);
ArrowToNearestPlayer = BooleanOptionItem.Create(7003, "Arrow to nearest player", true, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.BattleRoyale);
GracePeriod = FloatOptionItem.Create(7004, "Grace period", new(0f, 60f, 0.5f), 10f, TabGroup.GamemodeSettings, false)
BrGracePeriod = FloatOptionItem.Create(7004, "Grace period", new(0f, 60f, 0.5f), 10f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.BattleRoyale)
.SetValueFormat(OptionFormat.Seconds);

Expand Down Expand Up @@ -992,6 +1008,46 @@ public static void Load()
ShowDangerMeter = BooleanOptionItem.Create(15014, "Show danger meter", true, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.FreezeTag);

//Color wars
Leaders = TextOptionItem.Create(16000, "Leaders", TabGroup.GamemodeSettings)
.SetGamemode(Gamemodes.ColorWars)
.SetColor(Color.yellow);
LeadersAmount = IntegerOptionItem.Create(16001, "Leaders amount", new(2, 15, 1), 4, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Players);
LeaderLives = IntegerOptionItem.Create(16002, "Leader lives", new(1, 99, 1), 3, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars);
LivesVisibleToEnemies = BooleanOptionItem.Create(16003, "Lives visible to enemies", false, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars);
LeaderCooldown = FloatOptionItem.Create(16004, "Leader cooldown", new(1f, 60f, 0.5f), 10f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Seconds);
CwGracePeriod = FloatOptionItem.Create(16005, "Grace period", new(0f, 60f, 0.5f), 10f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Seconds);
Players = TextOptionItem.Create(16010, "Players", TabGroup.GamemodeSettings)
.SetGamemode(Gamemodes.ColorWars)
.SetColor(Color.green);
PlayerKillCooldown = FloatOptionItem.Create(16011, "Player kill cooldown", new FloatValueRule(1f, 60f, 0.5f), 15f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Seconds);
PlayerCanRespawn = BooleanOptionItem.Create(16012, "Player can respawn", true, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars);
CwRespawnCooldown = FloatOptionItem.Create(16013, "Respawn cooldown", new(5f, 60f, 2.5f), 20f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Seconds)
.SetParent(PlayerCanRespawn);
ArrowToLeader = BooleanOptionItem.Create(16014, "Arrow to leader", true, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars);
ArrowToNearestEnemyLeader = BooleanOptionItem.Create(16015, "Arrow to nearest enemy leader", true, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars);
NonTeamSpeed = FloatOptionItem.Create(16016, "Non team speed", new(0.1f, 3f, 0.05f), 0.4f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Multiplier);
NonTeamVision = FloatOptionItem.Create(16017, "Non team vision", new(0.05f, 5f, 0.05f), 0.2f, TabGroup.GamemodeSettings, false)
.SetGamemode(Gamemodes.ColorWars)
.SetValueFormat(OptionFormat.Multiplier);

//Additional gamemodes
RandomSpawn = TextOptionItem.Create(100000, "Random spawn", TabGroup.AdditionalGamemodes)
.SetGamemode(Gamemodes.All)
Expand Down
7 changes: 3 additions & 4 deletions Modules/DelayNetworkedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class InnerNetClientPatch
[HarmonyPrefix]
public static bool SendInitialDataPrefix(InnerNetClient __instance, int clientId)
{
if (!Main.ModdedProtocol.Value || __instance.NetworkMode != NetworkModes.OnlineGame) return true;
if (__instance.NetworkMode != NetworkModes.OnlineGame) return true;
// We make sure other stuffs like playercontrol and Lobby behavior is spawned properly
// Then we spawn networked data for new clients
MessageWriter messageWriter = MessageWriter.Get(SendOption.Reliable);
Expand Down Expand Up @@ -54,7 +54,6 @@ public static bool SendInitialDataPrefix(InnerNetClient __instance, int clientId

private static void DelaySpawnPlayerInfo(InnerNetClient __instance, int clientId)
{
if (!Main.ModdedProtocol.Value) return;
List<NetworkedPlayerInfo> players = GameData.Instance.AllPlayers.ToArray().ToList();
//Logging Stuff
Main.Instance.Log.LogInfo(players);
Expand Down Expand Up @@ -87,7 +86,7 @@ private static void DelaySpawnPlayerInfo(InnerNetClient __instance, int clientId
[HarmonyPrefix]
public static bool SendAllStreamedObjectsPrefix(InnerNetClient __instance, ref bool __result)
{
if (!Main.ModdedProtocol.Value || __instance.NetworkMode != NetworkModes.OnlineGame) return true;
if (__instance.NetworkMode != NetworkModes.OnlineGame) return true;
// Bypass all NetworkedData here.
__result = false;
Il2CppSystem.Collections.Generic.List<InnerNetObject> obj = __instance.allObjects;
Expand Down Expand Up @@ -145,7 +144,7 @@ public static bool SendAllStreamedObjectsPrefix(InnerNetClient __instance, ref b
public static void FixedUpdatePostfix(InnerNetClient __instance)
{
// Send a networked data pre 2 fixed update should be a good practice?
if (!__instance.AmHost || __instance.Streams == null || __instance.NetworkMode != NetworkModes.OnlineGame || !Main.ModdedProtocol.Value) return;
if (!__instance.AmHost || __instance.Streams == null || __instance.NetworkMode != NetworkModes.OnlineGame) return;

if (timer == 0)
{
Expand Down
8 changes: 4 additions & 4 deletions Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ public static Vent GetClosestVent(this PlayerControl player)
dis = Vector2.Distance(playerpos, vent.transform.position);
ventdistance.Add(vent, dis);
}
if (ventdistance.Count == 0) return null;
var min = ventdistance.OrderBy(c => c.Value).FirstOrDefault();
Vent target = min.Key;
return target;
Expand All @@ -294,8 +295,6 @@ public static IGameOptions BuildGameOptions(this PlayerControl player, float kil
opt.SetFloat(FloatOptionNames.PlayerSpeedMod, opt.GetFloat(FloatOptionNames.PlayerSpeedMod) * ((100f - ExplosionHole.LastSpeedDecrease[player.PlayerId]) / 100f));
if (opt.GetByte(ByteOptionNames.MapId) == 3)
opt.RoleOptions.SetRoleRate(RoleTypes.Engineer, 0, 0);
if (!Main.ModdedProtocol.Value)
opt.RoleOptions.SetRoleRate(RoleTypes.Phantom, 0, 0);
if (killCooldown >= 0) opt.SetFloat(FloatOptionNames.KillCooldown, killCooldown);
return opt;
}
Expand Down Expand Up @@ -435,7 +434,7 @@ public static void RpcRevive(this PlayerControl player)
}
return;
}
else if (Options.CurrentGamemode == Gamemodes.BattleRoyale)
else if (Options.CurrentGamemode is Gamemodes.BattleRoyale or Gamemodes.ColorWars)
{
player.RpcSetDesyncRole(RoleTypes.Impostor, player);
foreach (var pc in PlayerControl.AllPlayerControls)
Expand Down Expand Up @@ -581,7 +580,7 @@ public static void RpcDesyncUpdateSystem(this PlayerControl target, SystemTypes

public static RoleTypes GetSelfRole(this PlayerControl player)
{
if (CustomGamemode.Instance.Gamemode == Gamemodes.BattleRoyale) return RoleTypes.Impostor;
if (CustomGamemode.Instance.Gamemode is Gamemodes.BattleRoyale or Gamemodes.ColorWars) return RoleTypes.Impostor;
if (CustomGamemode.Instance.Gamemode is Gamemodes.BombTag or Gamemodes.PaintBattle or Gamemodes.KillOrDie or Gamemodes.Jailbreak or Gamemodes.BaseWars) return RoleTypes.Shapeshifter;
return Main.DesyncRoles.ContainsKey((player.PlayerId, player.PlayerId)) ? Main.DesyncRoles[(player.PlayerId, player.PlayerId)] : Main.StandardRoles[player.PlayerId];
}
Expand Down Expand Up @@ -614,6 +613,7 @@ public static PlayerControl GetClosestImpostor(this PlayerControl player)
pcdistance.Add(p, dis);
}
}
if (pcdistance.Count == 0) return null;
var min = pcdistance.OrderBy(c => c.Value).FirstOrDefault();
PlayerControl target = min.Key;
return target;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Gamemodes/BattleRoyaleGamemode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override void OnSelectRolesPostfix()

public override bool OnCheckMurder(PlayerControl killer, PlayerControl target)
{
if (Main.Timer < Options.GracePeriod.GetFloat())
if (Main.Timer < Options.BrGracePeriod.GetFloat())
return false;
if (GetLives(target) > 1)
{
Expand Down
3 changes: 2 additions & 1 deletion Modules/Gamemodes/BombTagGamemode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public override void OnSelectRolesPostfix()
{
if (HasBomb(pc))
{
pc.RpcSetColor(6);
pc.RpcSetColor(6);
foreach (var ar in PlayerControl.AllPlayerControls)
Main.NameColors[(pc.PlayerId, ar.PlayerId)] = Color.black;
}
Expand Down Expand Up @@ -297,6 +297,7 @@ public PlayerControl GetClosestNonBombed(PlayerControl player)
pcdistance.Add(p, dis);
}
}
if (pcdistance.Count == 0) return null;
var min = pcdistance.OrderBy(c => c.Value).FirstOrDefault();
PlayerControl target = min.Key;
return target;
Expand Down
Loading

0 comments on commit 4a0ab9c

Please sign in to comment.