using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Xml.Serialization; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("AshValheimMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AshValheimMod")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace AshValheimMod; public class AllySummon { public static GameObject CharredSpawn(string basePrefab, Vector3 position, int level) { //IL_001d: 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) GameObject prefab = PrefabManager.Instance.GetPrefab(basePrefab); if ((Object)(object)prefab != (Object)null) { GameObject val = Object.Instantiate(prefab, position, Quaternion.identity); AshCharacters.SetCreatureStars(val, level); AshCharacters.ResetCharacterFaction(val, (Faction)11); MonsterAI component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } BaseAI component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } LevelEffects component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.Destroy((Object)(object)component3); } val.AddComponent(); val.AddComponent(); Humanoid component4 = val.GetComponent(); if ((Object)(object)component4 != (Object)null) { ((Character)component4).m_name = AshNameManager.GetAshName(); ((Character)component4).m_health = 1200f; ((Character)component4).SetMaxHealth(1200f); ((Behaviour)component4).enabled = true; ((Character)component4).m_runSpeed = 8f; ((Character)component4).m_runTurnSpeed = 2f; ((Character)component4).m_speed = 7f; ((Character)component4).m_groundTiltSpeed = 1f; ((Character)component4).m_walkSpeed = 1f; ((Character)component4).m_turnSpeed = 1f; Debug.Log((object)"Ash Weapon Stats"); ItemData currentWeapon = component4.GetCurrentWeapon(); Debug.Log((object)currentWeapon?.m_shared.m_name); Debug.Log((object)currentWeapon?.m_shared.m_aiAttackInterval); Debug.Log((object)"End Ash Weapon Stats"); } Tameable val2 = val.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent(); } if ((Object)(object)val2 != (Object)null) { val2.m_startsTamed = true; val2.m_unsummonDistance = 150f; val2.m_unsummonOnOwnerLogoutSeconds = 1f; if ((Object)(object)component4 != (Object)null) { ((Character)component4).SetTamed(true); } } AddNecromancerTealEffect(val); ZNetView component5 = val.GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.GetZDO().Set("AshSummon", true); } Logger.LogInfo((object)("Summoned " + basePrefab + ".")); return val; } Logger.LogError((object)("Unable to retrieve " + basePrefab + " prefab.")); return null; } private static void AddNecromancerTealEffect(GameObject skeleton) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_004f: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) LineRenderer val = skeleton.AddComponent(); ((Renderer)val).material = new Material(Shader.Find("Sprites/Default")); val.useWorldSpace = false; val.loop = true; val.startWidth = 0.1f; val.endWidth = 0.3f; val.positionCount = 2; val.startColor = AshColor.NecromancerTeal; val.endColor = AshColor.NecromancerTeal; Vector3 zero = Vector3.zero; val.SetPosition(0, zero + new Vector3(0f, 1.4f, 0f)); val.SetPosition(1, zero + new Vector3(0f, 2.1f, 0f)); Logger.LogInfo((object)"Added NecromancerTeal effect to skeleton."); } } public class AshAI : MonoBehaviour { private Character characterAsh; private Humanoid humanoidAsh; private GameObject player; private int currentEnemyCount; private readonly List m_path = new List(); private float m_lastFindPathTime; private Vector3 m_lastFindPathTarget; private bool m_lastFindPathResult; private Vector3 m_lastPosition; private float m_stuckTimer; private float m_getOutOfCornerTimer; private float m_getOutOfCornerAngle; private string ashMode; public const string ASH_MODE_GUARD = "ASH_MODE_GUARD"; public const string ASH_MODE_STOP = "ASH_MODE_STOP"; public const string ASH_MODE_SENTINEL = "ASH_MODE_SENTINEL"; public const string ASH_MODE_CHOP = "ASH_MODE_CHOP"; private const float ASH_MOVE_MIN_ANGLE = 20f; private TreeBase currentTreeTarget = null; private int treeTargetCounter = 0; private readonly Collider[] m_treeOverlapResults = (Collider[])(object)new Collider[1024]; public string AshMode { get { return ashMode; } set { ashMode = value; } } protected void Awake() { characterAsh = ((Component)this).GetComponent(); humanoidAsh = ((Component)this).GetComponent(); DisableMonsterAI(); } private void Start() { player = ((Component)Player.m_localPlayer).gameObject; if (Object.op_Implicit((Object)(object)humanoidAsh)) { humanoidAsh.EquipBestWeapon((Character)null, (StaticTarget)null, (Character)null, (Character)null); } ItemData currentWeapon = humanoidAsh.GetCurrentWeapon(); if (currentWeapon == null) { return; } Attack attack = currentWeapon.m_shared.m_attack; if (attack == null) { return; } Debug.Log((object)"========== ASH BOW ATTACK =========="); Debug.Log((object)("Weapon: " + currentWeapon.m_shared.m_name)); Debug.Log((object)$"Attack: {attack}"); Debug.Log((object)$"Attack Height: {attack.m_attackHeight}"); Debug.Log((object)$"Attack Range: {attack.m_attackRange}"); Debug.Log((object)$"Attack Offset: {attack.m_attackOffset}"); Debug.Log((object)$"Launch Angle: {attack.m_launchAngle}"); Debug.Log((object)$"Projectile Velocity: {attack.m_projectileVel}"); Debug.Log((object)$"Projectile Velocity Min: {attack.m_projectileVelMin}"); Debug.Log((object)$"Projectile Accuracy: {attack.m_projectileAccuracy}"); Debug.Log((object)$"Projectile Accuracy Min: {attack.m_projectileAccuracyMin}"); Debug.Log((object)$"Bow Draw: {attack.m_bowDraw}"); Debug.Log((object)$"Use Character Facing: {attack.m_useCharacterFacing}"); Debug.Log((object)$"Use Character Facing Y Aim: {attack.m_useCharacterFacingYAim}"); Debug.Log((object)"==================================="); GameObject attackProjectile = attack.m_attackProjectile; if ((Object)(object)attackProjectile != (Object)null) { Projectile component = attackProjectile.GetComponent(); if ((Object)(object)component != (Object)null) { Debug.Log((object)"========== ASH PROJECTILE =========="); Debug.Log((object)("Projectile Prefab: " + ((Object)attackProjectile).name)); Debug.Log((object)$"Gravity: {component.m_gravity}"); Debug.Log((object)$"Drag: {component.m_drag}"); Debug.Log((object)$"Ray Radius: {component.m_rayRadius}"); Debug.Log((object)$"TTL: {component.m_ttl}"); Debug.Log((object)"===================================="); } else { Debug.LogError((object)"Ash's attack projectile has no Projectile component!"); } } else { Debug.LogError((object)"Ash's attack has no projectile prefab!"); } } private void Update() { IsSafe(); float deltaTime = Time.deltaTime; switch (AshMode) { case "ASH_MODE_GUARD": FollowMaster(deltaTime); break; case "ASH_MODE_SENTINEL": { AshStop(); Character targetEnemy = SeekOutTarget(); AttackEnemyClosestToMaster(targetEnemy); break; } case "ASH_MODE_CHOP": ChopTrees(); break; default: AshStop(); break; } } private void AshStop() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Character)humanoidAsh).SetMoveDir(Vector3.zero); ((Character)humanoidAsh).SetRun(false); ((Character)humanoidAsh).SetWalk(false); } protected void FollowMaster(float dt) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) float num = DistanceXZ(player.transform.position, ((Component)this).transform.position); if (num <= 4f) { StopMoving(); Character val = SeekOutTarget(); if ((Object)(object)val != (Object)null) { AttackEnemyClosestToMaster(val); } } else { bool run = num > 8f; MoveTo(dt, player.transform.position, 4f, run); } } private List GetNearbyEnemies(float detectionRadius) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Invalid comparison between Unknown and I4 List list = new List(); if ((Object)(object)characterAsh == (Object)null) { return list; } Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, detectionRadius, LayerMask.GetMask(new string[1] { "character" })); Collider[] array2 = array; foreach (Collider val in array2) { Character component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component == (Object)(object)characterAsh) && !component.IsDead() && ((Component)component).gameObject.activeInHierarchy && component.GetFaction() != characterAsh.GetFaction() && (int)component.GetFaction() != 0) { Debug.Log((object)("Enemy nearby: " + component.m_name)); list.Add(component); } } return list; } private Character SeekOutTarget() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0101: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) List nearbyEnemies = GetNearbyEnemies(50f); Character result = null; float num = float.MaxValue; int num2 = 0; RaycastHit val4 = default(RaycastHit); foreach (Character item in nearbyEnemies) { if ((Object)(object)item == (Object)(object)characterAsh || (Object)(object)item == (Object)(object)((Component)Player.m_localPlayer).GetComponent() || item.IsTamed() || item.IsDead()) { continue; } num2++; float num3 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position); if (num3 >= num) { continue; } Vector3 val = ((Component)this).transform.position + Vector3.up * 1.5f; Vector3 val2 = ((Component)item).transform.position + Vector3.up * 1f; Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (Physics.Raycast(val, ((Vector3)(ref val3)).normalized, ref val4, magnitude)) { Character componentInParent = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)(object)item) { Debug.Log((object)("ASH LINE OF SIGHT BLOCKED | Target: " + item.m_name + " | Obstacle: " + ((Object)((RaycastHit)(ref val4)).collider).name)); continue; } } num = num3; result = item; } currentEnemyCount = num2; return result; } private void AttackEnemyClosestToMaster(Character targetEnemy) { //IL_035e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)targetEnemy == (Object)null)) { EnsureDeathWatcher(targetEnemy); AdjustAim(targetEnemy); BaseAI component = ((Component)humanoidAsh).GetComponent(); if ((Object)(object)component != (Object)null) { Character targetCreature = component.GetTargetCreature(); Debug.Log((object)("ASH TARGET CHECK | Our Target: " + (((Object)(object)targetEnemy != (Object)null) ? targetEnemy.m_name : "NULL") + " | AI Target: " + (((Object)(object)targetCreature != (Object)null) ? targetCreature.m_name : "NULL"))); } else { Debug.Log((object)"ASH TARGET CHECK | NO BASEAI COMPONENT"); } if (((Character)humanoidAsh).StartAttack(targetEnemy, false)) { string text = ((Object)targetEnemy).name ?? ""; text = text.Replace("(Clone)", string.Empty); text = text.Replace("_", " "); string masterOrMistressTitle = GetMasterOrMistressTitle(); string[] array = new string[25] { text + "! You dare threaten my " + masterOrMistressTitle + "?", text + "! You shall not touch my " + masterOrMistressTitle + "!", text + "! You picked the wrong " + masterOrMistressTitle + " to threaten!", text + "! Face me, coward! My " + masterOrMistressTitle + " demands it!", text + "! You will pay for striking my " + masterOrMistressTitle + "!", text + "! My " + masterOrMistressTitle + " shall remain unharmed!", text + "! I will defend my " + masterOrMistressTitle + " to the death!", text + "! You will regret crossing my " + masterOrMistressTitle + "!", text + "! My arrows fly for the glory of my " + masterOrMistressTitle + "!", text + "! You have earned the wrath of my " + masterOrMistressTitle + "!", text + "! Back away from my " + masterOrMistressTitle + "!", text + "! I serve my " + masterOrMistressTitle + ", and I shall destroy you!", text + "! Your attack upon my " + masterOrMistressTitle + " will not go unanswered!", text + "! My " + masterOrMistressTitle + " commands, and I obey!", text + "! For my " + masterOrMistressTitle + ", you shall fall!", text + "! I was dead once. You will be next!", text + "! My " + masterOrMistressTitle + " has no need for your mercy!", text + "! You stand between me and my " + masterOrMistressTitle + "!", text + "! Your blood shall be tribute to my " + masterOrMistressTitle + "!", text + "! I will make you regret threatening my " + masterOrMistressTitle + "!", text + "! My bow serves my " + masterOrMistressTitle + ". You are its next victim!", text + "! The dead protect their own. My " + masterOrMistressTitle + " is mine to protect!", text + "! You have challenged my " + masterOrMistressTitle + ". Now you face me!", text + "! Nothing shall harm my " + masterOrMistressTitle + " while I draw breath!", text + "! I shall send you screaming into the afterlife for my " + masterOrMistressTitle + "!" }; string message = array[Random.Range(0, array.Length)]; AshMessageUI.Instance.Show(message); Debug.Log((object)("Ash fired at " + targetEnemy.m_name + " | " + $"Aim: {((Character)humanoidAsh).GetLookDir()}")); } } } private void AdjustAim(Character targetEnemy) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)targetEnemy == (Object)null)) { AdjustAim(targetEnemy.GetCenterPoint()); } } private void AdjustAim(TreeBase tree) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)tree == (Object)null)) { Vector3 val = ((Component)this).transform.position + ((Component)this).transform.up * 2f + ((Component)this).transform.forward * 1f; Vector3 position = ((Component)tree).transform.position; Vector3 val2 = position - ((Component)this).transform.position; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.001f)) { ((Vector3)(ref val2)).Normalize(); ((Character)humanoidAsh).SetLookDir(val2, 0f); Debug.Log((object)("ASH CHOP AIM: Tree=" + ((Object)tree).name + " | " + $"TreePosition={position} | " + $"AshPosition={((Component)this).transform.position}")); } } } private void AdjustAim(Vector3 targetPoint) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + ((Component)this).transform.up * 2f + ((Component)this).transform.forward * 1f; Vector3 val2 = targetPoint - val; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.001f)) { ((Vector3)(ref val2)).Normalize(); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x, 0f, val2.z); if (((Vector3)(ref val3)).sqrMagnitude > 0.001f) { ((Vector3)(ref val3)).Normalize(); ((Component)this).transform.rotation = Quaternion.LookRotation(val3, Vector3.up); } ((Character)humanoidAsh).SetLookDir(val2, 0f); Debug.Log((object)("Ash AdjustAim | " + $"Target: {targetPoint} | " + $"Spawn: {val} | " + $"Aim: {val2}")); } } private void DisableMonsterAI() { MonsterAI component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; Debug.Log((object)"AshAI: MonsterAI disabled."); } BaseAI component2 = ((Component)this).GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; Debug.Log((object)"AshAI: BaseAI disabled."); } } private void EnsureDeathWatcher(Character target) { if (!((Object)(object)target == (Object)null)) { AshDeathWatcher component = ((Component)target).GetComponent(); if ((Object)(object)component == (Object)null) { component = ((Component)target).gameObject.AddComponent(); component.Initialize(characterAsh); } } } private bool IsSafe() { if (!AshSceneUtility.IsScene(AshSceneUtility.GameScenes.Main)) { return false; } if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } return true; } public void StopMoving() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) characterAsh.SetMoveDir(Vector3.zero); } protected bool MoveTo(float dt, Vector3 point, float dist, bool run) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0089: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) float num = (run ? 1f : 0.5f); if (DistanceXZ(point, ((Component)this).transform.position) < Mathf.Max(dist, num)) { StopMoving(); return true; } if (!FindPath(point)) { StopMoving(); return true; } if (m_path.Count == 0) { StopMoving(); return true; } Vector3 val = m_path[0]; if (DistanceXZ(val, ((Component)this).transform.position) < num) { m_path.RemoveAt(0); if (m_path.Count == 0) { StopMoving(); return true; } } else { Vector3 val2 = val - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; MoveTowards(normalized, run); } return false; } protected bool MoveAndAvoid(float dt, Vector3 point, float dist, bool run) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point - ((Component)this).transform.position; if (characterAsh.IsFlying()) { if (((Vector3)(ref val)).magnitude < dist) { StopMoving(); return true; } } else { val.y = 0f; if (((Vector3)(ref val)).magnitude < dist) { StopMoving(); return true; } } ((Vector3)(ref val)).Normalize(); float radius = characterAsh.GetRadius(); float num = radius + 1f; if (!characterAsh.InAttack()) { m_getOutOfCornerTimer -= dt; if (m_getOutOfCornerTimer > 0f) { Vector3 dir = Quaternion.Euler(0f, m_getOutOfCornerAngle, 0f) * -val; MoveTowards(dir, run); return false; } m_stuckTimer += Time.fixedDeltaTime; if (m_stuckTimer > 1.5f) { if (Vector3.Distance(((Component)this).transform.position, m_lastPosition) < 0.2f) { m_getOutOfCornerTimer = 4f; m_getOutOfCornerAngle = Random.Range(-20f, 20f); m_stuckTimer = 0f; return false; } m_stuckTimer = 0f; m_lastPosition = ((Component)this).transform.position; } } if (CanMove(val, radius, num)) { MoveTowards(val, run); } else { Vector3 forward = ((Component)this).transform.forward; if (characterAsh.IsFlying()) { forward.y = 0.2f; ((Vector3)(ref forward)).Normalize(); } Vector3 val2 = ((Component)this).transform.right * radius * 0.75f; float num2 = num * 1.5f; Vector3 centerPoint = characterAsh.GetCenterPoint(); float num3 = Raycast(centerPoint - val2, forward, num2, 0.1f); float num4 = Raycast(centerPoint + val2, forward, num2, 0.1f); if (num3 >= num2 && num4 >= num2) { MoveTowards(forward, run); } else { Vector3 dir2 = Quaternion.Euler(0f, -20f, 0f) * forward; Vector3 dir3 = Quaternion.Euler(0f, 20f, 0f) * forward; if (num3 > num4) { MoveTowards(dir2, run); } else { MoveTowards(dir3, run); } } } return false; } private bool CanMove(Vector3 dir, float checkRadius, float distance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0035: 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) //IL_0042: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Vector3 centerPoint = characterAsh.GetCenterPoint(); Vector3 right = ((Component)this).transform.right; if (Raycast(centerPoint, dir, distance, 0.1f) < distance) { return false; } if (Raycast(centerPoint - right * (checkRadius - 0.1f), dir, distance, 0.1f) < distance) { return false; } if (Raycast(centerPoint + right * (checkRadius - 0.1f), dir, distance, 0.1f) < distance) { return false; } return true; } public float Raycast(Vector3 p, Vector3 dir, float distance, float radius) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (radius == 0f) { RaycastHit val = default(RaycastHit); if (Physics.Raycast(p, dir, ref val, distance, -5)) { return ((RaycastHit)(ref val)).distance; } return distance; } RaycastHit val2 = default(RaycastHit); if (Physics.SphereCast(p, radius, dir, ref val2, distance, -5)) { return ((RaycastHit)(ref val2)).distance; } return distance; } private void MoveTowards(Vector3 dir, bool run) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref dir)).sqrMagnitude < 0.001f) { AshStop(); return; } ((Vector3)(ref dir)).Normalize(); LookTowards(dir); if (!IsLookingTowards(dir, 20f)) { AshStop(); return; } characterAsh.SetMoveDir(dir); characterAsh.SetRun(run); characterAsh.SetWalk(!run); } private void LookTowards(Vector3 dir) { //IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references) dir.y = 0f; if (!(((Vector3)(ref dir)).sqrMagnitude < 0.001f)) { ((Vector3)(ref dir)).Normalize(); ((Component)this).transform.rotation = Quaternion.LookRotation(dir, Vector3.up); } } private bool IsLookingTowards(Vector3 dir, float minAngle) { //IL_0031: 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) dir.y = 0f; if (((Vector3)(ref dir)).sqrMagnitude < 0.001f) { return true; } ((Vector3)(ref dir)).Normalize(); float num = Vector3.Angle(((Component)this).transform.forward, dir); return num <= minAngle; } protected bool FindPath(Vector3 target) { //IL_0026: 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_0055: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; float num = time - m_lastFindPathTime; if (num < 1f) { return m_lastFindPathResult; } if (Vector3.Distance(target, m_lastFindPathTarget) < 1f && num < 5f) { return m_lastFindPathResult; } m_lastFindPathTarget = target; m_lastFindPathTime = time; m_lastFindPathResult = Pathfinding.instance.GetPath(((Component)this).transform.position, target, m_path, (AgentType)1, false, true, false); return m_lastFindPathResult; } private float DistanceXZ(Vector3 a, Vector3 b) { //IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) float num = a.x - b.x; float num2 = a.z - b.z; return Mathf.Sqrt(num * num + num2 * num2); } private void ChopTrees() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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) //IL_008e: 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_00cc: Unknown result type (might be due to invalid IL or missing references) AshStop(); if ((Object)(object)currentTreeTarget == (Object)null) { currentTreeTarget = FindNearestTreeByIncreasingRadius(); treeTargetCounter = 0; } else { treeTargetCounter++; if (treeTargetCounter > 4) { currentTreeTarget = null; } } TreeBase val = currentTreeTarget; if ((Object)(object)val == (Object)null) { currentTreeTarget = null; return; } Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.01f)) { ((Character)humanoidAsh).SetLookDir(((Vector3)(ref val2)).normalized, 0f); LookTowards(((Vector3)(ref val2)).normalized); AdjustAim(val); ((Character)humanoidAsh).StartAttack((Character)null, false); } } private TreeBase FindNearestTreeByIncreasingRadius() { TreeBase val = FindClosestTree(10f); if ((Object)(object)val != (Object)null) { return val; } val = FindClosestTree(20f); if ((Object)(object)val != (Object)null) { return val; } val = FindClosestTree(30f); if ((Object)(object)val != (Object)null) { return val; } val = FindClosestTree(40f); if ((Object)(object)val != (Object)null) { return val; } val = FindClosestTree(50f); if ((Object)(object)val != (Object)null) { return val; } return FindClosestTree(60f); } private TreeBase FindClosestTree(float maxDistance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0074: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, maxDistance, m_treeOverlapResults); TreeBase result = null; float num2 = maxDistance; for (int i = 0; i < num; i++) { Collider val = m_treeOverlapResults[i]; if ((Object)(object)val == (Object)null) { continue; } TreeBase componentInParent = ((Component)val).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { Vector3 val2 = val.ClosestPoint(((Component)this).transform.position); float num3 = Vector3.Distance(((Component)this).transform.position, val2); if (num3 < num2) { num2 = num3; result = componentInParent; } } } return result; } public bool IsChopping() { return AshMode == "ASH_MODE_CHOP"; } private string GetMasterOrMistressTitle() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return "Master"; } return (localPlayer.GetPlayerModel() == 1) ? "Mistress" : "Master"; } } public static class AshAIHelper { private static readonly FieldRef TargetField = AccessTools.FieldRefAccess("m_targetCreature"); private static readonly FieldRef StaticTargetField = AccessTools.FieldRefAccess("m_targetStatic"); public static void SetAshTarget(MonsterAI ai, Character target) { if (!((Object)(object)ai == (Object)null) && !((Object)(object)target == (Object)null)) { TargetField.Invoke(ai) = target; StaticTargetField.Invoke(ai) = null; } } public static void ClearTarget(MonsterAI ai) { if (!((Object)(object)ai == (Object)null)) { TargetField.Invoke(ai) = null; } } public static void TestHarmony() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("AshValheimMod.Test"); Debug.Log((object)("Harmony loaded successfully: " + val.Id)); } } public class AshButtonUI : MonoBehaviour { private bool panelOpen = false; private const float PANEL_WIDTH = 900f; private const float PANEL_HEIGHT = 180f; private const float BUTTON_SIZE = 120f; private const float BUTTON_GAP = 20f; private readonly string[] buttonNames = new string[6] { "SUMMON", "GUARD", "SENTINEL", "CHOP", "STOP", "DISPERSE" }; private readonly string[] resourcePaths = new string[6] { "AshValheimMod.Assets.Icons.summon.png", "AshValheimMod.Assets.Icons.guard.png", "AshValheimMod.Assets.Icons.sentinel.png", "AshValheimMod.Assets.Icons.chop.png", "AshValheimMod.Assets.Icons.stop.png", "AshValheimMod.Assets.Icons.disperse.png" }; private GameObject panel; private void Update() { if (IsSafe() && Input.GetKey((KeyCode)308) && Input.GetKeyDown((KeyCode)121)) { Debug.Log((object)"ASH BUTTON UI: ALT+Y DETECTED!"); panelOpen = !panelOpen; if ((Object)(object)panel == (Object)null) { CreatePanel(); } if ((Object)(object)panel != (Object)null) { panel.SetActive(panelOpen); } GUIManager.BlockInput(panelOpen); Debug.Log((object)("ASH BUTTON UI: Panel " + (panelOpen ? "OPENED" : "CLOSED"))); } } private void CreatePanel() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"ASH BUTTON UI: CreatePanel()"); if (GUIManager.Instance == null) { Debug.LogError((object)"ASH BUTTON UI: GUIManager.Instance is NULL"); return; } if ((Object)(object)GUIManager.CustomGUIFront == (Object)null) { Debug.LogError((object)"ASH BUTTON UI: GUIManager.CustomGUIFront is NULL"); return; } Debug.Log((object)"ASH BUTTON UI: Jotunn GUIManager is available."); panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 900f, 180f, true); if ((Object)(object)panel == (Object)null) { Debug.LogError((object)"ASH BUTTON UI: Failed to create Jotunn wood panel."); return; } ((Object)panel).name = "AshModePanel"; Debug.Log((object)"ASH BUTTON UI: Created Jotunn Ash Mode panel."); for (int i = 0; i < buttonNames.Length; i++) { CreateButton(panel.transform, buttonNames[i], resourcePaths[i], i); } } private void CreateButton(Transform parent, string buttonName, string resourcePath, int index) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown GameObject val = new GameObject("AshButton_" + buttonName); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = new Vector2(0.5f, 0.5f); val2.anchorMax = new Vector2(0.5f, 0.5f); val2.pivot = new Vector2(0.5f, 0.5f); val2.sizeDelta = new Vector2(120f, 120f); float num = (float)buttonNames.Length * 120f + (float)(buttonNames.Length - 1) * 20f; float num2 = 0f - num / 2f + 60f; val2.anchoredPosition = new Vector2(num2 + (float)index * 140f, 0f); Image val3 = val.AddComponent(); Sprite val4 = LoadSprite(resourcePath); if ((Object)(object)val4 == (Object)null) { Debug.LogError((object)("ASH BUTTON UI: Failed to load sprite: " + resourcePath)); Object.Destroy((Object)(object)val); return; } val3.sprite = val4; val3.preserveAspect = true; ((Graphic)val3).raycastTarget = true; Button val5 = val.AddComponent