public static void AddHostEnemy(EnemyProgression ep) { if (!hostDictionary.ContainsKey(ep.entity.networkId.PackedValue)) { CotfUtils.Log("Adding enemy " + ep.entity.networkId.PackedValue + " : Level " + ep.Level + " " + ep.enemyType + " with " + ep.MaxHealth.ToString("N0") + " hp"); hostDictionary.Add(ep.entity.networkId.PackedValue, ep); } else { hostDictionary[ep.entity.networkId.PackedValue] = ep; } }
public override void Hit(int damage, bool ignoreArmor, DamageType type) { var hitEventContext = new COTFEvents.GotHitParams(damage, ignoreArmor); COTFEvents.Instance.OnGetHit.Invoke(hitEventContext); if (type == DamageType.Physical) { COTFEvents.Instance.OnGetHitPhysical.Invoke(hitEventContext); if (UnityEngine.Random.value > ModdedPlayer.Stats.getHitChance) { COTFEvents.Instance.OnDodge.Invoke(); if (ModdedPlayer.Stats.i_isWindArmor) { //grant buffs; BuffDB.AddBuff(5, 84, 1.2f, 30); BuffDB.AddBuff(9, 85, 1.35f, 10); BuffDB.AddBuff(15, 86, 2000, 10); HealthTarget += ModdedPlayer.Stats.TotalMaxHealth * 0.05f; } Sfx.PlayWhoosh(); return; } } else { COTFEvents.Instance.OnGetHitNonPhysical.Invoke(hitEventContext); } float f = damage * ModdedPlayer.Stats.allDamageTaken; if (!ignoreArmor) { f *= 1 - ModReferences.DamageReduction(Mathf.Max(0, ModdedPlayer.Stats.armor - (int)ModdedPlayer.instance.lostArmor)); } if (type == DamageType.Fire) { f *= 0.01f * ModdedPlayer.Stats.TotalMaxHealth; f *= UnityEngine.Random.Range(0.9f, 1.4f); //f *= 1-ModdedPlayer.Stats.magicDamageTaken; f *= ModdedPlayer.Stats.fireDamageTaken; } if (ModdedPlayer.Stats.i_KingQruiesSword) { BuffDB.AddBuff(22, 80, f, 1); } CotfUtils.Log("Tanked damage: " + f, true); base.Hit(damage, ignoreArmor, type); }
//Called from Initializer public static void Initialize() { _Item_Bases = new List <BaseItem>(); ItemBases = new Dictionary <int, BaseItem>(); statList = new List <ItemStat>(); Stats = new Dictionary <int, ItemStat>(); ItemRarityGroups = new Dictionary <int, List <int> >(); PopulateStats(); for (int i = 0; i < statList.Count; i++) { Stats.Add(statList[i].StatID, statList[i]); } try { PopulateItems(); } catch (System.Exception ex) { CotfUtils.Log("Error with item " + ex.ToString()); } ItemBases.Clear(); for (int i = 0; i < _Item_Bases.Count; i++) { try { ItemBases.Add(_Item_Bases[i].ID, _Item_Bases[i]); if (ItemRarityGroups.ContainsKey(_Item_Bases[i].Rarity)) { ItemRarityGroups[_Item_Bases[i].Rarity].Add(_Item_Bases[i].ID); } else { ItemRarityGroups.Add(_Item_Bases[i].Rarity, new List <int>() { _Item_Bases[i].ID }); } } catch (System.Exception ex) { ModAPI.Log.Write("Error with adding an item " + ex.ToString()); } } //LogInfo(); }
private void DoLoad(string path, out float HealthPercentage, out Dictionary <int, int> ExtraCarriedItems) { ExtraCarriedItems = new Dictionary <int, int>(); HealthPercentage = 1; try { byte[] bytes = File.ReadAllBytes(path); BinaryReader buf = new BinaryReader(new MemoryStream(bytes)); //reading in the same order to saving string version = buf.ReadString(); if (ModSettings.RequiresNewSave) { var ver = Res.ResourceLoader.CompareVersion(version, ModSettings.RequiresNewSaveVersion); if (ver == Res.ResourceLoader.Status.Newer) { CotfUtils.Log("last time cotf was played on this save was on version: " + version + " \ndue to issues with this and following updates, new save will be used. Sorry for inconvenience"); return; } } ModdedPlayer.instance.ExpCurrent = buf.ReadInt64(); //buf.Write(ModdedPlayer.instance.ExpCurrent); HealthPercentage = buf.ReadSingle(); //buf.Write(LocalPlayer.Stats.Health / ModdedPlayer.Stats.TotalMaxHealth); ModdedPlayer.instance.MutationPoints = buf.ReadInt32(); //buf.Write(ModdedPlayer.instance.MutationPoints); ModdedPlayer.instance.level = buf.ReadInt32(); //buf.Write(ModdedPlayer.instance.Level); ModdedPlayer.instance.AssignLevelAttributes(); ModdedPlayer.instance.PermanentBonusPerkPoints = buf.ReadInt32(); //buf.Write(ModdedPlayer.instance.PermanentBonusPerkPoints); ModdedPlayer.instance.LastDayOfGeneration = buf.ReadInt32(); //buf.Write(ModdedPlayer.instance.LastDayOfGeneration); ModdedPlayer.instance.ExpGoal = ModdedPlayer.instance.GetGoalExp(); //extra carried item amounts //key - ID of an item //value - amount at the moment of saving int ExtraItemCount = buf.ReadInt32(); //buf.Write(ModdedPlayer.instance.ExtraCarryingCapactity.Count); for (int i = 0; i < ExtraItemCount; i++) { int ID = buf.ReadInt32(); int AMOUNT = buf.ReadInt32(); ExtraCarriedItems.Add(ID, AMOUNT); } //loading inventory int ItemSlotCount = buf.ReadInt32(); for (int i = 0; i < ItemSlotCount; i++) { int Slot = buf.ReadInt32(); int ID = buf.ReadInt32(); if (ID != -1) { int LVL = buf.ReadInt32(); int AMO = buf.ReadInt32(); int StatCount = buf.ReadInt32(); Item LoadedItem = new Item(ItemDataBase.ItemBases[ID], AMO, 0, false) { level = LVL }; for (int a = 0; a < StatCount; a++) { int statID = buf.ReadInt32(); int statgroupID = buf.ReadInt32(); float statAMO = buf.ReadSingle(); ItemStat stat = new ItemStat(ItemDataBase.Stats[statID], 1, statgroupID) { Amount = statAMO }; LoadedItem.Stats.Add(stat); LoadedItem.SortStats(); } Inventory.Instance.ItemSlots[Slot] = LoadedItem; } else { Inventory.Instance.ItemSlots[Slot] = null; } } //loading perks int perkCount = buf.ReadInt32(); for (int i = 0; i < perkCount; i++) { int id = buf.ReadInt32(); bool isBought = buf.ReadBoolean(); int applyCount = buf.ReadInt32(); PerkDatabase.perks[id].isBought = isBought; try { if (isBought) { PerkDatabase.perks[id].boughtTimes = applyCount; if (applyCount == 0) { PerkDatabase.perks[id].isApplied = true; PerkDatabase.perks[id].apply(); } else { for (int a = 0; a < applyCount; a++) { PerkDatabase.perks[id].apply(); } PerkDatabase.perks[id].isApplied = true; } PerkDatabase.perks[id].OnBuy(); } } catch (System.Exception ex) { ModAPI.Log.Write($"Loading perks exception: id = {id}, isBought = {isBought}, applycount ={applyCount}\n" + ex); } } //loading bought spells int spellCount = buf.ReadInt32(); for (int i = 0; i < spellCount; i++) { int ID = buf.ReadInt32(); bool isBought = buf.ReadBoolean(); SpellDataBase.spellDictionary[ID].Bought = isBought; } //loading spell loadout int spellLoadoutCount = buf.ReadInt32(); for (int i = 0; i < spellLoadoutCount; i++) { int ID = buf.ReadInt32(); if (ID == -1) { SpellCaster.instance.infos[i].spell = null; } else { SpellCaster.instance.infos[i].spell = SpellDataBase.spellDictionary[ID]; SpellCaster.instance.infos[i].spell.EquippedSlot = i; } } ModdedPlayer.ReapplyAllSpell(); } catch (System.Exception ex) { ModAPI.Log.Write(ex.ToString()); } }
private void Setup() { try { if (BoltNetwork.isRunning) { if (entity == null) { entity = transform.root.GetComponentInChildren <BoltEntity>(); } if (entity == null) { entity = HealthScript.entity; } if (entity == null) { entity = transform.root.GetComponent <BoltEntity>(); } EnemyManager.AddHostEnemy(this); } if (!EnemyManager.enemyByTransform.ContainsKey(transform)) { EnemyManager.enemyByTransform.Add(this.transform, this); } } catch (Exception ex) { ModAPI.Log.Write(ex.ToString()); } //Assiging base health, if new enemy if (baseHealth == 0) { baseHealth = HealthScript.Health; } else //reverting health to base health if reused enemy (in case enemies are pooled) { HealthScript.Health = baseHealth; } StopAllCoroutines(); Steadfast = 100; slows = new Dictionary <int, EnemyDebuff>(); dmgTakenDebuffs = new Dictionary <int, EnemyDebuff>(); dmgDealtDebuffs = new Dictionary <int, EnemyDebuff>(); FireDamageDebuffs = new Dictionary <int, EnemyDebuff>(); DamageOverTimeList = new List <DoT>(); abilities = new List <Abilities>(); //picking abilities if ((UnityEngine.Random.value < 0.1 || (AIScript.creepy_boss && !AIScript.girlFullyTransformed) || ModSettings.difficulty == ModSettings.Difficulty.Hell) && enemyType != Enemy.Baby) { int abilityAmount = UnityEngine.Random.Range(3, 7); if (AIScript.creepy_boss) { abilityAmount = 10; } //Megan boss always has abilities, a lot of them. int i = 0; Array abilityArray = Enum.GetValues(typeof(Abilities)); //Determining if enemy is Elite, Miniboss or Boss type of enemy if (abilityAmount > 6 && Random.value < 0.3f) { _rarity = EnemyRarity.Boss; abilities.Add(Abilities.BossSteadfast); } else if (abilityAmount > 4 && Random.value < 0.3f) { abilities.Add(Abilities.EliteSteadfast); _rarity = EnemyRarity.Miniboss; } else { _rarity = EnemyRarity.Elite; } if (AIScript.creepy_boss && !AIScript.girlFullyTransformed) //Force adding BossSteadfast to Megan { abilities.Clear(); _rarity = EnemyRarity.Boss; abilities.Add(Abilities.BossSteadfast); } //Trial and error method of picking abilities while (i < abilityAmount) { bool canAdd = true; Abilities ab = (Abilities)abilityArray.GetValue(UnityEngine.Random.Range(0, abilityArray.Length)); if (ab == Abilities.Steadfast || ab == Abilities.EliteSteadfast || ab == Abilities.BossSteadfast) { if (abilities.Contains(Abilities.Steadfast) || abilities.Contains(Abilities.EliteSteadfast) || abilities.Contains(Abilities.BossSteadfast)) { canAdd = false; } } else if (ab == Abilities.Tiny || ab == Abilities.Huge) { if (AIScript.creepy_boss && ab == Abilities.Tiny) { canAdd = false; } else if (abilities.Contains(Abilities.Huge) || abilities.Contains(Abilities.Tiny)) { canAdd = false; } } else if (ab == Abilities.Undead && !(AIScript.creepy || AIScript.creepy_fat)) { canAdd = false; } if (abilities.Contains(ab)) { canAdd = false; } if (canAdd) { i++; abilities.Add(ab); } } } else { _rarity = EnemyRarity.Normal; } SetType(); SetLevel(); RollName(); //Assigning rest of stats int dif = (int)ModSettings.difficulty; DamageMult = Mathf.Pow(Level, 3.5f) / 100f + 0.4f; DamageMult *= dif * 2f + 1; Armor = Mathf.FloorToInt(Random.Range(Mathf.Pow(Level, 2.4f) * 0.36f + 1, Mathf.Pow(Level, 2.45f) + 20) * ModSettings.EnemyArmorMultiplier); Armor *= dif / 2 + 1; ArmorReduction = 0; extraHealth = (HealthScript.Health * Mathf.Pow((float)Level, 2.215f + (dif * 0.19f)) / 16); extraHealth *= dif / 2 + 1; AnimSpeed = 0.94f + (float)Level / 190; extraHealth *= ModSettings.EnemyHealthMultiplier; DamageMult *= ModSettings.EnemyDamageMultiplier; AnimSpeed *= ModSettings.EnemySpeedMultiplier; if (_rarity != EnemyRarity.Normal) { Armor *= 2; } //Extra health for boss type enemies switch (_rarity) { case EnemyRarity.Elite: extraHealth *= 2; break; case EnemyRarity.Miniboss: extraHealth *= 5; break; case EnemyRarity.Boss: extraHealth *= 10; if (!abilities.Contains(Abilities.Tiny)) { gameObject.transform.localScale *= 1.1f; } break; } extraHealth *= (float)(dif * 0.25f + 0.75f); if (dif > 3) { extraHealth *= 2.15f; } if (dif > 6) { extraHealth *= 3.4f; } //Applying some abilities if (abilities.Contains(Abilities.Huge)) { Armor *= 2; gameObject.transform.localScale *= 2; extraHealth *= 2; DamageMult *= 2; AnimSpeed /= 1.6f; } else if (abilities.Contains(Abilities.Tiny)) { gameObject.transform.localScale *= 0.35f; AnimSpeed *= 1.1f; DamageMult *= 1.2f; BroadcastMessage("SetTriggerScaleForTiny", SendMessageOptions.DontRequireReceiver); } if (abilities.Contains(Abilities.Steadfast)) { Steadfast = 5; } if (abilities.Contains(Abilities.EliteSteadfast)) { Steadfast = 2f; } if (abilities.Contains(Abilities.BossSteadfast)) { Steadfast = 0.25f; } if (abilities.Contains(Abilities.ExtraHealth)) { extraHealth *= 3; } if (abilities.Contains(Abilities.ExtraDamage)) { DamageMult *= 4f; } if (abilities.Contains(Abilities.RainEmpowerement)) { prerainDmg = DamageMult; prerainArmor = Armor; } if (abilities.Contains(Abilities.Juggernaut)) { CCimmune = true; AnimSpeed /= 1.15f; } if (abilities.Contains(Abilities.Avenger)) { if (avengerability == null) { avengerability = gameObject.AddComponent <Avenger>(); } avengerability.progression = this; avengerability.Stacks = 0; } else if (avengerability != null) { Destroy(avengerability); } if (abilities.Contains(Abilities.FireAura)) { float aurDmg = (5 * Level + 1) * ((int)ModSettings.difficulty + 1.3f); FireAura.Cast(gameObject, aurDmg); if (BoltNetwork.isRunning) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(8); w.Write(2); w.Write(entity.networkId.PackedValue); w.Write(aurDmg); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Clients); answerStream.Close(); } } InvokeRepeating("SendFireAura", 20, 30); } else { var aura = gameObject.GetComponent <FireAura>(); if (aura != null) { Destroy(aura); } } //Clamping Health try { maxHealth = extraHealth; HealthScript.maxHealthFloat = extraHealth; Armor = Mathf.Min(Armor, int.MaxValue - 5); if (Armor < 0) { Armor = int.MaxValue; } //Setting other health variables HealthScript.maxHealth = Mathf.RoundToInt(Mathf.Min(extraHealth, int.MaxValue - 5)); HealthScript.Health = Mathf.RoundToInt(Mathf.Min(extraHealth, int.MaxValue - 5)); extraHealth -= HealthScript.Health; DebuffDmgMult = DamageMult; DualLifeSpend = false; setupComplete = true; OnDieCalled = false; BaseDamageMult = DamageMult; BaseAnimSpeed = AnimSpeed; } catch (Exception e) { ModAPI.Log.Write(e.ToString()); CotfUtils.Log(e.Message); } AssignBounty(); SteadfastCap = Mathf.Max(Steadfast * 0.01f * maxHealth, 1f); if (SteadfastCap < 1) // Making sure the enemy can be killed { SteadfastCap = 1; } CreationTime = Time.time; if (BoltNetwork.isRunning) { ulong id = entity.networkId.PackedValue; using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(30); w.Write(id); w.Write(BaseDamageMult); foreach (Abilities ability in abilities) { w.Write((int)ability); } w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Clients); answerStream.Close(); } } }
private void Setup() { try { if (BoltNetwork.isRunning) { if (entity == null) { entity = transform.root.GetComponentInChildren <BoltEntity>(); } if (entity == null) { entity = HealthScript.entity; } if (entity == null) { entity = transform.root.GetComponent <BoltEntity>(); } EnemyManager.AddHostEnemy(this); } if (!EnemyManager.enemyByTransform.ContainsKey(transform)) { EnemyManager.enemyByTransform.Add(this.transform, this); } } catch (Exception ex) { ModAPI.Log.Write(ex.ToString()); } //Assiging base health, if new enemy if (baseHealth == 0) { baseHealth = HealthScript.Health; } else //reverting health to base health if reused enemy (in case enemies are pooled) { HealthScript.Health = baseHealth; } StopAllCoroutines(); Steadfast = 100; slows = new Dictionary <int, EnemyDebuff>(); dmgTakenDebuffs = new Dictionary <int, EnemyDebuff>(); dmgDealtDebuffs = new Dictionary <int, EnemyDebuff>(); FireDamageDebuffs = new Dictionary <int, EnemyDebuff>(); DamageOverTimeList = new List <DoT>(); abilities = new List <Abilities>(); bool isElite = (Random.value < 0.1 || (AIScript.creepy_boss && !AIScript.girlFullyTransformed) || ModSettings.difficulty == ModSettings.Difficulty.Hell) && ModSettings.AllowElites; SetType(ref isElite); //picking abilities if (isElite) { int abilityAmount = (int)ModSettings.difficulty > (int)ModSettings.Difficulty.Veteran ? Random.Range(3, 7) : 2; if (AIScript.creepy_boss) { abilityAmount = 10; } //Megan boss always has abilities, a lot of them. int i = 0; Array abilityArray = Enum.GetValues(typeof(Abilities)); //Determining if enemy is Elite, Miniboss or Boss type of enemy if (abilityAmount > 6 && Random.value < 0.1f) { _rarity = EnemyRarity.Boss; abilities.Add(Abilities.BossSteadfast); } else if (abilityAmount > 4 && Random.value < 0.25f) { abilities.Add(Abilities.EliteSteadfast); _rarity = EnemyRarity.Miniboss; } else { _rarity = EnemyRarity.Elite; } if (AIScript.creepy_boss && !AIScript.girlFullyTransformed) //Force adding BossSteadfast to Megan { abilities.Clear(); _rarity = EnemyRarity.Boss; abilities.Add(Abilities.BossSteadfast); } //Trial and error method of picking abilities while (i < abilityAmount) { bool canAdd = true; Abilities ab = (Abilities)abilityArray.GetValue(Random.Range(0, abilityArray.Length)); if (ab == Abilities.Steadfast || ab == Abilities.EliteSteadfast || ab == Abilities.BossSteadfast) { if (abilities.Contains(Abilities.Steadfast) || abilities.Contains(Abilities.EliteSteadfast) || abilities.Contains(Abilities.BossSteadfast)) { canAdd = false; } } else if (ab == Abilities.Tiny || ab == Abilities.Gargantuan) { if (AIScript.creepy_boss && ab == Abilities.Tiny) { canAdd = false; } else if (abilities.Contains(Abilities.Gargantuan) || abilities.Contains(Abilities.Tiny)) { canAdd = false; } } else if (ab == Abilities.Undead && !(AIScript.creepy || AIScript.creepy_fat)) { canAdd = false; } else if (ab == Abilities.ArcaneCataclysm || ab == Abilities.BlackHole || ab == Abilities.FireCataclysm || ab == Abilities.Meteor) { if ((int)ModSettings.difficulty < (int)ModSettings.Difficulty.Master) { canAdd = false; } } if (abilities.Contains(ab)) { canAdd = false; } if (canAdd) { i++; abilities.Add(ab); } } } else { _rarity = EnemyRarity.Normal; } SetLevel(); RollName(isElite); setupDifficulty = ModSettings.difficulty; //Assigning rest of stats int dif = (int)setupDifficulty; DamageMult = level < 67 ? ((31f - 0.286f * (level - 20f)) * (level - 5f) + 3.5f) * (level - 1f) + 11 : Mathf.Pow(level - 60, 2.61f) * 600; armor = Mathf.FloorToInt(Random.Range(Mathf.Pow(level, 2.4f) * 0.36f + 1, Mathf.Pow(level, 2.45f) + 20) * ModSettings.EnemyArmorMultiplier); armor *= dif / 2 + 1; armorReduction = 0; extraHealth = (Mathf.Sqrt(HealthScript.Health) + 40) * Mathf.Pow(level, 2.22f) / 6f; extraHealth *= (level / 50) + 0.4f; AnimSpeed = 0.93f + (float)level / 175; HealthScript.Health = int.MaxValue; extraHealth *= ModSettings.EnemyHealthMultiplier; DamageMult *= ModSettings.EnemyDamageMultiplier; AnimSpeed *= ModSettings.EnemySpeedMultiplier; if (_rarity != EnemyRarity.Normal) { armor *= 2; } //Extra health for boss type enemies switch (_rarity) { case EnemyRarity.Elite: extraHealth *= 5; break; case EnemyRarity.Miniboss: extraHealth *= 10; break; case EnemyRarity.Boss: extraHealth *= 20; if (!abilities.Contains(Abilities.Tiny)) { gameObject.transform.localScale *= 1.1f; } break; } if (level > 25) { extraHealth *= 2.15f; } if (level > 50) { extraHealth *= 2f; } if (level > 100) { extraHealth *= 3.4f; } if (level > 200) { extraHealth *= 2.5f; } if (level > 300) { extraHealth *= 3.2f; } //Applying some abilities if (abilities.Contains(Abilities.Gargantuan)) { armor *= 3; extraHealth *= 2.5f; DamageMult *= 2.5f; AnimSpeed /= 1.5f; BroadcastMessage("SetTriggerScale", 2.5f, SendMessageOptions.DontRequireReceiver); } else if (abilities.Contains(Abilities.Tiny)) { AnimSpeed *= 1.1f; DamageMult *= 1.2f; BroadcastMessage("SetTriggerScale", 5f, SendMessageOptions.DontRequireReceiver); } else { BroadcastMessage("SetTriggerScale", 1.6f, SendMessageOptions.DontRequireReceiver); } if (abilities.Contains(Abilities.Steadfast)) { Steadfast = 6; armor *= 2; } if (abilities.Contains(Abilities.EliteSteadfast)) { Steadfast = 4f; armor *= 2; } if (abilities.Contains(Abilities.BossSteadfast)) { Steadfast = 1f; armor *= 2; } if (abilities.Contains(Abilities.ExtraHealth)) { extraHealth *= 4; } if (abilities.Contains(Abilities.ExtraDamage)) { DamageMult *= 5f; } if (abilities.Contains(Abilities.RainEmpowerment)) { prerainDmg = DamageMult; prerainArmor = armor; } if (abilities.Contains(Abilities.Juggernaut)) { CCimmune = true; AnimSpeed /= 1.15f; } if (abilities.Contains(Abilities.Avenger)) { if (avengerability == null) { avengerability = gameObject.AddComponent <Avenger>(); } avengerability.progression = this; avengerability.Stacks = 0; } else if (avengerability != null) { Destroy(avengerability); } if (abilities.Contains(Abilities.Radiance)) { float aurDmg = DamageMult / 20; FireAura.Cast(gameObject, aurDmg); if (BoltNetwork.isRunning) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(8); w.Write(2); w.Write(entity.networkId.PackedValue); w.Write(aurDmg); } Network.NetworkManager.SendLine(answerStream.ToArray(), Network.NetworkManager.Target.Clients); answerStream.Close(); } } InvokeRepeating("SendFireAura", 20, 30); } else { var aura = gameObject.GetComponent <FireAura>(); if (aura != null) { Destroy(aura); } } //Clamping Health try { maxHealth = extraHealth; HealthScript.maxHealthFloat = maxHealth; HealthScript.Health = (int)Mathf.Min(maxHealth, int.MaxValue); extraHealth = Mathf.Max(0, maxHealth - HealthScript.Health); ClampHealth(); armor = Mathf.Min(armor, int.MaxValue - 5); if (armor < 0) { armor = int.MaxValue; } DebuffDmgMult = 1; DualLifeSpend = false; setupComplete = true; OnDieCalled = false; BaseDamageMult = Mathf.Abs(DamageMult); BaseAnimSpeed = AnimSpeed; knockbackSpeed = 0; } catch (Exception e) { CotfUtils.Log(e.Message); } AssignBounty(); steadfastCap = Mathf.Max(Steadfast * 0.01f * maxHealth, 1f); if (steadfastCap < 1) // Making sure the enemy can be killed { steadfastCap = 1; } CreationTime = Time.time; if (BoltNetwork.isRunning) { ulong id = entity.networkId.PackedValue; color = normalColor; SyncAppearance(id); } }