-
-
Notifications
You must be signed in to change notification settings - Fork 372
WIP: Allow toggling loving impostor #301
base: master
Are you sure you want to change the base?
Changes from all commits
9635707
98b6c11
7d3570c
b2d1dd7
4c6b853
f182f8a
e92215a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -69,6 +69,7 @@ public class Generate | |||||
|
||||||
public static CustomHeaderOption Lovers; | ||||||
public static CustomToggleOption BothLoversDie; | ||||||
public static CustomNumberOption LovingImpostorOn; | ||||||
|
||||||
public static CustomHeaderOption Sheriff; | ||||||
public static CustomToggleOption ShowSheriff; | ||||||
|
@@ -284,6 +285,8 @@ public static void GenerateAll() | |||||
Lovers = | ||||||
new CustomHeaderOption(num++, "<color=#FF66CCFF>Lovers</color>"); | ||||||
BothLoversDie = new CustomToggleOption(num++, "Both Lovers Die"); | ||||||
LovingImpostorOn = new CustomNumberOption(num++, "Allow Loving Impostor",25f, 0f, 100f, 10f, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
PercentFormat); | ||||||
|
||||||
Sheriff = | ||||||
new CustomHeaderOption(num++, "<color=#FFFF00FF>Sheriff</color>"); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,24 +8,24 @@ namespace TownOfUs.Roles | |||||
{ | ||||||
public class Lover : Role | ||||||
{ | ||||||
public Lover(PlayerControl player, int num, bool loverImpostor) : base(player) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The convention where |
||||||
public Lover(PlayerControl player, bool impostor, bool eitherLoverImpostor) : base(player) | ||||||
{ | ||||||
var imp = num == 2 && loverImpostor; | ||||||
Name = imp ? "Loving Impostor" : "Lover"; | ||||||
Name = impostor ? "Loving Impostor" : "Lover"; | ||||||
Color = new Color(1f, 0.4f, 0.8f, 1f); | ||||||
ImpostorText = () => | ||||||
"You are in " + ColorString + "Love</color> with " + ColorString + OtherLover.Player.name; | ||||||
TaskText = () => $"Stay alive with your love {OtherLover.Player.name} \n and win together"; | ||||||
RoleType = imp ? RoleEnum.LoverImpostor : RoleEnum.Lover; | ||||||
Num = num; | ||||||
LoverImpostor = loverImpostor; | ||||||
Scale = imp ? 2.3f : 1f; | ||||||
Faction = imp ? Faction.Impostors : Faction.Crewmates; | ||||||
RoleType = impostor ? RoleEnum.LoverImpostor : RoleEnum.Lover; | ||||||
LoverImpostor = eitherLoverImpostor; | ||||||
Scale = impostor ? 2.3f : 1f; | ||||||
Faction = impostor ? Faction.Impostors : Faction.Crewmates; | ||||||
} | ||||||
|
||||||
public Lover OtherLover { get; set; } | ||||||
public bool LoveCoupleWins { get; set; } | ||||||
public int Num { get; set; } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find where this was used? |
||||||
|
||||||
// Returns true if either lover is an impostor | ||||||
|
||||||
public bool LoverImpostor { get; set; } | ||||||
|
||||||
protected override void IntroPrefix(IntroCutscene._CoBegin_d__14 __instance) | ||||||
|
@@ -64,27 +64,24 @@ protected override string NameText(PlayerVoteArea player = null) | |||||
|
||||||
return Player.name + "\n" + "Lover"; | ||||||
} | ||||||
|
||||||
public static void Gen(List<PlayerControl> crewmates, List<PlayerControl> impostors) | ||||||
{ | ||||||
//System.Console.WriteLine("LOVER2"); | ||||||
if (crewmates.Count <= 0) return; | ||||||
if (crewmates.Count <= 1 && impostors.Count < 1) return; | ||||||
|
||||||
//System.Console.WriteLine("LOVER3"); | ||||||
var b = Random.RandomRangeInt(0, 3); | ||||||
|
||||||
if ((b == 0) & (impostors.Count < 1)) b = 1; | ||||||
var lovingImpostorEnabled = Random.RandomRangeInt(1, 101) <= CustomGameOptions.LovingImpostorOn; | ||||||
|
||||||
var canMakeCrewCrewLovers = crewmates.Count >= 2; | ||||||
var canMakeCrewImpostorLovers = crewmates.Count >= 1 && impostors.Count >= 2 && lovingImpostorEnabled; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
there would only need to be one impostor free |
||||||
if (!canMakeCrewCrewLovers && !canMakeCrewImpostorLovers) { | ||||||
return; | ||||||
} | ||||||
|
||||||
if ((b != 0) & (crewmates.Count <= 1)) b = 0; | ||||||
var lovingImpostor = canMakeCrewImpostorLovers; | ||||||
|
||||||
//System.Console.WriteLine("LOVER4"); | ||||||
var flag2 = b == 0; | ||||||
var num = Random.RandomRangeInt(0, crewmates.Count); | ||||||
var player1 = crewmates[num]; | ||||||
crewmates.Remove(player1); | ||||||
PlayerControl player2; | ||||||
if (flag2) | ||||||
if (lovingImpostor) | ||||||
{ | ||||||
var num2 = Random.RandomRangeInt(0, impostors.Count); | ||||||
player2 = impostors[num2]; | ||||||
|
@@ -97,13 +94,15 @@ public static void Gen(List<PlayerControl> crewmates, List<PlayerControl> impost | |||||
crewmates.Remove(player2); | ||||||
} | ||||||
|
||||||
// These writes appear to be read by `case CustomRPC.SetCouple` in RpcHandling.cs | ||||||
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, | ||||||
(byte) CustomRPC.SetCouple, SendOption.Reliable, -1); | ||||||
writer.Write(player1.PlayerId); | ||||||
writer.Write(player2.PlayerId); | ||||||
writer.Write(b); | ||||||
var lover1 = new Lover(player1, 1, b == 0); | ||||||
var lover2 = new Lover(player2, 2, b == 0); | ||||||
writer.Write(lovingImpostor); | ||||||
|
||||||
var lover1 = new Lover(player1, false, lovingImpostor); | ||||||
var lover2 = new Lover(player2, lovingImpostor, lovingImpostor); | ||||||
|
||||||
lover1.OtherLover = lover2; | ||||||
lover2.OtherLover = lover1; | ||||||
|
@@ -179,4 +178,4 @@ public void Win() | |||||
OtherLover.LoveCoupleWins = true; | ||||||
} | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -338,12 +338,12 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) | |||||
case CustomRPC.SetCouple: | ||||||
var id = reader.ReadByte(); | ||||||
var id2 = reader.ReadByte(); | ||||||
var b1 = reader.ReadByte(); | ||||||
bool lovingImpostor = reader.ReadByte() == 0; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
var lover1 = Utils.PlayerById(id); | ||||||
var lover2 = Utils.PlayerById(id2); | ||||||
|
||||||
var roleLover1 = new Lover(lover1, 1, b1 == 0); | ||||||
var roleLover2 = new Lover(lover2, 2, b1 == 0); | ||||||
var roleLover1 = new Lover(lover1, false, lovingImpostor); | ||||||
var roleLover2 = new Lover(lover2, lovingImpostor, lovingImpostor); | ||||||
|
||||||
roleLover1.OtherLover = roleLover2; | ||||||
roleLover2.OtherLover = roleLover1; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.