Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValPH Client Mods v3.1.0
plugins/ValPhPvPTweaks.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("RemoveRaidIcon")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RemoveRaidIcon")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("67f40cdf-9038-4a7d-b7a1-fdc9567f1a85")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ValphPvPTweaks { internal class CircularQueue<T> : Queue<T> { private int capacity; public CircularQueue(int capacity) : base(capacity) { this.capacity = capacity; } public new void Enqueue(T item) { if (this.Count() >= capacity) { Dequeue(); } base.Enqueue(item); } } internal class Constants { internal const string InCombatZdoKey = "VPT_PlayerInCombat"; internal const string CharacterDeadRpc = "VPT_CharacterDeadRpc"; } public static class Extensions { public static bool InCombat(this Player player) { return (Object)(object)((Character)player).m_nview != (Object)null && ((Character)player).m_nview.IsValid() && ((Character)player).m_nview.GetZDO().GetBool("VPT_PlayerInCombat", false); } public static ZDO GetZdo(this ZNetPeer peer) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ZDOMan.instance.GetZDO(peer.m_characterID); } public static bool InCombat(this ZNetPeer peer) { ZDO zdo = peer.GetZdo(); return zdo != null && zdo.GetBool("VPT_PlayerInCombat", false); } } [BepInPlugin("pvptweaks.valph", "valPHPvPTweaks", "2.1.0")] public class valphpvptweaks : BaseUnityPlugin { [HarmonyPatch(typeof(PlatformUserID), "TryParse")] public static class Patch_PlatformUserID_TryParse { private static void Prefix(ref string platformUserID) { if (!string.IsNullOrEmpty(platformUserID) && !platformUserID.Contains("_")) { platformUserID = "Steam_" + platformUserID; } } } [HarmonyPatch(typeof(Minimap), "UpdateEventPin")] private class Minimap_UpdateEventPin_Patch { private static void Postfix(Minimap __instance, ref PinData ___m_randEventAreaPin, ref PinData ___m_randEventPin) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (___m_randEventAreaPin != null && (int)___m_randEventAreaPin.m_type == 13) { __instance.RemovePin(___m_randEventAreaPin); __instance.RemovePin(___m_randEventPin); } } } [HarmonyPatch(typeof(Chat), "SendText")] public class HideShoutPing { private static void Prefix(ref Vector3 __state) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { __state = ((Character)Player.m_localPlayer).m_head.position; ((Character)Player.m_localPlayer).m_head.position = default(Vector3); } } private static void Postfix(Vector3 __state) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).m_head.position = __state; } } } [HarmonyPatch(typeof(Character))] private class CharacterPatch { [HarmonyPrefix] [HarmonyPatch("ApplyDamage")] private static void ApplyDamagePrefix(Character __instance, HitData hit) { if (!((Object)(object)__instance == (Object)(object)Player.m_localPlayer)) { return; } Character attacker = hit.GetAttacker(); if (Object.op_Implicit((Object)(object)attacker) && attacker.IsPlayer()) { Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val != (Object)null) { string playerName = val.GetPlayerName(); float bodyArmor = ((Character)val).GetBodyArmor(); float stamina = val.GetStamina(); valphLogger.LogInfo((object)$"Hit by {playerName} | Hit Damage: {hit.GetTotalDamage()}"); } } recentHitQueue.Enqueue(hit); } } [HarmonyPatch(typeof(Player), "CreateTombStone")] private static class PatchItemLoss { [HarmonyPriority(700)] private static void Prefix(Player __instance, out Dictionary<ItemData, bool> __state) { List<ItemData> list = new List<ItemData>(); List<ItemData> list2 = new List<ItemData>(); __state = new Dictionary<ItemData, bool>(); foreach (ItemData item in ((Humanoid)__instance).m_inventory.m_inventory) { string text = ((item.m_gridPos.y == 0) ? "hotbar" : "inventory"); bool equipped = item.m_equipped; if (isPvpDeath() && text == "hotbar") { __state.Add(item, item.m_equipped); } else if (equipped && isPvpDeath()) { __state.Add(item, item.m_equipped); } else { list.Add(item); } } ((Humanoid)__instance).m_inventory.m_inventory = list; } [HarmonyPriority(100)] private static void Postfix(Player __instance, Dictionary<ItemData, bool> __state) { foreach (KeyValuePair<ItemData, bool> item in __state) { ((Humanoid)__instance).m_inventory.m_inventory.Add(item.Key); if (item.Value) { ((Humanoid)__instance).EquipItem(item.Key, false); } } ((Humanoid)__instance).m_inventory.Changed(); } } [HarmonyPatch(typeof(Skills), "OnDeath")] private static class SkillsOnDeathPatch { private static bool Prefix(Skills __instance) { return !isPvpDeath(); } } [HarmonyPatch(typeof(Terminal), "updateBinds")] public static class Patch_Bind_Command { public static bool Prefix() { return false; } } [HarmonyPatch(typeof(Player), "StartEmote")] public static class Patch_Player_StartEmote { public static bool Prefix(string emote) { if (Player.m_localPlayer.InCombat()) { return false; } return true; } } private static CircularQueue<HitData> recentHitQueue = new CircularQueue<HitData>(3); private static List<string> typeEnums = new List<string>(); private const string ModName = "valPHPvPTweaks"; public static readonly ManualLogSource valphLogger = Logger.CreateLogSource("valPHPvPTweaks"); private void Awake() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown foreach (int value in Enum.GetValues(typeof(ItemType))) { typeEnums.Add(Enum.GetName(typeof(ItemType), value)); } Harmony val = new Harmony("valPHPvPTweaks"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Steam Prefix Mod loaded and Harmony patches applied."); } private static bool isPvpDeath() { foreach (HitData item in recentHitQueue) { Character attacker = item.GetAttacker(); if (Object.op_Implicit((Object)(object)attacker) && attacker.IsPlayer()) { Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val != (Object)null) { string playerName = val.GetPlayerName(); return true; } } } return false; } } public class ZDOInternalExtensions { public static readonly int wardRadius = StringExtensionMethods.GetStableHashCode("wardRadius"); public static readonly int accessMode = StringExtensionMethods.GetStableHashCode("accessMode"); public static readonly int bubbleMode = StringExtensionMethods.GetStableHashCode("bubbleMode"); public static readonly int damageType = StringExtensionMethods.GetStableHashCode("damageType"); public static readonly int healthRegen = StringExtensionMethods.GetStableHashCode("healthRegen"); public static readonly int staminaBoost = StringExtensionMethods.GetStableHashCode("staminaBoost"); public static readonly int bubbleOn = StringExtensionMethods.GetStableHashCode("bubbleOn"); public static readonly int weatherDmgOn = StringExtensionMethods.GetStableHashCode("weatherDmgOn"); public static readonly int autoPickupOn = StringExtensionMethods.GetStableHashCode("autoPickupOn"); public static readonly int autoCloseDoorsOn = StringExtensionMethods.GetStableHashCode("autoCloseDoorsOn"); public static readonly int fireplaceUnlimOn = StringExtensionMethods.GetStableHashCode("fireplaceUnlimOn"); public static readonly int bathingUnlimOn = StringExtensionMethods.GetStableHashCode("bathingUnlimOn"); public static readonly int cookingUnlimOn = StringExtensionMethods.GetStableHashCode("cookingUnlimOn"); public static readonly int wardFireplaceList = StringExtensionMethods.GetStableHashCode("wardFireplaceList"); public static readonly int noDeathPenOn = StringExtensionMethods.GetStableHashCode("noDeathPenOn"); public static readonly int noFoodDrainOn = StringExtensionMethods.GetStableHashCode("noFoodDrainOn"); public static readonly int pushoutPlayersOn = StringExtensionMethods.GetStableHashCode("pushoutPlayersOn"); public static readonly int pushoutCreaturesOn = StringExtensionMethods.GetStableHashCode("pushoutCreaturesOn"); public static readonly int pvpOn = StringExtensionMethods.GetStableHashCode("pvpOn"); public static readonly int pveOn = StringExtensionMethods.GetStableHashCode("pveOn"); public static readonly int teleportOn = StringExtensionMethods.GetStableHashCode("teleportOn"); public static readonly int showFlashOn = StringExtensionMethods.GetStableHashCode("showFlashOn"); public static readonly int showMarkerOn = StringExtensionMethods.GetStableHashCode("showMarkerOn"); public static readonly int wardNotificationsOn = StringExtensionMethods.GetStableHashCode("wardNotificationsOn"); public static readonly int wardNotifyMessageEntry = StringExtensionMethods.GetStableHashCode("wardNotifyMessageEntry"); public static readonly int wardNotifyMessageExit = StringExtensionMethods.GetStableHashCode("wardNotifyMessageExit"); public static readonly int wardDamageAmount = StringExtensionMethods.GetStableHashCode("wardDamageAmount"); public static readonly int itemstandInteractOn = StringExtensionMethods.GetStableHashCode("itemstandInteractOn"); public static readonly int indestructibleOn = StringExtensionMethods.GetStableHashCode("indestructibleOn"); public static readonly int indestructList = StringExtensionMethods.GetStableHashCode("indestructList"); public static readonly int CreatDamageIncreaseAmount = StringExtensionMethods.GetStableHashCode("CreatDamageIncreaseAmount"); public static readonly int structDamageReducAmount = StringExtensionMethods.GetStableHashCode("structDamageReducAmount"); public static readonly int itemInteractOn = StringExtensionMethods.GetStableHashCode("itemInteractOn"); public static readonly int doorInteractOn = StringExtensionMethods.GetStableHashCode("doorInteractOn"); public static readonly int chestInteractOn = StringExtensionMethods.GetStableHashCode("chestInteractOn"); public static readonly int portalInteractOn = StringExtensionMethods.GetStableHashCode("portalInteractOn"); public static readonly int pickableInteractOn = StringExtensionMethods.GetStableHashCode("pickableInteractOn"); public static readonly int shipInteractOn = StringExtensionMethods.GetStableHashCode("shipInteractOn"); public static readonly int signInteractOn = StringExtensionMethods.GetStableHashCode("signInteractOn"); public static readonly int craftingStationInteractOn = StringExtensionMethods.GetStableHashCode("craftingStationInteractOn"); public static readonly int smelterInteractOn = StringExtensionMethods.GetStableHashCode("smelterInteractOn"); public static readonly int beehiveInteractOn = StringExtensionMethods.GetStableHashCode("beehiveInteractOn"); public static readonly int maptableInteractOn = StringExtensionMethods.GetStableHashCode("maptableInteractOn"); public static readonly int OnlyPermOn = StringExtensionMethods.GetStableHashCode("OnlyPermOn"); public static readonly int NotPermOn = StringExtensionMethods.GetStableHashCode("NotPermOn"); public static readonly int ctaMessage = StringExtensionMethods.GetStableHashCode("ctaMessage"); public static readonly int autoRepairOn = StringExtensionMethods.GetStableHashCode("autoRepairOn"); public static readonly int autoRepairAmount = StringExtensionMethods.GetStableHashCode("autoRepairAmount"); public static readonly int autoRepairTime = StringExtensionMethods.GetStableHashCode("autoRepairTime"); public static readonly int raidProtectionOn = StringExtensionMethods.GetStableHashCode("raidProtectionOn"); public static readonly int raidablePlayersNeeded = StringExtensionMethods.GetStableHashCode("raidablePlayersNeeded"); public static readonly int wardIsLoveOn = StringExtensionMethods.GetStableHashCode("wardIsLoveOn"); public static readonly int WILLimitedWard = StringExtensionMethods.GetStableHashCode("WILLimitedWard"); public static readonly int WILLimitedWardTime = StringExtensionMethods.GetStableHashCode("WILLimitedWardTime"); public static readonly int steamID = StringExtensionMethods.GetStableHashCode("steamID"); public static readonly int steamName = StringExtensionMethods.GetStableHashCode("steamName"); public static readonly int wardFresh = StringExtensionMethods.GetStableHashCode("wardFresh"); public static readonly int wardColorCount = StringExtensionMethods.GetStableHashCode("wardColorCount"); public static readonly int wardAlphaCount = StringExtensionMethods.GetStableHashCode("wardAlphaCount"); public static readonly int wardModelKey = StringExtensionMethods.GetStableHashCode("wardModelKey"); } } namespace ValphPvPTweaks.statuseffect { [HarmonyPatch] internal class Patches { [HarmonyPostfix] [HarmonyPatch(typeof(Player), "OnSpawned")] private static void Player_OnSpawned(Player __instance) { ((Component)__instance).gameObject.AddComponent<PlayerCombatHandler>(); } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static void ObjectDB_Awake(ObjectDB __instance) { __instance.m_StatusEffects.Add((StatusEffect)(object)SE_Combat.Create()); } [HarmonyPostfix] [HarmonyPatch(typeof(Game), "Start")] private static void Game_Start() { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Combat")); statusEffect.m_icon = ((Component)InventoryGui.instance.m_pvp).GetComponent<ToggleImage>().m_onImage; } } internal class PlayerCombatHandler : MonoBehaviour { private const string EnterCombatRpc = "EnterCombatRpc"; private Player _player; private void Awake() { _player = ((Component)this).GetComponent<Player>(); ((Character)_player).m_onDamaged = (Action<float, Character>)Delegate.Combine(((Character)_player).m_onDamaged, new Action<float, Character>(OnDamaged)); if ((Object)(object)((Character)_player).m_nview != (Object)null && ((Character)_player).m_nview.IsValid()) { ((Character)_player).m_nview.Register("EnterCombatRpc", (Action<long>)OnEnteredPvpMode); } } private void OnDamaged(float damage, Character character) { if (!(damage <= 0f) && !((Object)(object)character == (Object)null) && character.IsPlayer()) { OnEnteredPvpMode(0L); character.m_nview.InvokeRPC("EnterCombatRpc", Array.Empty<object>()); } } private void OnEnteredPvpMode(long obj) { ((Character)_player).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Combat"), true, 0, 0f); } public static void EnterCombat(Character character) { if ((Object)(object)character != (Object)null && (Object)(object)character.m_nview != (Object)null && character.m_nview.IsValid()) { character.m_nview.InvokeRPC("EnterCombatRpc", Array.Empty<object>()); } } } internal class SE_Combat : SE_Stats { public const string Name = "SE_Combat"; public override bool CanAdd(Character character) { return character.IsPlayer(); } public override void Setup(Character character) { ((SE_Stats)this).Setup(character); base.m_healthRegenMultiplier = 1f; ((StatusEffect)this).m_ttl = 120f; ZNetView nview = ((StatusEffect)this).m_character.m_nview; if (nview != null) { ZDO zDO = nview.GetZDO(); if (zDO != null) { zDO.Set("VPT_PlayerInCombat", true); } } } public override void Stop() { ((StatusEffect)this).Stop(); if (Game.instance.IsShuttingDown()) { return; } ZNetView nview = ((StatusEffect)this).m_character.m_nview; if (nview != null) { ZDO zDO = nview.GetZDO(); if (zDO != null) { zDO.Set("VPT_PlayerInCombat", false); } } } public static SE_Combat Create() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) SE_Combat sE_Combat = ScriptableObject.CreateInstance<SE_Combat>(); ((Object)sE_Combat).name = "SE_Combat"; ((StatusEffect)sE_Combat).m_name = "Battle"; ((StatusEffect)sE_Combat).m_startMessage = "Combat has begun!"; ((StatusEffect)sE_Combat).m_startMessageType = (MessageType)2; ((StatusEffect)sE_Combat).m_stopMessage = "Combat has begun"; ((StatusEffect)sE_Combat).m_stopMessageType = (MessageType)1; return sE_Combat; } } }