Finish Samurai

This commit is contained in:
Gurge44 committed 2024-04-09 20:41:25 +02:00
1 parent 5f5ebd137e
commit 24924815a6
8 files changed
+70 -114

No files matched your search

+6 -3
View File
@@ -85,11 +85,14 @@ internal static class FFAManager
.SetGameMode(CustomGameMode.FFA)
.SetColor(new Color32(0, 255, 165, byte.MaxValue))
.SetValueFormat(OptionFormat.Multiplier);
FFAModifiedSpeedDuration = FloatOptionItem.Create(67_223_009, "FFA_ModifiedSpeedDuration", new(1f, 60f, 1f), 10f, TabGroup.GameSettings).SetGameMode(CustomGameMode.FFA).SetColor(new Color32(0, 255, 165, byte.MaxValue))
FFAModifiedSpeedDuration = FloatOptionItem.Create(67_223_009, "FFA_ModifiedSpeedDuration", new(1f, 60f, 1f), 10f, TabGroup.GameSettings)
.SetGameMode(CustomGameMode.FFA).SetColor(new Color32(0, 255, 165, byte.MaxValue))
.SetValueFormat(OptionFormat.Seconds);
FFALowerVision = FloatOptionItem.Create(67_223_010, "FFA_LowerVision", new(0f, 1f, 0.05f), 0.5f, TabGroup.GameSettings).SetGameMode(CustomGameMode.FFA).SetColor(new Color32(0, 255, 165, byte.MaxValue))
FFALowerVision = FloatOptionItem.Create(67_223_010, "FFA_LowerVision", new(0f, 1f, 0.05f), 0.5f, TabGroup.GameSettings)
.SetGameMode(CustomGameMode.FFA).SetColor(new Color32(0, 255, 165, byte.MaxValue))
.SetValueFormat(OptionFormat.Multiplier);
FFAModifiedVisionDuration = FloatOptionItem.Create(67_223_011, "FFA_ModifiedVisionDuration", new(1f, 70f, 1f), 5f, TabGroup.GameSettings).SetGameMode(CustomGameMode.FFA).SetColor(new Color32(0, 255, 165, byte.MaxValue))
FFAModifiedVisionDuration = FloatOptionItem.Create(67_223_011, "FFA_ModifiedVisionDuration", new(1f, 70f, 1f), 5f, TabGroup.GameSettings)
.SetGameMode(CustomGameMode.FFA).SetColor(new Color32(0, 255, 165, byte.MaxValue))
.SetValueFormat(OptionFormat.Seconds);
FFAEnableRandomTwists = BooleanOptionItem.Create(67_223_012, "FFA_EnableRandomTwists", true, TabGroup.GameSettings)
.SetGameMode(CustomGameMode.FFA)
+7
View File
@@ -2129,6 +2129,13 @@ public static class Utils
TargetMark.Append($"<color={GetRoleColorCode(CustomRoles.Analyst)}>○</color>");
}
break;
case CustomRoles.Samurai: // Same as Analyst
if ((Main.PlayerStates[seer.PlayerId].Role as Samurai).Target.Id == target.PlayerId)
{
TargetMark.Append($"<color={GetRoleColorCode(CustomRoles.Samurai)}>○</color>");
}
break;
case CustomRoles.Puppeteer when Puppeteer.PuppeteerList.ContainsValue(seer.PlayerId) && Puppeteer.PuppeteerList.ContainsKey(target.PlayerId):
TargetMark.Append($"<color={GetRoleColorCode(CustomRoles.Impostor)}>◆</color>");
+1 -1
View File
@@ -227,7 +227,7 @@ class GameEndChecker
WinnerIds.RemoveWhere(x => CustomTeamManager.GetCustomTeam(x) != null);
}
if (WinnerTeam == CustomWinner.Lovers || WinnerIds.Any(x => Main.PlayerStates[x].SubRoles.Contains(CustomRoles.Lovers)))
if ((WinnerTeam == CustomWinner.Lovers || WinnerIds.Any(x => Main.PlayerStates[x].SubRoles.Contains(CustomRoles.Lovers))) && Main.LoversPlayers.All(x => x.IsAlive()))
{
if (WinnerTeam != CustomWinner.Lovers) AdditionalWinnerTeams.Add(AdditionalWinners.Lovers);
Main.AllPlayerControls
+7
View File
@@ -1407,6 +1407,13 @@ class FixedUpdatePatch
Mark.Append($"<color={GetRoleColorCode(CustomRoles.Analyst)}>○</color>");
}
break;
case CustomRoles.Samurai:
if ((Main.PlayerStates[seer.PlayerId].Role as Samurai).Target.Id == target.PlayerId)
{
Mark.Append($"<color={GetRoleColorCode(CustomRoles.Samurai)}>○</color>");
}
break;
case CustomRoles.Puppeteer:
if (Puppeteer.PuppeteerList.ContainsValue(seer.PlayerId) && Puppeteer.PuppeteerList.ContainsKey(target.PlayerId))
+23 -16
View File
@@ -195,23 +195,26 @@ class OnPlayerLeftPatch
else if (GameStates.IsLobby)
msg = GetString("Message.HostLeftGameInLobby");
player.SetName(title);
player?.SetName(title);
DestroyableSingleton<HudManager>.Instance.Chat.AddChat(player, msg);
player.SetName(name);
player?.SetName(name);
var writer = CustomRpcSender.Create("MessagesToSend");
writer.StartMessage(clientId);
writer.StartRpc(player.NetId, (byte)RpcCalls.SetName)
.Write(title)
.EndRpc();
writer.StartRpc(player.NetId, (byte)RpcCalls.SendChat)
.Write(msg)
.EndRpc();
writer.StartRpc(player.NetId, (byte)RpcCalls.SetName)
.Write(player.Data.PlayerName)
.EndRpc();
writer.EndMessage();
writer.SendMessage();
if (player != null && player.Data != null)
{
var writer = CustomRpcSender.Create("MessagesToSend");
writer.StartMessage(clientId);
writer.StartRpc(player.NetId, (byte)RpcCalls.SetName)
.Write(title)
.EndRpc();
writer.StartRpc(player.NetId, (byte)RpcCalls.SendChat)
.Write(msg)
.EndRpc();
writer.StartRpc(player.NetId, (byte)RpcCalls.SetName)
.Write(player.Data.PlayerName)
.EndRpc();
writer.EndMessage();
writer.SendMessage();
}
}
// Additional description of the reason for disconnection
@@ -243,7 +246,7 @@ class OnPlayerLeftPatch
Utils.CountAlivePlayers(true);
data.Character.Data.Disconnected = true;
if (data != null && data.Character != null) data.Character.Data.Disconnected = true;
}
catch (NullReferenceException)
{
@@ -252,6 +255,10 @@ class OnPlayerLeftPatch
{
Logger.Error(ex.ToString(), "OnPlayerLeftPatch.Postfix");
}
finally
{
Utils.NotifyRoles(NoCache: true);
}
}
}
+5 -89
View File
@@ -29,12 +29,12 @@
## Visit our website for more information: [EHR](https://sites.google.com/view/ehr-au)
## Main Features
- Note: The goal with this branch is to improve the existing stuff over adding new roles. If some of the stuff you see below are in TOHRE, they were originally coded by me.
### New gamemode
- Note: The goal with this branch is to improve the existing stuff over adding new roles. If some of the stuff you see below are in other mods, they were originally coded by me.
### Most Popular Game Mode
- A brand new official gamemode, Basic FFA (Free For All)
- This mode makes everyone a killer and the last player alive wins
- Features: Random events, ranks and scoring, random ability gain for every kill, game timer, scoreboard (task list), unique end screen, fully customizable
### Overall improvements
### Overall improvements compared to other mods
- Role spawn chances are in percentages
- Gain more ability uses for completing tasks as crewmate roles
- Gain more ability uses for getting kills as impostor roles
@@ -103,91 +103,7 @@
- Provocateur: No longer suicides after selecting a target
- Pursuer: Target doesn't die when trying to use their kill button, they'll just have their kill cooldown reset
### Now, some new roles as well
- Lighter (Crewmate)
- Demolitionist (Crewmate)
- Ventguard (Crewmate)
- Express (Crewmate)
- Witness (Crewmate)
- Alchemist (Crewmate)
- Task Manager (Crewmate)
- Speedrunner (Crewmate)
- Ignitor (Crewmate)
- Security Guard (Crewmate)
- Aid (Crewmate)
- Spy (Crewmate)
- Tether (Crewmate)
- Ricochet (Crewmate)
- Door Master (Crewmate)
- Hacker (Crewmate)
- Guess Manager (Crewmate)
- Altruist (Crewmate)
- Transmitter (Crewmate)
- Autocrat (Crewmate)
- Benefactor (Crewmate)
- Nightmare (Crewmate)
- Camera Man (Crewmate)
- Escort (Crewmate)
- Donut Delivery (Crewmate)
- Drainer (Crewmate)
- Insight (Crewmate)
- Tunneler (Crewmate)
- Detour (Crewmate)
- Gaulois (Crewmate)
- Analyst (Crewmate)
- Electric (Crewmate)
- Mole (Crewmate)
- Tornado (Crewmate)
- Sentinel (Crewmate)
- Rabbit (Crewmate)
- Perceiver (Crewmate)
- Convener (Crewmate)
- Mathematician (Crewmate)
- Romantic (Neutral)
- Werewolf (Neutral)
- Imitator (Neutral)
- Head Hunter (Neutral)
- Vengeance (Neutral)
- Eclipse (Neutral)
- Pyromaniac (Neutral)
- Weapon Master (Neutral)
- Postman (Neutral)
- Reckless (Neutral)
- Magician (Neutral)
- Enderman (Neutral)
- Mycologist (Neutral)
- Bubble (Neutral)
- Hookshot (Neutral)
- Sprayer (Neutral)
- Soul Hunter (Neutral)
- Necromancer / Deathknight (Neutral)
- Undertaker (Impostor)
- Gambler (Impostor)
- Mastermind (Impostor)
- Rift Maker (Impostor)
- Hitman (Impostor)
- Sapper (Impostor)
- Nullifier (Impostor)
- Chronomancer (Impostor)
- Librarian (Impostor)
- Yin Yanger (Impostor)
- Cantankerous (Impostor)
- Duellist (Impostor)
- Kamikaze (Impostor)
- Swapster (Impostor)
- Swiftclaw (Impostor)
- Damocles (Impostor-only Add-on)
- Deadly Quota (Impostor-only Add-on)
- Nimble (Add-on)
- Physicist (Add-on)
- Stressed (Add-on)
- Giant (Add-on)
- Magnet (Add-on)
- Sleuth (Add-on)
- Asthmatic (Add-on)
- Disco (Add-on)
- Truant (Add-on)
- Busy (Add-on)
### To see the full list of unique roles and their descriptions, visit our website: [EHR](https://sites.google.com/view/ehr-au)
## Note:
- You can use parts of the code in here, but if you do, you'll have to credit me (Gurge44) or the mod by mentioning its name (EHR) and providing a link to this github page. (Or leaving the in-game credits as they are is also fine!)
@@ -198,7 +114,7 @@
## Credit to these mods and their developers for the code and help:
### :star: [TOHER/TOHRE/TOHEN](https://github.com/0xDrMoe/TownofHost-Enhanced) :
>
> - Our repo is forked from TOHRE
> - Our repo is forked from TOHRE (from a long time ago)
>
### :star: [TOHE/TONX](https://github.com/KARPED1EM/TownOfHostEdited) :
>
+2
View File
@@ -357,6 +357,8 @@ namespace EHR.Roles.Neutral
}
foreach (var index in indexesToRemove) ActiveItems.RemoveAt(index);
Utils.GetPlayerById(BargainerId).ResetKillCooldown();
}
public static bool KnowRole(PlayerControl seer, PlayerControl target)
+19 -5
View File
@@ -16,7 +16,7 @@ namespace EHR.Roles.Neutral
private static OptionItem SuccessKCD;
private static OptionItem KillDelay;
private (byte Id, long TimeStamp) Target;
public (byte Id, long TimeStamp) Target;
private Dictionary<byte, long> Delays;
public static void SetupCustomOption()
@@ -30,6 +30,15 @@ namespace EHR.Roles.Neutral
.SetParent(CustomRoleSpawnChances[CustomRoles.Samurai]);
HasImpostorVision = BooleanOptionItem.Create(id + 4, "ImpostorVision", true, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Samurai]);
NearbyDuration = FloatOptionItem.Create(id + 5, "Samurai.NearbyDuration", new(0f, 30f, 0.5f), 3f, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Samurai])
.SetValueFormat(OptionFormat.Seconds);
SuccessKCD = FloatOptionItem.Create(id + 6, "Samurai.SuccessKCD", new(0f, 180f, 0.5f), 17.5f, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Samurai])
.SetValueFormat(OptionFormat.Seconds);
KillDelay = FloatOptionItem.Create(id + 7, "Samurai.KillDelay", new(0f, 60f, 0.5f), 5f, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Samurai])
.SetValueFormat(OptionFormat.Seconds);
}
public override void Init()
@@ -64,7 +73,7 @@ namespace EHR.Roles.Neutral
public override void OnFixedUpdate(PlayerControl pc)
{
if (Target.Id == byte.MaxValue || !GameStates.IsInTask || !pc.IsAlive()) return;
if (!GameStates.IsInTask) return;
long now = Utils.TimeStamp;
@@ -75,16 +84,20 @@ namespace EHR.Roles.Neutral
if (kvp.Value + KillDelay.GetInt() <= now)
{
player.Suicide(realKiller: pc);
if (pc.RpcCheckAndMurder(player, check: true))
player.Suicide(realKiller: pc);
}
}
if (Target.Id == byte.MaxValue || !pc.IsAlive()) return;
var target = Utils.GetPlayerById(Target.Id);
if (target == null) return;
if (Vector2.Distance(target.Pos(), pc.Pos()) > 1.5f)
if (Vector2.Distance(target.Pos(), pc.Pos()) > (NormalGameOptionsV07.KillDistances[Mathf.Clamp(pc.Is(CustomRoles.Reach) ? 2 : Main.NormalOptions.KillDistance, 0, 2)] + 0.5f))
{
Target = (byte.MaxValue, 0);
pc.RpcCheckAndMurder(target);
return;
}
@@ -92,7 +105,8 @@ namespace EHR.Roles.Neutral
{
Delays[Target.Id] = now;
Target = (byte.MaxValue, 0);
pc.SetKillCooldown(SuccessKCD.GetFloat());
}
}
}
}
}