live chat check

This commit is contained in:
Altixal authored and Cameron Ewell committed 2024-09-16 11:34:07 -04:00
1 parent 579f36a7e0
commit eb97369b32
3 files changed
+38 -5

No files matched your search

+1
View File
@@ -85,6 +85,7 @@ namespace CalamityMod.ILEditing
On_NPC.DoDeathEvents_BeforeLoot += PreventFoveanatorDefeatMessageIfNotKilledLast;
On_NPC.DoDeathEvents_CelebrateBossDeath += TripletsDefeatTextOverride;
On_TileDrawing.DrawSingleTile += GlowMaskTileRender;
On_Main.DoUpdate_HandleChat += SpawnPunchCard;
// Mana Burn (Chaos Stone) and Chalice of the Blood God
IL_Player.ApplyLifeAndOrMana += ManaSicknessAndChaliceBufferHeal;
+28
View File
@@ -36,6 +36,7 @@ using Mono.Cecil.Cil;
using MonoMod.Cil;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.Chat;
using Terraria.DataStructures;
using Terraria.GameContent;
@@ -76,6 +77,33 @@ namespace CalamityMod.ILEditing
public static event Func<VertexColors, int, Point, VertexColors> ExtraColorChangeConditions;
#region Punch Card Spawning Command
private static void SpawnPunchCard(Terraria.On_Main.orig_DoUpdate_HandleChat orig)
{
// Any of these conditions should result in normal behaviour
if (!Main.drawingPlayerChat || Main.CurrentInputTextTakerOverride != null || Main.editSign || PlayerInput.UsingGamepad)
{
orig();
return;
}
// Find 2 specific sets of text from the live chat box (as the player is typing)
// Gives the item to you and abruptly shuts the chat box down if both parts are found
string text = Main.chatText.ToLower();
string prefix = "Items.Accessories.PunchCard.SpawnText";
if ((text.Contains(CalamityUtils.GetTextValue($"{prefix}1")) || text.Contains(CalamityUtils.GetTextValue($"{prefix}1Alt"))) && text.Contains(CalamityUtils.GetTextValue($"{prefix}2")))
{
Main.player[Main.myPlayer].QuickSpawnItem(Player.GetSource_None(), ModContent.ItemType<PunchCard>(), 1);
Main.chatText = "";
Main.ClosePlayerChat();
Main.chatRelease = false;
SoundEngine.PlaySound(SoundID.MenuClose);
return;
}
orig();
}
#endregion
#region Dash Fixes and Improvements
private static void MakeShieldSlamIFramesConsistent(ILContext il)
{
@@ -2045,11 +2045,6 @@ GhostBracelet: {
Tooltip: Wow.... It looks at me with its hollow eyes full of curiosity
}
PunchCard: {
DisplayName: Punch Card
Tooltip: "[c/842593:'Please... please get world record...']"
}
HapuFruit: {
DisplayName: Ha-pu Fruit
Tooltip: "'A fruit that calms your nerves (may have unintended side effects)'"
@@ -2068,3 +2063,12 @@ Popo: {
'Don't let the demons steal your nose'
'''
}
PunchCard: {
DisplayName: Punch Card
Tooltip: "[c/842593:'Please... please get world record...']"
// These are used to spawn the item via chat -- both must be all lower case for the detection to work
SpawnText1: it's late
SpawnText1Alt: its late
SpawnText2: go to bed
}