Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ToN_MasterChange #92

Merged
merged 15 commits into from
Oct 18, 2024
Merged
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Latest Changelog

- Attempting to fix the False Positives with the two only FREE Anti Viruses. (Avast and AVG) again...
- Added OSC parameter option: 'ToN_MasterChange'
- You can use this parameter to detect when the instance master has changed.
- Updated Simplified Chinese localization (Thank you @Fallen-ice)
- I always knew.
- Updated Japanese localization (Thank you @nomlasvrc)
1 change: 1 addition & 0 deletions Docs/OSC/OSC_Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Parameter | Type | Description
`ToN_ItemStatus` | `BOOL` | (Experimental) Determines the active status of items like the **Chaos Coil**, **Emerald Coil**, **Corkscrew** and **TBH**.
`ToN_Saboteur` | `BOOL` | The player is the killer on a Sabotage round.
`ToN_DeathID` | `INT` | You can use this parameter to track when your friends die in the game.
`ToN_MasterChange` | `BOOL` | Set to `true` for a short period of time when the instance master has changed.

> You need to specify a list of player names to use with the **ToN_DeathID** parameter.<br>
> You can do so under Settings > Send Death ID > (Edit)<br>
Expand Down
7 changes: 6 additions & 1 deletion Localization/Language/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@
"SETTINGS.OSCDEATHEVENT_COOLDOWN": "(Cooldown)",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TT": "Set the time (in milliseconds) to wait before setting the ID value for this parameter after multiple players die in quick succession.",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TITLE": "Set Cooldown Time",
"SETTINGS.OSCMASTERCHANGE": "Send Master Change",
"SETTINGS.OSCMASTERCHANGE.TT": "Sends 'TRUE' to the parameter 'ToN_MasterChange' when the instance master has changed.",
"SETTINGS.OSCMASTERCHANGE_EDIT": "(Set Interval)",
"SETTINGS.OSCMASTERCHANGE_EDIT.TT": "Sets the interval (in milliseconds) to wait before setting this parameter value back to 'FALSE'",
"SETTINGS.OSCMASTERCHANGE.TITLE": "Set Master Interval",

"SETTINGS.GROUP.NOTIFICATIONS": "Notifications",

Expand Down Expand Up @@ -255,7 +260,7 @@
"OBJECTIVES.DIVINE_AVENGER": "Divine Avenger",
"OBJECTIVES.DIVINE_AVENGER.TT": "Survive Arkus with '$$OBJECTIVES.SEALED_SWORD$$' after hitting them at least two times.",
"OBJECTIVES.MAXWELL": "Maxwell",
"OBJECTIVES.MAXWELL.TT": "Found in Its Maze. (spawns once per round)",
"OBJECTIVES.MAXWELL.TT": "Found in Experimentation. (spawns once per round)",
"OBJECTIVES.ROCK": "Rock",
"OBJECTIVES.ROCK.TT": "Survive Fusion Pilot.",
"OBJECTIVES.ILLUMINA": "Illumina",
Expand Down
76 changes: 70 additions & 6 deletions Localization/Language/ja-JP.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"DISPLAY_INIT": "JP",
"DISPLAY_NAME": "日本語",

Expand Down Expand Up @@ -60,6 +60,7 @@
"MAIN.ENTRY_PLAYERS": "インスタンス内のプレイヤー:",
"MAIN.ENTRY_MAP": "マップ:",
"MAIN.ENTRY_WARNING": "$$SAVE.TAG_X$$ 警告!! このセーブコードは、セーブコードを読み込む前に生成されました。\n新規プレイヤーでない場合は、一つ前のセーブコードを読み込んでください。",
"MAIN.ENTRY_COPIED": "クリップボードにコピーしました!",

"ROUND_TYPE.INTERMISSION": "休憩時間",
"ROUND_TYPE.CLASSIC": "クラシック",
Expand Down Expand Up @@ -91,7 +92,9 @@
"SAVE.TAG_D": "🔌",
"SAVE.TAG_L": "💀",
"SAVE.TAG_X": "❗",

"SAVE.TAG_B": "😇",
"SAVE.TAG_C": "✅",

"SETTINGS.CHECK_UPDATE": "アップデートを確認",
"SETTINGS.OPEN_DATA_BTN": "データ",
"SETTINGS.OPEN_DATA_BTN.TT": "セーブデータが保存されているフォルダーを開きます。",
Expand Down Expand Up @@ -192,7 +195,17 @@
"SETTINGS.OSCDAMAGEDEVENT_EDIT": "(インターバルを設定)",
"SETTINGS.OSCDAMAGEDEVENT_EDIT.TT": "ダメージイベントの送信とそれをゼロにリセットするまでの間隔(ミリ秒)を設定します。",
"SETTINGS.OSCDAMAGEDEVENT.TITLE": "ダメージインターバルを設定",

"SETTINGS.OSCDEATHEVENT": "死亡イベントを送信",
"SETTINGS.OSCDEATHEVENT.TT": "INTパラメータ'ToN_DeathID'に死亡イベントを送信します。\nこの機能を使って、ゲーム内でフレンドがいつ死んだかを追跡できます。\n数値は死亡したユーザー名のリスト上の位置を表し、減衰時間が経過するとこの値は0にリセットされます。",
"SETTINGS.OSCDEATHEVENT.TITLE": "プレイヤー名を設定",
"SETTINGS.OSCDEATHEVENT_EDIT": "(編集)",
"SETTINGS.OSCDEATHEVENT_EDIT.TT": "このパラメータで使用するプレイヤー名のリストを設定します。\nプレイヤー名はカンマ(,)で区切ってください。",
"SETTINGS.OSCDEATHEVENT_DECAY": "(減衰)",
"SETTINGS.OSCDEATHEVENT_DECAY.TT": "値を0にリセットするまでの待機時間(ミリ秒単位)を設定します。",
"SETTINGS.OSCDEATHEVENT_DECAY.TITLE": "減衰時間を設定",
"SETTINGS.OSCDEATHEVENT_COOLDOWN": "(クールダウン)",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TT": "複数のプレイヤーが連続して死亡した場合に、このパラメータのID値を設定するまでの待機時間(ミリ秒)を設定します。",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TITLE": "クールダウンタイムを設定",

"SETTINGS.GROUP.NOTIFICATIONS": "通知",

Expand All @@ -201,10 +214,20 @@
"SETTINGS.XSOVERLAY.MESSAGE": "<color=#ff9999><b>ToN</b></color><color=grey>:</color> <color=#adff2f>セーブデータを保存しました。</color>",
"SETTINGS.XSOVERLAY.TOGGLE": "<color=#ff9999><b>ToN</b></color><color=grey>:</color> <color=#adff2f>通知が有効です。</color>",

"SETTINGS.PLAYAUDIO": "オーディオを再生 ({0})",
"SETTINGS.PLAYAUDIO.TT": "ダブルクリックしてカスタムオーディオファイルを選択します。\n右クリックで'default.wav'に戻します。",

"SETTINGS.PLAYAUDIO.TITLE": "カスタムオーディオを選択",

"SETTINGS.PLAYAUDIOSAVE": "セーブ時に音声を再生",
"SETTINGS.PLAYAUDIOSAVE.TT": "新しいセーブコードが作成されたときに音声を再生します。",

"SETTINGS.PLAYAUDIOCOPY": "コピー時に音声を再生",
"SETTINGS.PLAYAUDIOCOPY.TT": "セーブコードをコピーしたときに音声を再生します。",

"SETTINGS.PLAYAUDIO_SELECT": "(音声ファイルを選択)",
"SETTINGS.PLAYAUDIO_SELECT.TT": "通知に使うカスタムオーディオを選択します。",
"SETTINGS.PLAYAUDIO_SELECT.ALT": "$$SETTINGS.PLAYAUDIO_SELECT.TT$$\n通知音をデフォルトに戻すにはこのボタンを右クリックしてください。",


"SETTINGS.GROUP.TIME_FORMAT": "時刻フォーマット",
"SETTINGS.USE24HOUR": "24時間表示",
"SETTINGS.SHOWSECONDS": "秒を表示",
Expand Down Expand Up @@ -232,7 +255,7 @@
"OBJECTIVES.DIVINE_AVENGER": "ディバインアベンジャー",
"OBJECTIVES.DIVINE_AVENGER.TT": "Arkusを$$OBJECTIVES.SEALED_SWORD$$を持ったまま2回以上スタンして生存。",
"OBJECTIVES.MAXWELL": "マクスウェル",
"OBJECTIVES.MAXWELL.TT": "Its Mazeにある(1ラウンドに1回出現)。",
"OBJECTIVES.MAXWELL.TT": "Experimentationにある(1ラウンドに1回出現)。",
"OBJECTIVES.ROCK": "岩石",
"OBJECTIVES.ROCK.TT": "Fusion Pilotを生存。",
"OBJECTIVES.ILLUMINA": "イルミナ",
Expand All @@ -243,6 +266,7 @@
"OBJECTIVES.OMORI_PLUSH.TT": "Somethingを生存。",
"OBJECTIVES.PARADISE_LOST": "失楽園",
"OBJECTIVES.PARADISE_LOST.TT": "使徒を指定回数スタンさせる。",

"OBJECTIVES.ITEM_SKIN_UNLOCKS": "解放したアイテムスキン",
"OBJECTIVES.RED_MEDKIT": "赤メッドキット",
"OBJECTIVES.RED_MEDKIT.TT": "メッドキットを持ちながらVirusを生存。",
Expand Down Expand Up @@ -273,6 +297,44 @@
"OBJECTIVES.SNOWY_SPEED_COIL.TT": "雪の中に何かがある。",
"OBJECTIVES.TORCH_OF_OBSESSION": "松明",
"OBJECTIVES.TORCH_OF_OBSESSION.TT": "Cold Nightを生存。",

"OBJECTIVES.HAVE_PLUSH": "Have人形",
"OBJECTIVES.HAVE_PLUSH.TT": "The Observationを生存。",
"OBJECTIVES.PORTABLE_SLOTS": "ポータブルスロット",
"OBJECTIVES.PORTABLE_SLOTS.TT": "Haveの秘密に包まれた酒を持ちながらアンバウンドを生存。",
"OBJECTIVES.SOUL_VISITOR": "ソウルビジター",
"OBJECTIVES.SOUL_VISITOR.TT": "テレポーターを持ちながらアンバウンドを生存。",
"OBJECTIVES.DEFLECT_COIL": "蒼白のコイル",
"OBJECTIVES.DEFLECT_COIL.TT": "リジェネコイルを持ちながらオルタネイトを生存。",
"OBJECTIVES.ROOT_COIL": "樹根リジェネコイル",
"OBJECTIVES.ROOT_COIL.TT": "草むらで待つ。",
"OBJECTIVES.GHOST_BAT": "ゴーストバット",
"OBJECTIVES.GHOST_BAT.TT": "金属バットを持ちながらゴーストを生存。",
"OBJECTIVES.BLOODY_CHARM": "血濡れチャーム",
"OBJECTIVES.BLOODY_CHARM.TT": "シルバーキャットチャームを持ちながらブラッドバスを生存。",
"OBJECTIVES.LUNA_CHARM": "ルナチャーム",
"OBJECTIVES.LUNA_CHARM.TT": "Kimeraを生存。",
"OBJECTIVES.DESTROYER_COIL": "デストロイヤーコイル",
"OBJECTIVES.DESTROYER_COIL.TT": "コルクスクリューコイルを持ちながらミッドナイトを生存。",
"OBJECTIVES.BLOODY_REVOLVER": "血濡れリボルバー",
"OBJECTIVES.BLOODY_REVOLVER.TT": "アンティークリボルバーを持ちながらブラッドバスを生存。",
"OBJECTIVES.HAUNTED_HAMBURGER": "ハウント ハンバーガー",
"OBJECTIVES.HAUNTED_HAMBURGER.TT": "ハンバーガーを持ちながらゴーストを生存。",
"OBJECTIVES.THORN_GLOGNUT": "ソーングロッグナッツ",
"OBJECTIVES.THORN_GLOGNUT.TT": "Glaggle Gangを生存。",
"OBJECTIVES.JAILBIRD": "ジェイルバード",
"OBJECTIVES.JAILBIRD.TT": "全てのクラシックテラーで生存。",
"OBJECTIVES.JOYOUS_ORB": "ジョイアスオーブ",
"OBJECTIVES.JOYOUS_ORB.TT": "JOYを生存。",

"OBJECTIVES.CLAW_MACHINE_UNLOCKS": "クレーンゲームで解放",
"OBJECTIVES.NORA_PLUSH": "Nora人形",
"OBJECTIVES.NORA_PLUSH.TT": "Beyond人形が必要。",
"OBJECTIVES.ROBLANDER_PLUSH": "Roblander人形",
"OBJECTIVES.ROBLANDER_PLUSH.TT": "Darkgrey人形が必要。",
"OBJECTIVES.OBSERVATION_PLUSH": "Observation人形",
"OBJECTIVES.OBSERVATION_PLUSH.TT": "Have人形が必要。",


"STATS.TITLE": "ToN 統計トラッカー",
"STATS.SHOW_LOBBY": "ロビーの統計を表示",
Expand Down Expand Up @@ -333,6 +395,8 @@
"STATS.LABEL_MAPORIGIN.TT": "このマップの出典。",
"STATS.LABEL_ISALIVE": "生存中",
"STATS.LABEL_ISALIVE.TT": "プレイヤーが現在のラウンドで生きている場合「True」。",
"STATS.LABEL_ISREBORN": "復活",
"STATS.LABEL_ISREBORN.TT": "ラウンド中にマクスウェルで生き返った場合「True」。",
"STATS.LABEL_ISSTARTED": "ラウンド進行中",
"STATS.LABEL_ISSTARTED.TT": "ラウンドが開始して進行中の場合「True」。",
"STATS.LABEL_INSTANCEURL": "インスタンスURL",
Expand Down
8 changes: 7 additions & 1 deletion Localization/Language/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
"OBJECTIVES.DIVINE_AVENGER": "神圣复仇者(Divine Avenger)",
"OBJECTIVES.DIVINE_AVENGER.TT": "使用$$OBJECTIVES.SEALED_SWORD$$至少打中两下阿库斯(Arkus)并存活。",
"OBJECTIVES.MAXWELL": "麦克斯韦(Maxwell)",
"OBJECTIVES.MAXWELL.TT": "在迷宫(Its Maze)中找到(每轮生成一次)。",
"OBJECTIVES.MAXWELL.TT": "在实验室(Experimentation)中找到(每轮生成一次)。",
"OBJECTIVES.ROCK": "岩石(Rock)",
"OBJECTIVES.ROCK.TT": "在熔核领航者(Fusion Pilot)下存活。",
"OBJECTIVES.ILLUMINA": "依诺米那(Illumina)",
Expand Down Expand Up @@ -320,6 +320,12 @@
"OBJECTIVES.BLOODY_REVOLVER.TT": "使用古董左轮手枪(Antique Revolver)在血浴(Bloodbath)回合中存活。",
"OBJECTIVES.HAUNTED_HAMBURGER": "闹鬼汉堡(Haunted Hamburger)",
"OBJECTIVES.HAUNTED_HAMBURGER.TT": "使用汉堡(Hamburger)在幽灵(Ghost)回合中存活。",
"OBJECTIVES.THORN_GLOGNUT": "索恩·格洛鲁特(Thorn Glognut)",
"OBJECTIVES.THORN_GLOGNUT.TT": "在格拉格尔帮派(Glaggle Gang)下存活。",
"OBJECTIVES.JAILBIRD": "狱鸟(Jailbird)",
"OBJECTIVES.JAILBIRD.TT": "在所有经典(Classic)怪物下至少存活过一次。",
"OBJECTIVES.JOYOUS_ORB": "欢乐之球(Joyous Orb)",
"OBJECTIVES.JOYOUS_ORB.TT": "在欢乐(JOY)下存活。",

"OBJECTIVES.CLAW_MACHINE_UNLOCKS": "抓娃娃机解锁",
"OBJECTIVES.NORA_PLUSH": "Nora玩偶(Nora Plush)",
Expand Down
10 changes: 10 additions & 0 deletions Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ public int GetDeathID (string id) {
return Array.IndexOf(OSCDeathIDs, id) + 1;
}


/// <summary>
/// OSC Master Changed event for OSC.
/// </summary>
public bool OSCMasterChange { get; set; } = false;
/// <summary>
/// OSC Master Change event interval.
/// </summary>
public int OSCMasterChangeInterval { get; set; } = 500;

/// <summary>
/// Enables OSC chatbox messages.
/// </summary>
Expand Down
44 changes: 40 additions & 4 deletions Utils/LilOSC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ internal static class LilOSC {
const string ParamDeath = "ToN_DeathID";
const string ParamPages = "ToN_Pages";
const string ParamItemStatus = "ToN_ItemStatus";
const string ParamMaster = "ToN_MasterChange";

static readonly string[] ParamAll = [
ParamRoundType, ParamTerror1, ParamTerror2, ParamTerror3, ParamTPhase1, ParamTPhase2, ParamTPhase3,
ParamOptedIn, ParamSaboteur, ParamMap, ParamEncounter,
ParamTerrorColorH, ParamTerrorColorS, ParamTerrorColorV, ParamTerrorColorL,
ParamTerrorColorR, ParamTerrorColorG, ParamTerrorColorB,
ParamAlive, ParamReborn, ParamDamaged, ParamDeath, ParamPages, ParamItemStatus
ParamAlive, ParamReborn, ParamDamaged, ParamMaster, ParamDeath, ParamPages, ParamItemStatus
];
const string ParameterFileName = "osc_parameters.txt";
internal static void Initialize() {
Expand Down Expand Up @@ -186,6 +187,36 @@ private static void DeathTimer_Tick(object? sender, EventArgs e) {
}
#endregion

#region Host Change
private static Timer? HostTimer;
private static bool LastHost = false;
internal static void SendHostChange() {
if (LastHost || !MainWindow.Started || !Settings.Get.OSCMasterChange || !Settings.Get.OSCEnabled) return;

if (HostTimer == null) {
HostTimer = new Timer();
HostTimer.Tick += HostTimer_Tick;
HostTimer.Interval = Settings.Get.OSCMasterChangeInterval;
}

LastHost = true;
SendParam(ParamMaster, LastHost);

HostTimer.Stop();
if (Settings.Get.OSCMasterChangeInterval > 0) {
HostTimer.Interval = Settings.Get.OSCMasterChangeInterval;
HostTimer.Start();
} else LastHost = false;
}

private static void HostTimer_Tick(object? sender, EventArgs e) {
HostTimer?.Stop();

LastHost = false;
SendParam(ParamMaster, LastHost);
}
#endregion

private static Timer? DamageTimer;
private static int LastDamage = 0;
internal static void SetDamage(int damage) {
Expand All @@ -198,11 +229,16 @@ internal static void SetDamage(int damage) {
}

if (LastDamage != damage) {
DamageTimer.Stop();
DamageTimer.Start();

LastDamage = damage;
SendParam(ParamDamaged, damage); // change param to a const

DamageTimer.Stop();
if (Settings.Get.OSCDamagedInterval > 0) {
DamageTimer.Interval = Settings.Get.OSCDamagedInterval;
DamageTimer.Start();
} else {
LastDamage = 0;
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ private bool HandleTerrorIndex(string line, DateTime timestamp, ToNLogContext co
const string STAT_STUN_LANDED = " landed a stun!";
const string STAT_STUN_TARGET = " was stunned.";
const string STAT_HIT = "Hit - ";

const string EVENT_MASTER_CHANGE = "[Behaviour] OnMasterClientSwitched";

private bool HandleStatCollection(string line, DateTime timestamp, ToNLogContext context) {
if (!context.IsRecent) return false;

Expand All @@ -893,6 +896,11 @@ private bool HandleStatCollection(string line, DateTime timestamp, ToNLogContext
}

if (Settings.Get.OSCEnabled) {
if (Settings.Get.OSCMasterChange && line.StartsWith(EVENT_MASTER_CHANGE)) {
LilOSC.SendHostChange();
return true;
}

bool isActivated = line.StartsWith("[UNSTABLE COIL] Activated!") || line.StartsWith("[EMERALD COIL] Activated!") || line.StartsWith("[CORKSCREW COIL] Activated!");
bool isDeactivated = line.StartsWith("[UNSTABLE COIL] Deactivated!") || line.StartsWith("[EMERALD COIL] Deactivated!") || line.StartsWith("[CORKSCREW COIL] Deactivated!");
if (isActivated || isDeactivated) {
Expand Down
Loading