Skip to content

Commit

Permalink
Merge pull request #85 from Lacyway/master
Browse files Browse the repository at this point in the history
Fix voice spamming bug
  • Loading branch information
Lacyway authored Dec 8, 2023
2 parents faae81d + d96c0c2 commit f7710fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 65 deletions.
17 changes: 9 additions & 8 deletions Source/Coop/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,21 @@ public override void OnPhraseTold(EPhraseTrigger @event, TaggedClip clip, TagBan
{
base.OnPhraseTold(@event, clip, bank, speaker);

Dictionary<string, object> packet = new()
if (IsYourPlayer)
{
{ "event", @event.ToString() },
{ "index", clip.NetId },
{ "m", "Say" }
};
AkiBackendCommunicationCoop.PostLocalPlayerData(this, packet);
Dictionary<string, object> packet = new()
{
{ "event", @event.ToString() },
{ "index", clip.NetId },
{ "m", "Say" }
};
AkiBackendCommunicationCoop.PostLocalPlayerData(this, packet);
}
}

public void ReceiveSay(EPhraseTrigger trigger, int index)
{
BepInLogger.LogDebug($"{nameof(ReceiveSay)}({trigger},{index})");
if (IsYourPlayer)
return;

var prc = GetComponent<PlayerReplicatedComponent>();
if (prc == null || !prc.IsClientDrone)
Expand Down
60 changes: 3 additions & 57 deletions Source/Coop/Player/Player_Say_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using StayInTarkov.Coop.Web;
using EFT;
using StayInTarkov.Coop.Web;
using System;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -16,16 +17,6 @@ protected override MethodBase GetTargetMethod()
return ReflectionHelpers.GetMethodForType(InstanceType, MethodName);
}

//[PatchPrefix]
//public static bool PrePatch(EFT.Player __instance)
//{
// var result = false;
// if (CallLocally.Contains(__instance.ProfileId))
// result = true;

// return result;
//}

[PatchPostfix]
public static void PostPatch(
EFT.Player __instance,
Expand All @@ -37,61 +28,16 @@ EPhraseTrigger @event
, bool aggressive
)
{
// //var player = __instance;

// //if (CallLocally.Contains(player.ProfileId))
// //{
// // CallLocally.Remove(player.ProfileId);
// // return;
// //}

// //Dictionary<string, object> dictionary = new();
// //dictionary.Add("t", DateTime.Now.Ticks);
// //dictionary.Add("event", @event);
// //dictionary.Add("demand", demand.ToString());
// //dictionary.Add("delay", delay.ToString());
// //dictionary.Add("mask", mask);
// //dictionary.Add("probability", probability.ToString());
// //dictionary.Add("aggressive", aggressive.ToString());
// //dictionary.Add("m", "Say");
// //AkiBackendCommunicationCoop.PostLocalPlayerData(player, dictionary);

}


public override void Replicated(EFT.Player player, Dictionary<string, object> dict)
{
//Logger.LogInfo($"{nameof(Player_Say_Patch)}:{nameof(Replicated)}");
if (HasProcessed(GetType(), player, dict))
return;

if (CallLocally.Contains(player.ProfileId))
{
CallLocally.Remove(player.ProfileId);
return;
}

CallLocally.Add(player.ProfileId);

//try
//{
// CallLocally.Add(player.ProfileId);
// player.Say(
// (EPhraseTrigger)Enum.Parse(typeof(EPhraseTrigger), dict["event"].ToString())
// , demand: bool.Parse(dict["demand"].ToString())
// , delay: float.Parse(dict["delay"].ToString())
// , mask: (ETagStatus)Enum.Parse(typeof(ETagStatus), dict["mask"].ToString())
// , probability: int.Parse(dict["probability"].ToString())
// , aggressive: bool.Parse(dict["aggressive"].ToString())

// );
//}
//catch (Exception e)
//{
// Logger.LogInfo(e);
//}

((CoopPlayer)player).ReceiveSay((EPhraseTrigger)Enum.Parse(typeof(EPhraseTrigger), dict["event"].ToString()), int.Parse(dict["index"].ToString()));

}
}
}

0 comments on commit f7710fe

Please sign in to comment.