Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions asset_patches/assets/data/Papers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,37 @@
<page image="KeyKillInner.png"/>
</paper>

<!-- Bulletin -->
<paper id="Bulletin" outer="BulletinOuter.png" font="regular_short" textcolor="0x565656" reveal="ondesk:120,2" dock="true">
<page id="notice0" image="BulletinInner.png">
<mark image="$Emblem0" pos="110 25" inspectable="false"/>
<mark text="$Notice0" wrap="140" inspectable="false"/>
<mark text="$NowDate" align="right" pos="142 11"/>
<mark text="Assigned guards:" pos="6 140"/>
<mark text="LEFT" pos="10 155" textcolor="0xA3A3A3" />
<mark text="RIGHT" pos="10 180" textcolor="0xA3A3A3" />
<mark text="__GUARD0__" pos="40 149"/>
<mark text="__GUARD1__" pos="40 159"/>
<mark text="..............................................." pos="10 163" textcolor="0xA3A3A3" />
<mark text="__GUARD2__" pos="40 171"/>
<mark text="__GUARD3__" pos="40 181"/>
<mark text="__GUARD4__" pos="40 191" />
<mark text="$PageNumberNotice0" align="right" pos="129 195" inspectable="false"/>
<mark image="$PagesNote" pos="148 173" align="right" inspectable="false"/>
<mark image="BulletinGoNext.png" pos="132 184" link="#next"/>
</page>
<page id="criminals" image="BulletinInnerCriminals.png" backcolor="0xa3a3a3">
<mark image="$Criminal0" pos="19 46" scale="0.4"/>
<mark image="$Criminal1" pos="19 95" scale="0.4"/>
<mark image="$Criminal2" pos="19 144" scale="0.4"/>

<mark text="$PageNumberCriminals" align="right" pos="129 195" backcolor="0" inspectable="false"/>
<mark image="BulletinGoPrev.png" pos="0 184" link="#prev"/>
<mark image="BulletinGoNext.png" pos="132 184" link="#next"/>
</page>
</paper>


<!-- Rules -->
<paper id="Rules" outer="RulesOuter.png" font="regular" textcolor="0x574848" dock="true">
<page id="home" image="RulesInnerHome.png" backcolor="0xe4e6bd">
Expand Down
51 changes: 51 additions & 0 deletions psp-papers-mod/src/Patches/ChatterGuards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using data;
using HarmonyLib;
using Il2CppSystem;
using play.day.border;
using psp_papers_mod.Twitch;
using System.Collections.Generic;
using System.Linq;

namespace psp_papers_mod.Patches;

public class ChatterGuards {
public static ChatterCollection WantToGuardChatters = new ();
public static Chatter[] Guards = new Chatter[5];
// 0-1: left guards, 2-4: right guards

public static bool SetGuards() {
if (WantToGuardChatters.Count < 1) return false;

int[] order = { 2, 3, 4, 0, 1 }; // Prioritize setting the right ones first

foreach (int i in order) {
for (int j = 0; j < WantToGuardChatters.Count; j++) {
Chatter chatter = WantToGuardChatters.GetRandomChatter();

if (!Guards.Contains(chatter)) {
Guards[i] = chatter;
break;
}
}
}

return true;
}
}


[HarmonyPatch(typeof(Person))]
internal class GuardPersonPatch {

[HarmonyPrefix]
[HarmonyPatch("setAnim", typeof(Anim), typeof(Object))]
private static void PersonSetAnim(Anim anim, Object movingHorizontal, Person __instance) {
if (!anim.death) return;

// left guards can't die as of rn
if(__instance.id == "guard2") ChatterGuards.Guards[2]?.Shot();
if(__instance.id == "guard3") ChatterGuards.Guards[3]?.Shot();
if(__instance.id == "guard4") ChatterGuards.Guards[4]?.Shot();

}
}
28 changes: 22 additions & 6 deletions psp-papers-mod/src/Patches/TextPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,28 @@ public static string Process(string text) {
}

public static void SetMenuTextPrefix(ref string v) {
if (v is not "The day was cut short by a terrorist attack.") return;

Chatter attacker = TwitchIntegration.ActiveAttacker;
if (attacker == null) return;

v = v.Replace(".", " by " + attacker.Username + ".");
if (v == null) return;

if (v is "The day was cut short by a terrorist attack.") {
Chatter attacker = TwitchIntegration.ActiveAttacker;
if (attacker == null) return;

v = v.Replace(".", " by " + attacker.Username + ".");
return;
}

if (ChatterGuards.WantToGuardChatters.Count < 1) {
if (v.Contains("__GUARD")) v = "";
} else {
// hacky, but executes once per day right when it's needed
if (v is "Assigned guards:") ChatterGuards.SetGuards();

if (v is "__GUARD0__") v = ChatterGuards.Guards[0]?.Username;
if (v is "__GUARD1__") v = ChatterGuards.Guards[1]?.Username;
if (v is "__GUARD2__") v = ChatterGuards.Guards[2]?.Username;
if (v is "__GUARD3__") v = ChatterGuards.Guards[3]?.Username;
if (v is "__GUARD4__") v = ChatterGuards.Guards[4]?.Username;
}
}

}
Expand Down
5 changes: 4 additions & 1 deletion psp-papers-mod/src/Twitch/Chatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ public int GetWeight(bool attacker = false) {

// The active chatter can't be the attacker and vice versa
(attacker && TwitchIntegration.ActiveChatter == this) ||
(!attacker && TwitchIntegration.ActiveAttacker == this)
(!attacker && TwitchIntegration.ActiveAttacker == this) ||

// Guards can't be active chatters
(ChatterGuards.Guards.Contains(this))
)
return 0;

Expand Down
13 changes: 13 additions & 0 deletions psp-papers-mod/src/Twitch/Commands/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ public static void NoBomb(Chatter sender, ChatMessage chatMessage, string[] args
sender.WantsBomb = false;
}

[ChatCommand("guard")]
public static void WantsGuard(Chatter sender, ChatMessage chatMessage, string[] args) {
string username = sender.Username;
if (!ChatterGuards.WantToGuardChatters.ContainsKey(username)) {
ChatterGuards.WantToGuardChatters.Add(username, new Chatter(chatMessage));

chatMessage.Reply("Thank you for enlisting in the border patrol o7");
} else {
ChatterGuards.WantToGuardChatters.Remove(username);
chatMessage.Reply("Opted out of being a guard.");
}
}

[ChatCommand("give")]
public static void GiveEmote(Chatter sender, ChatMessage chatMessage, string[] args) {
if (!sender.IsActiveChatter) return;
Expand Down
2 changes: 2 additions & 0 deletions psp-papers-mod/src/Twitch/TwitchIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class TwitchIntegration {
public const float DENIED_WEIGHT_MODIFIER = 0.8f;

public ChatterCollection FrequentChatters { get; }


public static Chatter NextChatter { get; set; }

Expand All @@ -57,6 +58,7 @@ public class TwitchIntegration {
public TwitchIntegration() {
this.FrequentChatters = new ChatterCollection();


Task<LocalAuthResponse> authTask = LocalAuthResponse.Fetch();
authTask.Wait();

Expand Down
2 changes: 0 additions & 2 deletions psp-papers-mod/src/Utils/SplitUsername.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public static (string, string) Process(string username) {

// uni1g -> 1g, uni
if (username.EndsWith("1g")) {
Console.WriteLine("1g");

splitIndex = username.LastIndexOf("1g", StringComparison.Ordinal);
}

Expand Down