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 NotRaces v1.0.0
plugins/NotRaces.dll
Decompiled 15 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("NotTerra")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Valheim mod: choose a bloodline and shapeshift into a Fenring, a Drake, Moder, a Troll or a Lox.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NotRaces")] [assembly: AssemblyTitle("NotRaces")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 NotRaces { internal static class Combat { private static readonly Collider[] s_hits = (Collider[])(object)new Collider[256]; private static readonly HashSet<GameObject> s_done = new HashSet<GameObject>(); private static int s_attackMask; private static int s_groundMask; private static int s_characterMask; internal static int AttackMask { get { if (s_attackMask == 0) { s_attackMask = LayerMask.GetMask(new string[11] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle" }); } return s_attackMask; } } internal static int GroundMask { get { if (s_groundMask == 0) { s_groundMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); } return s_groundMask; } } internal static int CharacterMask { get { if (s_characterMask == 0) { s_characterMask = LayerMask.GetMask(new string[5] { "character", "character_net", "character_ghost", "hitbox", "character_noenv" }); } return s_characterMask; } } internal static float DamageMultiplier(Player p, FormDef form) { float num = Progression.DamageScale(Progression.Bosses()) * Mathf.Max(0.01f, NotRacesPlugin.DamageMultiplier.Value); try { num *= 1f + 0.5f * ((Character)p).GetSkillFactor((SkillType)11); } catch { } if (form.Race == RaceId.Werewolf && NotRacesPlugin.WerewolfMoonBonus.Value) { try { if (EnvMan.IsNight()) { num *= 1.25f; } } catch { } } return num; } private static HitData MakeHit(Player p, AttackDef def, float mult, int toolTier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0064: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown HitData val = new HitData { m_damage = { m_blunt = def.Blunt * mult }, m_damage = { m_slash = def.Slash * mult }, m_damage = { m_pierce = def.Pierce * mult }, m_damage = { m_fire = def.Fire * mult }, m_damage = { m_frost = def.Frost * mult }, m_damage = { m_poison = def.Poison * mult }, m_damage = { m_spirit = def.Spirit * mult }, m_damage = { m_chop = def.Chop * mult }, m_damage = { m_pickaxe = def.Pickaxe * mult }, m_toolTier = (short)toolTier, m_pushForce = def.Push, m_staggerMultiplier = def.Stagger, m_backstabBonus = 2f, m_blockable = true, m_dodgeable = true, m_skill = (SkillType)11, m_skillRaiseAmount = 1f, m_hitType = (HitType)2 }; val.SetAttacker((Character)(object)p); return val; } internal static bool IsValidTarget(Player p, Character target) { if ((Object)(object)target == (Object)null || (Object)(object)target == (Object)(object)p || target.IsDead()) { return false; } if (target.IsPlayer()) { if (((Character)p).IsPVPEnabled()) { return target.IsPVPEnabled(); } return false; } return BaseAI.IsEnemy((Character)(object)p, target); } internal static void Execute(NotRacesPlayer owner, Player p, FormDef form, AttackDef def, int index) { if ((Object)(object)p == (Object)null || form == null || def == null) { return; } float mult = DamageMultiplier(p, form); CreatureAttack ca = Creatures.Get(form.Id)?.GetAttack(index); if (def.Kind == AttackKind.Projectile) { Shoot(p, form, def, ca, mult); return; } float num = AreaHit(p, form, def, ca, mult); if (num > 0f && (Object)(object)owner != (Object)null) { owner.OnHitCreatures(num); } } internal static void Aura(Player p, FormDef form) { //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Invalid comparison between Unknown and I4 //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Invalid comparison between Unknown and I4 //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null || form == null || form.AuraRadius <= 0f) { return; } Vector3 val = ((Component)p).transform.position + Vector3.up; float num = form.AuraDamage * Progression.DamageScale(Progression.Bosses()) * Mathf.Max(0.01f, NotRacesPlugin.DamageMultiplier.Value); int num2 = Physics.OverlapSphereNonAlloc(val, form.AuraRadius, s_hits, CharacterMask, (QueryTriggerInteraction)0); s_done.Clear(); for (int i = 0; i < num2; i++) { Collider val2 = s_hits[i]; s_hits[i] = null; if ((Object)(object)val2 == (Object)null) { continue; } Character componentInParent = ((Component)val2).GetComponentInParent<Character>(); if (!((Object)(object)componentInParent == (Object)null) && !s_done.Contains(((Component)componentInParent).gameObject) && IsValidTarget(p, componentInParent)) { s_done.Add(((Component)componentInParent).gameObject); HitData val3 = new HitData(); if ((int)form.AuraType == 32) { val3.m_damage.m_fire = num; } else if ((int)form.AuraType == 256) { val3.m_damage.m_poison = num; } else if ((int)form.AuraType == 128) { val3.m_damage.m_lightning = num; } else { val3.m_damage.m_frost = num; } val3.m_point = componentInParent.GetCenterPoint(); Vector3 val4 = ((Component)componentInParent).transform.position - ((Component)p).transform.position; val4.y = 0f; val3.m_dir = ((((Vector3)(ref val4)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val4)).normalized : ((Component)p).transform.forward); val3.m_pushForce = 0f; val3.m_staggerMultiplier = 0f; val3.m_blockable = false; val3.m_dodgeable = false; val3.m_ranged = true; val3.m_hitType = (HitType)2; val3.SetAttacker((Character)(object)p); try { componentInParent.Damage(val3); } catch (Exception e) { Util.LogOnce("frost-aura", e); } MorphFx.Pulse(val3.m_point, form.FxColor, form.FxColor2, 0.4f, 10, rising: true); } } } private static float AreaHit(Player p, FormDef form, AttackDef def, CreatureAttack ca, float mult) { //IL_0042: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)p).transform; Vector3 val = ((def.Kind == AttackKind.Melee) ? (transform.position + transform.forward * def.Range + Vector3.up * 1f) : (transform.position + transform.forward * def.Range + Vector3.up * 0.5f)); int toolTier = (def.ToolTier ? Progression.ToolTier(Progression.Bosses()) : 0); int num = Physics.OverlapSphereNonAlloc(val, def.Radius, s_hits, AttackMask, (QueryTriggerInteraction)0); s_done.Clear(); bool flag = false; bool flag2 = false; float num2 = 0f; for (int i = 0; i < num; i++) { Collider val2 = s_hits[i]; s_hits[i] = null; if ((Object)(object)val2 == (Object)null) { continue; } GameObject val3 = Projectile.FindHitObject(val2); if ((Object)(object)val3 == (Object)null || (Object)(object)val3 == (Object)(object)((Component)p).gameObject || s_done.Contains(val3) || val3.transform.IsChildOf(transform)) { continue; } IDestructible component = val3.GetComponent<IDestructible>(); if (component == null) { continue; } Character component2 = val3.GetComponent<Character>(); if ((Object)(object)component2 != (Object)null) { if (!IsValidTarget(p, component2)) { continue; } } else if (!NotRacesPlugin.AttacksHitBuildings.Value && ((Object)(object)val3.GetComponent<WearNTear>() != (Object)null || (Object)(object)val3.GetComponent<Piece>() != (Object)null)) { continue; } s_done.Add(val3); Bounds bounds = val2.bounds; Vector3 val4 = ((Bounds)(ref bounds)).ClosestPoint(val); Vector3 val5 = val4 - transform.position; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = transform.forward; } HitData val6 = MakeHit(p, def, mult, toolTier); val6.m_point = val4; val6.m_dir = ((Vector3)(ref val5)).normalized; val6.m_hitCollider = val2; float num3 = def.Blunt + def.Slash + def.Pierce + def.Fire + def.Frost + def.Poison + def.Spirit; try { component.Damage(val6); flag2 = true; if ((Object)(object)component2 != (Object)null) { flag = true; num2 += num3 * mult; } } catch (Exception e) { Util.LogOnce("damage-" + ((Object)val3).name, e); } if (ca != null) { if (ca.Attack != null) { Fx.Play(ca.Attack.m_hitEffect, val4, Quaternion.identity, null, 1f); } if (ca.Item != null && ca.Item.m_shared != null) { Fx.Play(ca.Item.m_shared.m_hitEffect, val4, Quaternion.identity, null, 1f); } } } if (flag) { try { ((Character)p).RaiseSkill((SkillType)11, 0.4f); } catch (Exception e2) { Util.LogOnce("raiseskill", e2); } } if (def.Kind != AttackKind.Melee || def.Push >= 50f || (flag2 && def.Blunt > 0f)) { try { if ((Object)(object)GameCamera.instance != (Object)null) { GameCamera.instance.AddShake(val, 20f, (def.Kind == AttackKind.Melee) ? 0.5f : 1.2f, false); } } catch { } } return num2; } private static void Shoot(Player p, FormDef form, AttackDef def, CreatureAttack ca, float mult) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)p).transform; float num = ((form.DefScale > 0f) ? (form.Scale / form.DefScale) : 1f); Vector3 val = transform.position + transform.forward * (form.Mouth.x * num) + Vector3.up * (form.Mouth.y * num + form.OffsetY); Vector3 val2; try { val2 = ((Humanoid)p).GetAimDir(val); } catch { val2 = ((Character)p).GetLookDir(); } if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = transform.forward; } ((Vector3)(ref val2)).Normalize(); GameObject val3 = ca?.Projectile; float num2 = def.ProjectileSpeed; if (num2 <= 0f && ca != null && ca.Attack != null) { num2 = ca.Attack.m_projectileVel; } if (num2 <= 0f) { num2 = 25f; } int num3 = Mathf.Max(1, def.Projectiles); Vector3 val4 = Vector3.Cross(Vector3.up, val2); if (((Vector3)(ref val4)).sqrMagnitude < 0.001f) { val4 = transform.right; } ((Vector3)(ref val4)).Normalize(); for (int i = 0; i < num3; i++) { Vector3 val5 = val2; if (def.Spread > 0f) { float num4 = ((num3 > 1) ? (Mathf.Lerp(0f - def.Spread, def.Spread, (float)i / (float)(num3 - 1)) + Random.Range(-2f, 2f)) : Random.Range(0f - def.Spread, def.Spread)); float num5 = Random.Range((0f - def.Spread) * 0.35f, def.Spread * 0.35f); val5 = Quaternion.AngleAxis(num4, Vector3.up) * Quaternion.AngleAxis(num5, val4) * val2; } HitData val6 = MakeHit(p, def, mult, 0); val6.m_ranged = true; val6.m_point = val; val6.m_dir = val5; bool flag = false; if ((Object)(object)val3 != (Object)null) { try { GameObject val7 = Object.Instantiate<GameObject>(val3, val, Quaternion.LookRotation(val5)); IProjectile component = val7.GetComponent<IProjectile>(); if (component != null) { ItemData val8 = ((ca.Item != null) ? ca.Item.Clone() : null); component.Setup((Character)(object)p, val5 * num2, def.Noise, val6, val8, (ItemData)null); flag = true; } else { ZNetView component2 = val7.GetComponent<ZNetView>(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.Destroy(); } else { Object.Destroy((Object)(object)val7); } } } catch (Exception e) { Util.LogOnce("projectile-" + ((Object)val3).name, e); } } if (!flag) { RayHit(p, val, val5, val6, ca); } } } private static void RayHit(Player p, Vector3 origin, Vector3 dir, HitData hit, CreatureAttack ca) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) int num = AttackMask | LayerMask.GetMask(new string[1] { "terrain" }); RaycastHit[] array = Physics.SphereCastAll(origin, 0.4f, dir, 40f, num, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num2 = 0; num2 < array2.Length; num2++) { RaycastHit val = array2[num2]; if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) { continue; } GameObject val2 = Projectile.FindHitObject(((RaycastHit)(ref val)).collider); if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)((Component)p).gameObject || val2.transform.IsChildOf(((Component)p).transform)) { continue; } Vector3 val3; if (!(((RaycastHit)(ref val)).point == Vector3.zero)) { val3 = ((RaycastHit)(ref val)).point; } else { Bounds bounds = ((RaycastHit)(ref val)).collider.bounds; val3 = ((Bounds)(ref bounds)).ClosestPoint(origin); } Vector3 val4 = val3; IDestructible component = val2.GetComponent<IDestructible>(); Character component2 = val2.GetComponent<Character>(); bool flag = component == null; if (component != null) { if ((Object)(object)component2 != (Object)null && !IsValidTarget(p, component2)) { continue; } if ((Object)(object)component2 == (Object)null && !NotRacesPlugin.AttacksHitBuildings.Value && ((Object)(object)val2.GetComponent<WearNTear>() != (Object)null || (Object)(object)val2.GetComponent<Piece>() != (Object)null)) { flag = true; } else { hit.m_point = val4; hit.m_hitCollider = ((RaycastHit)(ref val)).collider; try { component.Damage(hit); } catch (Exception e) { Util.LogOnce("raydamage", e); } } } if (ca != null) { if (ca.Attack != null) { Fx.Play(ca.Attack.m_hitEffect, val4, Quaternion.identity, null, 1f); } if (ca.Item != null && ca.Item.m_shared != null) { Fx.Play(ca.Item.m_shared.m_hitEffect, val4, Quaternion.identity, null, 1f); } } if (flag || component != null) { break; } } } } internal class CreatureAttack { public string ItemName; public ItemData Item; public Attack Attack; public bool IsProjectile; public GameObject Projectile { get { if (!IsProjectile || Attack == null) { return null; } return Attack.m_attackProjectile; } } public string PickAnimation() { if (Attack == null || string.IsNullOrEmpty(Attack.m_attackAnimation)) { return null; } string attackAnimation = Attack.m_attackAnimation; if (Attack.m_attackChainLevels > 1) { return attackAnimation + "0"; } if (Attack.m_attackRandomAnimations >= 2) { return attackAnimation + Random.Range(0, Attack.m_attackRandomAnimations); } return attackAnimation; } } internal class CreatureInfo { public GameObject Prefab; public GameObject Visual; public readonly List<CreatureAttack> Attacks = new List<CreatureAttack>(); public CreatureAttack Primary; public CreatureAttack Secondary; public EffectList Alert; public EffectList Idle; public float IdleInterval = 10f; public float IdleChance = 0.5f; public EffectList Hit; public EffectList Jump; public EffectList FlyLoop; public readonly List<StepEffect> Steps = new List<StepEffect>(); public readonly List<string> Feet = new List<string>(); public bool Footless; public float FootlessDistance = 1.5f; public bool HasStepEvents; public CreatureAttack GetAttack(int index) { if (index != 0) { return Secondary; } return Primary; } } internal static class Creatures { private static readonly Dictionary<FormId, CreatureInfo> s_cache = new Dictionary<FormId, CreatureInfo>(); private static readonly HashSet<AnimationClip> s_preparedClips = new HashSet<AnimationClip>(); internal static CreatureInfo Get(FormId id) { if (s_cache.TryGetValue(id, out var value) && value != null && (Object)(object)value.Prefab != (Object)null) { return value; } FormDef formDef = Forms.Get(id); ZNetScene instance = ZNetScene.instance; if (formDef == null || (Object)(object)instance == (Object)null) { return null; } GameObject val = null; try { val = instance.GetPrefab(formDef.Prefab); } catch (Exception e) { Util.LogOnce("getprefab-" + formDef.Prefab, e); } if ((Object)(object)val == (Object)null) { Util.WarnOnce("noprefab-" + formDef.Prefab, "Creature prefab '" + formDef.Prefab + "' for the " + formDef.Name + " form was not found - the form works, but without its model."); return null; } CreatureInfo creatureInfo; try { creatureInfo = Build(val, formDef); } catch (Exception e2) { Util.LogOnce("build-" + formDef.Prefab, e2); creatureInfo = new CreatureInfo { Prefab = val }; } s_cache[id] = creatureInfo; return creatureInfo; } private static CreatureInfo Build(GameObject prefab, FormDef form) { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Invalid comparison between Unknown and I4 //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Invalid comparison between Unknown and I4 CreatureInfo creatureInfo = new CreatureInfo { Prefab = prefab }; Transform val = prefab.transform.Find("Visual"); if ((Object)(object)val == (Object)null) { Animator componentInChildren = prefab.GetComponentInChildren<Animator>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Component)componentInChildren).gameObject != (Object)(object)prefab) { val = ((Component)componentInChildren).transform; } } creatureInfo.Visual = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null); List<GameObject> list = new List<GameObject>(); Humanoid component = prefab.GetComponent<Humanoid>(); if ((Object)(object)component != (Object)null) { AddItems(list, component.m_defaultItems); AddItems(list, component.m_randomWeapon); if (component.m_randomSets != null) { ItemSet[] randomSets = component.m_randomSets; foreach (ItemSet val2 in randomSets) { if (val2 != null) { AddItems(list, val2.m_items); } } } } foreach (GameObject item in list) { ItemDrop component2 = item.GetComponent<ItemDrop>(); ItemData val3 = (((Object)(object)component2 != (Object)null) ? component2.m_itemData : null); Attack val4 = ((val3 != null && val3.m_shared != null) ? val3.m_shared.m_attack : null); if (val4 != null && (!string.IsNullOrEmpty(val4.m_attackAnimation) || !((Object)(object)val4.m_attackProjectile == (Object)null))) { bool isProjectile = (Object)(object)val4.m_attackProjectile != (Object)null && ((int)val4.m_attackType == 2 || (int)val4.m_attackType == 5); creatureInfo.Attacks.Add(new CreatureAttack { ItemName = ((Object)item).name.ToLowerInvariant(), Item = val3, Attack = val4, IsProjectile = isProjectile }); } } creatureInfo.Primary = Pick(creatureInfo.Attacks, form.Primary); creatureInfo.Secondary = Pick(creatureInfo.Attacks, form.Secondary); BaseAI component3 = prefab.GetComponent<BaseAI>(); if ((Object)(object)component3 != (Object)null) { creatureInfo.Alert = component3.m_alertedEffects; creatureInfo.Idle = component3.m_idleSound; if (component3.m_idleSoundInterval > 0f) { creatureInfo.IdleInterval = component3.m_idleSoundInterval; } if (component3.m_idleSoundChance > 0f) { creatureInfo.IdleChance = component3.m_idleSoundChance; } } Character component4 = prefab.GetComponent<Character>(); if ((Object)(object)component4 != (Object)null) { creatureInfo.Hit = component4.m_hitEffects; creatureInfo.Jump = component4.m_jumpEffects; creatureInfo.FlyLoop = component4.m_flyingContinuousEffect; } FootStep componentInChildren2 = prefab.GetComponentInChildren<FootStep>(true); if ((Object)(object)componentInChildren2 != (Object)null) { if (componentInChildren2.m_effects != null) { creatureInfo.Steps.AddRange(componentInChildren2.m_effects); } if (componentInChildren2.m_feet != null) { Transform[] feet = componentInChildren2.m_feet; foreach (Transform val5 in feet) { if ((Object)(object)val5 != (Object)null) { creatureInfo.Feet.Add(((Object)val5).name); } } } creatureInfo.Footless = componentInChildren2.m_footlessFootsteps; if (componentInChildren2.m_footlessTriggerDistance > 0.1f) { creatureInfo.FootlessDistance = componentInChildren2.m_footlessTriggerDistance; } } if ((Object)(object)creatureInfo.Visual != (Object)null) { Animator componentInChildren3 = creatureInfo.Visual.GetComponentInChildren<Animator>(true); if ((Object)(object)componentInChildren3 != (Object)null) { creatureInfo.HasStepEvents = PrepareClips(componentInChildren3.runtimeAnimatorController); } } StringBuilder stringBuilder = new StringBuilder(); foreach (CreatureAttack attack in creatureInfo.Attacks) { stringBuilder.Append(attack.ItemName).Append(attack.IsProjectile ? "(projectile)" : "").Append(' '); } NotRacesPlugin.Log.LogInfo((object)(form.Name + " form uses '" + ((Object)prefab).name + "'. Visual: " + (((Object)(object)creatureInfo.Visual != (Object)null) ? ((Object)creatureInfo.Visual).name : "missing") + ". " + string.Format("Attacks: {0}| primary={1} secondary={2} | ", stringBuilder, creatureInfo.Primary?.ItemName ?? "-", creatureInfo.Secondary?.ItemName ?? "-") + $"steps={creatureInfo.Steps.Count} feet={creatureInfo.Feet.Count} stepEvents={creatureInfo.HasStepEvents} footless={creatureInfo.Footless}")); return creatureInfo; } private static bool PrepareClips(RuntimeAnimatorController controller) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 bool result = false; if ((Object)(object)controller == (Object)null) { return false; } AnimationClip[] animationClips; try { animationClips = controller.animationClips; } catch { return false; } if (animationClips == null) { return false; } AnimationClip[] array = animationClips; foreach (AnimationClip val in array) { if ((Object)(object)val == (Object)null) { continue; } try { AnimationEvent[] events = val.events; if (events == null || events.Length == 0) { continue; } bool flag = false; AnimationEvent[] array2 = events; foreach (AnimationEvent val2 in array2) { if (val2.functionName == "FootStep") { result = true; } if ((int)val2.messageOptions != 1) { val2.messageOptions = (SendMessageOptions)1; flag = true; } } if (flag && s_preparedClips.Add(val)) { val.events = events; } } catch (Exception e) { Util.LogOnce("clip-" + ((Object)val).name, e); } } return result; } private static void AddItems(List<GameObject> list, GameObject[] items) { if (items == null) { return; } foreach (GameObject val in items) { if ((Object)(object)val != (Object)null && !list.Contains(val)) { list.Add(val); } } } private static bool IsTaunt(CreatureAttack a) { if (!a.ItemName.Contains("taunt")) { return a.ItemName.Contains("idle"); } return true; } private static CreatureAttack Pick(List<CreatureAttack> list, AttackDef def) { if (def == null || list.Count == 0) { return null; } bool flag = def.Kind == AttackKind.Projectile; string[] hints = def.Hints; foreach (string value in hints) { foreach (CreatureAttack item in list) { if (item.IsProjectile == flag && (def.UseTaunt || !IsTaunt(item)) && item.ItemName.Contains(value)) { return item; } } } foreach (CreatureAttack item2 in list) { if (item2.IsProjectile == flag && !IsTaunt(item2)) { return item2; } } hints = def.Hints; foreach (string value2 in hints) { foreach (CreatureAttack item3 in list) { if ((def.UseTaunt || !IsTaunt(item3)) && item3.ItemName.Contains(value2)) { return item3; } } } foreach (CreatureAttack item4 in list) { if (!IsTaunt(item4)) { return item4; } } return null; } } public enum RaceId { None, Human, Werewolf, Dragonborn, Trollkin, Loxkin } public enum FormId { None, Fenring, Drake, Moder, Troll, Lox, Wolf, Ulv, Cultist, Asksvin, Fader } public enum AttackKind { Melee, Leap, Stomp, Projectile } public class AttackDef { public string Name; public AttackKind Kind; public string[] Hints = new string[0]; public bool UseTaunt; public float Blunt; public float Slash; public float Pierce; public float Chop; public float Pickaxe; public float Fire; public float Frost; public float Poison; public float Spirit; public float Stamina = 10f; public float Cooldown = 1f; public float HitDelay = 0.3f; public float Range = 1.5f; public float Radius = 2f; public float Push = 20f; public float Stagger = 1f; public int Projectiles = 1; public float Spread; public float ProjectileSpeed = 25f; public float LeapUp; public float LeapForward; public bool ToolTier; public float Noise = 20f; public string Note; } public class FormDef { public FormId Id; public RaceId Race; public string Name; public string Prefab; public string Icon; public string Blurb; public float BaseHp; public float Armor; public float Speed; public float JumpUp; public float JumpForward; public float Carry; public float HealthRegen = 1f; public float StaminaRegen = 1f; public float RunStaminaDrain; public float FallDamage; public List<DamageModPair> Mods = new List<DamageModPair>(); public bool CanJump = true; public bool CanDodge = true; public string PassiveName; public string PassiveText; public float Lifesteal; public float RegenPerSecond; public float AuraRadius; public float AuraDamage; public DamageType AuraType = (DamageType)64; public bool Immovable; public bool Frenzy; public bool Flying; public float FlySpeed = 10f; public float FlyFastSpeed = 18f; public float FlyVertical = 7f; public float FlyHoverStamina = 2f; public float FlyMoveStamina = 4f; public float FlyFastStamina = 9f; public float TakeoffStamina = 8f; public Vector2 Mouth = new Vector2(1.2f, 1.6f); public AttackDef Primary; public AttackDef Secondary; public string UnlockKey; public string UnlockText; public List<string> Features = new List<string>(); public Color FxColor = Color.white; public Color FxColor2 = Color.gray; public string[] PowerEffects = new string[0]; public float Stride = 1.6f; public float DefScale = 1f; public float DefOffsetY; public float DefCamHeight; public float DefCamDistance; internal ConfigEntry<float> CfgScale; internal ConfigEntry<float> CfgOffsetY; internal ConfigEntry<float> CfgCamHeight; internal ConfigEntry<float> CfgCamDistance; public float Scale { get { if (CfgScale == null) { return DefScale; } return Mathf.Clamp(CfgScale.Value, 0.02f, 5f); } } public float OffsetY { get { if (CfgOffsetY == null) { return DefOffsetY; } return CfgOffsetY.Value; } } public float CamHeight { get { if (CfgCamHeight == null) { return DefCamHeight; } return CfgCamHeight.Value; } } public float CamDistance { get { if (CfgCamDistance == null) { return DefCamDistance; } return Mathf.Max(0f, CfgCamDistance.Value); } } public bool IsUnlocked { get { if (!string.IsNullOrEmpty(UnlockKey)) { return Progression.HasKey(UnlockKey); } return true; } } } public class RaceDef { public RaceId Id; public string Name; public string Tagline; public string Icon; public FormId[] Forms = new FormId[0]; public float Speed; public float Carry; public float HealthRegen = 1f; public float StaminaRegen = 1f; public float SkillGain; public float FallDamage; public float RunStaminaDrain; public bool ColdResistance; public List<DamageModPair> Mods = new List<DamageModPair>(); public string[] Gifts = new string[0]; public string[] Weakness = new string[0]; } internal static class D { internal static DamageModPair Mod(DamageType type, DamageModifier mod) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new DamageModPair { m_type = type, m_modifier = mod }; } internal static Color Rgb(float r, float g, float b) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return new Color(r, g, b, 1f); } } public static class Forms { private static readonly Dictionary<FormId, FormDef> s_forms; public static IEnumerable<FormDef> All => s_forms.Values; public static FormDef Get(FormId id) { if (!s_forms.TryGetValue(id, out var value)) { return null; } return value; } static Forms() { //IL_00ab: 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) //IL_0100: 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_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_0970: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_0b9d: Unknown result type (might be due to invalid IL or missing references) //IL_0bd6: Unknown result type (might be due to invalid IL or missing references) //IL_0c3a: Unknown result type (might be due to invalid IL or missing references) //IL_0c3f: Unknown result type (might be due to invalid IL or missing references) //IL_0c54: Unknown result type (might be due to invalid IL or missing references) //IL_0c59: Unknown result type (might be due to invalid IL or missing references) //IL_0c6e: Unknown result type (might be due to invalid IL or missing references) //IL_0c73: Unknown result type (might be due to invalid IL or missing references) //IL_0eef: Unknown result type (might be due to invalid IL or missing references) //IL_0f35: Unknown result type (might be due to invalid IL or missing references) //IL_0f3a: Unknown result type (might be due to invalid IL or missing references) //IL_0f4f: Unknown result type (might be due to invalid IL or missing references) //IL_0f54: Unknown result type (might be due to invalid IL or missing references) //IL_0f8b: Unknown result type (might be due to invalid IL or missing references) //IL_0f90: Unknown result type (might be due to invalid IL or missing references) //IL_1198: Unknown result type (might be due to invalid IL or missing references) //IL_11d1: Unknown result type (might be due to invalid IL or missing references) //IL_123c: Unknown result type (might be due to invalid IL or missing references) //IL_1241: Unknown result type (might be due to invalid IL or missing references) //IL_126c: Unknown result type (might be due to invalid IL or missing references) //IL_1271: Unknown result type (might be due to invalid IL or missing references) //IL_1286: Unknown result type (might be due to invalid IL or missing references) //IL_128b: Unknown result type (might be due to invalid IL or missing references) //IL_14ff: Unknown result type (might be due to invalid IL or missing references) //IL_1512: Unknown result type (might be due to invalid IL or missing references) //IL_154b: Unknown result type (might be due to invalid IL or missing references) //IL_1571: Unknown result type (might be due to invalid IL or missing references) //IL_1576: Unknown result type (might be due to invalid IL or missing references) //IL_158b: Unknown result type (might be due to invalid IL or missing references) //IL_1590: Unknown result type (might be due to invalid IL or missing references) //IL_15a5: Unknown result type (might be due to invalid IL or missing references) //IL_15aa: Unknown result type (might be due to invalid IL or missing references) //IL_185a: Unknown result type (might be due to invalid IL or missing references) //IL_185f: Unknown result type (might be due to invalid IL or missing references) //IL_1874: Unknown result type (might be due to invalid IL or missing references) //IL_1879: Unknown result type (might be due to invalid IL or missing references) //IL_188e: Unknown result type (might be due to invalid IL or missing references) //IL_1893: Unknown result type (might be due to invalid IL or missing references) //IL_1b00: Unknown result type (might be due to invalid IL or missing references) //IL_1b32: Unknown result type (might be due to invalid IL or missing references) //IL_1b37: Unknown result type (might be due to invalid IL or missing references) //IL_1b4c: Unknown result type (might be due to invalid IL or missing references) //IL_1b51: Unknown result type (might be due to invalid IL or missing references) //IL_1b66: Unknown result type (might be due to invalid IL or missing references) //IL_1b6b: Unknown result type (might be due to invalid IL or missing references) s_forms = new Dictionary<FormId, FormDef>(); Add(new FormDef { Id = FormId.Fenring, Race = RaceId.Werewolf, Name = "Fenring", Prefab = "Fenring", Icon = "TrophyFenring", Blurb = "The true werewolf - a swift hunter of the mountain nights.", BaseHp = 30f, Armor = 4f, Speed = 0.4f, JumpUp = 0.5f, JumpForward = 0.3f, HealthRegen = 1.5f, StaminaRegen = 1.25f, FallDamage = -0.5f, Mods = { D.Mod((DamageType)32, (DamageModifier)2) }, PassiveName = "Bloodlust", PassiveText = "your claws heal you for 15% of the damage they deal", Lifesteal = 0.15f, FxColor = D.Rgb(1f, 0.22f, 0.12f), FxColor2 = D.Rgb(0.55f, 0.04f, 0.06f), PowerEffects = new string[2] { "GP_Eikthyr", "GP_Bonemass" }, Stride = 1.5f, DefScale = 0.85f, DefCamHeight = 0.3f, DefCamDistance = 0.8f, Primary = new AttackDef { Name = "Claw swipe", Kind = AttackKind.Melee, Hints = new string[2] { "claw", "attack" }, Slash = 22f, Stamina = 6f, Cooldown = 0.55f, HitDelay = 0.22f, Range = 1.4f, Radius = 1.7f, Push = 20f, Stagger = 1f, Noise = 15f }, Secondary = new AttackDef { Name = "Pounce", Kind = AttackKind.Leap, Hints = new string[3] { "jump", "leap", "pounce" }, Slash = 34f, Stamina = 22f, Cooldown = 4.5f, HitDelay = 0.55f, Range = 0.6f, Radius = 2.6f, Push = 45f, Stagger = 2.5f, LeapUp = 6.5f, LeapForward = 11f, Noise = 25f, Note = "leap forward" }, Features = { "+40% movement speed, higher jumps, faster healing", "Weak to fire while transformed" } }); Add(new FormDef { Id = FormId.Wolf, Race = RaceId.Werewolf, Name = "Wolf", Prefab = "Wolf", Icon = "TrophyWolf", Blurb = "Four paws, sharp ears - the shape for long hunts and long journeys.", BaseHp = 15f, Armor = 2f, Speed = 0.6f, JumpUp = 0.3f, JumpForward = 0.3f, StaminaRegen = 1.3f, FallDamage = -0.3f, RunStaminaDrain = -1f, PassiveName = "Swift hunter", PassiveText = "running costs no stamina", FxColor = D.Rgb(0.78f, 0.84f, 1f), FxColor2 = D.Rgb(0.3f, 0.36f, 0.52f), PowerEffects = new string[1] { "GP_Eikthyr" }, Stride = 1.2f, Mouth = new Vector2(1.2f, 0.8f), DefScale = 0.9f, DefCamHeight = 0f, DefCamDistance = 0.5f, Primary = new AttackDef { Name = "Bite", Kind = AttackKind.Melee, Hints = new string[3] { "attack1", "bite", "attack" }, Slash = 18f, Stamina = 5f, Cooldown = 0.5f, HitDelay = 0.2f, Range = 1.3f, Radius = 1.4f, Push = 15f, Stagger = 1f, Noise = 10f }, Secondary = new AttackDef { Name = "Lunge", Kind = AttackKind.Leap, Hints = new string[4] { "attack3", "jump", "lunge", "attack2" }, Pierce = 26f, Stamina = 18f, Cooldown = 4f, HitDelay = 0.45f, Range = 0.6f, Radius = 2f, Push = 30f, Stagger = 1.5f, LeapUp = 4.5f, LeapForward = 13f, Noise = 15f, Note = "long leap" }, Features = { "+60% movement speed - the fastest way across the land", "Fragile: small health bonus" } }); Add(new FormDef { Id = FormId.Ulv, Race = RaceId.Werewolf, Name = "Ulv", Prefab = "Ulv", Icon = "TrophyUlv", Blurb = "A spectral wolf-beast from the frozen caves.", BaseHp = 40f, Armor = 6f, Speed = 0.45f, JumpUp = 0.4f, JumpForward = 0.3f, HealthRegen = 1.5f, StaminaRegen = 1.25f, FallDamage = -0.5f, Mods = { D.Mod((DamageType)64, (DamageModifier)1) }, PassiveName = "Frenzy", PassiveText = "every hit makes your next attacks faster (up to 3 stacks)", Frenzy = true, UnlockKey = "defeated_bonemass", UnlockText = "Defeat Bonemass to unlock", FxColor = D.Rgb(0.4f, 1f, 0.85f), FxColor2 = D.Rgb(0.1f, 0.35f, 0.42f), PowerEffects = new string[2] { "GP_Bonemass", "GP_Eikthyr" }, Stride = 1.5f, DefScale = 0.85f, DefCamHeight = 0.3f, DefCamDistance = 0.8f, Primary = new AttackDef { Name = "Rend", Kind = AttackKind.Melee, Hints = new string[3] { "claw", "slash", "attack" }, Slash = 26f, Stamina = 7f, Cooldown = 0.6f, HitDelay = 0.25f, Range = 1.4f, Radius = 1.8f, Push = 25f, Stagger = 1.2f, Noise = 15f }, Secondary = new AttackDef { Name = "Dread howl", Kind = AttackKind.Stomp, Hints = new string[4] { "howl", "taunt", "scream", "roar" }, UseTaunt = true, Slash = 8f, Stamina = 20f, Cooldown = 8f, HitDelay = 0.4f, Range = 0f, Radius = 6f, Push = 40f, Stagger = 6f, Noise = 50f, Note = "staggers every enemy around you" }, Features = { "+45% movement speed and resistant to frost" } }); Add(new FormDef { Id = FormId.Cultist, Race = RaceId.Werewolf, Name = "Cultist", Prefab = "Fenring_Cultist", Icon = "TrophyCultist", Blurb = "A fire-touched Fenring shaman of the mountain cults.", BaseHp = 45f, Armor = 6f, Speed = 0.3f, JumpUp = 0.4f, HealthRegen = 1.5f, FallDamage = -0.5f, Mods = { D.Mod((DamageType)32, (DamageModifier)1) }, PassiveName = "Burning claws", PassiveText = "your claws set enemies on fire", UnlockKey = "defeated_dragon", UnlockText = "Defeat Moder to unlock", FxColor = D.Rgb(1f, 0.55f, 0.12f), FxColor2 = D.Rgb(0.6f, 0.1f, 0.02f), PowerEffects = new string[2] { "GP_Yagluth", "GP_Eikthyr" }, Stride = 1.5f, DefScale = 0.85f, DefCamHeight = 0.3f, DefCamDistance = 0.8f, Primary = new AttackDef { Name = "Burning claw", Kind = AttackKind.Melee, Hints = new string[2] { "claw", "attack" }, Slash = 20f, Fire = 12f, Stamina = 7f, Cooldown = 0.6f, HitDelay = 0.25f, Range = 1.4f, Radius = 1.8f, Push = 20f, Stagger = 1f, Noise = 15f }, Secondary = new AttackDef { Name = "Flame spit", Kind = AttackKind.Projectile, Hints = new string[5] { "fire", "flame", "ball", "spit", "projectile" }, Fire = 28f, Stamina = 22f, Cooldown = 4f, HitDelay = 0.35f, Projectiles = 3, Spread = 7f, ProjectileSpeed = 22f, Push = 10f, Noise = 25f }, Features = { "Resistant to fire, +30% movement speed" } }); Add(new FormDef { Id = FormId.Drake, Race = RaceId.Dragonborn, Name = "Drake", Prefab = "Hatchling", Icon = "TrophyHatchling", Blurb = "A frost drake - light, fast and made for the sky.", BaseHp = 20f, Armor = 2f, FallDamage = -1f, Mods = { D.Mod((DamageType)64, (DamageModifier)3) }, PassiveName = "Frost aura", PassiveText = "enemies within 5 m are chilled and slowed", AuraRadius = 5f, AuraDamage = 4f, AuraType = (DamageType)64, Flying = true, FlySpeed = 10f, FlyFastSpeed = 18f, FlyVertical = 7f, FlyHoverStamina = 1.5f, FlyMoveStamina = 3f, FlyFastStamina = 7f, TakeoffStamina = 6f, Mouth = new Vector2(1.6f, 1.2f), FxColor = D.Rgb(0.55f, 0.88f, 1f), FxColor2 = D.Rgb(0.9f, 0.98f, 1f), PowerEffects = new string[1] { "GP_Moder" }, Stride = 1.2f, DefScale = 0.75f, DefOffsetY = 0.9f, DefCamHeight = 0.6f, DefCamDistance = 2f, Primary = new AttackDef { Name = "Frost spit", Kind = AttackKind.Projectile, Hints = new string[4] { "spit", "cold", "frost", "attack" }, Frost = 16f, Pierce = 6f, Stamina = 7f, Cooldown = 0.65f, HitDelay = 0.2f, Projectiles = 1, ProjectileSpeed = 30f, Push = 10f, Noise = 15f }, Secondary = new AttackDef { Name = "Ice volley", Kind = AttackKind.Projectile, Hints = new string[4] { "spit", "cold", "frost", "attack" }, Frost = 11f, Pierce = 4f, Stamina = 24f, Cooldown = 6f, HitDelay = 0.3f, Projectiles = 5, Spread = 9f, ProjectileSpeed = 28f, Push = 10f, Noise = 25f }, Features = { "Fly! Jump, then press Jump again in the air to take off", "Jump / Crouch = up / down, Run = fast flight (uses stamina)", "Immune to frost, no fall damage" } }); Add(new FormDef { Id = FormId.Asksvin, Race = RaceId.Dragonborn, Name = "Asksvin", Prefab = "Asksvin", Icon = "TrophyAsksvin", Blurb = "A wingless fire lizard of the Ashlands - kin of the dragons.", BaseHp = 35f, Armor = 6f, Speed = 0.5f, JumpUp = 0.3f, JumpForward = 0.3f, StaminaRegen = 1.2f, FallDamage = -0.5f, Mods = { D.Mod((DamageType)32, (DamageModifier)3) }, PassiveName = "Ash scales", PassiveText = "you are immune to fire", UnlockKey = "defeated_gdking", UnlockText = "Defeat The Elder to unlock", FxColor = D.Rgb(1f, 0.45f, 0.15f), FxColor2 = D.Rgb(0.35f, 0.12f, 0.05f), PowerEffects = new string[2] { "GP_Fader", "GP_Moder" }, Stride = 1.6f, Mouth = new Vector2(1.8f, 1.2f), DefScale = 0.8f, DefCamHeight = 0.3f, DefCamDistance = 1.2f, Primary = new AttackDef { Name = "Bite", Kind = AttackKind.Melee, Hints = new string[2] { "bite", "attack" }, Pierce = 26f, Stamina = 7f, Cooldown = 0.6f, HitDelay = 0.25f, Range = 1.8f, Radius = 1.7f, Push = 25f, Stagger = 1.2f, Noise = 15f }, Secondary = new AttackDef { Name = "Tail lash", Kind = AttackKind.Stomp, Hints = new string[4] { "tail", "sweep", "swipe", "attack" }, Blunt = 24f, Stamina = 18f, Cooldown = 4f, HitDelay = 0.4f, Range = 0f, Radius = 3.4f, Push = 65f, Stagger = 2f, Noise = 20f, Note = "hits all around you" }, Features = { "+50% movement speed - a fast runner" } }); Add(new FormDef { Id = FormId.Moder, Race = RaceId.Dragonborn, Name = "Moder", Prefab = "Dragon", Icon = "TrophyDragonQueen", Blurb = "The mother of dragons lives on in your blood.", BaseHp = 100f, Armor = 10f, Speed = -0.1f, FallDamage = -1f, Mods = { D.Mod((DamageType)64, (DamageModifier)3) }, PassiveName = "Winter's breath", PassiveText = "enemies within 8 m are chilled and slowed", AuraRadius = 8f, AuraDamage = 8f, AuraType = (DamageType)64, Flying = true, FlySpeed = 9f, FlyFastSpeed = 15f, FlyVertical = 6f, FlyHoverStamina = 2f, FlyMoveStamina = 4f, FlyFastStamina = 8f, TakeoffStamina = 10f, CanDodge = false, Mouth = new Vector2(3f, 1.6f), UnlockKey = "defeated_dragon", UnlockText = "Defeat Moder to unlock", FxColor = D.Rgb(0.7f, 0.95f, 1f), FxColor2 = D.Rgb(0.35f, 0.6f, 1f), PowerEffects = new string[1] { "GP_Moder" }, Stride = 2.6f, DefScale = 0.2f, DefOffsetY = 0f, DefCamHeight = 2f, DefCamDistance = 6f, Primary = new AttackDef { Name = "Ice barrage", Kind = AttackKind.Projectile, Hints = new string[4] { "spit", "shotgun", "cold", "ice" }, Frost = 24f, Pierce = 8f, Stamina = 12f, Cooldown = 1.1f, HitDelay = 0.3f, Projectiles = 3, Spread = 5f, ProjectileSpeed = 32f, Push = 15f, Noise = 25f }, Secondary = new AttackDef { Name = "Frost storm", Kind = AttackKind.Projectile, Hints = new string[4] { "breath", "spit", "shotgun", "cold" }, Frost = 22f, Pierce = 6f, Stamina = 35f, Cooldown = 9f, HitDelay = 0.5f, Projectiles = 10, Spread = 16f, ProjectileSpeed = 30f, Push = 20f, Noise = 40f }, Features = { "Flies like the Drake, but bigger, tougher and deadlier", "Immune to frost, no fall damage" } }); Add(new FormDef { Id = FormId.Fader, Race = RaceId.Dragonborn, Name = "Fader", Prefab = "Fader", Icon = "TrophyFader", Blurb = "The fallen fire dragon of the Ashlands - a walking volcano.", BaseHp = 180f, Armor = 18f, Speed = -0.15f, Carry = 100f, HealthRegen = 1.3f, FallDamage = -1f, CanDodge = false, Mods = { D.Mod((DamageType)32, (DamageModifier)3), D.Mod((DamageType)64, (DamageModifier)2) }, PassiveName = "Inferno aura", PassiveText = "enemies within 6 m burn", AuraRadius = 6f, AuraDamage = 6f, AuraType = (DamageType)32, UnlockKey = "defeated_fader", UnlockText = "Defeat Fader to unlock", Mouth = new Vector2(3.2f, 2.2f), FxColor = D.Rgb(1f, 0.38f, 0.06f), FxColor2 = D.Rgb(1f, 0.82f, 0.25f), PowerEffects = new string[2] { "GP_Fader", "GP_Yagluth" }, Stride = 3f, DefScale = 0.18f, DefCamHeight = 2.5f, DefCamDistance = 7f, Primary = new AttackDef { Name = "Claw slam", Kind = AttackKind.Melee, Hints = new string[4] { "claw", "slam", "stomp", "attack" }, Blunt = 40f, Fire = 20f, Chop = 30f, Pickaxe = 30f, ToolTier = true, Stamina = 16f, Cooldown = 1.2f, HitDelay = 0.5f, Range = 3f, Radius = 3.2f, Push = 70f, Stagger = 2.5f, Noise = 35f }, Secondary = new AttackDef { Name = "Fire breath", Kind = AttackKind.Projectile, Hints = new string[5] { "breath", "flame", "fire", "meteor", "spit" }, Fire = 34f, Stamina = 30f, Cooldown = 6f, HitDelay = 0.45f, Projectiles = 6, Spread = 12f, ProjectileSpeed = 26f, Push = 20f, Noise = 40f }, Features = { "A grounded titan: huge health and armor, immune to fire", "Slow and weak to frost" } }); Add(new FormDef { Id = FormId.Troll, Race = RaceId.Trollkin, Name = "Troll", Prefab = "Troll", Icon = "TrophyForestTroll", Blurb = "Big, blue and very angry.", BaseHp = 100f, Armor = 10f, Speed = -0.1f, JumpUp = -0.3f, Carry = 200f, HealthRegen = 1.5f, CanDodge = false, PassiveName = "Troll regeneration", PassiveText = "heals 2% of your max health every second", RegenPerSecond = 0.02f, Mouth = new Vector2(1.2f, 2.4f), FxColor = D.Rgb(0.45f, 0.95f, 0.4f), FxColor2 = D.Rgb(0.2f, 0.5f, 0.85f), PowerEffects = new string[1] { "GP_TheElder" }, Stride = 2.2f, DefScale = 0.5f, DefCamHeight = 1.2f, DefCamDistance = 2.5f, Primary = new AttackDef { Name = "Smash", Kind = AttackKind.Melee, Hints = new string[4] { "groundslam", "slam", "punch", "attack" }, Blunt = 30f, Chop = 40f, Pickaxe = 40f, ToolTier = true, Stamina = 15f, Cooldown = 1.3f, HitDelay = 0.55f, Range = 2f, Radius = 2.6f, Push = 60f, Stagger = 2f, Noise = 30f }, Secondary = new AttackDef { Name = "Boulder throw", Kind = AttackKind.Projectile, Hints = new string[2] { "throw", "rock" }, Blunt = 45f, Stamina = 20f, Cooldown = 5f, HitDelay = 0.6f, Projectiles = 1, ProjectileSpeed = 25f, Push = 50f, Stagger = 2f, Noise = 25f }, Features = { "Lots of extra health and armor, +200 carry weight", "Smash fells trees and breaks rocks and ore", "A bit slower, cannot roll" } }); Add(new FormDef { Id = FormId.Lox, Race = RaceId.Loxkin, Name = "Lox", Prefab = "Lox", Icon = "TrophyLox", Blurb = "A walking mountain of fur.", BaseHp = 120f, Armor = 14f, Speed = -0.05f, Carry = 400f, HealthRegen = 1.3f, CanJump = false, CanDodge = false, Mods = { D.Mod((DamageType)1, (DamageModifier)1) }, PassiveName = "Immovable", PassiveText = "nothing can stagger you or knock you back", Immovable = true, Mouth = new Vector2(2f, 1.6f), FxColor = D.Rgb(1f, 0.75f, 0.32f), FxColor2 = D.Rgb(0.65f, 0.4f, 0.2f), PowerEffects = new string[2] { "GP_TheElder", "GP_Bonemass" }, Stride = 2f, DefScale = 0.6f, DefCamHeight = 0.8f, DefCamDistance = 2.5f, Primary = new AttackDef { Name = "Headbutt", Kind = AttackKind.Melee, Hints = new string[2] { "bite", "attack" }, Blunt = 30f, Stamina = 10f, Cooldown = 0.9f, HitDelay = 0.35f, Range = 2f, Radius = 1.8f, Push = 50f, Stagger = 1.5f, Noise = 20f }, Secondary = new AttackDef { Name = "Stomp", Kind = AttackKind.Stomp, Hints = new string[1] { "stomp" }, Blunt = 26f, Stamina = 25f, Cooldown = 6f, HitDelay = 0.5f, Radius = 4.2f, Push = 90f, Stagger = 3f, Noise = 35f, Note = "hits all around you" }, Features = { "Huge health pool, resistant to blunt damage", "+400 carry weight - haul ore like a true beast of burden", "Cannot jump or roll" } }); } private static void Add(FormDef f) { s_forms[f.Id] = f; } internal static void BindConfig(ConfigFile cfg) { foreach (FormDef value in s_forms.Values) { string text = "4 - Visuals - " + value.Name; value.CfgScale = cfg.Bind<float>(text, "Model scale", value.DefScale, "Size of the beast model."); value.CfgOffsetY = cfg.Bind<float>(text, "Model height offset", value.DefOffsetY, "Moves the beast model up or down (meters)."); value.CfgCamHeight = cfg.Bind<float>(text, "Camera height", value.DefCamHeight, "Extra camera height while in this form (meters)."); value.CfgCamDistance = cfg.Bind<float>(text, "Camera distance", value.DefCamDistance, "Extra camera distance while in this form (meters)."); } } } public static class Races { public static readonly RaceDef[] All = new RaceDef[5] { new RaceDef { Id = RaceId.Human, Name = "Human", Tagline = "No beast in your blood - just stubborn Viking spirit.", Icon = "HelmetBronze", SkillGain = 0.2f, StaminaRegen = 1.15f, Carry = 50f, Gifts = new string[3] { "+20% faster skill gain", "+15% stamina regeneration", "+50 carry weight" }, Weakness = new string[1] { "None" } }, new RaceDef { Id = RaceId.Werewolf, Name = "Werewolf", Tagline = "Wolf blood runs in your veins. When the moon rises, so do you.", Icon = "TrophyFenring", Forms = new FormId[4] { FormId.Fenring, FormId.Wolf, FormId.Ulv, FormId.Cultist }, Speed = 0.1f, RunStaminaDrain = -0.25f, Mods = { D.Mod((DamageType)512, (DamageModifier)2) }, Gifts = new string[3] { "+10% movement speed", "-25% stamina drain while running", "Moon-blessed: beast forms deal +25% damage at night" }, Weakness = new string[1] { "Weak to spirit damage (silver)" } }, new RaceDef { Id = RaceId.Dragonborn, Name = "Dragonborn", Tagline = "Dragon fire and dragon frost sleep beneath your skin.", Icon = "TrophyHatchling", Forms = new FormId[4] { FormId.Drake, FormId.Asksvin, FormId.Moder, FormId.Fader }, FallDamage = -0.5f, ColdResistance = true, Mods = { D.Mod((DamageType)64, (DamageModifier)1), D.Mod((DamageType)32, (DamageModifier)2) }, Gifts = new string[2] { "Resistant to frost - the cold cannot freeze you", "-50% fall damage" }, Weakness = new string[1] { "Weak to fire (the Asksvin and Fader forms are immune)" } }, new RaceDef { Id = RaceId.Trollkin, Name = "Trollkin", Tagline = "Big, thick-skinned and always hungry.", Icon = "TrophyForestTroll", Forms = new FormId[1] { FormId.Troll }, HealthRegen = 1.5f, Carry = 75f, Mods = { D.Mod((DamageType)4, (DamageModifier)2) }, Gifts = new string[2] { "+50% health regeneration", "+75 carry weight" }, Weakness = new string[1] { "Weak to pierce damage (arrows, spears)" } }, new RaceDef { Id = RaceId.Loxkin, Name = "Loxkin", Tagline = "Born on the Plains. Slow to anger, impossible to stop.", Icon = "TrophyLox", Forms = new FormId[1] { FormId.Lox }, Carry = 150f, StaminaRegen = 1.1f, Mods = { D.Mod((DamageType)256, (DamageModifier)2) }, Gifts = new string[2] { "+150 carry weight", "+10% stamina regeneration" }, Weakness = new string[1] { "Weak to poison" } } }; public static RaceDef Get(RaceId id) { RaceDef[] all = All; foreach (RaceDef raceDef in all) { if (raceDef.Id == id) { return raceDef; } } return null; } } internal static class Fx { private static readonly string[] s_smokeFx = new string[3] { "vfx_odin_despawn", "vfx_spawn", "vfx_prespawn" }; private static readonly Dictionary<GameObject, bool> s_safe = new Dictionary<GameObject, bool>(); private const float MaxLifetime = 12f; internal static bool IsSafe(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return false; } if (s_safe.TryGetValue(prefab, out var value)) { return value; } value = (Object)(object)prefab.GetComponentInChildren<ZNetView>(true) == (Object)null && (Object)(object)prefab.GetComponentInChildren<Aoe>(true) == (Object)null && prefab.GetComponentInChildren<IProjectile>(true) == null && (Object)(object)prefab.GetComponentInChildren<Character>(true) == (Object)null && (Object)(object)prefab.GetComponentInChildren<ItemDrop>(true) == (Object)null && (Object)(object)prefab.GetComponentInChildren<SpawnAbility>(true) == (Object)null && (Object)(object)prefab.GetComponentInChildren<Ragdoll>(true) == (Object)null && prefab.GetComponentInChildren<IDestructible>(true) == null; s_safe[prefab] = value; return value; } internal static GameObject Spawn(GameObject prefab, Vector3 pos, Quaternion rot, Transform parent = null, float scale = 1f, float lifetime = 12f) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (NotRacesPlugin.Headless || !IsSafe(prefab)) { return null; } try { GameObject val = Object.Instantiate<GameObject>(prefab, pos, rot); if (!Mathf.Approximately(scale, 1f)) { val.transform.localScale = prefab.transform.localScale * scale; } if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, true); } if (lifetime > 0f) { Object.Destroy((Object)(object)val, lifetime); } return val; } catch (Exception e) { Util.LogOnce("fx-" + ((Object)prefab).name, e); return null; } } internal static bool HasEffects(EffectList list) { if (list == null || list.m_effectPrefabs == null) { return false; } EffectData[] effectPrefabs = list.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if (val != null && val.m_enabled && (Object)(object)val.m_prefab != (Object)null) { return true; } } return false; } internal static void Play(EffectList list, Vector3 pos, Quaternion rot, Transform parent, float scale, float lifetime = 12f) { //IL_0046: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (NotRacesPlugin.Headless || list == null || list.m_effectPrefabs == null) { return; } EffectData[] effectPrefabs = list.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if (val != null && val.m_enabled && !((Object)(object)val.m_prefab == (Object)null)) { Quaternion rot2 = (val.m_randomRotation ? Random.rotation : rot); Spawn(val.m_prefab, pos, rot2, val.m_attach ? parent : null, val.m_scale ? scale : 1f, lifetime); } } } internal static List<GameObject> PlayLoop(EffectList list, Transform parent) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) List<GameObject> list2 = new List<GameObject>(); if (NotRacesPlugin.Headless || list == null || list.m_effectPrefabs == null || (Object)(object)parent == (Object)null) { return list2; } EffectData[] effectPrefabs = list.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if (val != null && val.m_enabled && !((Object)(object)val.m_prefab == (Object)null)) { GameObject val2 = Spawn(val.m_prefab, parent.position, parent.rotation, parent, 1f, 0f); if ((Object)(object)val2 != (Object)null) { list2.Add(val2); } } } return list2; } internal static bool PlayPrefab(string name, Vector3 pos, Quaternion rot, float scale = 1f) { //IL_002c: 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) if (NotRacesPlugin.Headless || (Object)(object)ZNetScene.instance == (Object)null) { return false; } GameObject prefab = ZNetScene.instance.GetPrefab(name); if ((Object)(object)prefab != (Object)null) { return (Object)(object)Spawn(prefab, pos, rot, null, scale) != (Object)null; } return false; } private static void Smoke(Vector3 pos, float scale) { //IL_000d: 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) string[] array = s_smokeFx; for (int i = 0; i < array.Length && !PlayPrefab(array[i], pos, Quaternion.identity, scale); i++) { } } internal static void MorphIn(Transform player, FormDef form) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_0107: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || form == null || NotRacesPlugin.Headless) { return; } Vector3 pos = player.position + Vector3.up * 1f; float num = Mathf.Clamp(form.Scale / Mathf.Max(0.05f, form.DefScale), 0.6f, 2f); if (form.CamDistance >= 5f) { num *= 1.6f; } else if (form.CamDistance >= 2.5f) { num *= 1.3f; } if (NotRacesPlugin.TransformEffects.Value) { Smoke(pos, 1.4f * num); MorphFx.Transformation(pos, form.FxColor, form.FxColor2, num, small: false); Shake(pos, 1.6f); } if (NotRacesPlugin.BeastSounds.Value) { Play(GameSounds.Power(form), player.position, player.rotation, player, 1f, 6f); CreatureInfo creatureInfo = Creatures.Get(form.Id); if (creatureInfo != null && creatureInfo.Alert != null) { Play(creatureInfo.Alert, pos, player.rotation, player, 1f); } } } internal static void MorphOut(Transform player, FormDef form) { //IL_0012: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !NotRacesPlugin.Headless) { Vector3 pos = player.position + Vector3.up * 1f; if (NotRacesPlugin.TransformEffects.Value) { Smoke(pos, 1f); Color color = ((form != null) ? Color.Lerp(form.FxColor, Color.white, 0.5f) : Color.white); MorphFx.Transformation(pos, color, new Color(0.85f, 0.8f, 0.7f), 0.7f, small: true); Shake(pos, 0.6f); } } } private static void Shake(Vector3 pos, float strength) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)GameCamera.instance != (Object)null) { GameCamera.instance.AddShake(pos, 20f, strength, false); } } catch { } } } internal static class GameSounds { private static readonly string[] s_allPowers = new string[7] { "GP_Moder", "GP_Eikthyr", "GP_TheElder", "GP_Bonemass", "GP_Yagluth", "GP_Queen", "GP_Fader" }; private static readonly Dictionary<string, EffectList> s_powers = new Dictionary<string, EffectList>(); private static readonly HashSet<string> s_logged = new HashSet<string>(); private static EffectList Gp(string name) { if (s_powers.TryGetValue(name, out var value)) { return value; } ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null) { return null; } EffectList val = null; try { StatusEffect statusEffect = instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(name)); if ((Object)(object)statusEffect != (Object)null) { val = statusEffect.m_startEffects; } } catch (Exception e) { Util.LogOnce("gp-" + name, e); } s_powers[name] = val; return val; } internal static EffectList Power(FormDef form) { string text = null; EffectList val = null; if (form != null) { string[] powerEffects = form.PowerEffects; foreach (string text2 in powerEffects) { EffectList val2 = Gp(text2); if (Fx.HasEffects(val2)) { val = val2; text = text2; break; } } } if (val == null) { string[] powerEffects = s_allPowers; foreach (string text3 in powerEffects) { EffectList val3 = Gp(text3); if (Fx.HasEffects(val3)) { val = val3; text = text3; break; } } } if (val == null) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && Fx.HasEffects(localPlayer.m_adrenalinePopEffects)) { val = localPlayer.m_adrenalinePopEffects; text = "adrenaline"; } else if ((Object)(object)localPlayer != (Object)null && Fx.HasEffects(localPlayer.m_skillLevelupEffects)) { val = localPlayer.m_skillLevelupEffects; text = "levelup"; } } string text4 = ((form != null) ? form.Name : "-"); if (s_logged.Add(text4)) { NotRacesPlugin.Log.LogInfo((object)("Transformation sound for " + text4 + ": " + (text ?? "none found"))); } return val; } } internal static class MorphFx { private static Material s_glow; private static Texture2D s_dot; private static bool s_failed; private static readonly string[] s_shaders = new string[5] { "Legacy Shaders/Particles/Additive", "Mobile/Particles/Additive", "Particles/Additive", "Legacy Shaders/Particles/Alpha Blended", "Sprites/Default" }; private static Material Glow { get { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_glow != (Object)null || s_failed) { return s_glow; } try { Shader val = null; string[] array = s_shaders; for (int i = 0; i < array.Length; i++) { val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { s_failed = true; Util.WarnOnce("noshader", "No particle shader found - transformation particles are disabled."); return null; } s_glow = new Material(val) { name = "NotRaces_Glow", hideFlags = (HideFlags)61 }; s_glow.mainTexture = (Texture)(object)Dot; if (s_glow.HasProperty("_TintColor")) { s_glow.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f)); } } catch (Exception e) { s_failed = true; Util.LogOnce("glow-material", e); } return s_glow; } } private static Texture2D Dot { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_dot != (Object)null) { return s_dot; } s_dot = new Texture2D(64, 64, (TextureFormat)4, false) { name = "NotRaces_Dot", hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Clamp01(1f - num3); num4 = num4 * num4 * (3f - 2f * num4); array[i * 64 + j] = new Color(1f, 1f, 1f, num4); } } s_dot.SetPixels(array); s_dot.Apply(); return s_dot; } } private static ParticleSystem MakeSystem(Transform parent, string name, int count, Vector2 life, Vector2 speed, Vector2 size, Color a, Color b, float gravity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_004e: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); ParticleSystem val2 = val.AddComponent<ParticleSystem>(); val2.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val2.main; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).duration = 1f; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(life.x, life.y); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(speed.x, speed.y); ((MainModule)(ref main)).startSize = new MinMaxCurve(size.x, size.y); ((MainModule)(ref main)).startColor = new MinMaxGradient(a, b); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(gravity); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).maxParticles = count + 8; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)count) }); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0.9f, 0.35f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3); SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0.15f)); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = Glow; component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; return val2; } internal static void Transformation(Vector3 pos, Color color, Color color2, float scale, bool small) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0027: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) if (NotRacesPlugin.Headless || (Object)(object)Glow == (Object)null) { return; } try { GameObject val = new GameObject("NotRaces_TransformFx"); val.transform.position = pos; float num = (small ? 0.55f : 1f); ParticleSystem val2 = MakeSystem(val.transform, "sparks", (int)(110f * num), new Vector2(0.5f, 1.2f), new Vector2(3f * scale, 10f * scale), new Vector2(0.12f * scale, 0.38f * scale), color, color2, -0.1f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.6f * scale; ParticleSystem val3 = MakeSystem(val.transform, "ring", (int)(90f * num), new Vector2(0.45f, 0.7f), new Vector2(9f * scale, 12f * scale), new Vector2(0.3f * scale, 0.55f * scale), color2, color, 0f); ((Component)val3).transform.localPosition = new Vector3(0f, -0.85f, 0f); ShapeModule shape2 = val3.shape; ((ShapeModule)(ref shape2)).enabled = true; ((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape2)).radius = 0.4f * scale; ((ShapeModule)(ref shape2)).radiusThickness = 0f; ((ShapeModule)(ref shape2)).rotation = new Vector3(90f, 0f, 0f); ParticleSystem obj = MakeSystem(val.transform, "swirl", (int)(70f * num), new Vector2(0.9f, 1.6f), new Vector2(0f, 0.5f), new Vector2(0.15f * scale, 0.3f * scale), color, Color.white, 0f); ((Component)obj).transform.localPosition = new Vector3(0f, -0.9f, 0f); ShapeModule shape3 = obj.shape; ((ShapeModule)(ref shape3)).enabled = true; ((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape3)).radius = 1.1f * scale; ((ShapeModule)(ref shape3)).radiusThickness = 0f; ((ShapeModule)(ref shape3)).rotation = new Vector3(90f, 0f, 0f); VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = new MinMaxCurve(4f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = new MinMaxCurve(-0.4f); MainModule main = obj.main; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.35f); val2.Play(); val3.Play(); obj.Play(); GameObject val4 = new GameObject("flash"); val4.transform.SetParent(val.transform, false); Light obj2 = val4.AddComponent<Light>(); obj2.type = (LightType)2; obj2.color = color; obj2.range = (small ? 6f : 10f) * scale; obj2.intensity = (small ? 3f : 6f); obj2.shadows = (LightShadows)0; val4.AddComponent<FadeLight>(); Object.Destroy((Object)(object)val, 3f); } catch (Exception e) { Util.LogOnce("transform-fx", e); } } internal static void Pulse(Vector3 pos, Color color, Color color2, float radius, int count, bool rising) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown if (NotRacesPlugin.Headless || !NotRacesPlugin.PassiveEffects.Value || (Object)(object)Glow == (Object)null) { return; } try { GameObject val = new GameObject("NotRaces_PassiveFx"); val.transform.position = pos; ParticleSystem obj = MakeSystem(val.transform, "pulse", count, rising ? new Vector2(0.8f, 1.3f) : new Vector2(0.5f, 0.9f), rising ? new Vector2(0.2f, 0.8f) : new Vector2(radius * 1.2f, radius * 1.8f), new Vector2(0.08f, 0.22f), color, color2, rising ? (-0.25f) : 0f); ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape)).radius = (rising ? Mathf.Max(0.4f, radius) : 0.3f); ((ShapeModule)(ref shape)).radiusThickness = (rising ? 1f : 0f); ((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f); obj.Play(); Object.Destroy((Object)val, 2f); } catch (Exception e) { Util.LogOnce("pulse-fx", e); } } } internal class FadeLight : MonoBehaviour { private Light m_light; private float m_start; private float m_time; private void Awake() { m_light = ((Component)this).GetComponent<Light>(); m_start = (((Object)(object)m_light != (Object)null) ? m_light.intensity : 0f); } private void Update() { if (!((Object)(object)m_light == (Object)null)) { m_time += Time.deltaTime; float num = m_time / 0.7f; m_light.intensity = Mathf.Lerp(m_start, 0f, num * num); if (num >= 1f) { ((Behaviour)m_light).enabled = false; } } } } public class NotRacesPlayer : MonoBehaviour { private enum RevertReason { Manual, Expired, Attached, Died, Silent } private struct PendingHit { public float Time; public int Index; public FormId Form; } internal static readonly int ZForm = StringExtensionMethods.GetStableHashCode("notraces_form"); internal static readonly int ZFly = StringExtensionMethods.GetStableHashCode("notraces_fly"); internal static readonly int ZHidden = StringExtensionMethods.GetStableHashCode("notraces_hidden"); private const string RpcAttack = "NotRaces_Attack"; internal static NotRacesPlayer Local; private ZNetView m_nview; private FormId m_shownForm; private bool m_firstSync = true; private Puppet m_puppet; private readonly List<Renderer> m_hidden = new List<Renderer>(); private static readonly List<Renderer> s_tmpRenderers = new List<Renderer>(); private float m_rescanTimer; private Vector3 m_lastPos; private Vector3 m_vel; private float m_lastYaw; private float m_turn; private float m_passiveFxTimer; private bool m_puppetHidden; internal bool WantPrimary; internal bool WantSecondary; private bool m_flying; private bool m_gliding; private bool m_safeFall; private flo