Please disclose if any significant portion of your mod was created 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 VikingCompanions v0.1.60
plugins/VikingCompanions.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.Sprites; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("SagaCompanions.RuntimeTests")] [assembly: InternalsVisibleTo("SagaCompanions.OfflineTests")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("VikingCompanions")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.60.0")] [assembly: AssemblyInformationalVersion("0.1.60")] [assembly: AssemblyProduct("VikingCompanions")] [assembly: AssemblyTitle("VikingCompanions")] [assembly: AssemblyVersion("0.1.60.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } namespace Zephyrfit.SagaCompanions { internal static class AbandonedHomes { [HarmonyPatch(typeof(SpawnSystem), "FindBaseSpawnPoint")] private static class ChooseHome { private static bool Prefix(SpawnData spawn, List<Player> allPlayers, ref Vector3 spawnCenter, ref Player targetPlayer, ref bool __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spawn.m_prefab != (Object)(object)Prefabs.Actor) { return true; } targetPlayer = null; spawnCenter = default(Vector3); __result = false; foreach (Player allPlayer in allPlayers) { if (Object.op_Implicit((Object)(object)allPlayer) && Find(allPlayer, spawn.m_spawnRadiusMin, spawn.m_spawnRadiusMax, out spawnCenter)) { targetPlayer = allPlayer; __result = true; break; } } return false; } } [HarmonyPatch(typeof(SpawnSystem), "IsSpawnPointGood")] private static class CheckHome { private static bool Prefix(SpawnData spawn, ref Vector3 spawnPoint, ref bool __result) { //IL_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spawn.m_prefab != (Object)(object)Prefabs.Actor) { return true; } __result = Interior(spawnPoint + Vector3.up * 1.15f, out var floor) && Vacant(floor); if (__result) { spawnPoint = floor; } return false; } } [HarmonyPatch(typeof(SpawnSystem), "Spawn")] private static class Settle { private static bool Prefix(SpawnSystem __instance, SpawnData critter, Vector3 spawnPoint) { //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) if ((Object)(object)critter.m_prefab != (Object)(object)Prefabs.Actor) { return true; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsOwner()) { CompanionSpawner.Natural(component.GetZDO().m_uid, spawnPoint); } return false; } } private static readonly List<Piece> Pieces = new List<Piece>(); private static readonly List<ZDO> Nearby = new List<ZDO>(); private static readonly FieldInfo Locations = AccessTools.Field(typeof(Location), "s_allLocations"); private static readonly Func<ZoneSystem, int, ZoneLocation> LocationByHash = AccessTools.MethodDelegate<Func<ZoneSystem, int, ZoneLocation>>(AccessTools.Method(typeof(ZoneSystem), "GetLocation", new Type[1] { typeof(int) }, (Type[])null), (object)null, true); private static readonly Vector3[] Walls = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.right, Vector3.back, Vector3.left }; private static readonly string[] RoofNames = new string[4] { "roof", "thatch", "shingle", "ceiling" }; private static readonly string[] WallNames = new string[12] { "wall", "beam", "post", "log", "stone", "marble", "grausten", "arch", "gate", "pillar", "stake", "door" }; private static readonly string[] BuildingNames = new string[15] { "house", "hut", "cabin", "hall", "tower", "fort", "ruin", "castle", "lodge", "village", "camp", "settlement", "outpost", "barrack", "stronghold" }; private static readonly string[] EnclosedModels = new string[6] { "house", "hut", "cabin", "tower", "lodge", "barrack" }; private static readonly string[] DetachedWalls = new string[8] { "wall", "beam", "post", "arch", "gate", "pillar", "stake", "door" }; private static readonly string[] MasonryBlocks = new string[5] { "stone_wall", "blackmarble_1x", "blackmarble_2x", "grausten_wall", "grausten_pillar" }; private static readonly int Solids = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); private static bool Contains(string name, string[] words) { foreach (string value in words) { if (name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } internal static bool WildNearby(Vector3 point, bool natural = false) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_00e9: 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) Nearby.Clear(); float spacing = WorldRules.Spacing; int num = Mathf.CeilToInt(spacing / 64f) + 1; ZDOMan.instance.FindSectorObjects(ZoneSystem.GetZone(point), new SimulationDistance(num, 0, true), Nearby, (List<ZDO>)null); SettlementHome? settlementHome = null; int num2 = 0; foreach (ZDO item in Nearby) { if (item.GetPrefab() != StringExtensionMethods.GetStableHashCode("Zephyrfit_SagaCompanion") || item.GetBool("zsf_spirit", false) || item.GetFloat(ZDOVars.s_health, 1f) <= 0f || item.GetLong("zsf_owner", 0L) != 0L) { continue; } float num3 = Utils.DistanceXZ(point, item.GetPosition()); if (!(num3 >= spacing)) { if (!natural) { return true; } SettlementHome valueOrDefault = settlementHome.GetValueOrDefault(); if (!settlementHome.HasValue) { valueOrDefault = SettlementHome.At(point, Recruitment.At(point)); settlementHome = valueOrDefault; } SettlementHome other = SettlementHome.At(item.GetPosition(), Recruitment.At(item.GetPosition())); if (num3 < settlementHome.Value.Separation(other, spacing) || ++num2 >= 2) { return true; } } } return false; } internal static bool Vacant(Vector3 point) { //IL_0000: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (ClearAround(point)) { if ((int)Recruitment.At(point) == 16 && FulingVillage.At(point, out var village)) { return village.Clear(); } return true; } return false; } private static bool ClearAround(Vector3 point) { //IL_0000: 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_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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (Player.IsPlayerInRange(point, 24f) || WildNearby(point, natural: true)) { return false; } foreach (IMonoUpdater instance in CraftingStation.Instances) { CraftingStation val = (CraftingStation)(object)((instance is CraftingStation) ? instance : null); if (val != null && Object.op_Implicit((Object)(object)val) && Utils.DistanceXZ(((Component)val).transform.position, point) < 24f) { return false; } } foreach (Character allCharacter in Character.GetAllCharacters()) { if (Object.op_Implicit((Object)(object)allCharacter) && !(allCharacter is Companion) && allCharacter.GetBaseAI() is MonsterAI && !allCharacter.IsDead() && !allCharacter.IsTamed()) { Vector3 val2 = ((Component)allCharacter).transform.position - point; if (((Vector3)(ref val2)).sqrMagnitude < 576f) { return false; } } } Pieces.Clear(); Piece.GetAllPiecesInRadius(point, 18f, Pieces); foreach (Piece piece in Pieces) { if (Object.op_Implicit((Object)(object)piece) && piece.IsPlacedByPlayer()) { return false; } } return true; } internal static bool RemoteSite(Vector3 point) { //IL_0029: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00e3: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Invalid comparison between Unknown and I4 //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { ZDO zDO = ZDOMan.instance.GetZDO(peer.m_characterID); if (zDO != null) { Vector3 val = zDO.GetPosition() - point; if (((Vector3)(ref val)).sqrMagnitude < 576f) { return false; } } } Nearby.Clear(); ZDOMan.instance.FindSectorObjects(ZoneSystem.GetZone(point), new SimulationDistance(2, 0, true), Nearby, (List<ZDO>)null); bool flag = false; Biome val2 = Recruitment.At(point); FulingVillage? fulingVillage = null; int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)instance.m_locationProxyPrefab).name); foreach (ZDO item in Nearby) { Vector3 val3 = item.GetPosition() - point; if (item.GetPrefab() == stableHashCode) { ZoneLocation val4 = LocationByHash(instance, item.GetInt(ZDOVars.s_location, 0)); float num = val4?.m_exteriorRadius ?? 0f; if (num > 0f && val3.x * val3.x + val3.z * val3.z <= num * num) { flag = true; if ((int)val2 == 16 && FulingVillage.At(val4.m_prefabName, item.GetPosition(), num, point, out var village)) { fulingVillage = village; } } } if (!(((Vector3)(ref val3)).sqrMagnitude > 576f)) { GameObject prefab = ZNetScene.instance.GetPrefab(item.GetPrefab()); if (Object.op_Implicit((Object)(object)prefab) && (Object.op_Implicit((Object)(object)prefab.GetComponent<CraftingStation>()) || (Object.op_Implicit((Object)(object)prefab.GetComponent<Piece>()) && item.GetLong(ZDOVars.s_creator, 0L) != 0L) || (item.GetPrefab() != StringExtensionMethods.GetStableHashCode("Zephyrfit_SagaCompanion") && Object.op_Implicit((Object)(object)prefab.GetComponent<MonsterAI>()) && !item.GetBool(ZDOVars.s_tamed, false) && item.GetFloat(ZDOVars.s_health, 1f) > 0f))) { return false; } } } if (flag && (!fulingVillage.HasValue || fulingVillage.Value.Clear())) { if (!fulingVillage.HasValue || !CampRules.Villages) { return Recruitment.IsSettlement(point, val2); } return true; } return false; } private static bool BuildingSurface(RaycastHit hit, Location site, bool ceiling) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) Collider collider = ((RaycastHit)(ref hit)).collider; Piece componentInParent = ((Component)collider).GetComponentInParent<Piece>(); if (Object.op_Implicit((Object)(object)componentInParent)) { if (componentInParent.IsPlacedByPlayer()) { return false; } if (!ceiling) { return Contains(((Object)componentInParent).name, WallNames); } if (!Contains(((Object)componentInParent).name, RoofNames)) { if (Object.op_Implicit((Object)(object)site) && Contains(((Object)site).name, BuildingNames)) { if (!((Object)componentInParent).name.Contains("floor") && !((Object)componentInParent).name.Contains("arch")) { if (((RaycastHit)(ref hit)).normal.y < -0.65f) { return Contains(((Object)componentInParent).name, MasonryBlocks); } return false; } return true; } return false; } return true; } if (!Object.op_Implicit((Object)(object)site) || !Contains(((Object)site).name, BuildingNames) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Heightmap>())) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent<Location>() == (Object)(object)site) { return true; } ZNetView componentInParent2 = ((Component)collider).GetComponentInParent<ZNetView>(); if (!Object.op_Implicit((Object)(object)componentInParent2) || !componentInParent2.IsValid() || componentInParent2.GetZDO().GetLong(ZDOVars.s_creator, 0L) != 0L) { return false; } string name = ((Object)componentInParent2).name; if (!Contains(name, EnclosedModels)) { return Contains(name, ceiling ? RoofNames : DetachedWalls); } return true; } private static bool HutRoof(Collider roof) { if (Object.op_Implicit((Object)(object)roof)) { Piece componentInParent = ((Component)roof).GetComponentInParent<Piece>(); if (componentInParent == null || !componentInParent.IsPlacedByPlayer()) { Transform val = ((Component)roof).transform; while (Object.op_Implicit((Object)(object)val)) { string name = ((Object)val).name; if (Contains(name, RoofNames) || name.IndexOf("goblinhut", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("goblin_hut", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("tent", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return false; } } return false; } internal static bool Interior(Vector3 probe, out Vector3 floor) { //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_0017: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0035: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) floor = default(Vector3); Location location = Location.GetLocation(probe, true); if (!Object.op_Implicit((Object)(object)location) || Character.InInterior(probe)) { return false; } Biome val = Recruitment.At(probe); if (!Recruitment.HasResidents(val)) { return false; } bool flag = (int)val == 16 && CampRules.Villages && FulingVillage.IsVillage(((Object)location).name); int solids = Solids; RaycastHit hit = default(RaycastHit); if ((!Physics.Raycast(probe, Vector3.up, ref hit, 7f, solids, (QueryTriggerInteraction)1) || !BuildingSurface(hit, location, ceiling: true)) && (!flag || !Physics.Raycast(probe + Vector3.up * 7f, Vector3.down, ref hit, 7f, solids, (QueryTriggerInteraction)1) || !HutRoof(((RaycastHit)(ref hit)).collider))) { return false; } RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(probe, Vector3.down, ref val2, 7f, solids, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.72f || ((RaycastHit)(ref hit)).point.y - ((RaycastHit)(ref val2)).point.y < 2.05f || ((RaycastHit)(ref val2)).point.y < ZoneSystem.instance.m_waterLevel) { return false; } floor = ((RaycastHit)(ref val2)).point + Vector3.up * 0.08f; if (Physics.CheckCapsule(floor + Vector3.up * 0.38f, floor + Vector3.up * 1.55f, 0.32f, solids, (QueryTriggerInteraction)1)) { return false; } if (flag && HutRoof(((RaycastHit)(ref hit)).collider)) { return true; } Vector3 val3 = floor + Vector3.up * 1.15f; int num = 0; Vector3[] walls = Walls; RaycastHit hit2 = default(RaycastHit); foreach (Vector3 val4 in walls) { if (Physics.Raycast(val3, val4, ref hit2, 7f, solids, (QueryTriggerInteraction)1) && Mathf.Abs(((RaycastHit)(ref hit2)).normal.y) < 0.64f && BuildingSurface(hit2, location, ceiling: false)) { num++; } } if (num >= 2) { if (!flag) { return Recruitment.IsSettlement(floor, Recruitment.At(floor)); } return true; } return false; } internal static bool Find(Player player, float min, float max, out Vector3 point) { //IL_0019: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: 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_02da: Unknown result type (might be due to invalid IL or missing references) point = default(Vector3); List<Piece> list = new List<Piece>(); Piece.GetAllPiecesInRadius(((Component)player).transform.position, max + 6f, list); int num = Random.Range(0, Math.Max(1, list.Count)); Location lastVillage = null; bool villageClear = false; for (int i = 0; i < list.Count; i++) { Piece val = list[(i + num) % list.Count]; if (Object.op_Implicit((Object)(object)val) && !val.IsPlacedByPlayer()) { if (((Object)val).name.IndexOf("floor", StringComparison.OrdinalIgnoreCase) >= 0 && Try(((Component)val).transform.position + Vector3.up * 1.2f, out point)) { return true; } if (Contains(((Object)val).name, RoofNames) && Try(((Component)val).transform.position - Vector3.up * 0.85f, out point)) { return true; } } } float num9 = default(float); foreach (Location item in (List<Location>)Locations.GetValue(null)) { if (!Object.op_Implicit((Object)(object)item) || !Contains(((Object)item).name, BuildingNames) || Utils.DistanceXZ(((Component)item).transform.position, ((Component)player).transform.position) > max + item.m_exteriorRadius) { continue; } float exteriorRadius = item.m_exteriorRadius; Vector3 val2 = ((Component)player).transform.position - ((Component)item).transform.position; float num2 = Mathf.Max(0f - exteriorRadius, val2.x - max); float num3 = Mathf.Min(exteriorRadius, val2.x + max); float num4 = Mathf.Max(0f - exteriorRadius, val2.z - max); float num5 = Mathf.Min(exteriorRadius, val2.z + max); for (float num6 = num2; num6 <= num3; num6 += 3f) { for (float num7 = num4; num7 <= num5; num7 += 3f) { Vector3 val3 = ((Component)item).transform.position + new Vector3(num6, 0f, num7); float num8 = Utils.DistanceXZ(val3, ((Component)player).transform.position); if (!(num6 * num6 + num7 * num7 > exteriorRadius * exteriorRadius) && !(num8 < min) && !(num8 > max) && ZoneSystem.instance.GetGroundHeight(val3, ref num9)) { val3.y = num9 + 1.5f; if (Try(val3, out point) || Try(val3 + Vector3.up * 2.8f, out point)) { return true; } } } } } return false; bool Try(Vector3 probe, out Vector3 found) { //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_0013: 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_0060: 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_004c: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) found = default(Vector3); float num10 = Utils.DistanceXZ(probe, ((Component)player).transform.position); if (num10 < min || num10 > max || !Interior(probe, out found) || (ZNet.instance.IsServer() && !VisitedZones.Has(found, Recruitment.At(found)))) { return false; } Location location = Location.GetLocation(found, true); if (Object.op_Implicit((Object)(object)location) && FulingVillage.IsVillage(((Object)location).name) && (int)Recruitment.At(found) == 16) { if ((Object)(object)lastVillage != (Object)(object)location) { lastVillage = location; villageClear = FulingVillage.At(((Object)location).name, ((Component)location).transform.position, location.m_exteriorRadius, found, out var village) && village.Clear(); } if (!villageClear) { return false; } } return ClearAround(found); } } } internal enum Order { Recruit, Free, Guard, Follow, Inventory, Heal, Recall, FreeKeep, AcceptQuest, ChangeQuest, AlternativeDelivery, HauntGrave, ReturnToStones } public sealed class Companion : Humanoid, Interactable { [HarmonyPatch(typeof(Player), "StartEmote")] private static class PlayerDance { private static void Postfix(Player __instance, string emote, bool __result) { if (__result && !(emote != "dance") && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)ZNet.instance)) { ZDO val = CompanionBeds.Data((Component)(object)__instance); if (val != null && val.IsOwner()) { val.Set("zvc_playerDance51", ZNet.instance.GetTime().Ticks); } } } } [HarmonyPatch(typeof(CharacterAnimEvent), "DodgeMortal")] private static class RollWindow { private static void Postfix(Character ___m_character) { if (___m_character is Companion companion) { companion.rollProtection = false; } } } private struct Meal { internal ItemDrop Food; internal float Left; } private enum Memory { Mist, Enemy, Fire, Frost, Poison, Fall, Water } private Character shotTarget; private ItemData preparing; private ItemData loadedCrossbow; private ItemData sightWeapon; private Character sightTarget; private float reloadProgress; private float nextSightCheck; private bool inSight; private static readonly int LowAmmoKey = StringExtensionMethods.GetStableHashCode("zvc_lowArrows"); private static readonly int NoFoodKey = StringExtensionMethods.GetStableHashCode("zvc_noFood"); private static readonly int ConditionsKey = StringExtensionMethods.GetStableHashCode("zvc_conditions"); private static readonly int FireSaid = StringExtensionMethods.GetStableHashCode("zvc_fireSaid"); private static readonly int PoisonSaid = StringExtensionMethods.GetStableHashCode("zvc_poisonSaid"); private static readonly int WarRoll = StringExtensionMethods.GetStableHashCode("zvc_warRoll"); private static readonly int WarSaid = StringExtensionMethods.GetStableHashCode("zvc_warSaid"); private float captionUntil; private float lastFighting = -1000f; private float combatOpened; private float rallyUntil; private float rallyReadyAt; private int captionMask; private bool triedRally; private Character rallyTarget; private Character noticedTarget; private ItemData rallyWeapon; private BattlePose rallyPose; private BattleSalute salute; internal const string KitKey = "zvc_boundKit_v1"; internal const string MigratedEmptyDeath = "zvc_emptyKitDeath"; internal readonly Inventory BoundKit = new Inventory("Viking equipment", (Sprite)null, 8, 1); private readonly List<ItemData> pendingEquipment = new List<ItemData>(); private bool pendingOutfit; internal const int AdviceInterval = 480; internal static readonly int LastAdvice = StringExtensionMethods.GetStableHashCode("zvc_lastFieldAdvice"); internal static readonly int AdviceTopic = StringExtensionMethods.GetStableHashCode("zvc_fieldAdviceTopic"); private float quietSince; private float lastQuietCheck; private float nextAdviceCheck; private BiomePassage passage; private float nextBiomeSample; private static float nextHeardAdvice; private const string DanceCue = "zvc_playerDance51"; private const string DanceStart = "zvc_danceStart51"; private const string SongDanceEnd = "zvc_songDanceEnd51"; private const long DanceLength = 351684685L; private const float DanceRadius = 8f; private long performedDance; private long ignoredDanceThrough; private int performedPhrase; private const string CampSongRpc = "ZVC_CampSong43"; private CraftingStation campBench; private ZNetView campTarget; private Vector3 campPoint; private RestPose campIntent; private Fireplace campFire; private float scanCampAfter; private float campArrivalBy; private float nextCampChest; private float nextBenchSearch; private const string RestUntilKey = "zvc_campRestUntil"; private Chair campChair; private readonly List<Chair> campSeats = new List<Chair>(); private long campChant; private bool campChairAtNight; private ZDOID unreachableFurniture; private float retryFurnitureAfter; private readonly List<Piece> campPieces = new List<Piece>(); private const string LastChoice = "zsf_weapon"; private const string MeleeChoice = "zsf_melee"; private const string RangedChoice = "zsf_archery"; private const string ShieldChoice = "zsf_shield"; private static readonly MethodInfo CloneShared = AccessTools.Method(typeof(object), "MemberwiseClone", (Type[])null, (Type[])null); private static readonly ConditionalWeakTable<SharedData, SharedData> OriginalSettings = new ConditionalWeakTable<SharedData, SharedData>(); private static readonly int MosquitoPrefab = StringExtensionMethods.GetStableHashCode("Deathsquito"); private Character equipmentTarget; private float nextEquipmentCheck; private bool mosquito; private Character bracedTarget; private ItemData extendedWeapon; private float normalDecisionRange; internal static readonly HashSet<Companion> All = new HashSet<Companion>(); internal const string OwnerKey = "zsf_owner"; internal const string SpiritKey = "zsf_spirit"; internal const string FollowKey = "zsf_follow"; internal const string PostKey = "zsf_post"; private const string Pack = "zsf_pack_v1"; private const string NameKey = "zsf_name"; private const string TierKey = "zsf_birthTier"; private const string SeedKey = "zsf_seed"; private static readonly FieldRef<Character, bool> NativeDead = AccessTools.FieldRefAccess<Character, bool>("m_isDead"); private static readonly int WoundKey = StringExtensionMethods.GetStableHashCode("zvc_wounds58"); internal CompanionAI Brain; private bool loaded; private bool loading; private bool priorOwner; private string lastPack; private readonly PackSnapshot savedContents = new PackSnapshot(); private float nextTick; private float nextPackCheck; private float nextNameRequest; private int packedCapacity; private int packedUtilities; private bool excessCargo; private const string BeforeUtilityProgression = "zvc_packBeforeUtility37"; private static ZoneSystem stoneWorld; private static Vector3 stonePosition; private static bool stoneFound; private static float nextStoneLookup; internal const string HandlerKey = "zsf_guestFollow"; private ZDOID guestCharacter; private float guestLastSeen; private static readonly FieldRef<Humanoid, HashSet<StatusEffect>> NativeEquipmentEffects = AccessTools.FieldRefAccess<Humanoid, HashSet<StatusEffect>>("m_equipmentStatusEffects"); private readonly HashSet<StatusEffect> accessoryEffects = new HashSet<StatusEffect>(); private readonly HashSet<StatusEffect> desiredAccessories = new HashSet<StatusEffect>(); private const string PotionIcons = "zvc_activePotions"; private const string HealingFood = "zvc_healingFood"; private const string DrinkEnd = "zvc_resistEnd_"; private static readonly FieldRef<SE_Stats, float> HealthTicks = AccessTools.FieldRefAccess<SE_Stats, float>("m_healthOverTimeTicks"); private static readonly FieldRef<SE_Stats, float> HealthTickTimer = AccessTools.FieldRefAccess<SE_Stats, float>("m_healthOverTimeTimer"); private static readonly FieldRef<SE_Stats, float> PeriodicTimer = AccessTools.FieldRefAccess<SE_Stats, float>("m_tickTimer"); private readonly List<ItemDrop> activeDrinks = new List<ItemDrop>(); private readonly List<ItemDrop> visibleDrinks = new List<ItemDrop>(); private byte[] lastDrinkBytes; private static readonly int DodgeTag = ZSyncAnimation.GetHash("dodge"); private float braceUntil; private float nextRoll; private float rollUntil; private long handledSwing; private bool rollProtection; private static readonly FieldRef<Humanoid, float> NativeBlockTime = AccessTools.FieldRefAccess<Humanoid, float>("m_blockTimer"); internal const string DeathEvent = "zsf_falling"; internal const string DeathPoint = "zsf_fallPos"; private const string PoseKey = "zvc_pose"; private const string Link = "zvc_anchor"; private const string Local = "zvc_seatPos"; private const string Rotation = "zvc_seatRot"; private const string Animation = "zvc_seatAnim"; private const string Night = "zvc_night"; private const string Woke = "zvc_morning"; private const string Pillow = "zvc_pillow"; private ZNetView furniture; private ZDOID requestedSeat; private RestPose wanted; private float retrySeat; private float lastOnBoard; private float nightStarted; private float missingSince; private float nextAnchorSearch; private string poseAnimation = ""; private bool held; private bool savedGravity; private bool savedKinematic; private ZNetView ignoredFurniture; private readonly List<Collider> ignoredContacts = new List<Collider>(); private float nextPositionSync; private float queryAfter; private string noBedFor; private static readonly int FloorRequest = StringExtensionMethods.GetStableHashCode("zvc_waitForFloor"); private Vector2s physicsSector; private bool hasPhysicsSector; private bool terrainReady; private bool terrainHold; private bool bodyWasKinematic; private float nextFloorCheck; private Vector3 suspendedVelocity; private Vector3 suspendedSpin; private static readonly Vector3[] ChairExits = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.back, Vector3.right, Vector3.left }; private static readonly Vector3[] ExitDirections = (Vector3[])(object)new Vector3[4] { Vector3.right, Vector3.left, Vector3.back, Vector3.forward }; private Vector3? socialDestination; private float approachUntil; private float ignoreChairsUntil; private float startledUntil; private static readonly float[] BankAngles = new float[3] { 0f, -30f, 30f }; private const string FoodHealth = "zvc_foodHP"; private const string FoodStamina = "zvc_foodSta"; private const string FoodEitr = "zvc_foodEitr"; private static readonly string[] MealName = new string[3] { "zvc_food0", "zvc_food1", "zvc_food2" }; private static readonly string[] MealTime = new string[3] { "zvc_foodTime0", "zvc_foodTime1", "zvc_foodTime2" }; private readonly Meal[] meals = new Meal[3]; private float mealClock; private float regenClock; private float mealSaveClock; private float previousBaseHealth; private float activeMealRegen; private bool mealsLoaded; private const string SupplyOriginKnown = "zvc_supplyOrigin_v1"; private const string WildPackBackup = "zvc_wildPackBeforeBinding"; private const string SupplyCredit = "zvc_recruitSupplies"; private static readonly Action<Inventory> Reweigh = AccessTools.MethodDelegate<Action<Inventory>>(AccessTools.Method(typeof(Inventory), "UpdateTotalWeight", (Type[])null, (Type[])null), (object)null, true); private const string StaminaKey = "zsf_stamina"; private const string EitrKey = "zsf_eitr"; private const string MagicKey = "zsf_hasMagic"; private float stamina; private float eitr; private float staminaDelay; private float eitrDelay; private float publishIn; private bool resourcesLoaded; private const string EncumberedKey = "zvc_encumbered"; internal const string CarryCalledKey = "zvc_heavyPackCalled"; private Player sampledLeader; private Vector3 nearestLeaderPosition; private const float BaseStaminaRegen = 8f; private static readonly int TopicCount = StringExtensionMethods.GetStableHashCode("zvc_topics57"); private readonly List<Character> teachersNearby = new List<Character>(); private float nextAdviceExchange; private int teachingRound; private int opponentSpecies; internal float NextFlankCheck; private const string FormationKey = "zvc_formationRole"; private readonly HitData formationEstimate = new HitData(); private static readonly int AimMask = LayerMask.GetMask(new string[12] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle" }); private static readonly RaycastHit[] aimHits = (RaycastHit[])(object)new RaycastHit[32]; internal const string PickupModeKey = "zvc_resourcePickupMode"; private static Collider[] nearbyDrops = (Collider[])(object)new Collider[32]; private static int itemMask; private static readonly int[] Stops = new int[3] { StringExtensionMethods.GetStableHashCode("zsf_stop0"), StringExtensionMethods.GetStableHashCode("zsf_stop1"), StringExtensionMethods.GetStableHashCode("zsf_stop2") }; private const string PunchRpc = "ZVC_PatronPunch42"; private const string RecoilRpc = "ZVC_PatronRecoil42"; private static readonly Func<Character, Collider, short> WeakSpot = AccessTools.MethodDelegate<Func<Character, Collider, short>>(AccessTools.Method(typeof(Character), "FindWeakSpotIndex", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<Character, long, HitData> ApplyNativeHit = AccessTools.MethodDelegate<Action<Character, long, HitData>>(AccessTools.Method(typeof(Character), "RPC_Damage", (Type[])null, (Type[])null), (object)null, true); private static readonly int KickObstacles = LayerMask.GetMask(new string[6] { "terrain", "piece", "static_solid", "Default", "Default_small", "viewblock" }); private HitData acceptedPunch; private Player kickTarget; private float kickImpact; private float kickEnds; private float nextPatronKick; private bool kickLanded; private float recentHurtUntil; internal const string OfferKey = "zvc_offer43"; internal const string ClaimKey = "zvc_questPlayer43"; internal const string ContractKey = "zvc_contract43"; internal const string TargetKey = "zvc_guardian43"; internal const string SiteKey = "zvc_questSite43"; internal const string EscrowKey = "zvc_lostWeapons43"; internal const string CountKey = "zvc_questQty43"; internal const string LeaseKey = "zvc_questUntil43"; private const string Hunt = "hunt"; private const string Looking = "search"; private const string Coins = "coins"; private float askGuardianAfter; private int exposure; private float exposureUntil; internal const string HauntKey = "zvc_hauntsGrave50"; internal const string GraveIdKey = "zvc_lastGrave50"; internal const string GraveGoneKey = "zvc_graveGone50"; internal const string ShrineOfferUntil = "zvc_shrineOffer50"; internal const string OfferPayer = "zvc_offeringPlayer50"; internal const string OfferMoved = "zvc_offeringMoved50"; private const string MemoryKey = "zvc_lastMemory50"; private const string EnemyKey = "zvc_lastEnemy50"; private const string MurmurKey = "zvc_murmur50"; private const string LastVoice = "zvc_spokeAsSpirit50"; private SpectralOutfit spectralLook; private bool spiritHasGoal; private float nextSpiritStep; private float nextSpiritVoice; private Vector3 spiritGoal; private static readonly RaycastHit[] spiritHits = (RaycastHit[])(object)new RaycastHit[16]; private static float nextAudibleSpirit; internal static readonly int RevivalTimestamp = StringExtensionMethods.GetStableHashCode("zvc_revived59"); private static readonly int RevivedAtBed = StringExtensionMethods.GetStableHashCode("zvc_revivedAtBed59"); private static readonly int GuardianPose = Animator.StringToHash("Base Layer.gpower"); private long seenRevival; private GameObject revivalAura; private Light hearthGlow; private RevivalRibbons revivalRibbons; private bool pendingGuardianPose; private readonly List<Player> greetedHere = new List<Player>(); private static readonly int IdleGestureKey = StringExtensionMethods.GetStableHashCode("zvc_idleGesture"); private static readonly int HandsOnBackKey = StringExtensionMethods.GetStableHashCode("zvc_handsOnBack"); private static readonly string[] IdleGestures = new string[3] { "flex", "thumbsup", "cheer" }; private float gestureEnds; private float nextIdleGesture; private float settledSince; private bool handsOnBack; private string gestureAfterStowing; private float handsReadyAt; private int[] idleOrder; private int idleRemaining; private const string NoticePrefix = "zvc_supplyNotice_"; private static float nextLocalSupplyVoice; private string ammoNoticeKey; private string foodNoticeKey; private long chantStart; private long chantEnd; private ItemData lamp; private ItemData previousRight; private ItemData previousLeft; private Character torchOpponent; private bool equippingTorch; private CompanionVoice speaker; private static float nextLocalGreeting; private float nextSocial; private float lastWarning = -100f; private float lastThreatSeen = -100f; private float nextHeart; private Line? lastThreat; private Character criedAt; private bool announcedApproach; private readonly Dictionary<Line, int> lastTakes = new Dictionary<Line, int>(); private static readonly int LastFarewell = StringExtensionMethods.GetStableHashCode("zvc_lastFarewell52"); private static readonly int LastBossOath = StringExtensionMethods.GetStableHashCode("zvc_lastBossOath52"); private long lastToastRound; private readonly List<Character> audibleCreatures = new List<Character>(); internal bool HeartsActive { get { if (Data != null && Object.op_Implicit((Object)(object)ZNet.instance)) { return Data.GetLong("zsf_hearts", 0L) > ZNet.instance.GetTime().Ticks; } return false; } } internal string SavedName => StoredName(Data); internal string DisplayName { get { ZDO data = Data; string text = ((data != null) ? data.GetString("zsf_called", "") : null); if (string.IsNullOrEmpty(text)) { ZDO data2 = Data; return ((data2 != null) ? data2.GetString("zsf_name", Plugin.Text("Viking", "Viking")) : null) ?? Plugin.Text("Viking", "Viking"); } return CensorShittyWords.FilterUGC(text, (UGCType)2, Data.GetLong("zsf_namedBy", 0L)); } } internal bool Committed { get { if (!((Character)this).InAttack()) { if (base.m_currentAttack != null) { return !base.m_currentAttack.IsDone(); } return false; } return true; } } internal bool Withdrawing { get { if (Patron != 0L) { if (!Data.GetBool("zsf_retreat", false)) { return ((Character)this).GetHealthPercentage() <= WorldRules.Flee; } return true; } return false; } } internal bool LowAmmo { get { if (Patron != 0L && !Spirit && !PendingDeath) { return Data.GetBool(LowAmmoKey, false); } return false; } } internal bool NoFood { get { if (Patron != 0L && !Spirit && !PendingDeath) { return Data.GetBool(NoFoodKey, false); } return false; } } internal bool ShowSupplyMark { get { if (!Plugin.AmmoAlerts.Value || !LowAmmo) { if (Plugin.FoodAlerts.Value) { return NoFood; } return false; } return true; } } internal bool ShowingCondition => Time.unscaledTime < captionUntil; private bool CalmForAdvice { get { if (Patron != 0L && !Spirit && !PendingDeath && !Singing && !Dancing && !Withdrawing && !Brain.Sneaking && !Object.op_Implicit((Object)(object)((BaseAI)Brain).GetTargetCreature()) && !((Character)this).InAttack() && !((Character)this).InDodge() && !((Character)this).IsStaggering() && !((Character)this).IsSwimming()) { return Data.GetInt(ConditionsKey, 0) == 0; } return false; } } private bool RestingForAdvice { get { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) int num; if (CalmForAdvice) { Vector3 velocity = ((Character)this).GetVelocity(); num = ((((Vector3)(ref velocity)).sqrMagnitude < 0.16f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; if (flag) { RestPose pose = Pose; bool flag2 = ((pose == RestPose.Chair || (uint)(pose - 4) <= 2u) ? true : false); flag = flag2 || (Pose == RestPose.None && ((Character)this).IsOnGround()); } return flag; } } internal bool Dancing { get { if (Data != null) { return Data.GetLong("zvc_danceStart51", 0L) != 0; } return false; } } private bool IdleGuard { get { if (Patron != 0L && !Following && !RouteActive && !Spirit) { return !PendingDeath; } return false; } } internal ZDO Data { get { if (!Object.op_Implicit((Object)(object)((Character)this).m_nview) || !((Character)this).m_nview.IsValid()) { return null; } return ((Character)this).m_nview.GetZDO(); } } internal long Patron { get { ZDO data = Data; if (data == null) { return 0L; } return data.GetLong("zsf_owner", 0L); } } internal bool Spirit { get { ZDO data = Data; if (data == null) { return false; } return data.GetBool("zsf_spirit", false); } } internal bool Following { get { ZDO data = Data; if (data == null) { return false; } return data.GetBool("zsf_follow", false); } } internal bool Mine { get { if (Object.op_Implicit((Object)(object)((Character)this).m_nview)) { return ((Character)this).m_nview.IsOwner(); } return false; } } internal int Wounds { get { ZDO data = Data; if (data == null) { return 0; } return data.GetInt(WoundKey, 0); } } internal int VoiceStyle { get { ZDO data = Data; if (data == null) { return 0; } return Voices.Style(data.GetInt("zsf_seed", 0), BodyModel(data)); } } internal string SoulId { get { ZDO data = Data; return ((data != null) ? data.GetString("zsf_soulId", "") : null) ?? ""; } } internal int PackRevision { get; private set; } private bool PackSizeChanged { get { if (packedCapacity == CompanionSlots.Capacity) { return packedUtilities != AccessoryProgression.Count; } return true; } } internal long LeaderId { get { ZDO data = Data; long? num = ((data != null) ? new long?(data.GetLong("zsf_guestFollow", 0L)) : ((long?)null)); if (num.HasValue) { long valueOrDefault = num.GetValueOrDefault(); if (valueOrDefault != 0L) { return valueOrDefault; } } return Patron; } } internal ItemData Blocker => base.m_leftItem ?? ((Humanoid)this).GetCurrentWeapon(); internal float GuardStrength { get { if (!CombatTactics.InRepair(Blocker)) { return 0f; } return Blocker.GetBlockPower(((Character)this).GetSkillFactor((SkillType)6)); } } internal bool PendingDeath { get { if (Data != null) { return Data.GetString("zsf_falling", "").Length != 0; } return false; } } internal RestPose Pose { get { ZDO data = Data; if (data == null) { return RestPose.None; } return (RestPose)data.GetInt("zvc_pose", 0); } } internal bool RestingTonight { get { if (Data != null) { return Data.GetLong("zvc_night", 0L) != 0; } return false; } } internal bool AwaitingBed { get { if (WorldRules.Beds) { return noBedFor != Data.GetString("zvc_fall", ""); } return false; } } internal int FedSlots { get { ZDO data = Data; if (data == null) { return 0; } return data.GetInt("zvc_meals", 0); } } internal int WantedMeals { get { if (Patron == 0L) { return WildAppetite(FedSlots); } return PlayerMeals.For(Patron); } } internal CompanionMeters OverheadMeters { get; set; } internal bool ShowCarryMark { get { if (!Spirit && !PendingDeath) { return ((Character)this).IsEncumbered(); } return false; } } internal bool VisibleCarryMark { get { if (Plugin.OverloadAlerts.Value) { return ShowCarryMark; } return false; } } internal float CarriedWeight => base.m_inventory.GetTotalWeight() + BoundKit.GetTotalWeight(); internal float CarryLimit { get { float maxCarryWeight = Prefabs.PlayerTemplate.m_maxCarryWeight; ((Character)this).m_seman.ModifyMaxCarryWeight(maxCarryWeight, ref maxCarryWeight); return maxCarryWeight * Game.m_carryWeightRate; } } internal bool HasMagic { get { ZDO data = Data; if (data == null) { return false; } return data.GetBool("zsf_hasMagic", false); } } internal float StaminaFraction { get { float num; if (!Mine || !resourcesLoaded) { ZDO data = Data; num = ((data != null) ? data.GetFloat("zsf_stamina", 100f) : 100f); } else { num = stamina; } return num / ((Character)this).GetMaxStamina(); } } internal bool Learns { get { ZDO data = Data; if (data == null) { return false; } return data.GetBool("zsf_learn", true); } } internal FormationRole Formation { get { ZDO data = Data; return (FormationRole)Mathf.Clamp((data != null) ? data.GetInt("zvc_formationRole", 0) : 0, 0, 2); } } internal GroundPickupMode PickupMode { get { ZDO data = Data; return ((data != null) ? new int?(data.GetInt("zvc_resourcePickupMode", 0)) : ((int?)null)) switch { 1 => GroundPickupMode.Enabled, 2 => GroundPickupMode.Disabled, _ => GroundPickupMode.PlayerDefault, }; } } internal bool PickupEnabled { get { bool flag = WorldRules.AllowPickup && Patron != 0; if (flag) { flag = PickupMode switch { GroundPickupMode.Enabled => true, GroundPickupMode.PlayerDefault => GroundPickupSettings.For(Patron), _ => false, }; } return flag; } } internal Vector3 GuardPost => Data.GetVec3("zsf_post", ((Component)this).transform.position); internal int StopCount { get { ZDO data = Data; return Mathf.Clamp((data != null) ? data.GetInt("zsf_stops", 0) : 0, 0, 3); } } internal bool RouteActive { get { if (!Following && Patron != 0L && Data.GetBool("zsf_patrolActive", false)) { return StopCount >= 2; } return false; } } internal bool HoldingPatronKick { get { if (Object.op_Implicit((Object)(object)kickTarget) && Time.time < kickEnds && !((Character)this).IsDead() && !Spirit && !PendingDeath) { return true; } kickTarget = null; return false; } } internal Biome Origin { get { ZDO data = Data; if (data != null) { return (Biome)data.GetInt("zvc_birthBiome", 0); } return (Biome)0; } } internal int HirePrice => RecruitmentPrices.For(Origin); private string Offer { get { ZDO data = Data; return ((data != null) ? data.GetString("zvc_offer43", "") : null) ?? ""; } } internal RecruitmentDelivery CurrentDelivery => RecruitmentDeliveries.Resolve(Origin, Offer, Data.GetInt("zvc_questQty43", 0)); private bool AvailableWild { get { if (Data != null && Patron == 0L && !Spirit && !PendingDeath) { return !Data.GetBool("zsf_hiredOnce", false); } return false; } } internal bool QuestWaiting { get { if (CampRules.Quests && AvailableWild) { return Offer == "search"; } return false; } } internal bool GuardianCommission => Offer == "hunt"; internal bool HasCommission { get { if (CampRules.Quests && AvailableWild && Offer != "" && Offer != "coins") { return Offer != "search"; } return false; } } private static long QuestNow => ZNet.instance.GetTime().Ticks; private bool HasClaim { get { if (Data.GetLong("zvc_questPlayer43", 0L) != 0L) { return Data.GetLong("zvc_questUntil43", 0L) > QuestNow; } return false; } } internal bool HauntsGrave => Data.GetBool("zvc_hauntsGrave50", false); internal bool OfferActive => Data.GetLong("zvc_shrineOffer50", 0L) > ZNet.instance.GetTime().Ticks; internal int RevivalCost => RecallPrices.For(Origin); internal bool HasBurial { get { //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) if (!Data.GetBool("zvc_graveGone50", false)) { if (!(Data.GetZDOID("zvc_lastGrave50") != ZDOID.None)) { return Data.GetString("zsf_graveWritten", "").Length != 0; } return true; } return false; } } private static long SocialNow => ZNet.instance.GetTime().Ticks / 10000000; internal bool CanSing { get { if (Patron != 0L && !Spirit && !PendingDeath && !((Character)this).IsDead() && Pose != RestPose.Bed && Pose != RestPose.CampBed && !Withdrawing && !((Character)this).InAttack() && !((Character)this).InDodge() && !Object.op_Implicit((Object)(object)((BaseAI)Brain).GetTargetCreature())) { return !Data.GetBool(ZDOVars.s_haveTargetHash, false); } return false; } } internal bool Singing { get { if (chantEnd > 0 && Object.op_Implicit((Object)(object)ZNet.instance)) { return ZNet.instance.GetTime().Ticks < chantEnd; } return false; } } internal string Execute(Player player, Order order, ItemData food = null) { //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (!CanTalk(player) || !Mine || !Prepare() || !WorldRules.Ready) { return Plugin.Text("Interaction indisponible.", "Interaction unavailable."); } long playerID = player.GetPlayerID(); if (Spirit) { if (playerID == 0L || AwaitingBed) { return Plugin.Text("Interaction indisponible.", "Interaction unavailable."); } switch (order) { case Order.HauntGrave: case Order.ReturnToStones: if (Patron != playerID) { return Plugin.Text("Interaction indisponible.", "Interaction unavailable."); } SpiritShrine.ChangeHaunt(player, this, order == Order.HauntGrave); return ""; default: return Plugin.Text("Interaction indisponible.", "Interaction unavailable."); case Order.Recall: if (Patron != playerID) { return SpiritShrine.OfferHere(this, player); } return ReviveFor(player); } } if (playerID == 0L || !MayInteract(player)) { return Plugin.Text("Ce compagnon a déjà un allié.", "This companion already has an ally."); } if (Patron == 0L) { if ((order != Order.Recruit && order != Order.AcceptQuest && order != Order.ChangeQuest && order != Order.AlternativeDelivery) || HostileTo(player)) { return Plugin.Text("Recrutement indisponible.", "Recruitment unavailable."); } if (!Recruitment.CanHire(Origin)) { return Recruitment.LockedText(Origin); } EnsureCommission(); if (HasCommission) { string text = PerformCommission(player, order); if (text != null) { return text; } } else { if (order != Order.Recruit || QuestWaiting) { return QuestWaitText(); } if (QuestReservedForAnother(player)) { return QuestBusyText(); } if (!Pay(player, HirePrice)) { return TooPoor(); } FinishCommission(); } Bond(player); Speak(Line.Hire, important: true); return string.Format(Plugin.Text("{0} te rejoint.", "{0} joins you."), ((Character)this).GetHoverName()); } switch (order) { case Order.Guard: case Order.Follow: { bool flag = order == Order.Follow; SetOrder(player, flag); Speak(flag ? Line.Follow : Line.Guard, important: true); if (!flag) { return Plugin.Text("Je veille ici.", "I will guard this place."); } return Plugin.Text("Je te suis.", "I will follow."); } case Order.Heal: if (((Character)this).GetHealth() >= ((Character)this).GetMaxHealth() - 0.01f) { return Plugin.Text("Déjà en pleine santé.", "Already at full health."); } if (HeartsActive) { return Plugin.Text("Le soin est encore actif.", "Healing is still active."); } if (food == null || !((Humanoid)player).GetInventory().ContainsItem(food) || !Gear.Food(food)) { return Plugin.Text("Choisis une nourriture.", "Choose some food."); } if (!((Humanoid)player).GetInventory().RemoveItem(food, 1)) { return Plugin.Text("Nourriture indisponible.", "Food unavailable."); } ((Character)this).Heal(Mathf.Max(15f, food.m_shared.m_food + food.m_shared.m_foodRegen * 3f), true); Data.Set("zvc_healingFood", Object.op_Implicit((Object)(object)food.m_dropPrefab) ? StringExtensionMethods.GetStableHashCode(((Object)food.m_dropPrefab).name) : 0); Data.Set("zsf_hearts", ZNet.instance.GetTime().AddSeconds(15.0).Ticks); Speak(Line.Thanks, important: true); return string.Format(Plugin.Text("{0} vous remercie !", "{0} thanks you!"), ((Character)this).GetHoverName()); case Order.Free: case Order.FreeKeep: if (Patron != playerID) { return Plugin.Text("Seul son propriétaire peut lui rendre la liberté.", "Only the owner can release this companion."); } if (((Character)this).InAttack()) { return Plugin.Text("Attends la fin de l'attaque.", "Wait for the attack to finish."); } if (order == Order.Free && !ReturnBelongings(player)) { RestoreBaseEquipment(); return Plugin.Text("Récupère les objets restants dans son inventaire.", "Collect the remaining items from the inventory."); } if (order == Order.Free) { ClearWeaponChoices(); } RestoreBaseEquipment(); SetOrder(player, follow: false); CompanionBeds.ReleaseFor(player, SoulId); ClearMeals(); Data.Set("zvc_recruitSupplies", ""); ((BaseAI)Brain).ResetPatrolPoint(); Data.Set("zvc_resourcePickupMode", 0); Data.Set("zsf_owner", 0L); PublishGooOutfit(); ((Character)this).SetTamed(false); SavePack(); Speak(Line.Free, important: true); return string.Format(Plugin.Text("{0} reprend sa route.", "{0} sets off on their own."), ((Character)this).GetHoverName()); default: return ""; } } internal void Bond(Player player) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) bool num = Patron == 0; Data.Set("zsf_owner", player.GetPlayerID()); Data.Set("zsf_lastPatron", player.GetPlayerID()); Data.Set("zsf_provoker", 0L); if (!Data.GetBool("zsf_hiredOnce", false) && !Data.GetBool("zvc_returnedKit43", false) && BoundKit.NrOfItems() > 0) { OutfitAtHire(player); } Data.Set("zsf_hiredOnce", true); if (num) { IssueProvisions(RegionalKit.Saved(this) ?? RegionalKit.Legacy(Origin)); } ((MonsterAI)Brain).MakeTame(); Brain.RestoreDisposition(this); SetOrder(player, follow: true); PublishGooOutfit(); SavePack(); if (num) { SettlementPopulation.Hired(Data); } } internal static bool CanPay(Player p, int amount) { if (amount == 0) { return true; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Coins"); if (!Object.op_Implicit((Object)(object)itemPrefab) || amount < 0) { return false; } return ((Humanoid)p).GetInventory().CountItems(itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name, -1, false) >= amount; } private static bool Pay(Player p, int amount) { if (!CanPay(p, amount)) { return false; } if (amount > 0) { ((Humanoid)p).GetInventory().RemoveItem(ObjectDB.instance.GetItemPrefab("Coins").GetComponent<ItemDrop>().m_itemData.m_shared.m_name, amount, -1, false); } return true; } private static string TooPoor() { return Plugin.Text("Tu n'as pas assez de piastres.", "You need more coins."); } private static bool CanFit(Inventory inv, ItemData item, int amount) { int max = item.m_shared.m_maxStackSize; int num = (inv.GetWidth() * inv.GetHeight() - inv.NrOfItems()) * max; if (max > 1) { num += (from i in inv.GetAllItems() where i.m_shared.m_name == item.m_shared.m_name && i.m_quality == item.m_quality && i.m_worldLevel == item.m_worldLevel select i).Sum((ItemData i) => Math.Max(0, max - i.m_stack)); } return num >= amount; } private bool ReturnBelongings(Player player) { Inventory inventory = ((Humanoid)player).GetInventory(); ItemData[] array = (from i in base.m_inventory.GetAllItems() orderby i.m_shared.m_questItem descending select i).ToArray(); foreach (ItemData val in array) { if (!Gear.Bound(val)) { bool flag = CanFit(inventory, val, val.m_stack); if (!flag && val.m_shared.m_questItem) { return false; } ((Humanoid)this).UnequipItem(val, false); RestoreWeaponSettings(val); if (flag) { inventory.MoveItemToThis(base.m_inventory, val); } else { ((Humanoid)this).DropItem(base.m_inventory, val, val.m_stack); } if (base.m_inventory.ContainsItem(val)) { PrepareWeapon(val); return false; } } } return true; } internal string Transfer(Player p, ItemData item, bool give) { return Transfer(p, item, give, item?.m_stack ?? 0); } internal string Transfer(Player p, ItemData item, bool give, int amount) { return Transfer(p, item, give, amount, -1); } internal string Transfer(Player p, ItemData item, bool give, int amount, int preferredSlot) { //IL_018f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)p) || !CanTalk(p) || Spirit || Patron == 0L || !Mine || !Prepare() || !MayInteract(p)) { return Plugin.Text("Échange indisponible.", "Cannot trade right now."); } Inventory val = (give ? ((Humanoid)p).GetInventory() : base.m_inventory); Inventory val2 = (give ? base.m_inventory : ((Humanoid)p).GetInventory()); if (item == null || !val.ContainsItem(item) || IsPersonalItem(item)) { return Plugin.Text("Équipement personnel du compagnon.", "This equipment belongs to the companion."); } if (amount < 1 || amount > item.m_stack) { return Plugin.Text("Échange indisponible.", "Cannot trade right now."); } if (!give && !CanFit(val2, item, amount)) { return Plugin.Text("Inventaire plein.", "Inventory full."); } ItemData received = item; if (give) { if (preferredSlot >= 0 && !CompanionSlots.Accepts(preferredSlot, item)) { return Plugin.Text("Cet objet ne va pas dans cet emplacement.", "This item does not fit this slot."); } if (Gear.ReadyFood(item)) { if (!DepositFood(val, item, amount, preferredSlot, out received)) { return Plugin.Text("Inventaire plein.", "Inventory full."); } } else if (item.m_shared.m_maxStackSize == 1) { Vector2i? val3 = CompanionSlots.FreeSlots(base.m_inventory, item, preferredSlot).Cast<Vector2i?>().FirstOrDefault(); if (!val3.HasValue) { return Plugin.Text("Inventaire plein.", "Inventory full."); } ((Humanoid)p).UnequipItem(item, false); if (!val.RemoveItem(item)) { return Plugin.Text("Échange indisponible.", "Cannot trade right now."); } if (!base.m_inventory.AddItem(item, val3.Value)) { val.AddItem(item); return Plugin.Text("Inventaire plein.", "Inventory full."); } } else if (!PlaceStack(val, item, amount, out received, preferredSlot)) { return Plugin.Text("Inventaire plein.", "Inventory full."); } } else if (amount == item.m_stack) { ((Humanoid)this).UnequipItem(item, false); RestoreWeaponSettings(item); val2.MoveItemToThis(val, item); if (val.ContainsItem(item)) { PrepareWeapon(item); return Plugin.Text("Échange indisponible.", "Cannot trade right now."); } } else { received = item.Clone(); received.m_stack = amount; received.m_equipped = false; RestoreWeaponSettings(received); bool num = val2.AddItem(received); int num2 = (num ? amount : (amount - received.m_stack)); if (num2 > 0) { val.RemoveItem(item, num2); } if (!num) { return Plugin.Text("Inventaire plein.", "Inventory full."); } } if (give && Gear.Wearable(received) && base.m_inventory.ContainsItem(received)) { ChooseItem(received); } RestoreBaseEquipment(); RefreshAccessories(); SavePack(); return ""; } internal static string StoredName(ZDO data) { string text = ((data != null) ? data.GetString("zsf_called", "") : null); object obj; if (text == null || text.Length == 0) { obj = ((data != null) ? data.GetString("zsf_name", "Viking") : null); if (obj == null) { return "Viking"; } } else { obj = text; } return (string)obj; } internal static int BodyModel(ZDO data) { if (!data.GetBool("zsf_styled", false)) { return data.GetInt("zsf_seed", 0) & 1; } return data.GetInt("zsf_body", 0); } internal bool MayPersonalize(Player player) { if (Object.op_Implicit((Object)(object)player) && Patron != 0L && MayInteract(player) && !Spirit) { return HoldDialogue(player); } return false; } internal bool Rename(Player player, string input, bool restore = false) { if (!MayPersonalize(player)) { return false; } string name = ""; if (!restore && !CompanionRules.TryName(input, out name)) { return false; } Data.Set("zsf_namedBy", player.GetPlayerID()); Data.Set("zsf_called", name); return true; } internal Appearance CurrentAppearance() { //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_0093: 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) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!Data.GetBool("zsf_styled", false)) { return Appearance.FromSeed(Data.GetInt("zsf_seed", 0)); } return new Appearance { Model = BodyModel(Data), Hair = Data.GetString("zsf_hair", ""), Beard = Data.GetString("zsf_beard", ""), Skin = Data.GetVec3("zsf_skin", Vector3.one), Tint = Data.GetVec3("zsf_tint", Vector3.one) }; } private void ApplyAppearance() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) Appearance appearance = CurrentAppearance(); base.m_visEquipment.SetModel(appearance.Model); base.m_hairItem = appearance.Hair; base.m_beardItem = appearance.Beard; base.m_visEquipment.SetHairItem((!string.IsNullOrEmpty(appearance.Hair)) ? StringExtensionMethods.GetStableHashCode(appearance.Hair) : 0); base.m_visEquipment.SetBeardItem((!string.IsNullOrEmpty(appearance.Beard)) ? StringExtensionMethods.GetStableHashCode(appearance.Beard) : 0); base.m_visEquipment.SetSkinColor(appearance.Skin); base.m_visEquipment.SetHairColor(appearance.Tint); } internal bool Restyle(Player player, Barber station, Appearance look) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (!BarberShop.Eligible(station, player, this) || !MayPersonalize(player) || look.Model < 0 || look.Model >= base.m_visEquipment.m_models.Length || !Appearance.ValidColor(look.Skin) || !Appearance.ValidColor(look.Tint) || !BarberShop.Allows(look.Hair, look.Beard)) { return false; } Data.Set("zsf_body", look.Model); Data.Set("zsf_hair", look.Hair); Data.Set("zsf_beard", look.Beard); Data.Set("zsf_skin", look.Skin); Data.Set("zsf_tint", look.Tint); Data.Set("zsf_styled", true); ApplyAppearance(); return true; } internal static bool OrdinaryAmmo(string name) { if (!(name == "ArrowWood") && !(name == "ArrowFlint")) { return name == "BoltBone"; } return true; } internal static int AmmoPriority(bool conserve, bool reserved, bool elite) { if (conserve && reserved) { if (!elite) { return -1; } return 1; } return 0; } internal bool Reserved(ItemData ammo) { return !Data.GetBool("zsf_common_" + ((Object)ammo.m_dropPrefab).name, Gear.Bound(ammo) || OrdinaryAmmo(((Object)ammo.m_dropPrefab).name)); } internal void ToggleAmmo(Player p, ItemData ammo) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (MayPersonalize(p) && base.m_inventory.ContainsItem(ammo) && (int)ammo.m_shared.m_itemType == 9) { Data.Set("zsf_common_" + ((Object)ammo.m_dropPrefab).name, Reserved(ammo)); nextEquipmentCheck = (nextSightCheck = 0f); } } internal ItemData AllowedAmmo(ItemData weapon, Character enemy) { //IL_0066: 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_0060: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Invalid comparison between Unknown and I4 //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_012b: 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) //IL_011c: Unknown result type (might be due to invalid IL or missing references) ItemData val = null; int num = -1; bool elite = Object.op_Implicit((Object)(object)enemy) && (enemy.IsBoss() || enemy.GetLevel() > 1); bool flag = Patron != 0L && Data.GetBool("zsf_saveAmmo", true); bool flag2 = Patron != 0L && FieldGuide.Known(enemy); DamageModifiers modifiers = (DamageModifiers)(flag2 ? enemy.GetDamageModifiers((WeakSpot)null) : default(DamageModifiers)); float num2 = -1f; foreach (ItemData allItem in base.m_inventory.GetAllItems()) { if (allItem.m_stack <= 0 || allItem.m_shared.m_ammoType != weapon.m_shared.m_ammoType || ((int)allItem.m_shared.m_itemType != 9 && (int)allItem.m_shared.m_itemType != 23) || !Object.op_Implicit((Object)(object)allItem.m_dropPrefab)) { continue; } int num3 = AmmoPriority(flag, flag && Reserved(allItem), elite); if (num3 >= 0 && num3 >= num) { float num4; if (!flag2) { DamageTypes damage = allItem.GetDamage(); num4 = ((DamageTypes)(ref damage)).GetTotalDamage(); } else { num4 = ExpectedDamage(weapon, allItem, modifiers); } float num5 = num4; if ((!flag2 || !(num5 <= 0f)) && (val == null || num3 > num || num5 > num2)) { val = allItem; num = num3; num2 = num5; } } } return val; } internal bool CanShootAt(Character enemy) { foreach (ItemData allItem in base.m_inventory.GetAllItems()) { if (CombatTactics.Role(allItem) == WeaponRole.Archery && Usable(allItem, enemy)) { return true; } } foreach (ItemData allItem2 in BoundKit.GetAllItems()) { if (CombatTactics.Role(allItem2) == WeaponRole.Archery && Usable(allItem2, enemy)) { return true; } } return false; } private bool LoadPermittedAmmo(ItemData weapon, Character target) { if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType)) { return true; } ItemData val = AllowedAmmo(weapon, target); if (val != null) { if (((Humanoid)this).GetAmmoItem() != val) { return ((Humanoid)this).EquipItem(val, false); } return true; } return false; } internal void CancelCombat() { if (preparing != null) { StopPreparing(); } if (base.m_currentAttack != null && !base.m_currentAttack.IsDone()) { base.m_currentAttack.Stop(); } base.m_currentAttack = null; shotTarget = null; } public override void OnAttackTrigger() { if (Spirit || PendingDeath || Object.op_Implicit((Object)(object)Dialogue.ConversationPartner(this)) || PatronKickContact()) { return; } ItemData currentWeapon = ((Humanoid)this).GetCurrentWeapon(); if (Mine && CombatTactics.Role(currentWeapon) == WeaponRole.Archery && base.m_currentAttack != null && (!Object.op_Implicit((Object)(object)shotTarget) || (Object)(object)shotTarget != (Object)(object)((BaseAI)Brain).GetTargetCreature() || shotTarget.IsDead() || !Brain.AllowsTarget(shotTarget) || !((BaseAI)Brain).CanSeeTarget(shotTarget) || Brain.BlockedShot(shotTarget) || !LoadPermittedAmmo(currentWeapon, shotTarget))) { CancelCombat(); return; } ((Humanoid)this).OnAttackTrigger(); if (Mine && UsesAmmunition(currentWeapon)) { RefreshSupplyAlerts(); } if (Mine && CombatTactics.Role(currentWeapon) == WeaponRole.Archery && Object.op_Implicit((Object)(object)Brain)) { Brain.EndFiringStep(); } } private void StopPreparing() { Attack val = preparing?.m_shared.m_attack; if (val != null) { string text = (val.m_requiresReload ? val.m_reloadAnimation : val.m_drawAnimationState); if (!string.IsNullOrEmpty(text)) { ((Character)this).m_zanim.SetBool(text, false); } } preparing = null; base.m_attackDrawTime = (reloadProgress = 0f); } public override void ResetLoadedWeapon() { StopPreparing(); loadedCrossbow = null; if (Mine && Data != null && Data.GetBool(ZDOVars.s_weaponLoaded, false)) { Data.Set(ZDOVars.s_weaponLoaded, false); } } public override bool IsWeaponLoaded() { if (!Mine) { ZDO data = Data; if (data == null) { return false; } return data.GetBool(ZDOVars.s_weaponLoaded, false); } if (loadedCrossbow != null) { return loadedCrossbow == ((Humanoid)this).GetCurrentWeapon(); } return false; } private void UpdateReadiness(float dt) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) ItemData currentWeapon = ((Humanoid)this).GetCurrentWeapon(); if (preparing != null && preparing != currentWeapon) { StopPreparing(); } if (CombatTactics.Role(currentWeapon) != WeaponRole.Archery || loadedCrossbow == currentWeapon) { return; } Attack attack = currentWeapon.m_shared.m_attack; if (!attack.m_bowDraw && !attack.m_requiresReload) { return; } Character val = (Object.op_Implicit((Object)(object)Dialogue.ConversationPartner(this)) ? null : ((BaseAI)Brain).GetTargetCreature()); if (!Object.op_Implicit((Object)(object)val) || val.IsDead() || !Brain.AllowsTarget(val) || Withdrawing || ((Character)this).InAttack() || ((Character)this).IsStaggering() || ((Character)this).IsKnockedBack() || (base.m_currentAttack != null && !base.m_currentAttack.IsDone())) { if (preparing != null) { StopPreparing(); } return; } if ((Object)(object)sightTarget != (Object)(object)val || sightWeapon != currentWeapon || Time.time >= nextSightCheck) { sightTarget = val; sightWeapon = currentWeapon; nextSightCheck = Time.time + 0.15f; float num = currentWeapon.m_shared.m_aiAttackRange + val.GetRadius() + 3f; Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; inSight = ((Vector3)(ref val2)).sqrMagnitude <= num * num && CombatTactics.InRepair(currentWeapon) && CombatTactics.Supplied(base.m_inventory, currentWeapon) && ((BaseAI)Brain).CanSeeTarget(val); } if (!inSight) { if (preparing != null) { StopPreparing(); } return; } if (preparing == null) { if (!LoadPermittedAmmo(currentWeapon, val) || !attack.StartDraw((Humanoid)(object)this, currentWeapon)) { return; } preparing = currentWeapon; string text = (attack.m_requiresReload ? attack.m_reloadAnimation : attack.m_drawAnimationState); if (!string.IsNullOrEmpty(text)) { ((Character)this).m_zanim.SetBool(text, true); } } if (attack.m_requiresReload) { reloadProgress += dt; if (!(reloadProgress < CombatTactics.ReloadSeconds(attack.m_reloadTime, ((Character)this).GetSkillFactor(currentWeapon.m_shared.m_skillType)))) { StopPreparing(); loadedCrossbow = currentWeapon; Data.Set(ZDOVars.s_weaponLoaded, true); if (!string.IsNullOrEmpty(attack.m_reloadAnimation)) { ((Character)this).m_zanim.SetTrigger(attack.m_reloadAnimation + "_done"); } } } else if (base.m_attackDrawTime == 0f || ((Humanoid)this).GetAttackDrawPercentage() < 1f) { base.m_attackDrawTime += dt; if (!string.IsNullOrEmpty(attack.m_drawAnimationState)) { ((Character)this).m_zanim.SetFloat("drawpercent", ((Humanoid)this).GetAttackDrawPercentage()); } } } public override bool StartAttack(Character target, bool secondaryAttack) { //IL_012b: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (Spirit || PendingDeath || Object.op_Implicit((Object)(object)Dialogue.ConversationPartner(this)) || Withdrawing || (Object.op_Implicit((Object)(object)Brain) && (Brain.Sneaking || Brain.Evading || Brain.CalledBack || (Object.op_Implicit((Object)(object)target) && !Brain.AllowsTarget(target))))) { return false; } if (Mine && Object.op_Implicit((Object)(object)target)) { ReadyForDanger(); } if (Object.op_Implicit((Object)(object)target) && Time.time < rallyUntil - 0.62f && (rallyPose == BattlePose.LiftLeft || rallyPose == BattlePose.LiftRight) && (Object)(object)target == (Object)(object)rallyTarget && ((Humanoid)this).GetCurrentWeapon() == rallyWeapon) { Vector3 val = ((Component)target).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 25f) { return false; } } ItemData currentWeapon = ((Humanoid)this).GetCurrentWeapon(); if (HoldingPatronKick || (IsTorch(currentWeapon) && (!Object.op_Implicit((Object)(object)target) || (Object)(object)target != (Object)(object)torchOpponent || !WeakToFire(target.GetDamageModifiers((WeakSpot)null))))) { return false; } if (Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)Brain) && Brain.ReserveDefence(target, currentWeapon, secondaryAttack)) { return false; } bool flag = CombatTactics.Role(currentWeapon) == WeaponRole.Archery; if (flag && (!Object.op_Implicit((Object)(object)target) || Brain.BlockedShot(target) || !LoadPermittedAmmo(currentWeapon, target))) { return false; } bool flag2 = !secondaryAttack && CombatTactics.Role(currentWeapon) == WeaponRole.Archery && currentWeapon.m_shared.m_attack.m_bowDraw; if (flag2 && (preparing != currentWeapon || ((Humanoid)this).GetAttackDrawPercentage() < 1f)) { return false; } bool num = ((Humanoid)this).StartAttack(target, secondaryAttack); if (num) { shotTarget = (flag ? target : null); } if (num && flag2) { StopPreparing(); } return num; } public override Vector3 GetAimDir(Vector3 origin) { //IL_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Character val = (Object.op_Implicit((Object)(object)Brain) ? ((BaseAI)Brain).GetTargetCreature() : null); if (!Object.op_Implicit((Object)(object)val)) { return ((Humanoid)this).GetAimDir(origin); } Vector3 val2 = val.GetCenterPoint() - origin; return ((Vector3)(ref val2)).normalized; } private static bool UsesAmmunition(ItemData item) { if (item?.m_shared != null && !string.IsNullOrEmpty(item.m_shared.m_ammoType)) { return CombatTactics.Role(item) == WeaponRole.Archery; } return false; } private bool ShortOnAmmunition() { List<ItemData> cargo = base.m_inventory.GetAllItems(); ItemData currentWeapon = ((Humanoid)this).GetCurrentWeapon(); if (UsesAmmunition(currentWeapon)) { return !Stocked(currentWeapon); } bool hasLauncher = false; return !HasSuppliedWeapon(cargo) && !HasSuppliedWeapon(BoundKit.GetAllItems()) && hasLauncher; bool HasSuppliedWeapon(List<ItemData> items) { foreach (ItemData item in items) { if (UsesAmmunition(item)) { hasLauncher = true; if (Stocked(item)) { return true; } } } return false; } bool Stocked(ItemData weapon) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 int num = 0; foreach (ItemData item2 in cargo) { ItemType itemType = item2.m_shared.m_itemType; if (((int)itemType == 9 || (int)itemType == 23) && item2.m_shared.m_ammoType == weapon.m_shared.m_ammoType) { num += item2.m_stack; } if (num >= 10) { return true; } } return false; } } private void RefreshSupplyAlerts() { ZDO data = Data; if (!Mine || data == null) { return; } int num; int num2; if (Patron != 0L && !Spirit) { num = ((!PendingDeath) ? 1 : 0); if (num != 0) { num2 = (ShortOnAmmunition() ? 1 : 0); goto IL_003b; } } else { num = 0; } num2 = 0; goto IL_003b; IL_003b: bool flag = (byte)num2 != 0; bool flag2 = num != 0 && !base.m_inventory.GetAllItems().Exists(Gear.ReadyFood); if (data.GetBool(LowAmmoKey, false) != flag) { data.Set(LowAmmoKey, flag); } if (data.GetBool(NoFoodKey, false) != flag2) { data.Set(NoFoodKey, flag2); } } internal void NoticeNewOpponent(Character enemy) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) if ((Object)(object)enemy == (Object)(object)noticedTarget) { return; } noticedTarget = enemy; if (!Object.op_Implicit((Object)(object)enemy) || WorldRules.WarChance <= 0f || (triedRally && Time.time - lastFighting <= 8f) || enemy.IsDead() || !Brain.AllowsTarget(enemy)) { return; } if (!enemy.IsBoss() && enemy.GetLevel() <= 1) { bool flag = false; foreach (Character allCharacter in Character.GetAllCharacters()) { if (Object.op_Implicit((Object)(object)allCharacter) && (Object)(object)allCharacter != (Object)(object)this && (Object)(object)allCharacter != (Object)(object)enemy && Object.op_Implicit((Object)(object)allCharacter.GetBaseAI()) && !allCharacter.IsDead() && !allCharacter.IsTamed()) { Vector3 val = ((Component)allCharacter).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude < 400f && ((BaseAI)Brain).IsEnemy(allCharacter)) { flag = true; break; } } } if (!flag) { return; } } if (((BaseAI)Brain).CanSeeTarget(enemy)) { UpdateVoice(); } } private void CheckConditions() { int num = (((Character)this).m_seman.HaveStatusEffect(SEMan.s_statusEffectBurning) ? 1 : 0) | (((Character)this).m_seman.HaveStatusEffect(SEMan.s_statusEffectPoison) ? 2 : 0); int num2 = Data.GetInt(ConditionsKey, 0); if (num == num2) { return; } Data.Set(ConditionsKey, num, false); int num3 = num & ~num2; long now; if (num3 != 0) { StopSocialGesture(); EndSong(); now = ZNet.instance.GetTime().Ticks; int num4 = 0; if ((num3 & 1) != 0 && Due(FireSaid)) { Data.Set(FireSaid, now); num4 |= 1; } if ((num3 & 2) != 0 && Due(PoisonSaid)) { Data.Set(PoisonSaid, now); num4 |= 2; } if (num4 != 0) { ((Character)this).m_nview.InvokeRPC(ZNetView.Everybody, "ZVC_Exposure25", new object[1] { num4 }); } } bool Due(int key) { return now - Data.GetLong(key, 0L) >= 120000000; } } private void HearCondition(long sender, int mask) { //IL_004b: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (VoiceAuthority(sender) && mask >= 1 && mask <= 3 && Plugin.Subtitles.Value && Object.op_Implicit((Object)(object)Chat.instance) && Object.op_Implicit((Object)(object)Hud.instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Vector3 val = ((Component)Player.m_localPlayer).transform.position - ((Component)this).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude > 1024f)) { captionMask = (ShowingCondition ? (captionMask | mask) : mask); captionUntil = Time.unscaledTime + 3.6f; string text = Plugin.Text("Aaah ! Je brûle !", "Aaah! I'm burning!"); string text2 = Plugin.Text("Un nuage toxique !!", "A toxic cloud!!"); string text3 = ((captionMask == 3) ? (text + "\n" + text2) : ((captionMask == 1) ? text : text2)); Chat.instance.SetNpcText(((Component)this).gameObject, ((Character)this).GetHeadPoint() - ((Component)this).transform.position + Vector3.up * 0.43f, 32f, 3.6f, "", text3, false); } } } internal static BattlePose PoseFor(ItemData weapon, bool left) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected I4, but got Unknown if (weapon == null) { return BattlePose.None; } if (MagicWeapon(weapon) || CombatTactics.Role(weapon) == WeaponRole.Archery) { if (!left) { return BattlePose.LiftRight; } return BattlePose.LiftLeft; } if ((int)weapon.m_shared.m_itemType != 3 || CombatTactics.Role(weapon) != WeaponRole.Melee) { return BattlePose.None; } SkillType skillType = weapon.m_shared.m_skillType; switch (skillType - 1) { case 0: case 2: case 4: case 6: return (!left) ? BattlePose.ShoulderRight : BattlePose.ShoulderLeft; default: return BattlePose.None; } } private bool TryBattleCry(Character enemy, int otherAttackers) { //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (time - lastFighting > 8f) { combatOpened = time; triedRally = false; } lastFighting = time; if (WorldRules.WarChance <= 0f || triedRally || time < rallyReadyAt || time - combatOpened > 6f || enemy is Player || enemy.IsTamed() || (!enemy.IsBoss() && enemy.GetLevel() <= 1 && otherAttackers == 0) || Pose != RestPose.None || Committed || Withdrawing || Brain.Evading || ((Character)this).InDodge() || ((Character)this).IsStaggering() || !Brain.AllowsTarget(enemy) || Data.GetInt(ConditionsKey, 0) != 0) { return false; } triedRally = true; long ticks = ZNet.instance.GetTime().Ticks; if (ticks - Data.GetLong(WarRoll, 0L) < 600000000) { return false; } Data.Set(WarRoll, ticks); foreach (Companion item in All) { if (Object.op_Implicit((Object)(object)item) && (Object)(object)item != (Object)(object)this && item.Data != null) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude < 400f && ticks - item.Data.GetLong(WarSaid, 0L) < 80000000) { return false; } } } if (WorldRules.WarChance < 100f && Random.value >= WorldRules.WarChance / 100f) { return false; } Data.Set(WarSaid, ticks); rallyWeapon = ((Humanoid)this).GetCurrentWeapon(); rallyPose = PoseFor(rallyWeapon, rallyWeapon != null && rallyWeapon == base.m_leftItem); rallyTarget = enemy; rallyUntil = time + 1.25f; if (rallyPose != BattlePose.None) { ((Character)this).m_nview.InvokeRPC(ZNetView.Everybody, "ZVC_Salute25", new object[2] { (int)rallyPose, StringExtensionMethods.GetStableHashCode(((Object)rallyWeapon.m_dropPrefab).name) }); } if (enemy.IsBoss()) { int num = Voices.Takes(Line.BossOath); SayTake(Line.BossOath, NextVerse(LastBossOath, num, num), important: true); } else { Speak(Line.Rally, important: true); } criedAt = enemy; lastWarning = time; return true; } internal BattlePose RallyFor(Character enemy) { if (Time.time >= rallyUntil || (Object)(object)enemy != (Object)(object)rallyTarget || !Object.op_Implicit((Object)(object)enemy) || enemy.IsDead() || Withdrawing || Committed || ((Character)this).InDodge() || ((Character)this).IsStaggering() || !((Character)this).IsOnGround() || ((Humanoid)this).GetCurrentWeapon() != rallyWeapon) { return BattlePose.None; } return rallyPose; } private void HearSalute(long sender, int pose, int weapon) { if (VoiceAuthority(sender) && pose >= 1 && pose <= 4 && !Application.isBatchMode && Object.op_Implicit((Object)(object)((Character)this).m_animator) && ((Character)this).m_animator.isHuman) { if (!Object.op_Implicit((Object)(object)salute)) { salute = ((Component)this).gameObject.AddComponent<BattleSalute>(); } salute.StartPose(this, ((Character)this).m_animator, (BattlePose)pose, weapon); } } internal bool IsPersonalItem(ItemData item) { if (item != null) { if (!Gear.Bound(item)) { return BoundKit.ContainsItem(item); } return true; } return false; } internal ItemData BasePiece(ItemType type) { //IL_0007: 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) return BoundKit.GetAllItems().Find((ItemData i) => i.m_shared.m_itemType == type); } internal bool EnsureWolfCape() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Origin != 4 || BasePiece((ItemType)17) != null) { return false; } ItemData val = Gear.NewItem("Cap