using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Service;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DPS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DPS")]
[assembly: AssemblyTitle("DPS")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
internal sealed class ConfigurationManagerAttributes
{
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public string Description;
public string DispName;
public int? Order;
public bool? ReadOnly;
public bool? IsAdvanced;
public Func<object, string> ObjToStr;
public Func<string, object> StrToObj;
}
namespace Service
{
public class Format
{
public const string FORMAT = "0.##";
public static string GetValidColor(bool valid)
{
if (!valid)
{
return "grey";
}
return "yellow";
}
public static string String(string value, string color = "yellow")
{
return "<color=" + color + ">" + value + "</color>";
}
public static string String(string value, bool valid)
{
return "<color=" + GetValidColor(valid) + ">" + value + "</color>";
}
public static string Float(double value, string format = "0.##", string color = "yellow")
{
return String(value.ToString(format, CultureInfo.InvariantCulture), color);
}
public static string Multiplier(double value, string color = "yellow")
{
return String(value.ToString("0.##", CultureInfo.InvariantCulture) + "x", color);
}
public static string Meters(double value, string color = "yellow")
{
return String(value.ToString("0.##", CultureInfo.InvariantCulture) + " meters", color);
}
public static string Degrees(double value, string color = "yellow")
{
return String(value.ToString("0.##", CultureInfo.InvariantCulture) + " degrees", color);
}
public static string Fixed(double value)
{
return String(value.ToString("N2", CultureInfo.InvariantCulture).PadLeft(5, '0'));
}
public static string Percent(double value, string color = "yellow")
{
return String((100.0 * value).ToString("0.##", CultureInfo.InvariantCulture) + " %", color);
}
public static string PercentInt(double value, string color = "yellow")
{
return String(value.ToString("P0", CultureInfo.InvariantCulture), color);
}
public static string Range(double min, double max, string color = "yellow")
{
if (min == max)
{
return String(max.ToString("0.##", CultureInfo.InvariantCulture), color);
}
return String(min.ToString("0.##", CultureInfo.InvariantCulture), color) + "-" + String(max.ToString("0.##", CultureInfo.InvariantCulture), color);
}
public static string PercentRange(double min, double max)
{
if (min == max)
{
return max.ToString("P0", CultureInfo.InvariantCulture);
}
return min.ToString("P0", CultureInfo.InvariantCulture) + "-" + max.ToString("P0", CultureInfo.InvariantCulture);
}
public static string Progress(double value, double limit, bool percent = false)
{
return String(value.ToString("N0")) + "/" + String(limit.ToString("N0")) + (percent ? (" (" + PercentInt(value / limit) + ")") : "");
}
public static string Int(double value, string color = "yellow")
{
return String(value.ToString("N0"), color);
}
public static string ProgressPercent(string header, double value, double limit)
{
return header + ": " + Progress(value, limit) + " seconds (" + Percent(value / limit) + ")";
}
public static string JoinLines(IEnumerable<string> lines)
{
return string.Join("\n", lines.Where((string line) => line != ""));
}
public static string JoinRow(IEnumerable<string> lines)
{
return string.Join(", ", lines.Where((string line) => line != ""));
}
}
[HarmonyPatch(typeof(MessageHud), "Update")]
public class MessageHud_UpdateMessage : MonoBehaviour
{
public static Func<List<string>> GetMessage = () => new List<string> { "Default test. Replace with own function." };
private static void Postfix(MessageHud __instance)
{
if ((Object)(object)Player.m_localPlayer == (Object)null || Hud.IsUserHidden())
{
return;
}
string text = __instance.m_messageText.text;
List<string> list = GetMessage();
if (list.Count != 0)
{
while (text.StartsWith(" \n"))
{
text = text.Substring(2);
}
int num = ((text != "") ? text.Split(new char[1] { '\n' }).Length : 0) + list.Count - 2;
for (int i = 0; i < num; i++)
{
list.Insert(0, " ");
}
if (text != "")
{
list.Insert(0, " ");
list.Insert(0, " ");
list.Add(" ");
list.Add(text);
}
__instance.m_messageText.text = Format.JoinLines(list);
((Graphic)__instance.m_messageText).CrossFadeAlpha(1f, 0f, true);
((Graphic)__instance.m_messageIcon).canvasRenderer.SetAlpha(0f);
((Graphic)__instance.m_messageIcon).CrossFadeAlpha(0f, 0f, true);
}
}
}
[HarmonyPatch(typeof(MessageHud), "UpdateMessage")]
public class MessageHud_GetBaseMessage : MonoBehaviour
{
private static string BaseMessage = "";
private static void Prefix(out string __state)
{
__state = MessageHud.instance.m_messageText.text;
}
private static void Postfix(MessageHud __instance, float ___m_msgQueueTimer, string __state)
{
if (__instance.m_messageText.text != __state)
{
BaseMessage = __instance.m_messageText.text;
}
if (___m_msgQueueTimer >= 4f)
{
BaseMessage = "";
}
__instance.m_messageText.text = BaseMessage;
}
}
}
namespace DPS
{
[HarmonyPatch(typeof(Skills), "GetSkillFactor")]
public class Skills_GetSkillFactor
{
public static void Postfix(ref float __result)
{
if (!(Settings.SetSkills < 0f))
{
__result = Settings.SetSkills;
}
}
}
[HarmonyPatch(typeof(Skills), "GetRandomSkillRange")]
public class Skills_GetRandomSkillRange
{
public static void Postfix(Skills __instance, out float min, out float max, SkillType skillType)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
float num = ((Settings.PlayerDamageRange >= 0f) ? Settings.PlayerDamageRange : 0.15f);
float skillFactor = __instance.GetSkillFactor(skillType);
float num2 = Mathf.Lerp(0.4f, 1f, skillFactor);
max = Mathf.Clamp01(num2 + num);
min = Mathf.Clamp01(num2 - num);
}
}
[HarmonyPatch(typeof(Skills), "GetRandomSkillFactor")]
public class Skills_GetRandomSkillFactor
{
private static void Postfix(Skills __instance, ref float __result, SkillType skillType)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (!(Settings.PlayerDamageRange < 0f))
{
float skillFactor = __instance.GetSkillFactor(skillType);
float num = Mathf.Lerp(0.4f, 1f, skillFactor);
float num2 = Mathf.Clamp01(num - Settings.PlayerDamageRange);
float num3 = Mathf.Clamp01(num + Settings.PlayerDamageRange);
__result = Mathf.Lerp(num2, num3, Random.value);
}
}
}
[HarmonyPatch(typeof(Character), "GetRandomSkillFactor")]
public class Character_GetRandomSkillFactor
{
private static void Postfix(ref float __result)
{
if (!(Settings.CreatureDamageRange < 0f))
{
__result = Random.Range(1f - Settings.CreatureDamageRange, 1f);
}
}
}
[HarmonyPatch(typeof(Player), "RPC_UseStamina")]
public class Player_RPC_UseStamina
{
private static void Prefix(ref float v)
{
if (Settings.NoStaminaUsage)
{
v = 0f;
}
}
}
[HarmonyPatch(typeof(Attack), "Start")]
public class Attack_Start_CapChain
{
private static void Prefix(ref Attack? previousAttack, ref int ___m_currentAttackCainLevel)
{
if (Settings.MaxAttackChainLevels >= 0 && previousAttack != null && previousAttack.m_nextAttackChainLevel >= Settings.MaxAttackChainLevels)
{
previousAttack = null;
___m_currentAttackCainLevel = 0;
}
}
}
[HarmonyPatch(typeof(Player), "PlayerAttackInput")]
public class AutoShootBow
{
private static void Prefix(Player __instance)
{
if (!((Character)__instance).InPlaceMode() && Settings.AutoFireBow)
{
ItemData currentWeapon = ((Humanoid)__instance).GetCurrentWeapon();
if (currentWeapon != null && !(currentWeapon.m_shared.m_attack.m_drawDurationMin <= 0f) && !(((Humanoid)__instance).GetAttackDrawPercentage() < 1f))
{
((Character)__instance).m_attackHold = false;
}
}
}
}
[BepInPlugin("dps", "DPS", "1.6")]
public class DPS : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static ConsoleEvent <>9__6_0;
public static ConsoleEvent <>9__6_1;
public static ConsoleEvent <>9__6_2;
public static ConsoleEvent <>9__6_3;
public static ConsoleEvent <>9__6_4;
internal void <InitCommands>b__6_0(ConsoleEventArgs args)
{
if (Settings.ShowDPS && DPSMeter.Running)
{
DPSMeter.Reset();
args.Context.AddString("DPS tool reseted.");
}
else
{
Settings.configShowDPS.Value = !Settings.ShowDPS;
args.Context.AddString("DPS tool " + (Settings.ShowDPS ? "enabled" : "disabled") + ".");
}
}
internal void <InitCommands>b__6_1(ConsoleEventArgs args)
{
if (Settings.ShowExperience && ExperienceMeter.Running)
{
ExperienceMeter.Reset();
args.Context.AddString("Experience tool reseted.");
}
else
{
Settings.configShowExperience.Value = !Settings.ShowExperience;
args.Context.AddString("Experience tool " + (Settings.ShowExperience ? "enabled" : "disabled") + ".");
}
}
internal void <InitCommands>b__6_2(ConsoleEventArgs args)
{
if (!Settings.IsCheats)
{
AddMessage(args.Context, "Unauthorized to spawn dummies.");
return;
}
Dummy.Spawn(args.Args);
((Character)Player.m_localPlayer).Message((MessageType)1, "Spawned a training dummy", 0, (Sprite)null);
}
internal void <InitCommands>b__6_3(ConsoleEventArgs args)
{
if (!Settings.IsCheats)
{
AddMessage(args.Context, "Unauthorized to kill dummies.");
return;
}
int num = Dummy.Kill();
((Character)Player.m_localPlayer).Message((MessageType)1, "Killing all training dummies:" + num, 0, (Sprite)null);
}
internal void <InitCommands>b__6_4(ConsoleEventArgs args)
{
if (!Settings.IsCheats)
{
AddMessage(args.Context, "Unauthorized to spawn dummies.");
return;
}
Dummy.Kill();
Dummy.Spawn(args.Args);
((Character)Player.m_localPlayer).Message((MessageType)1, "Spawned a training dummy", 0, (Sprite)null);
}
}
public const string GUID = "dps";
public const string NAME = "DPS";
public const string VERSION = "1.6";
public void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Settings.Init(((BaseUnityPlugin)this).Config);
new Harmony("dps").PatchAll();
InitCommands();
MessageHud_UpdateMessage.GetMessage = GetMessage;
}
private static List<string> GetMessage()
{
List<string> list = new List<string>();
List<string> list2 = DPSMeter.Get();
List<string> list3 = ExperienceMeter.Get();
if (list2 != null || list3 != null)
{
if (Settings.CheatsRequired())
{
list.Add(Format.String("No cheat access, some features won't work.", "red"));
}
else
{
if (Settings.CreatureDamageRange >= 0f)
{
list.Add("Creature damage range: " + Format.Percent(Settings.CreatureDamageRange));
}
if (Settings.MaxAttackChainLevels >= 0)
{
list.Add("Max attack chain: " + Format.Int(Settings.MaxAttackChainLevels));
}
if (Settings.PlayerDamageRange >= 0f)
{
list.Add("Player damage range: " + Format.Percent(Settings.PlayerDamageRange));
}
if (Settings.NoStaminaUsage)
{
list.Add("No stamina usage");
}
if (Settings.SetSkills >= 0f)
{
list.Add("Override skills: " + Format.Int(Settings.SetSkills * 100f));
}
}
}
if (list2 != null)
{
list.Add(" ");
list.AddRange(list2);
}
if (list3 != null)
{
list.Add(" ");
list.AddRange(list3);
}
return list;
}
public static void AddMessage(Terminal context, string message)
{
context.AddString(message);
if (Object.op_Implicit((Object)(object)MessageHud.instance))
{
Player localPlayer = Player.m_localPlayer;
if (localPlayer != null)
{
((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null);
}
}
}
private static void InitCommands()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
object obj = <>c.<>9__6_0;
if (obj == null)
{
ConsoleEvent val = delegate(ConsoleEventArgs args)
{
if (Settings.ShowDPS && DPSMeter.Running)
{
DPSMeter.Reset();
args.Context.AddString("DPS tool reseted.");
}
else
{
Settings.configShowDPS.Value = !Settings.ShowDPS;
args.Context.AddString("DPS tool " + (Settings.ShowDPS ? "enabled" : "disabled") + ".");
}
};
<>c.<>9__6_0 = val;
obj = (object)val;
}
new ConsoleCommand("dps", "Toggles DPS tool.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj2 = <>c.<>9__6_1;
if (obj2 == null)
{
ConsoleEvent val2 = delegate(ConsoleEventArgs args)
{
if (Settings.ShowExperience && ExperienceMeter.Running)
{
ExperienceMeter.Reset();
args.Context.AddString("Experience tool reseted.");
}
else
{
Settings.configShowExperience.Value = !Settings.ShowExperience;
args.Context.AddString("Experience tool " + (Settings.ShowExperience ? "enabled" : "disabled") + ".");
}
};
<>c.<>9__6_1 = val2;
obj2 = (object)val2;
}
new ConsoleCommand("exp", "Toggles experience tool.", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj3 = <>c.<>9__6_2;
if (obj3 == null)
{
ConsoleEvent val3 = delegate(ConsoleEventArgs args)
{
if (!Settings.IsCheats)
{
AddMessage(args.Context, "Unauthorized to spawn dummies.");
}
else
{
Dummy.Spawn(args.Args);
((Character)Player.m_localPlayer).Message((MessageType)1, "Spawned a training dummy", 0, (Sprite)null);
}
};
<>c.<>9__6_2 = val3;
obj3 = (object)val3;
}
new ConsoleCommand("dummy_spawn", "[resistance1=modifier1] [resistance2=modifier2]... - Spawns a training dummy.", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj4 = <>c.<>9__6_3;
if (obj4 == null)
{
ConsoleEvent val4 = delegate(ConsoleEventArgs args)
{
if (!Settings.IsCheats)
{
AddMessage(args.Context, "Unauthorized to kill dummies.");
}
else
{
int num = Dummy.Kill();
((Character)Player.m_localPlayer).Message((MessageType)1, "Killing all training dummies:" + num, 0, (Sprite)null);
}
};
<>c.<>9__6_3 = val4;
obj4 = (object)val4;
}
new ConsoleCommand("dummy_kill", "Kills all training dummies.", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj5 = <>c.<>9__6_4;
if (obj5 == null)
{
ConsoleEvent val5 = delegate(ConsoleEventArgs args)
{
if (!Settings.IsCheats)
{
AddMessage(args.Context, "Unauthorized to spawn dummies.");
}
else
{
Dummy.Kill();
Dummy.Spawn(args.Args);
((Character)Player.m_localPlayer).Message((MessageType)1, "Spawned a training dummy", 0, (Sprite)null);
}
};
<>c.<>9__6_4 = val5;
obj5 = (object)val5;
}
new ConsoleCommand("dummy_reset", "[resistance1=modifier1] [resistance2=modifier2]... - Kills all training dummies and spawns a new one.", (ConsoleEvent)obj5, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
}
}
internal class Stats
{
public float Hits;
public float Damage;
public float StructureDamage;
public float Staggering;
public float TotalStamina;
public float Stamina;
public float DamagePerStamina
{
get
{
if (!(Stamina > 0f))
{
return 0f;
}
return Damage / Stamina;
}
}
public float StructureDamagePerStamina
{
get
{
if (!(Stamina > 0f))
{
return 0f;
}
return StructureDamage / Stamina;
}
}
public static Stats operator +(Stats a, Stats b)
{
return new Stats
{
Hits = a.Hits + b.Hits,
Damage = a.Damage + b.Damage,
StructureDamage = a.StructureDamage + b.StructureDamage,
Staggering = a.Staggering + b.Staggering,
TotalStamina = a.TotalStamina + b.TotalStamina,
Stamina = a.Stamina + b.Stamina
};
}
public static Stats operator *(Stats a, float b)
{
return new Stats
{
Hits = a.Hits * b,
Damage = a.Damage * b,
StructureDamage = a.StructureDamage * b,
Staggering = a.Staggering * b,
TotalStamina = a.TotalStamina * b,
Stamina = a.Stamina * b
};
}
}
public class DPSMeter
{
private static DateTime? startTime = null;
private static DateTime? endTime = null;
private static float damageTaken = 0f;
private static Stats stats = new Stats();
private static Stats pending = new Stats();
public static bool Running => startTime.HasValue;
public static void Start()
{
if (Settings.ShowDPS && !startTime.HasValue)
{
Reset();
startTime = DateTime.Now;
}
}
public static void Reset()
{
startTime = null;
endTime = null;
damageTaken = 0f;
stats = new Stats();
pending = new Stats();
}
private static void AddStructureDamage(HitData hit, int tooltier)
{
if (startTime.HasValue && !(hit.m_damage.m_damage > 1E+09f) && hit.m_toolTier >= tooltier)
{
pending.StructureDamage += hit.GetTotalDamage();
}
}
public static void AddStructureDamage(HitData hit)
{
AddStructureDamage(hit, 0);
}
public static void AddStructureDamage(HitData hit, TreeLog obj)
{
AddStructureDamage(hit, obj.m_minToolTier);
}
public static void AddStructureDamage(HitData hit, TreeBase obj)
{
AddStructureDamage(hit, obj.m_minToolTier);
}
public static void AddStructureDamage(HitData hit, MineRock5 obj)
{
AddStructureDamage(hit, obj.m_minToolTier);
}
public static void AddStructureDamage(HitData hit, MineRock obj)
{
AddStructureDamage(hit, obj.m_minToolTier);
}
public static void AddStructureDamage(HitData hit, Destructible obj)
{
AddStructureDamage(hit, obj.m_minToolTier);
}
public static void AddDamageTaken(HitData hit)
{
if (startTime.HasValue)
{
damageTaken += hit.GetTotalDamage();
SetTime();
}
}
public static void AddDamage(HitData hit)
{
if (startTime.HasValue && !(hit.m_damage.m_damage > 1E+09f))
{
pending.Damage += hit.GetTotalDamage();
pending.Staggering += ((DamageTypes)(ref hit.m_damage)).GetTotalStaggerDamage() * hit.m_staggerMultiplier;
}
}
public static void AddDot(HitData hit)
{
if (startTime.HasValue && !(hit.m_damage.m_damage > 1E+09f))
{
pending.Damage += hit.GetTotalDamage();
}
}
public static void AddStamina(float stamina)
{
if (startTime.HasValue)
{
pending.Stamina += stamina;
}
}
public static void AddHit()
{
if (startTime.HasValue)
{
pending.Hits += 1f;
}
}
public static void AddTotalStamina(float stamina)
{
if (startTime.HasValue)
{
pending.TotalStamina += stamina;
}
}
public static void SetTime()
{
if (startTime.HasValue)
{
endTime = DateTime.Now;
stats += pending;
pending = new Stats();
}
}
public static List<string>? Get()
{
if (!Settings.ShowDPS)
{
return null;
}
double num = 1E-05;
if (startTime.HasValue && endTime.HasValue)
{
num = endTime.Value.Subtract(startTime.Value).TotalSeconds;
}
float num2 = 1f / (float)num;
Stats stats = DPSMeter.stats * num2;
Stats stats2 = DPSMeter.stats + pending;
float num3 = ((stats.Hits > 0f) ? (1f / stats.Hits) : 0f);
List<string> list = new List<string>();
list.Add("Time: " + Format.Float(num) + " seconds with " + Format.Float(DPSMeter.stats.Hits) + " hits");
list.Add("DPS: " + Format.Float(stats.Damage) + " (total " + Format.Float(stats2.Damage) + "), per stamina: " + Format.Float(DPSMeter.stats.DamagePerStamina));
list.Add("Stamina: " + Format.Float(stats.Stamina) + " (total " + Format.Float(stats2.Stamina) + ")");
List<string> list2 = list;
if (DPSMeter.stats.TotalStamina != DPSMeter.stats.Stamina)
{
list2.Add("Total stamina: " + Format.Float(stats.TotalStamina) + " (total " + Format.Float(stats2.TotalStamina) + ")");
}
list2.Add("Staggering: " + Format.Float(stats.Staggering) + " (total " + Format.Float(stats2.Staggering) + ")");
list2.Add("Attack speed: " + Format.Float(stats.Hits) + " (" + Format.Float(num3) + " s per attack)");
if (damageTaken > 0f)
{
list2.Add("Damage taken: " + Format.Float(damageTaken * num2) + " (total " + Format.Float(damageTaken) + ")");
}
if (DPSMeter.stats.StructureDamage > 0f)
{
list2.Add("Structure DPS: " + Format.Float(stats.StructureDamage) + " (total " + Format.Float(stats2.StructureDamage) + "), per stamina: " + Format.Float(DPSMeter.stats.StructureDamagePerStamina));
}
return list2;
}
}
[HarmonyPatch(typeof(Attack), "Start")]
public class Attack_Start
{
private static void Postfix(Attack __instance, Humanoid character, bool __result)
{
if (__result && (Object)(object)character == (Object)(object)Player.m_localPlayer)
{
DPSMeter.Start();
DPSMeter.AddStamina(__instance.GetAttackStamina());
DPSMeter.AddHit();
}
}
}
[HarmonyPatch(typeof(Attack), "Stop")]
public class Attack_OnAttackStop
{
private static void Postfix(Humanoid ___m_character)
{
if ((Object)(object)___m_character == (Object)(object)Player.m_localPlayer)
{
DPSMeter.SetTime();
}
}
}
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
public class Destructible_RPC_Damage
{
private static void Postfix(Destructible __instance, HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddStructureDamage(hit, __instance);
}
}
}
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
public class MineRock_RPC_Hit
{
private static void Postfix(MineRock __instance, HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddStructureDamage(hit, __instance);
}
}
}
[HarmonyPatch(typeof(WearNTear), "RPC_Damage")]
public class WearNTear_RPC_Damage
{
private static void Postfix(HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddStructureDamage(hit);
}
}
}
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
public class MineRock5_DamageArea
{
private static void Postfix(MineRock5 __instance, HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddStructureDamage(hit, __instance);
}
}
}
[HarmonyPatch(typeof(TreeBase), "RPC_Damage")]
public class TreeBase_RPC_Damage
{
private static void Postfix(TreeBase __instance, HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddStructureDamage(hit, __instance);
}
}
}
[HarmonyPatch(typeof(TreeLog), "RPC_Damage")]
public class TreeLog_RPC_Damage
{
private static void Postfix(TreeLog __instance, HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddStructureDamage(hit, __instance);
}
}
}
[HarmonyPatch(typeof(Character), "ApplyDamage")]
public class Character_ApplyDamage
{
private static void Prefix(Character __instance, HitData hit)
{
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddDamage(hit);
}
if ((Object)(object)hit.GetAttacker() == (Object)null)
{
DPSMeter.AddDot(hit);
}
if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddDamageTaken(hit);
}
}
}
[HarmonyPatch(typeof(Player), "UseStamina")]
public class Player_UseStamina
{
private static void Prefix(Player __instance, float v)
{
if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
{
DPSMeter.AddTotalStamina(v);
}
}
}
public class Dummy
{
private static Character Create()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
return Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("TrainingDummy"), ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 2f + Vector3.up, Quaternion.identity).GetComponent<Character>();
}
private static DamageModifier GetModifier(string value)
{
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
value = value.Trim().ToLower();
return (DamageModifier)(value switch
{
"ignore" => 4,
"weak" => 2,
"veryweak" => 6,
"resistant" => 1,
"veryresistant" => 5,
"normal" => 0,
"immune" => 3,
"-" => 4,
"1.5" => 2,
"2.0" => 6,
"2" => 6,
"0.5" => 1,
"0.25" => 5,
"1.0" => 0,
"1" => 0,
"0.0" => 3,
"0" => 3,
_ => 0,
});
}
public static void Spawn(string[] args)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got I4
//IL_012a: Expected O, but got I4
//IL_00ff->IL00ff: Incompatible stack types: O vs I4
//IL_00f6->IL00ff: Incompatible stack types: I4 vs O
//IL_00f6->IL00ff: Incompatible stack types: O vs I4
Character val = Create();
BaseAI component = ((Component)val).GetComponent<BaseAI>();
if (Object.op_Implicit((Object)(object)component))
{
component.SetHuntPlayer(true);
}
SEMan sEMan = val.GetSEMan();
val.m_damageModifiers.m_blunt = (DamageModifier)0;
val.m_damageModifiers.m_chop = (DamageModifier)4;
val.m_damageModifiers.m_fire = (DamageModifier)0;
val.m_damageModifiers.m_frost = (DamageModifier)0;
val.m_damageModifiers.m_lightning = (DamageModifier)0;
val.m_damageModifiers.m_pickaxe = (DamageModifier)4;
val.m_damageModifiers.m_pierce = (DamageModifier)0;
val.m_damageModifiers.m_poison = (DamageModifier)0;
val.m_damageModifiers.m_slash = (DamageModifier)0;
val.m_damageModifiers.m_spirit = (DamageModifier)0;
foreach (string item in args.OrderBy((string item) => item))
{
string[] array = item.Split(new char[1] { '=' });
object obj = array[0].ToLower();
int num;
if (array.Length > 1)
{
obj = GetModifier(array[1]);
num = (int)obj;
}
else
{
num = 0;
obj = num;
num = (int)obj;
}
DamageModifier modifier = (DamageModifier)obj;
int result;
bool flag = int.TryParse((array.Length > 1) ? array[1] : "", out result);
UpdateModifier((string)num, val, modifier);
string statusEffect = GetStatusEffect((string)num);
if (statusEffect != "")
{
StatusEffect val2 = sEMan.AddStatusEffect(StringExtensionMethods.GetStableHashCode(statusEffect), true, 0, 0f);
if (flag)
{
val2.m_ttl = result;
}
}
}
}
private static string GetStatusEffect(string value)
{
value = value.Trim().ToLower();
return value switch
{
"cold" => "Cold",
"corpserun" => "CorpseRun",
"freezing" => "Freezing",
"shield" => "GoblinShaman_shield",
"bonemass" => "GP_Bonemass",
"eikthyr" => "GP_Eikthyr",
"moder" => "GP_Moder",
"elder" => "GP_TheElder",
"yagluth" => "GP_Yagluth",
"barleywine" => "Potion_barleywine",
"frostresist" => "Potion_frostresist",
"poisonresist" => "Potion_poisonresist",
"tared" => "Tared",
"wet" => "Wet",
_ => "",
};
}
private static void UpdateModifier(string type, Character character, DamageModifier modifier)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
if (type == "*" || type == "blunt")
{
character.m_damageModifiers.m_blunt = modifier;
}
if (type == "*" || type == "chop")
{
character.m_damageModifiers.m_chop = modifier;
}
if (type == "*" || type == "fire")
{
character.m_damageModifiers.m_fire = modifier;
}
if (type == "*" || type == "frost")
{
character.m_damageModifiers.m_frost = modifier;
}
if (type == "*" || type == "lightning")
{
character.m_damageModifiers.m_lightning = modifier;
}
if (type == "*" || type == "pickaxe")
{
character.m_damageModifiers.m_pickaxe = modifier;
}
if (type == "*" || type == "pierce")
{
character.m_damageModifiers.m_pierce = modifier;
}
if (type == "*" || type == "poison")
{
character.m_damageModifiers.m_poison = modifier;
}
if (type == "*" || type == "slash")
{
character.m_damageModifiers.m_slash = modifier;
}
if (type == "*" || type == "spirit")
{
character.m_damageModifiers.m_spirit = modifier;
}
}
public static int Kill()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
IEnumerable<Character> enumerable = from item in Character.GetAllCharacters()
where item.m_name.ToLower() == "trainingdummy"
select item;
foreach (Character item in enumerable)
{
HitData val = new HitData();
val.m_damage.m_damage = 1E+10f;
item.Damage(val);
}
return enumerable.Count();
}
}
[HarmonyPatch(typeof(Skill), "Raise")]
public class Skill_Raise
{
private static void Prefix(Skill __instance, float factor)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ExperienceMeter.AddExperience(__instance.m_info.m_skill, factor * __instance.m_info.m_increseStep);
}
}
public class ExperienceMeter
{
private static DateTime? startTime = null;
private static DateTime? endTime = null;
private static readonly Dictionary<SkillType, float> experiences = new Dictionary<SkillType, float>();
private static readonly Dictionary<SkillType, int> instances = new Dictionary<SkillType, int>();
public static bool Running => startTime.HasValue;
public static void Start()
{
if (Settings.ShowExperience && !startTime.HasValue)
{
Reset();
startTime = DateTime.Now;
}
}
public static void Reset()
{
startTime = null;
endTime = null;
experiences.Clear();
instances.Clear();
}
public static void AddExperience(SkillType skill, float value = 1f)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
Start();
if (startTime.HasValue)
{
if (!experiences.ContainsKey(skill))
{
experiences.Add(skill, 0f);
}
if (!instances.ContainsKey(skill))
{
instances.Add(skill, 0);
}
experiences[skill] += value;
instances[skill]++;
endTime = DateTime.Now;
}
}
public static float GetExperienceModifier()
{
SEMan seman = ((Character)Player.m_localPlayer).m_seman;
float result = 1f;
seman.ModifyRaiseSkill((SkillType)999, ref result);
return result;
}
private static Skill GetSkill(SkillType type)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return Player.m_localPlayer.m_skills.GetSkill(type);
}
public static float GetLevel(SkillType type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return GetSkill(type).m_level;
}
public static float GetCurrent(SkillType type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return GetSkill(type).m_accumulator;
}
public static float GetTotal(SkillType type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return GetSkill(type).GetNextLevelRequirement();
}
public static List<string>? Get()
{
if (!Settings.ShowExperience)
{
return null;
}
double time = 1.0;
if (startTime.HasValue && endTime.HasValue)
{
time = endTime.Value.Subtract(startTime.Value).TotalMilliseconds;
}
time /= 60000.0;
if (time == 0.0)
{
time = 1.0;
}
List<string> list = experiences.Select(delegate(KeyValuePair<SkillType, float> kvp)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
SkillType key = kvp.Key;
float value = kvp.Value;
string text = ((object)(SkillType)(ref key)).ToString() + " " + Format.Float(GetLevel(key), "0.##", "white") + " (" + Format.Progress(GetCurrent(key), GetTotal(key)) + "): ";
float num = value * (float)(instances[key] - 1) / (float)instances[key];
return text + Format.Float(kvp.Value) + " (" + Format.Float((double)num / time) + " per minute)";
}).ToList();
list.Insert(0, "Experience gain: " + Format.Percent(GetExperienceModifier()));
return list;
}
}
public class Settings
{
public static ConfigEntry<bool> configShowDPS;
public static ConfigEntry<bool> configShowExperience;
public static ConfigEntry<int> configSetSkills;
public static ConfigEntry<int> configPlayerDamageRange;
public static ConfigEntry<int> configCreatureDamageRange;
public static ConfigEntry<int> configMaxAttackChainLevels;
public static ConfigEntry<bool> configNoStaminaUsage;
public static ConfigEntry<bool> configAutoFireBow;
public static bool IsCheats
{
get
{
if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer())
{
return ((Terminal)Console.instance).IsCheatsEnabled();
}
return true;
}
}
public static bool ShowDPS => configShowDPS.Value;
public static bool ShowExperience => configShowExperience.Value;
private static bool SettingsEnabled
{
get
{
if (IsCheats)
{
if (!ShowDPS)
{
return ShowExperience;
}
return true;
}
return false;
}
}
public static float SetSkills
{
get
{
if (!SettingsEnabled || configSetSkills.Value == -1)
{
return -1f;
}
return FromPercent(configSetSkills.Value);
}
}
public static float PlayerDamageRange
{
get
{
if (!SettingsEnabled || configPlayerDamageRange.Value == 15)
{
return -1f;
}
return FromPercent(configPlayerDamageRange.Value);
}
}
public static float CreatureDamageRange
{
get
{
if (!SettingsEnabled || configCreatureDamageRange.Value == 25)
{
return -1f;
}
return FromPercent(configCreatureDamageRange.Value);
}
}
public static int MaxAttackChainLevels
{
get
{
if (!SettingsEnabled || configMaxAttackChainLevels.Value == -1)
{
return -1;
}
return configMaxAttackChainLevels.Value;
}
}
public static bool NoStaminaUsage
{
get
{
if (SettingsEnabled)
{
return configNoStaminaUsage.Value;
}
return false;
}
}
public static bool AutoFireBow
{
get
{
if (SettingsEnabled)
{
return configAutoFireBow.Value;
}
return false;
}
}
private static float FromPercent(int value)
{
return (float)value / 100f;
}
public static void Init(ConfigFile config)
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
string text = "DPS";
configShowDPS = config.Bind<bool>(text, "Show DPS meter", false, "Show DPS meter (toggle with P button in the game)");
configShowDPS.SettingChanged += delegate
{
if (!ShowDPS)
{
DPSMeter.Reset();
}
};
configShowExperience = config.Bind<bool>(text, "Show experience meter", false, "Show experience meter (toggle with L button in the game)");
configShowExperience.SettingChanged += delegate
{
if (!ShowExperience)
{
ExperienceMeter.Reset();
}
};
configSetSkills = config.Bind<int>(text, "Override skill levels", -1, new ConfigDescription("Overrides skill level checks (-1 to disable).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>()));
configPlayerDamageRange = config.Bind<int>(text, "Min/max damage range for players", 15, new ConfigDescription("Overrides player damage range (15 to disable).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 40), Array.Empty<object>()));
configCreatureDamageRange = config.Bind<int>(text, "Min/max damage range for creatures", 25, new ConfigDescription("Overrides creature damage range (25 to disable).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
{
new ConfigurationManagerAttributes
{
ShowRangeAsPercent = false
}
}));
configMaxAttackChainLevels = config.Bind<int>(text, "Maximum attack chain levels", -1, new ConfigDescription("Caps the attack chains for easier testing (-1 to disable).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 5), Array.Empty<object>()));
configNoStaminaUsage = config.Bind<bool>(text, "No stamina usage", false, "Set true to disable stamina usage.");
configAutoFireBow = config.Bind<bool>(text, "Auto fire bow", false, "Automatically fires the bow when fully drawn.");
}
public static bool CheatsRequired()
{
if (!IsCheats)
{
if (configSetSkills.Value < 0 && configPlayerDamageRange.Value == 15 && configCreatureDamageRange.Value == 25 && configMaxAttackChainLevels.Value < 0 && !configNoStaminaUsage.Value)
{
return configAutoFireBow.Value;
}
return true;
}
return false;
}
}
}