protected override void Start() { if (ModSettings.IsDedicated) { base.Start(); return; } BaseDmg = damage; base.Start(); float dmg = (BaseDmg + ModdedPlayer.instance.RangedDamageBonus) * ModdedPlayer.instance.RangedAMP * ModdedPlayer.instance.CritDamageBuff; if (crossbowBoltType) { dmg = dmg * ModdedPlayer.instance.CrossbowDamageMult; } else if (flintLockAmmoType) { dmg = dmg * ModdedPlayer.instance.BulletDamageMult; } else if (spearType) { dmg = dmg * ModdedPlayer.instance.SpearDamageMult; } else //if arrow { dmg = dmg * ModdedPlayer.instance.BowDamageMult; } DamageMath.DamageClamp(dmg, out damage, out Repetitions); }
void HitEnemeyDelayed() { DamageMath.DamageClamp(ModdedPlayer.instance.thornsDamage, out int dmg, out int reps); for (int i = 0; i < reps; i++) { EnemyProg._Health.Hit(dmg); } }
private void OnTriggerEnter(Collider other) { if (!setupComplete) { } //if (other.gameObject.CompareTag("PlayerNet")) //{ // if (!ModSettings.FriendlyFire) // { // return; // } // BoltEntity component3 = other.GetComponent<BoltEntity>(); // if (component3 != null && component3.networkId.PackedValue != casterID) // { // if (BoltNetwork.isRunning) // { // ModdedPlayer.instance.DoOnHit(); // ModdedPlayer.instance.DoMeleeOnHit(); // HitPlayer hitPlayer = HitPlayer.Create(component3, EntityTargets.Everyone); // hitPlayer.damage = Mathf.FloorToInt(Damage); // hitPlayer.Send(); // return; // } // } //} if (other.gameObject.CompareTag("enemyCollide")) { if (!GameSetup.IsMpClient) { EnemyProgression prog = other.GetComponentInParent <EnemyProgression>(); if (prog != null) { DamageMath.DamageClamp(Damage, out int d, out int a); for (int i = 0; i < a; i++) { prog.HitMagic(d); } float slowAmount = 0.35f; if (GiveDoubleSlow) { slowAmount *= 2; } prog.Slow(41, 1 - slowAmount, DebuffDuration); if (GiveDmgDebuff) { prog.DmgTakenDebuff(41, 1.15f, DebuffDuration); } } } } }
public static void Create(Vector3 position, Vector3 speed, float damage, uint id) { GameObject o = GameObject.Instantiate(prefab, position, Quaternion.identity); o.tag = "enemyCollide"; BallLightning b = o.AddComponent <BallLightning>(); DamageMath.DamageClamp(damage, out int dmg, out int rep); b.dmg = dmg; b.rep = rep; b.ID = id; b.speed = speed; list.Add(id, b); }
public static void HostAction(Vector3 pos, float dist, float slowMultipier, float duration, float damage) { var hits = Physics.SphereCastAll(pos, dist, Vector3.one); for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.CompareTag("enemyCollide")) { var prog = hits[i].transform.gameObject.GetComponentInParent <EnemyProgression>(); prog?.Slow(20, slowMultipier, duration); DamageMath.DamageClamp(damage, out int dmg, out int rep); for (int a = 0; a < rep; a++) { prog?.HitMagic(dmg); } } } }
public void DoGuaranteedAreaDamage(Transform rootTR, float damage) { RaycastHit[] hits = Physics.SphereCastAll(rootTR.position, stats.areaDamageRadius, Vector3.one, stats.areaDamageRadius, -9); var d = damage * stats.areaDamage; if (d > 0) { for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.root != rootTR.root) { if (hits[i].transform.tag == "enemyCollide") { if (GameSetup.IsMpClient) { BoltEntity entity = hits[i].transform.GetComponent <BoltEntity>(); if (entity == null) { entity = hits[i].transform.GetComponentInParent <BoltEntity>(); } if (entity != null) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Hit = DamageMath.GetSendableDamage(d); playerHitEnemy.getAttackerType = DamageMath.SILENTattackerType; //silent hit playerHitEnemy.Target = entity; playerHitEnemy.Send(); } } else { hits[i].transform.root.SendMessage("Hit", d, SendMessageOptions.DontRequireReceiver); } } else if (hits[i].transform.tag == "BreakableWood" || hits[i].transform.tag == "animalCollide") { hits[i].transform.root.SendMessage("Hit", d, SendMessageOptions.DontRequireReceiver); } } } } }
public static void HostAction(Vector3 pos, float dist, float slowMultipier, float duration, float damage) { RaycastHit[] hits = Physics.SphereCastAll(pos, dist, Vector3.one, -10); DamageMath.DamageClamp(damage, out int dmg, out int rep); for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.CompareTag("enemyCollide")) { EnemyProgression prog = hits[i].transform.gameObject.GetComponentInParent <EnemyProgression>(); prog?.Slow(20, slowMultipier, duration); for (int a = 0; a < rep; a++) { prog?.HitMagic(dmg); } if (prog == null) { hits[i].transform.SendMessageUpwards("HitMagic", dmg, SendMessageOptions.DontRequireReceiver); } } } }
private void OnTriggerEnter(Collider other) { if (!setupComplete) { } if (other.gameObject.CompareTag("enemyCollide")) { if (!GameSetup.IsMpClient) { EnemyProgression prog = other.GetComponentInParent <EnemyProgression>(); DamageMath.DamageClamp(Damage, out int d, out int a); if (prog != null) { for (int i = 0; i < a; i++) { prog.HitMagic(d); } float slowAmount = 0.45f; if (GiveDoubleSlow) { slowAmount *= 2; } prog.Slow(41, 1 - slowAmount, DebuffDuration); if (GiveDmgDebuff) { prog.DmgTakenDebuff(41, 1.25f, DebuffDuration); } } else { other.SendMessageUpwards("HitMagic", d, SendMessageOptions.DontRequireReceiver); } } } }
public static void DoBlink() { blinkAim?.Disable(); Transform t = Camera.main.transform; Vector3 blinkPoint = Vector3.zero; var hits1 = Physics.RaycastAll(t.position, t.forward, ModdedPlayer.Stats.spell_blinkRange + 1f); foreach (var hit in hits1) { if (!hit.transform.CompareTag("enemyCollide") && hit.transform.root != LocalPlayer.Transform.root) { blinkPoint = hit.point - t.forward + Vector3.up * 0.25f; break; } } if (blinkPoint == Vector3.zero) { blinkPoint = LocalPlayer.Transform.position + t.forward * ModdedPlayer.Stats.spell_blinkRange; } if (ModdedPlayer.Stats.spell_blinkDamage > 0) { RaycastHit[] hits = Physics.BoxCastAll(t.position, Vector3.one * 1.2f, blinkPoint - t.position, t.rotation, Vector3.Distance(blinkPoint, t.position) + 1); foreach (RaycastHit hit in hits) { if (hit.transform.CompareTag("enemyCollide")) { ModAPI.Console.Write("Hit enemy on layer " + hit.transform.gameObject.layer); float dmg = ModdedPlayer.Stats.spell_blinkDamage + ModdedPlayer.Stats.spellFlatDmg * ModdedPlayer.Stats.spell_blinkDamageScaling; dmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; if (GameSetup.IsMpClient) { BoltEntity enemyEntity = hit.transform.GetComponentInParent <BoltEntity>(); if (enemyEntity == null) { enemyEntity = hit.transform.gameObject.GetComponent <BoltEntity>(); } if (enemyEntity != null) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(enemyEntity); playerHitEnemy.hitFallDown = true; playerHitEnemy.getAttackerType = DamageMath.CONVERTEDFLOATattackerType; playerHitEnemy.Hit = DamageMath.GetSendableDamage(dmg); playerHitEnemy.Send(); } } else { if (EnemyManager.enemyByTransform.ContainsKey(hit.transform.root)) { EnemyManager.enemyByTransform[hit.transform.root].HitMagic(dmg); } else { hit.transform.SendMessageUpwards("HitMagic", dmg, SendMessageOptions.DontRequireReceiver); } } } } } if (ModdedPlayer.Stats.spell_blinkDoExplosion) { Effects.Sound_Effects.GlobalSFX.Play(Effects.Sound_Effects.GlobalSFX.SFX.Boom); var raycastHitExplosion = Physics.OverlapSphere(blinkPoint, (blinkPoint - t.position).magnitude / 4f); float dmg = ModdedPlayer.Stats.spell_blinkDamage + LocalPlayer.Rigidbody.velocity.magnitude * ModdedPlayer.Stats.spellFlatDmg * ModdedPlayer.Stats.spell_blinkDamageScaling / 7f; dmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier * ModdedPlayer.Stats.RandomCritDamage; foreach (var hitCollider in raycastHitExplosion) { if (hitCollider.transform.CompareTag("enemyCollide")) { if (GameSetup.IsMpClient) { BoltEntity enemyEntity = hitCollider.transform.GetComponentInParent <BoltEntity>(); if (enemyEntity == null) { enemyEntity = hitCollider.transform.gameObject.GetComponent <BoltEntity>(); } if (enemyEntity != null) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(enemyEntity); playerHitEnemy.hitFallDown = true; playerHitEnemy.getAttackerType = DamageMath.CONVERTEDFLOATattackerType; playerHitEnemy.Hit = DamageMath.GetSendableDamage(dmg); playerHitEnemy.Send(); } } else { if (EnemyManager.enemyByTransform.ContainsKey(hitCollider.transform.root)) { EnemyManager.enemyByTransform[hitCollider.transform.root].HitMagic(dmg); } else { hitCollider.transform.SendMessageUpwards("HitMagic", dmg, SendMessageOptions.DontRequireReceiver); } } } } } BlinkTowards(blinkPoint); }
public static void OnCommand(byte[] bytes) { using (MemoryStream stream = new MemoryStream(bytes)) { using (BinaryReader r = new BinaryReader(stream)) { int cmdIndex = r.ReadInt32(); if (cmdIndex == 1) //previousely AB { if (GameSetup.IsMpServer && ModSettings.DifficultyChoosen) { using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(2); w.Write((int)ModSettings.difficulty); w.Write(ModSettings.FriendlyFire); w.Write((int)ModSettings.dropsOnDeath); w.Write(ModSettings.killOnDowned); w.Close(); } Network.NetworkManager.SendLine(answerStream.ToArray(), Network.NetworkManager.Target.Clients); answerStream.Close(); } } } else if (cmdIndex == 2) //request for the what is the difficulty { if (!GameSetup.IsMpClient || ModSettings.IsDedicated) { return; } int index = r.ReadInt32(); ModSettings.FriendlyFire = r.ReadBoolean(); ModSettings.dropsOnDeath = (ModSettings.DropsOnDeathMode)r.ReadInt32(); ModSettings.killOnDowned = r.ReadBoolean(); Array values = Enum.GetValues(typeof(ModSettings.Difficulty)); ModSettings.difficulty = (ModSettings.Difficulty)values.GetValue(index); if (!ModSettings.DifficultyChoosen) { LocalPlayer.FpCharacter.UnLockView(); LocalPlayer.FpCharacter.MovementLocked = false; } ModSettings.DifficultyChoosen = true; } else if (cmdIndex == 3) //spell casted { int spellid = r.ReadInt32(); if (spellid == 1) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); BlackHole.CreateBlackHole(pos, r.ReadBoolean(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadString()); } else if (spellid == 2) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); HealingDome.CreateHealingDome(pos, r.ReadSingle(), r.ReadSingle(), r.ReadBoolean(), r.ReadBoolean(), r.ReadSingle()); } else if (spellid == 3) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); DarkBeam.Create(pos, r.ReadBoolean(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } else if (spellid == 4) { bool isOn = r.ReadBoolean(); string packed = r.ReadString(); BlackFlame.ToggleOtherPlayer(packed, isOn); } else if (spellid == 5) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float radius = r.ReadSingle(); float speed = r.ReadSingle(); float dmg = r.ReadSingle(); bool GiveDmg = r.ReadBoolean(); bool GiveAr = r.ReadBoolean(); int ar = 0; if (GiveAr) { ar = r.ReadInt32(); } WarCry.Cast(pos, radius, speed, dmg, GiveDmg, GiveAr, ar); } else if (spellid == 6) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float duration = r.ReadSingle(); int id = r.ReadInt32(); Portal.CreatePortal(pos, duration, id, r.ReadBoolean(), r.ReadBoolean()); } else if (spellid == 7) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); Vector3 dir = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float dmg = r.ReadSingle(); string caster = r.ReadString(); float duration = r.ReadSingle(); bool slow = r.ReadBoolean(); bool dmgdebuff = r.ReadBoolean(); if (GameSetup.IsMpServer) { MagicArrow.Create(pos, dir, dmg, caster, duration, slow, dmgdebuff); } else { MagicArrow.CreateEffect(pos, dir, dmgdebuff, duration); } } else if (spellid == 8) { Purge.Cast(new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()), r.ReadSingle(), r.ReadBoolean(), r.ReadBoolean()); } else if (spellid == 9) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float dist = r.ReadSingle(); SnapFreeze.CreateEffect(pos, dist); if (!GameSetup.IsMpClient) { SnapFreeze.HostAction(pos, dist, r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } } else if (spellid == 10) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); Vector3 speed = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float dmg = r.ReadSingle(); uint id = r.ReadUInt32(); if (BallLightning.lastID < id) { BallLightning.lastID = id; } BallLightning.Create(pos, speed, dmg, id); } else if (spellid == 11) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float radius = r.ReadSingle(); float dmg = r.ReadSingle(); float duration = r.ReadSingle(); bool isArcane = r.ReadBoolean(); bool fromEnemy = r.ReadBoolean(); Cataclysm.Create(pos, radius, dmg, duration, isArcane ? Cataclysm.TornadoType.Arcane : Cataclysm.TornadoType.Fire, fromEnemy); } else if (spellid == 12) { //a request from a client to a host to spawn a ball lightning. The host assigns the id of //a ball lightning to not create overlapping ids using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(3); w.Write(10); w.Write(r.ReadSingle()); w.Write(r.ReadSingle()); w.Write(r.ReadSingle()); w.Write(r.ReadSingle()); w.Write(r.ReadSingle()); w.Write(r.ReadSingle()); w.Write(r.ReadSingle()); w.Write((uint)(BallLightning.lastID + 1)); w.Close(); BallLightning.lastID++; } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Everyone); answerStream.Close(); } } else if (spellid == 13) //parry was casted by a client { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float radius = r.ReadSingle(); bool ignite = r.ReadBoolean(); float dmg = r.ReadSingle(); DamageMath.DamageClamp(dmg, out int d, out int rep); var hits = Physics.SphereCastAll(pos, radius, Vector3.one); for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.CompareTag("enemyCollide")) { for (int a = 0; a < rep; a++) { hits[i].transform.SendMessageUpwards("Hit", d, SendMessageOptions.DontRequireReceiver); if (ignite) { hits[i].transform.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } } } } } } else if (cmdIndex == 4) //remove item { PickUpManager.RemovePickup(r.ReadUInt64()); } else if (cmdIndex == 5) //create item { Item item = new Item(ItemDataBase.ItemBases[r.ReadInt32()], 1, 0, false); //reading first value, id ulong id = r.ReadUInt64(); item.level = r.ReadInt32(); int amount = r.ReadInt32(); Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); while (r.BaseStream.Position != r.BaseStream.Length) { ItemStat stat = new ItemStat(ItemDataBase.Stats[r.ReadInt32()]) { Amount = r.ReadSingle() }; item.Stats.Add(stat); } PickUpManager.SpawnPickUp(item, pos, amount, id); } else if (cmdIndex == 6) //host has been asked to share info on enemy { if (!GameSetup.IsMpClient) { ulong packed = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(packed)) { EnemyProgression ep = EnemyManager.hostDictionary[packed]; using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(7); w.Write(packed); w.Write(ep.EnemyName); w.Write(ep.Level); w.Write(ep._hp + ep._Health.Health); w.Write(ep.MaxHealth); w.Write(ep.bounty); w.Write(ep.Armor); w.Write(ep.ArmorReduction); w.Write(ep.Steadfast); w.Write(ep.abilities.Count); foreach (EnemyProgression.Abilities item in ep.abilities) { w.Write((int)item); } w.Close(); } Network.NetworkManager.SendLine(answerStream.ToArray(), Network.NetworkManager.Target.Clients); answerStream.Close(); } } else { CotfUtils.Log("no enemy in host's dictionary"); } } } else if (cmdIndex == 7) //host answered info about a enemy and the info is processed { if (ModSettings.IsDedicated) { return; } if (GameSetup.IsMpClient) { ulong packed = r.ReadUInt64(); if (!EnemyManager.allboltEntities.ContainsKey(packed)) { EnemyManager.GetAllEntities(); } if (EnemyManager.allboltEntities.ContainsKey(packed)) { BoltEntity entity = EnemyManager.allboltEntities[packed]; string name = r.ReadString(); int level = r.ReadInt32(); float health = r.ReadSingle(); float maxhealth = r.ReadSingle(); long bounty = r.ReadInt64(); int armor = r.ReadInt32(); int armorReduction = r.ReadInt32(); float steadfast = r.ReadSingle(); int length = r.ReadInt32(); int[] affixes = new int[length]; for (int i = 0; i < length; i++) { affixes[i] = r.ReadInt32(); } if (EnemyManager.clinetProgressions.ContainsKey(entity)) { ClinetEnemyProgression cp = EnemyManager.clinetProgressions[entity]; cp.creationTime = Time.time; cp.Entity = entity; cp.Level = level; cp.Health = health; cp.MaxHealth = maxhealth; cp.Armor = armor; cp.ArmorReduction = armorReduction; cp.EnemyName = name; cp.ExpBounty = bounty; cp.Steadfast = steadfast; cp.Affixes = affixes; } else { new ClinetEnemyProgression(entity, name, level, health, maxhealth, bounty, armor, armorReduction, steadfast, affixes); } } } } else if (cmdIndex == 8) //enemy spell casted { int id = r.ReadInt32(); if (id == 1) //snow aura { ulong packed = r.ReadUInt64(); SnowAura sa = new GameObject("Snow").AddComponent <SnowAura>(); if (!EnemyManager.allboltEntities.ContainsKey(packed)) { EnemyManager.GetAllEntities(); } sa.followTarget = EnemyManager.allboltEntities[packed].transform; } else if (id == 2) //fire aura { ulong packed = r.ReadUInt64(); float dmg = r.ReadSingle(); GameObject go = EnemyManager.allboltEntities[packed].gameObject; FireAura.Cast(go, dmg); } } else if (cmdIndex == 9) //poison Player { string playerID = r.ReadString(); if (ModReferences.ThisPlayerID == playerID) { int source = r.ReadInt32(); float amount = r.ReadSingle(); float duration = r.ReadSingle(); BuffDB.AddBuff(3, source, amount, duration); } } else if (cmdIndex == 10) //kill experience { ModdedPlayer.instance.AddKillExperience(r.ReadInt64()); } else if (cmdIndex == 11) //add experience without massacre { ModdedPlayer.instance.AddFinalExperience(r.ReadInt64()); } else if (cmdIndex == 12) //root the player { if (ModdedPlayer.instance.RootImmune == 0 && ModdedPlayer.instance.StunImmune == 0) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); if ((LocalPlayer.Transform.position - pos).sqrMagnitude < 1250) { float duration = r.ReadSingle(); ModdedPlayer.instance.Root(duration); using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(14); w.Write(LocalPlayer.Transform.position.x); w.Write(LocalPlayer.Transform.position.y); w.Write(LocalPlayer.Transform.position.z); w.Write(duration); w.Close(); } NetworkManager.SendLine(answerStream.ToArray(), NetworkManager.Target.Everyone); answerStream.Close(); } } } } else if (cmdIndex == 13) //stun the player { if (ModSettings.IsDedicated) { return; } if (ModdedPlayer.instance.StunImmune == 0) { string playerID = r.ReadString(); if (ModReferences.ThisPlayerID == playerID) { float duration = r.ReadSingle(); ModdedPlayer.instance.Stun(duration); } } } else if (cmdIndex == 14) //player has been chained, now spawn effect { if (ModSettings.IsDedicated) { return; } Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float duration = r.ReadSingle(); RootSpell.Create(pos, duration); } else if (cmdIndex == 15) //create trap sphere { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); float duration = r.ReadSingle(); float radius = r.ReadSingle(); TrapSphereSpell.Create(pos, radius, duration); } else if (cmdIndex == 16) //create enemy laser, aka plasma cannon { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); Vector3 dir = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); EnemyLaser.CreateLaser(pos, dir); } else if (cmdIndex == 17) //create enemy meteor rain { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); Meteor.CreateEnemy(pos, r.ReadInt32()); } else if (cmdIndex == 18) //player's level info, or command to wipe level data { if (r.BaseStream.Position == r.BaseStream.Length) { ModReferences.PlayerLevels.Clear(); } using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(19); w.Write(ModReferences.ThisPlayerID); w.Write(ModdedPlayer.instance.Level); w.Close(); } Network.NetworkManager.SendLine(answerStream.ToArray(), NetworkManager.Target.Others); answerStream.Close(); } } else if (cmdIndex == 19)//add or update some players level to list { string packed = r.ReadString(); int level = r.ReadInt32(); if (ModReferences.PlayerLevels.ContainsKey(packed)) { ModReferences.PlayerLevels[packed] = level; } else { ModReferences.PlayerLevels.Add(packed, level); } } else if (cmdIndex == 20) //enemy hitmarker { if (ModSettings.IsDedicated) { return; } int amount = r.ReadInt32(); Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); Color c = new Color(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); MainMenu.CreateHitMarker(amount, pos, c); } else if (cmdIndex == 21) //player hitmarker { if (ModSettings.IsDedicated) { return; } int amount = r.ReadInt32(); Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); new MainMenu.HitMarker(amount, pos, true); } else if (cmdIndex == 22) //slow Enemy { if (GameSetup.IsMpServer || GameSetup.IsSinglePlayer) { ulong id = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(id)) { float amount = r.ReadSingle(); float time = r.ReadSingle(); int src = r.ReadInt32(); EnemyManager.hostDictionary[id].Slow(src, amount, time); } } } else if (cmdIndex == 23) //sync magic find { if (GameSetup.IsMpServer) { if (ModSettings.IsDedicated) { ItemDataBase.MagicFind = 1; } else { ItemDataBase.MagicFind = ModdedPlayer.instance.MagicFindMultipier; } } else { using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(24); w.Write(ModdedPlayer.instance.MagicFindMultipier); w.Close(); } Network.NetworkManager.SendLine(answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } else if (cmdIndex == 24) //update magic find for host { if (GameSetup.IsMpServer) { ItemDataBase.MagicFind *= r.ReadSingle(); } } else if (cmdIndex == 25) //ask for item { if (GameSetup.IsMpServer) { ulong itemID = r.ReadUInt64(); if (PickUpManager.PickUps.ContainsKey(itemID)) { int itemAmount = r.ReadInt32(); string playerID = r.ReadString(); if (PickUpManager.PickUps[itemID].amount > 0) { int givenAmount = itemAmount; if (itemAmount > PickUpManager.PickUps[itemID].amount) { givenAmount = Mathf.Min(PickUpManager.PickUps[itemID].amount, itemAmount); } NetworkManager.SendItemToPlayer(PickUpManager.PickUps[itemID].item, playerID, givenAmount); PickUpManager.PickUps[itemID].amount -= givenAmount; if (PickUpManager.PickUps[itemID].amount > 0) { return; } } } using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(4); w.Write(itemID); w.Close(); } Network.NetworkManager.SendLine(answerStream.ToArray(), Network.NetworkManager.Target.Clients); answerStream.Close(); } } } else if (cmdIndex == 26) //give item to player { string playerID = r.ReadString(); if (ModReferences.ThisPlayerID == playerID) { //creating the item. Item item = new Item(ItemDataBase.ItemBases[r.ReadInt32()], r.ReadInt32(), 0, false) { level = r.ReadInt32() }; //adding stats to the item while (r.BaseStream.Position != r.BaseStream.Length) { ItemStat stat = new ItemStat(ItemDataBase.Stats[r.ReadInt32()]) { Amount = r.ReadSingle() }; item.Stats.Add(stat); } Player.Inventory.Instance.AddItem(item, item.Amount); } } else if (cmdIndex == 27) // bonus fire damage { if (GameSetup.IsMpServer || GameSetup.IsSinglePlayer) { ulong id = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(id)) { float amount = r.ReadSingle(); float time = r.ReadSingle(); int src = r.ReadInt32(); EnemyManager.hostDictionary[id].FireDebuff(src, amount, time); } } } else if (cmdIndex == 28) //custom weapon in mp { string id = r.ReadString(); int weaponID = r.ReadInt32(); if (!ModReferences.PlayerHands.ContainsKey(id)) { ModReferences.FindHands(); } if (ModReferences.PlayerHands.ContainsKey(id)) { CoopCustomWeapons.SetWeaponOn(ModReferences.PlayerHands[id], weaponID); Console.WriteLine(ModReferences.PlayerHands[id].name); } else { Debug.LogWarning("NO HAND IN COMMAND READER"); } } else if (cmdIndex == 29) //request for enemy damage information { if (GameSetup.IsMpServer) { ulong id = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(id)) { EnemyProgression p = EnemyManager.hostDictionary[id]; using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(30); w.Write(id); w.Write(p.BaseDamageMult); foreach (EnemyProgression.Abilities ability in p.abilities) { w.Write((int)ability); } w.Close(); } NetworkManager.SendLine(answerStream.ToArray(), NetworkManager.Target.Clients); answerStream.Close(); } } } } else if (cmdIndex == 30) //answer to client damage { ulong id = r.ReadUInt64(); float dmg = r.ReadSingle(); List <EnemyProgression.Abilities> abilities = new List <EnemyProgression.Abilities>(); while (r.BaseStream.Position != r.BaseStream.Length) { abilities.Add((EnemyProgression.Abilities)r.ReadInt32()); } new ClientEnemy(id, dmg, abilities); } else if (cmdIndex == 31) //detonate ball lightning { uint id = r.ReadUInt32(); Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); if (BallLightning.list.ContainsKey(id)) { BallLightning.list[id].CoopTrigger(pos); } } else if (cmdIndex == 32) //apply DoT to an enemy { ulong id = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(id)) { EnemyProgression p = EnemyManager.hostDictionary[id]; p.DoDoT(r.ReadInt32(), r.ReadSingle()); } } else if (cmdIndex == 33) //enemy got bashed { ulong enemy = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(enemy)) { EnemyProgression p = EnemyManager.hostDictionary[enemy]; float duration = r.ReadSingle(); var source = r.ReadInt32(); float slowAmount = r.ReadSingle(); float dmgDebuff = r.ReadSingle(); var bleedDmg = r.ReadInt32(); float bleedChance = r.ReadSingle(); p.Slow(source, slowAmount, duration); p.DmgTakenDebuff(source, dmgDebuff, duration); if (UnityEngine.Random.value < bleedChance) { p.DoDoT(bleedDmg, duration); } } } else if (cmdIndex == 34) { if (GameSetup.IsMpServer) { ulong enemy = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(enemy)) { EnemyProgression p = EnemyManager.hostDictionary[enemy]; var source = r.ReadInt32(); float amount = r.ReadSingle(); float duration = r.ReadSingle(); p.DmgTakenDebuff(source, amount, duration); } } } else if (cmdIndex == 35) //clear ping command { string player = r.ReadString(); if (MainMenu.Instance.otherPlayerPings.ContainsKey(player)) { MainMenu.Instance.otherPlayerPings.Remove(player); } } else if (cmdIndex == 36) //create ping command { string PlayerID = r.ReadString(); MarkObject.PingType ptype = (MarkObject.PingType)r.ReadInt32(); switch (ptype) { case MarkObject.PingType.Enemy: ulong EnemyID = r.ReadUInt64(); if (!EnemyManager.allboltEntities.ContainsKey(EnemyID)) { EnemyManager.GetAllEntities(); } if (EnemyManager.allboltEntities.ContainsKey(EnemyID)) { bool isElite = r.ReadBoolean(); string name = r.ReadString(); Transform tr = EnemyManager.allboltEntities[EnemyID].transform; if (PlayerID == ModReferences.ThisPlayerID) { MainMenu.Instance.localPlayerPing = new MarkEnemy(tr, name, isElite); } else { if (MainMenu.Instance.otherPlayerPings.ContainsKey(PlayerID)) { MainMenu.Instance.otherPlayerPings[PlayerID] = new MarkEnemy(tr, name, isElite); } else { MainMenu.Instance.otherPlayerPings.Add(PlayerID, new MarkEnemy(tr, name, isElite)); } } } break; case MarkObject.PingType.Location: float x = r.ReadSingle(), y = r.ReadSingle(), z = r.ReadSingle(); if (PlayerID == ModReferences.ThisPlayerID) { MainMenu.Instance.localPlayerPing = new MarkPostion(new Vector3(x, y, z)); } else { if (MainMenu.Instance.otherPlayerPings.ContainsKey(PlayerID)) { MainMenu.Instance.otherPlayerPings[PlayerID] = new MarkPostion(new Vector3(x, y, z)); } else { MainMenu.Instance.otherPlayerPings.Add(PlayerID, new MarkPostion(new Vector3(x, y, z))); } } break; case MarkObject.PingType.Item: ulong PickupID = r.ReadUInt64(); if (PickUpManager.PickUps.ContainsKey(PickupID)) { var pu = PickUpManager.PickUps[PickupID]; if (PlayerID == ModReferences.ThisPlayerID) { MainMenu.Instance.localPlayerPing = new MarkPickup(pu.transform, pu.item.name, pu.item.Rarity); } else { if (MainMenu.Instance.otherPlayerPings.ContainsKey(PlayerID)) { MainMenu.Instance.otherPlayerPings[PlayerID] = new MarkPickup(pu.transform, pu.item.name, pu.item.Rarity); } else { MainMenu.Instance.otherPlayerPings.Add(PlayerID, new MarkPickup(pu.transform, pu.item.name, pu.item.Rarity)); } } } break; } } else if (cmdIndex == 37) //create ping for enemy { if (GameSetup.IsMpServer) { string PlayerID = r.ReadString(); ulong EnemyID = r.ReadUInt64(); if (EnemyManager.hostDictionary.ContainsKey(EnemyID)) { var enemy = EnemyManager.hostDictionary[EnemyID]; using (MemoryStream answerStream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(answerStream)) { w.Write(36); w.Write(PlayerID); w.Write(0); w.Write(EnemyID); w.Write(enemy._rarity != EnemyProgression.EnemyRarity.Normal); w.Write(enemy.EnemyName); w.Close(); } NetworkManager.SendLine(answerStream.ToArray(), NetworkManager.Target.Everyone); answerStream.Close(); } } } } else if (cmdIndex == 38) //spark of light after darkness callback to clients { if (GameSetup.IsMpClient) { string PlayerID = r.ReadString(); if (ModReferences.ThisPlayerID == PlayerID) { Vector3 pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); SpellActions.CastBallLightning(pos, Vector3.down); } } } else if (cmdIndex == 39) //archangel bow hit a player { var s = r.ReadString(); if (ModReferences.ThisPlayerID == s) { BuffDB.AddBuff(25, 91, r.ReadSingle(), 30); BuffDB.AddBuff(9, 92, 1.35f, 30); ModdedPlayer.instance.damageAbsorbAmounts[2] = r.ReadSingle(); } } else if (cmdIndex == 40) //buff a player by ID { var s = r.ReadString(); if (ModReferences.ThisPlayerID == s) { BuffDB.AddBuff(r.ReadInt32(), r.ReadInt32(), r.ReadSingle(), r.ReadSingle()); } } else if (cmdIndex == 41) //buff a player by distance { var vector = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); var dist = r.ReadSingle(); if ((vector - LocalPlayer.Transform.position).sqrMagnitude <= dist * dist) { BuffDB.AddBuff(r.ReadInt32(), r.ReadInt32(), r.ReadSingle(), r.ReadSingle()); } } else if (cmdIndex == 42) //buff all players globally { BuffDB.AddBuff(r.ReadInt32(), r.ReadInt32(), r.ReadSingle(), r.ReadSingle()); } r.Close(); } stream.Close(); } }
protected override void OnTriggerEnter(Collider other) { try { currState = animator.GetCurrentAnimatorStateInfo(0); nextState = animator.GetNextAnimatorStateInfo(0); if (currState.tagHash != damagedHash && currState.tagHash != staggerHash && currState.tagHash != hitStaggerHash && currState.tagHash != deathHash && nextState.tagHash != damagedHash && nextState.tagHash != staggerHash && nextState.tagHash != hitStaggerHash && nextState.tagHash != deathHash) { if (other.gameObject.CompareTag("trapTrigger")) { other.gameObject.SendMessage("CutRope", SendMessageOptions.DontRequireReceiver); } if (!netPrefab && LocalPlayer.Animator && LocalPlayer.Animator.GetBool("deathBool")) { return; } if (other.gameObject.CompareTag("playerHitDetect") && mainTrigger) { if (!Scene.SceneTracker.hasAttackedPlayer) { Scene.SceneTracker.hasAttackedPlayer = true; Scene.SceneTracker.Invoke("resetHasAttackedPlayer", Random.Range(120, 240)); } targetStats component = other.transform.root.GetComponent <targetStats>(); if (component && component.targetDown) { return; } Animator componentInParent = other.gameObject.GetComponentInParent <Animator>(); Vector3 position = rootTr.position; position.y += 3.3f; Vector3 direction = other.transform.position - position; if (!Physics.Raycast(position, direction, out hit, direction.magnitude, enemyHitMask, QueryTriggerInteraction.Ignore)) { bool doParry = SpellActions.ParryAnythingIsTimed; if (doParry || (!creepy_male && !creepy && !creepy_baby && !creepy_fat && events)) { if (componentInParent) { bool flag = InFront(other.gameObject); if (doParry || ((!BoltNetwork.isServer || !netPrefab) && flag && events.parryBool && ((componentInParent.GetNextAnimatorStateInfo(1).tagHash == blockHash || componentInParent.GetCurrentAnimatorStateInfo(1).tagHash == blockHash)))) { SpellActions.DoParry(transform.position); ModAPI.Console.Write("Parrying successful"); if ((!creepy_male && !creepy && !creepy_baby && !creepy_fat && events)) { int parryDir = events != null ? events.parryDir : 1; BoltSetReflectedShim.SetIntegerReflected(animator, "parryDirInt", parryDir); if (BoltNetwork.isClient && netPrefab) { BoltSetReflectedShim.SetTriggerReflected(animator, "ClientParryTrigger"); hitPrediction.StartParryPrediction(); FMODCommon.PlayOneshot(parryEvent, base.transform); parryEnemy parryEnemy = parryEnemy.Create(GlobalTargets.OnlyServer); parryEnemy.Target = transform.root.GetComponent <BoltEntity>(); parryEnemy.Send(); } else { BoltSetReflectedShim.SetTriggerReflected(animator, "parryTrigger"); } events.StartCoroutine("disableAllWeapons"); playerHitReactions componentInParent2 = other.gameObject.GetComponentInParent <playerHitReactions>(); if (componentInParent2 != null) { componentInParent2.enableParryState(); } FMODCommon.PlayOneshotNetworked(parryEvent, base.transform, FMODCommon.NetworkRole.Server); events.parryBool = false; } return; } } } if ((bool)events) { events.parryBool = false; } other.transform.root.SendMessage("getHitDirection", rootTr.position, SendMessageOptions.DontRequireReceiver); float num = 0; if (maleSkinny || femaleSkinny) { if (pale) { num = ((!skinned) ? Mathf.Floor(10f * GameSettings.Ai.skinnyDamageRatio) : Mathf.Floor(10f * GameSettings.Ai.skinnyDamageRatio * GameSettings.Ai.skinMaskDamageRatio)); } else { num = Mathf.Floor(13f * GameSettings.Ai.skinnyDamageRatio); if (maleSkinny && props.regularStick.activeSelf && events.leftHandWeapon) { num = Mathf.Floor(num * 1.35f); } } } else if (male && pale) { num = ((!skinned) ? Mathf.Floor(22f * GameSettings.Ai.largePaleDamageRatio) : Mathf.Floor(22f * GameSettings.Ai.largePaleDamageRatio * GameSettings.Ai.skinMaskDamageRatio)); } else if (male && !firemanMain) { num = ((!painted) ? Mathf.Floor(20f * GameSettings.Ai.regularMaleDamageRatio) : Mathf.Floor(20f * GameSettings.Ai.regularMaleDamageRatio * GameSettings.Ai.paintedDamageRatio)); } else if (female) { num = Mathf.Floor(17f * GameSettings.Ai.regularFemaleDamageRatio); } else if (creepy) { num = ((!pale) ? Mathf.Floor(28f * GameSettings.Ai.creepyDamageRatio) : Mathf.Floor(35f * GameSettings.Ai.creepyDamageRatio)); } else if (creepy_male) { num = ((!pale) ? Mathf.Floor(60f * GameSettings.Ai.creepyDamageRatio) : Mathf.Floor(120f * GameSettings.Ai.creepyDamageRatio)); } else if (creepy_baby) { num = Mathf.Floor(26f * GameSettings.Ai.creepyBabyDamageRatio); } else if (firemanMain) { num = Mathf.Floor(12f * GameSettings.Ai.regularMaleDamageRatio); if (events && !enemyAtStructure && !events.noFireAttack) { if (BoltNetwork.isRunning && netPrefab) { other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } else { other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } } } if (!female && male) { if (holdingRegularWeapon() && events.leftHandWeapon) { num += 7; } else if (holdingAdvancedWeapon() && events.leftHandWeapon) { num += 15; } } if (setup && setup.health.poisoned) { num = Mathf.Floor(num / 2); } //COTF additional code try { if (GameSetup.IsMpClient) { if (other.transform.root == LocalPlayer.Transform.root) { var x = EnemyManager.clientEnemies[entity.networkId.PackedValue]; num = x.damagemult + num - 20f; if (x.abilities.Contains(EnemyProgression.Abilities.RainEmpowerment)) { if (Scene.WeatherSystem.Raining) { num *= 5; } } hitDamage = num; if (x.abilities.Contains(EnemyProgression.Abilities.Poisonous)) { BuffDB.AddBuff(3, 32, Mathf.Sqrt(num / 10) / 7, poisonDuration); } if (x.abilities.Contains(EnemyProgression.Abilities.Basher)) { ModdedPlayer.instance.Stun(stunDuration); } if (ModdedPlayer.Stats.TotalThornsDamage > 0) { if (ModdedPlayer.Stats.TotalThornsArmorPiercing > 0) { EnemyProgression.ReduceArmor(entity, ModdedPlayer.Stats.TotalThornsArmorPiercing); } PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = entity; //this integer make the attack not stagger the enemy playerHitEnemy.getAttackerType = 2000000; playerHitEnemy.Hit = DamageMath.GetSendableDamage(ModdedPlayer.Stats.TotalThornsDamage); playerHitEnemy.Send(); } } } else { if (other.transform.root == LocalPlayer.Transform.root && EnemyManager.enemyByTransform.ContainsKey(this.rootTr)) { if (EnemyProg == null) { EnemyProg = EnemyManager.enemyByTransform[this.rootTr]; } num = EnemyProg.DamageAmp * EnemyProg.DebuffDmgMult + num - 20f; hitDamage = num; CotfUtils.Log($"Damage dealt to player: d{hitDamage} amp{EnemyProg.DamageAmp} lv{EnemyProg.level} php{hitDamage*100 / ModdedPlayer.Stats.TotalMaxHealth}%", true); //POISON ATTACKS if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Poisonous)) { BuffDB.AddBuff(3, 32, Mathf.Sqrt(num / 10) / 10, poisonDuration); } //STUN ON HIT if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Basher)) { ModdedPlayer.instance.Stun(stunDuration); } if (ModdedPlayer.Stats.TotalThornsDamage > 0) { EnemyProg.HitPhysicalSilent(ModdedPlayer.Stats.TotalThornsDamage); if (ModdedPlayer.Stats.TotalThornsArmorPiercing > 0) { EnemyProg.ReduceArmor(ModdedPlayer.Stats.TotalThornsArmorPiercing); } } } } } catch (System.Exception ex) { ModAPI.Log.Write(ex.ToString()); } PlayerStats component2 = other.transform.root.GetComponent <PlayerStats>(); if (male || female || creepy_male || creepy_fat || creepy || creepy_baby) { netId component3 = other.transform.GetComponent <netId>(); if (BoltNetwork.isServer && component3) { other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver); return; } if (BoltNetwork.isClient && netPrefab && !(bool)component3) { other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("hitFromEnemy", Mathf.RoundToInt(num), SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver); } else if (BoltNetwork.isServer) { if (!(bool)component3) { other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("hitFromEnemy", Mathf.RoundToInt(num), SendMessageOptions.DontRequireReceiver); } } else if (!BoltNetwork.isRunning && component2) { component2.setCurrentAttacker(this); component2.hitFromEnemy(Mathf.RoundToInt(num)); } } else if (!netPrefab && component2) { component2.setCurrentAttacker(this); component2.hitFromEnemy(Mathf.RoundToInt(num)); } goto IL_092f; } return; } goto IL_092f; } return; IL_092f: if (other.gameObject.CompareTag("enemyCollide") && mainTrigger && bodyCollider && !enemyAtStructure) { setupAttackerType(); if (other.gameObject != bodyCollider) { other.transform.SendMessageUpwards("getAttackDirection", Random.Range(0, 2), SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("getCombo", Random.Range(1, 4), SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("getAttackerType", attackerType, SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("getAttacker", rootTr.gameObject, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("HitPhysical", Random.Range(30f, 50f) * Mathf.Pow(ModdedPlayer.Stats.explosionDamage, 1.25f), SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } } if (other.gameObject.CompareTag("BreakableWood") || (other.gameObject.CompareTag("BreakableRock") && mainTrigger)) { other.transform.SendMessage("Hit", 50, SendMessageOptions.DontRequireReceiver); other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, 50f), SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } if (other.gameObject.CompareTag("SmallTree") && !mainTrigger) { other.SendMessage("Hit", 2, SendMessageOptions.DontRequireReceiver); } if (other.gameObject.CompareTag("Fire") && mainTrigger && firemanMain && !events.noFireAttack) { other.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } if (other.gameObject.CompareTag("Tree") && mainTrigger && creepy_male) { other.SendMessage("Explosion", 5f, SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } if (!other.gameObject.CompareTag("structure") && !other.gameObject.CompareTag("SLTier1") && !other.gameObject.CompareTag("SLTier2") && !other.gameObject.CompareTag("SLTier3") && !other.gameObject.CompareTag("jumpObject") && !other.gameObject.CompareTag("UnderfootWood")) { return; } if (!mainTrigger) { return; } getStructureStrength component4 = other.gameObject.GetComponent <getStructureStrength>(); bool flag2 = component4 == null; enemyAtStructure = true; int num2; if (!creepy_male && !creepy && !creepy_fat && !creepy_baby) { if (!flag2) { num2 = ((maleSkinny || femaleSkinny) ? ((component4._strength == getStructureStrength.strength.weak) ? Mathf.FloorToInt(8f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((pale || painted || skinned) ? ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(16f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(12f * GameSettings.Ai.regularStructureDamageRatio) : 0))); goto IL_0d63; } return; } num2 = ((!creepy_baby) ? Mathf.FloorToInt(30f * GameSettings.Ai.creepyStructureDamageRatio) : Mathf.FloorToInt(10f * GameSettings.Ai.creepyStructureDamageRatio)); goto IL_0d63; IL_0d63: if (setup && setup.health.poisoned) { num2 /= 2; } other.SendMessage("Hit", num2, SendMessageOptions.DontRequireReceiver); other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, num2), SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } catch (System.Exception ee) { ModAPI.Log.Write(ee.ToString()); } }
private void NewHitAi(Transform target, bool hitDelay, bool headDamage) { float dmgUnclamped = this.OutputDmg; if (SpellActions.SeekingArrow) { float dist = Vector3.Distance(target.position, startposition); dmgUnclamped *= 1 + dist * SpellActions.SeekingArrow_DamagePerDistance; } if (spearType) { if (ModdedPlayer.instance.SpearhellChance > 0 && Random.value <= ModdedPlayer.instance.SpearhellChance && OutputDmg > 1) { var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(Camera.main.transform.forward)); obj.velocity = PhysicBody.velocity * 1.05f; Destroy(obj.gameObject, 30); } } else { if (headDamage) { if (ModdedPlayer.instance.EruptionBow && GreatBow.isEnabled) { //if (GameSetup.IsMultiplayer) //{ BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity); //} } } } if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.instance.BulletCritChance) || (spearType && Random.value <= ModdedPlayer.instance.SpearCritChance)) { headDamage = true; dmgUnclamped *= ModdedPlayer.instance.HeadShotDamage; dmgUnclamped *= SpellActions.FocusOnHeadShot(); if (SpellActions.SeekingArrow) { dmgUnclamped *= SpellActions.SeekingArrow_HeadDamage; } } else { dmgUnclamped *= SpellActions.FocusOnBodyShot(); } if (GreatBow.isEnabled) { dmgUnclamped *= 2.1f; } dmgUnclamped *= ModdedPlayer.instance.RangedAMP * ModdedPlayer.instance.CritDamageBuff; if (ModdedPlayer.instance.ProjectileDamageIncreasedBySize) { dmgUnclamped *= ModdedPlayer.instance.ProjectileSizeRatio; } DamageMath.DamageClamp(dmgUnclamped, out int sendDamage, out Repetitions); if (this.PhysicBody) { this.PhysicBody.velocity = Vector3.zero; } if (this.spearType) { this.PhysicBody.isKinematic = false; this.PhysicBody.useGravity = true; this.disableLive(); if (this.MyPickUp) { this.MyPickUp.SetActive(true); } } if (target) { Vector3 vector = target.transform.root.GetChild(0).InverseTransformPoint(base.transform.position); float targetAngle = Mathf.Atan2(vector.x, vector.z) * 57.29578f; int animalHitDirection = animalHealth.GetAnimalHitDirection(targetAngle); BoltEntity componentInParent = target.GetComponentInParent <BoltEntity>(); if (!componentInParent) { componentInParent = target.GetComponent <BoltEntity>(); } if (BoltNetwork.isClient && componentInParent) { ModdedPlayer.instance.OnHitEffectsClient(componentInParent, dmgUnclamped); if (ignite) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(componentInParent.networkId.PackedValue); w.Write(Effects.BlackFlame.FireDamageBonus); w.Write(20f); w.Write(2200); w.Close(); } AsyncHit.SendCommandDelayed(3, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } if (SpellActions.Focus && headDamage) { if (SpellActions.FocusBonusDmg == 0) { //slow enemy by 80% using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(22); w.Write(componentInParent.networkId.PackedValue); w.Write(SpellActions.FocusSlowAmount); w.Write(SpellActions.FocusSlowDuration); w.Write(90); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } //Network.NetworkManager.SendLine(s, Network.NetworkManager.Target.OnlyServer); } } else if (SpellActions.SeekingArrow) { //slow enemy by 80% using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(22); w.Write(componentInParent.networkId.PackedValue); w.Write(SpellActions.SeekingArrow_SlowAmount); w.Write(SpellActions.SeekingArrow_SlowDuration); w.Write(91); w.Close(); } AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } if (ignite) { if (BlackFlame.GiveAfterburn && Random.value < 0.1f) { int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(34); w.Write(componentInParent.networkId.PackedValue); w.Write(id); w.Write(1.15f); w.Write(25f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } } if (hitDelay) { target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver); target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver); BoltEntity component = this.parent.GetComponent <BoltEntity>(); PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = componentInParent; playerHitEnemy.Weapon = component; playerHitEnemy.getAttacker = 10; if (target.gameObject.CompareTag("animalRoot")) { playerHitEnemy.getAttackDirection = animalHitDirection; } else { playerHitEnemy.getAttackDirection = 3; } playerHitEnemy.getAttackerType = 4; playerHitEnemy.Hit = sendDamage; if (GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites) { playerHitEnemy.Burn = true; } AsyncHit.SendPlayerHitEnemy(playerHitEnemy, Repetitions); } else { target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver); target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver); PlayerHitEnemy playerHitEnemy2 = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy2.Target = componentInParent; if (target.gameObject.CompareTag("animalRoot")) { playerHitEnemy2.getAttackDirection = animalHitDirection; } else { playerHitEnemy2.getAttackDirection = 3; } playerHitEnemy2.getAttackerType = 4; if (ignite || GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites) { playerHitEnemy2.Burn = true; } playerHitEnemy2.Hit = sendDamage; AsyncHit.SendPlayerHitEnemy(playerHitEnemy2, Repetitions); } } else { if (target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("enemyCollide")) { var ep = target.gameObject.GetComponentInParent <EnemyProgression>(); if (ep == null) { ep = target.gameObject.GetComponent <EnemyProgression>(); if (ep == null) { ep = target.gameObject.GetComponentInChildren <EnemyProgression>(); } } if (ignite) { ep.FireDebuff(2200, Effects.BlackFlame.FireDamageBonus, 20); if (BlackFlame.GiveAfterburn && Random.value < 0.1f) { if (ep != null) { int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); ep.DmgTakenDebuff(id, 1.15f, 25); } } } ModdedPlayer.instance.OnHitEffectsHost(ep, dmgUnclamped); if (SpellActions.Focus && headDamage) { if (SpellActions.FocusBonusDmg == 0) { //slow enemy by 80% ep.Slow(90, SpellActions.FocusSlowAmount, SpellActions.FocusSlowDuration); } } else if (SpellActions.SeekingArrow) { ep.Slow(91, SpellActions.SeekingArrow_SlowAmount, SpellActions.SeekingArrow_SlowDuration); } } target.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver); target.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver); GameObject closestPlayerFromPos = TheForest.Utils.Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position); target.gameObject.SendMessageUpwards("getAttacker", closestPlayerFromPos, SendMessageOptions.DontRequireReceiver); if (target.gameObject.CompareTag("lb_bird") || target.gameObject.CompareTag("animalRoot") || target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("PlayerNet")) { if (target.gameObject.CompareTag("enemyRoot")) { EnemyHealth componentInChildren = target.GetComponentInChildren <EnemyHealth>(); if (componentInChildren) { componentInChildren.getAttackDirection(3); componentInChildren.setSkinDamage(2); mutantTargetSwitching componentInChildren2 = target.GetComponentInChildren <mutantTargetSwitching>(); if (componentInChildren2) { componentInChildren2.getAttackerType(4); componentInChildren2.getAttacker(closestPlayerFromPos); } for (int i = 0; i < Repetitions; i++) { componentInChildren.Hit(sendDamage); } } } else { if (target.gameObject.CompareTag("animalRoot")) { Repetitions = 1; target.gameObject.SendMessage("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver); } AsyncHit.SendPlayerHitEnemy(target, Repetitions, sendDamage); if (ignite || GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites) { target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } target.gameObject.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver); } } else { if (target.gameObject.CompareTag("animalCollide")) { Repetitions = 1; target.gameObject.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver); } AsyncHit.SendPlayerHitEnemy(target, Repetitions, sendDamage); if (GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites) { target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } target.gameObject.SendMessageUpwards("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver); } } } if (this.MyPickUp) { this.MyPickUp.SetActive(true); } FMODCommon.PlayOneshotNetworked(this.hitAiEvent, base.transform, FMODCommon.NetworkRole.Any); }
IEnumerator DealDamage() { float dmg = 5 + ModdedPlayer.Stats.spellFlatDmg / 3f; dmg *= ModdedPlayer.Stats.SpellDamageMult; float crit = ModdedPlayer.Stats.RandomCritDamage; dmg *= crit; dmg *= radius / 3.33333f; dmg *= ModdedPlayer.Stats.spell_snowstormDamageMult; var hits = Physics.SphereCastAll(LocalPlayer.Transform.position, radius, Vector3.one, radius, -9); int onHitEffectProcs = 0; if (GameSetup.IsMpClient) { for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.CompareTag("enemyCollide")) { var entity = hits[i].transform.GetComponentInParent <BoltEntity>(); if (entity != null) { var phe = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); phe.Target = entity; phe.getAttackerType = DamageMath.SILENTattackerTypeMagic; phe.Hit = DamageMath.GetSendableDamage(dmg); phe.Send(); if (onHitEffectProcs < 6) { { var hitContext = new COTFEvents.HitOtherParams(dmg, crit != 1, entity, this); COTFEvents.Instance.OnHitSpell.Invoke(hitContext); COTFEvents.Instance.OnHitEnemy.Invoke(hitContext); } ModdedPlayer.instance.OnHit(); onHitEffectProcs++; } yield return(null); EnemyProgression.ReduceArmor(entity, Mathf.CeilToInt(dmg / 100f)); EnemyProgression.Slow(entity, 144, 0.2f, 0.95f); yield return(null); if (ModdedPlayer.Stats.spell_snowstormPullEnemiesIn) { if ((hits[i].point - LocalPlayer.Transform.position).sqrMagnitude > 4) { EnemyProgression.AddKnockbackByDistance(entity.networkId.PackedValue, (LocalPlayer.Transform.position - hits[i].transform.position).normalized, 1); } } } } } } else { for (int i = 0; i < hits.Length; i++) { if (EnemyManager.enemyByTransform.ContainsKey(hits[i].transform.root)) { EnemyProgression prog = EnemyManager.enemyByTransform[hits[i].transform.root]; if (prog == null) { continue; } prog.HitMagic(dmg); prog.Slow(144, 0.2f, 0.85f); prog.ReduceArmor(Mathf.CeilToInt(dmg / 100f)); if (onHitEffectProcs < 6) { ModdedPlayer.instance.OnHit(); onHitEffectProcs++; } { var hitContext = new COTFEvents.HitOtherParams(dmg, crit != 1, prog, this); COTFEvents.Instance.OnHitSpell.Invoke(hitContext); COTFEvents.Instance.OnHitEnemy.Invoke(hitContext); } if (ModdedPlayer.Stats.spell_snowstormPullEnemiesIn) { if ((hits[i].point - LocalPlayer.Transform.position).sqrMagnitude > 4) { prog.AddKnockbackByDistance((LocalPlayer.Transform.position - hits[i].transform.position).normalized, 1); } } yield return(null); } } } }
private void NewHitAi(Transform target, bool hitDelay, bool headDamage) { float dmgUnclamped = this.OutputDmg; ModAPI.Console.Write("dmgUnclamped: " + dmgUnclamped); if (ModdedPlayer.Stats.spell_seekingArrow) { float dist = Vector3.Distance(target.position, startposition); dmgUnclamped *= 1 + dist * ModdedPlayer.Stats.spell_seekingArrow_DamagePerDistance; } if (spearType) { if (ModdedPlayer.Stats.perk_thrownSpearhellChance > 0 && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance && OutputDmg > 1) { var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(PhysicBody.position - Camera.main.transform.position)); obj.velocity = PhysicBody.velocity.normalized * 90f * ModdedPlayer.Stats.projectileSpeed; Destroy(obj.gameObject, 18); } } else { if (headDamage) { if (ModdedPlayer.Stats.i_EruptionBow && GreatBow.isEnabled) { //if (GameSetup.IsMultiplayer) //{ BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity); //} } } } if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.Stats.perk_bulletCritChance) || (spearType && Random.value <= ModdedPlayer.Stats.perk_thrownSpearCritChance)) { headDamage = true; dmgUnclamped *= ModdedPlayer.Stats.headShotDamage; dmgUnclamped *= SpellActions.FocusOnHeadShot(); if (ModdedPlayer.Stats.spell_seekingArrow) { dmgUnclamped *= ModdedPlayer.Stats.spell_seekingArrow_HeadDamage; } } else { dmgUnclamped *= SpellActions.FocusOnBodyShot(); } if (target) { Vector3 vector = target.transform.root.GetChild(0).InverseTransformPoint(base.transform.position); float targetAngle = Mathf.Atan2(vector.x, vector.z) * 57.29578f; int animalHitDirection = animalHealth.GetAnimalHitDirection(targetAngle); BoltEntity entity = target.GetComponentInParent <BoltEntity>(); if (!entity) { entity = target.GetComponent <BoltEntity>(); } if (BoltNetwork.isClient && entity) { ModdedPlayer.instance.OnHitEffectsClient(entity, dmgUnclamped); if (ignite) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(entity.networkId.PackedValue); w.Write(Effects.BlackFlame.FireDamageBonus); w.Write(20f); w.Write(2200); w.Close(); } AsyncHit.SendCommandDelayed(3, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } if (ModdedPlayer.Stats.spell_focus && headDamage) { if (ModdedPlayer.Stats.spell_focusBonusDmg == 0) { //slow enemy by 80% using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(22); w.Write(entity.networkId.PackedValue); w.Write(ModdedPlayer.Stats.spell_focusSlowAmount); w.Write(ModdedPlayer.Stats.spell_focusSlowDuration); w.Write(90); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } //Network.NetworkManager.SendLine(s, Network.NetworkManager.Target.OnlyServer); } } else if (ModdedPlayer.Stats.spell_seekingArrow) { //slow enemy by 80% using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(22); w.Write(entity.networkId.PackedValue); w.Write(ModdedPlayer.Stats.spell_seekingArrow_SlowAmount); w.Write(ModdedPlayer.Stats.spell_seekingArrow_SlowDuration); w.Write(91); w.Close(); } AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } if (ignite) { if (BlackFlame.GiveAfterburn && Random.value < 0.1f) { int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(34); w.Write(entity.networkId.PackedValue); w.Write(id); w.Write(1.15f); w.Write(25f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } } if (hitDelay) { target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver); target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver); BoltEntity component = this.parent.GetComponent <BoltEntity>(); PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = entity; playerHitEnemy.Weapon = component; playerHitEnemy.getAttacker = 10; if (target.gameObject.CompareTag("animalRoot")) { playerHitEnemy.getAttackDirection = animalHitDirection; } else { playerHitEnemy.getAttackDirection = 3; } playerHitEnemy.getAttackerType = 4; playerHitEnemy.Hit = DamageMath.GetSendableDamage(dmgUnclamped); if ((GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites) || (ignite && Random.value < 0.5f)) { playerHitEnemy.Burn = true; } playerHitEnemy.getAttackerType += 1000000; playerHitEnemy.Send(); } else { target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver); target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver); PlayerHitEnemy playerHitEnemy2 = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy2.Target = entity; if (target.gameObject.CompareTag("animalRoot")) { playerHitEnemy2.getAttackDirection = animalHitDirection; } else { playerHitEnemy2.getAttackDirection = 3; } playerHitEnemy2.getAttackerType = 4; if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites) { playerHitEnemy2.Burn = true; } playerHitEnemy2.Hit = DamageMath.GetSendableDamage(dmgUnclamped); playerHitEnemy2.getAttackerType += DamageMath.CONVERTEDFLOATattackerType; playerHitEnemy2.Send(); } goto afterdamage; } else { if (target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("enemyCollide")) { if (EnemyManager.enemyByTransform.ContainsKey(target.root)) { var ep = EnemyManager.enemyByTransform[target.root]; if (ignite) { if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites) { ep.HealthScript.Burn(); } ep.FireDebuff(2200, Effects.BlackFlame.FireDamageBonus, 20); if (BlackFlame.GiveAfterburn && Random.value < 0.1f) { if (ep != null) { int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); ep.DmgTakenDebuff(id, 1.15f, 25); } } } ModdedPlayer.instance.OnHitEffectsHost(ep, dmgUnclamped); if (ModdedPlayer.Stats.spell_focus && headDamage) { if (ModdedPlayer.Stats.spell_focusBonusDmg == 0) { //slow enemy by 80% ep.Slow(90, ModdedPlayer.Stats.spell_focusSlowAmount, ModdedPlayer.Stats.spell_focusSlowDuration); } } else if (ModdedPlayer.Stats.spell_seekingArrow) { ep.Slow(91, ModdedPlayer.Stats.spell_seekingArrow_SlowAmount, ModdedPlayer.Stats.spell_seekingArrow_SlowDuration); } ep.HealthScript.getAttackDirection(3); ep.HitPhysical(dmgUnclamped); Debug.Log("HIT PHYSICAL"); goto afterdamage; } } target.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver); target.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver); GameObject closestPlayerFromPos = TheForest.Utils.Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position); target.gameObject.SendMessageUpwards("getAttacker", closestPlayerFromPos, SendMessageOptions.DontRequireReceiver); if (target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("lb_bird") || target.gameObject.CompareTag("animalRoot")) { Debug.Log("HIT NORMAL"); if (target.gameObject.CompareTag("enemyRoot")) { EnemyHealth targetEnemyHealth = target.GetComponentInChildren <EnemyHealth>(); if (targetEnemyHealth) { targetEnemyHealth.getAttackDirection(3); targetEnemyHealth.setSkinDamage(2); mutantTargetSwitching componentInChildren2 = target.GetComponentInChildren <mutantTargetSwitching>(); if (componentInChildren2) { componentInChildren2.getAttackerType(4); componentInChildren2.getAttacker(closestPlayerFromPos); } targetEnemyHealth.Hit((int)Mathf.Min((float)int.MaxValue, dmgUnclamped)); if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites) { targetEnemyHealth.Burn(); } } } else { if (target.gameObject.CompareTag("animalRoot")) { target.gameObject.SendMessage("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver); } target.SendMessageUpwards("Hit", (int)Mathf.Min(dmgUnclamped, int.MaxValue / 2), SendMessageOptions.DontRequireReceiver); if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites) { target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } target.gameObject.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver); } } else { if (target.gameObject.CompareTag("animalCollide")) { target.gameObject.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver); } target.SendMessageUpwards("Hit", (int)Mathf.Min(dmgUnclamped, int.MaxValue / 2), SendMessageOptions.DontRequireReceiver); if (GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites || (ignite && Random.value < 0.5f)) { target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } target.gameObject.SendMessageUpwards("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver); } } } afterdamage: if (ModdedPlayer.Stats.perk_projectileNoConsumeChance > 0.35f) { FMODCommon.PlayOneshotNetworked(this.hitAiEvent, base.transform, FMODCommon.NetworkRole.Any); } }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = transform.GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!(bool)component) { component = target.root.GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { if (crossbowBoltType) { } else if (flintLockAmmoType) { } else if (spearType) { } else { if (ModdedPlayer.instance.IsCrossfire) { if (Time.time - ModdedPlayer.instance.LastCrossfireTime > 10) { ModdedPlayer.instance.LastCrossfireTime = Time.time; float damage1 = 55 + ModdedPlayer.instance.SpellDamageBonus * 1.25f; damage1 = damage1 * ModdedPlayer.instance.SpellAMP; Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5; Vector3 dir = transform.position - pos; dir.Normalize(); if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { MagicArrow.Create(pos, dir, damage1, ModReferences.ThisPlayerID, SpellActions.MagicArrowDuration, SpellActions.MagicArrowDoubleSlow, SpellActions.MagicArrowDmgDebuff); if (BoltNetwork.isRunning) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(3); w.Write(7); w.Write(pos.x); w.Write(pos.y); w.Write(pos.z); w.Write(dir.x); w.Write(dir.y); w.Write(dir.z); w.Write(damage1); w.Write(ModReferences.ThisPlayerID); w.Write(SpellActions.MagicArrowDuration); w.Write(SpellActions.MagicArrowDoubleSlow); w.Write(SpellActions.MagicArrowDmgDebuff); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Others); answerStream.Close(); } } } else if (GameSetup.IsMpClient) { MagicArrow.CreateEffect(pos, dir, SpellActions.MagicArrowDmgDebuff, SpellActions.MagicArrowDuration); using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(3); w.Write(7); w.Write(pos.x); w.Write(pos.y); w.Write(pos.z); w.Write(dir.x); w.Write(dir.y); w.Write(dir.z); w.Write(damage1); w.Write(ModReferences.ThisPlayerID); w.Write(SpellActions.MagicArrowDuration); w.Write(SpellActions.MagicArrowDoubleSlow); w.Write(SpellActions.MagicArrowDmgDebuff); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Others); answerStream.Close(); } } } } } bool flag = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool flag2 = target.CompareTag("Fish"); bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } if (!spearType && !flintLockAmmoType && !flag2) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (flag) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(flag3, flag, flag2); if (BoltNetwork.isRunning) { if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if ((bool)arrowStickToTarget) { base.Invoke("destroyMe", 0.1f); } } if (SpellActions.SeekingArrow_ChangeTargetOnHit) { SpellActions.SeekingArrow = true; SpellActions.SeekingArrow_Target.gameObject.SetActive(true); SpellActions.SeekingArrow_Target.transform.parent = target.transform; SpellActions.SeekingArrow_Target.transform.position = new Vector3(target.transform.position.x, transform.position.y - 0.075f, target.transform.position.z); SpellActions.SeekingArrow_TimeStamp = Time.time; startposition = transform.position; SpellActions.SeekingArrow_ChangeTargetOnHit = false; } if (headDamage && !flintLockAmmoType && ModdedPlayer.instance.TrueAim && SpellActions.SeekingArrow) { float dist = (startposition - transform.position).sqrMagnitude; if (dist >= 3600f) { OutputDmg *= 4; NewHitAi(target, flag || flag3, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); if (ModdedPlayer.instance.TrueAimUpgrade && dist >= 14400f) { OutputDmg *= 10; NewHitAi(target, flag || flag3, headDamage); NewHitAi(target, flag || flag3, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); } } } NewHitAi(target, flag || flag3, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (be == null) { be = target.GetComponent <BoltEntity>(); } if (ModdedPlayer.instance.SpellAmpFireDmg) { int myID = 1000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float dmg = 1 + ModdedPlayer.instance.SpellDamageBonus / 3; dmg *= ModdedPlayer.instance.SpellAMP; dmg *= ModdedPlayer.instance.FireAmp + 1; dmg *= 0.3f; if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { target.GetComponentInParent <EnemyProgression>()?.FireDebuff(myID, dmg, 14); } else { if (be != null) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(be.networkId.PackedValue); w.Write(dmg); w.Write(14.5f); w.Write(1); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } } if (ModdedPlayer.instance.RangedArmorReduction > 0 && target.gameObject.CompareTag("enemyCollide")) { if (BoltNetwork.isClient) { if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.instance.RangedArmorReduction); } } else { target.transform.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.RangedArmorReduction, SendMessageOptions.DontRequireReceiver); } } if (flag2) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } disableLive(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (!(bool)be) { be = target.GetComponent <BoltEntity>(); } if (be) { if (ModdedPlayer.instance.ArchangelBow && GreatBow.isEnabled) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(39); w.Write(be.GetState <IPlayerState>().name); w.Write((ModdedPlayer.instance.LifeRegen) * ModdedPlayer.instance.HealingMultipier * (1 + ModdedPlayer.instance.HealthRegenPercent)); w.Write(ModdedPlayer.instance.MaxHealth * 0.25f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } else if (ModSettings.FriendlyFire) { float dmgUnclamped = this.OutputDmg; if (SpellActions.SeekingArrow) { float dist = Vector3.Distance(target.position, startposition); dmgUnclamped *= 1 + dist * SpellActions.SeekingArrow_DamagePerDistance; } if (spearType) { if (ModdedPlayer.instance.SpearhellChance > 0 && Random.value <= ModdedPlayer.instance.SpearhellChance && OutputDmg > 1) { var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(Camera.main.transform.forward)); obj.velocity = PhysicBody.velocity * 1.05f; Destroy(obj.gameObject, 30); } } else { if (headDamage) { if (ModdedPlayer.instance.EruptionBow && GreatBow.isEnabled) { //if (GameSetup.IsMultiplayer) //{ BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity); //} } } } if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.instance.BulletCritChance) || (spearType && Random.value <= ModdedPlayer.instance.SpearCritChance)) { headDamage = true; dmgUnclamped *= ModdedPlayer.instance.HeadShotDamage; dmgUnclamped *= SpellActions.FocusOnHeadShot(); if (SpellActions.SeekingArrow) { dmgUnclamped *= SpellActions.SeekingArrow_HeadDamage; } } else { dmgUnclamped *= SpellActions.FocusOnBodyShot(); } if (GreatBow.isEnabled) { dmgUnclamped *= 2.1f; } dmgUnclamped *= ModdedPlayer.instance.RangedAMP * ModdedPlayer.instance.CritDamageBuff; if (ModdedPlayer.instance.ProjectileDamageIncreasedBySize) { dmgUnclamped *= ModdedPlayer.instance.ProjectileSizeRatio; } DamageMath.DamageClamp(dmgUnclamped, out int sendDamage, out Repetitions); HitPlayer HP = HitPlayer.Create(be, EntityTargets.Everyone); HP.damage = sendDamage; for (int i = 0; i < Repetitions; i++) { HP.Send(); } disableLive(); } } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }
public static void DoParry(Vector3 parryPos) { if (Parry) { BuffDB.AddBuff(6, 61, 1, ParryBuffDuration); float dmg = ParryDamage + ModdedPlayer.instance.SpellDamageBonus + ModdedPlayer.instance.MeleeDamageBonus; dmg *= ModdedPlayer.instance.SpellDamageAmplifier * 1.2f; float heal = ParryHeal + ModdedPlayer.instance.SpellDamageBonus / 6 + ModdedPlayer.instance.LifeRegen + ModdedPlayer.instance.LifeOnHit * 2; heal *= ModdedPlayer.instance.HealingMultipier * (1 + ModdedPlayer.instance.HealthRegenPercent); LocalPlayer.Stats.HealthTarget += heal; ParrySound.Play(parryPos); float energy = ParryEnergy * ModdedPlayer.instance.StaminaAndEnergyRegenAmp + ModdedPlayer.instance.EnergyOnHit * 2 + ModdedPlayer.instance.MaxEnergy / 12.5f; LocalPlayer.Stats.Energy += energy; LocalPlayer.Stats.Stamina += energy; if (ParryDmgBonus > 0) { float f = dmg * ParryDmgBonus; ModdedPlayer.instance.ParryCounterStrikeDamage += f; BuffDB.AddBuff(23, 88, f, 20); } if (GameSetup.IsMpClient) { if (BoltNetwork.isRunning) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(3); w.Write(13); w.Write(parryPos.x); w.Write(parryPos.y); w.Write(parryPos.z); w.Write(ParryRadius); w.Write(ParryIgnites); w.Write(dmg); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } else { DamageMath.DamageClamp(dmg, out int d, out int r); var hits = Physics.SphereCastAll(parryPos, ParryRadius, Vector3.one); for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.CompareTag("enemyCollide")) { for (int a = 0; a < r; a++) { hits[i].transform.SendMessageUpwards("Hit", d, SendMessageOptions.DontRequireReceiver); if (ParryIgnites) { hits[i].transform.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } } } } } } }
public static void DoBlink() { blinkAim?.Disable(); Transform t = Camera.main.transform; Vector3 blinkPoint = Vector3.zero; var hits1 = Physics.RaycastAll(t.position, t.forward, BlinkRange + 1f); foreach (var hit in hits1) { if (!hit.transform.CompareTag("enemyCollide") && hit.transform.root != LocalPlayer.Transform.root) { blinkPoint = hit.point - t.forward + Vector3.up * 0.25f; break; } } if (blinkPoint == Vector3.zero) { blinkPoint = LocalPlayer.Transform.position + t.forward * BlinkRange; } if (BlinkDamage > 0) { RaycastHit[] hits = Physics.BoxCastAll(t.position, Vector3.one * 1.2f, blinkPoint - t.position, t.rotation, Vector3.Distance(blinkPoint, t.position) + 1); foreach (RaycastHit hit in hits) { if (hit.transform.CompareTag("enemyCollide")) { ModAPI.Console.Write("Hit enemy on layer " + hit.transform.gameObject.layer); float dmg = BlinkDamage + ModdedPlayer.instance.SpellDamageBonus; dmg *= ModdedPlayer.instance.SpellAMP * 3; DamageMath.DamageClamp(dmg, out int dmgInt, out int repetitions); if (GameSetup.IsMpClient) { BoltEntity enemyEntity = hit.transform.GetComponentInParent <BoltEntity>(); if (enemyEntity == null) { enemyEntity = hit.transform.gameObject.GetComponent <BoltEntity>(); } if (enemyEntity != null) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(enemyEntity); playerHitEnemy.hitFallDown = true; playerHitEnemy.explosion = true; playerHitEnemy.Hit = dmgInt; for (int i = 0; i < repetitions; i++) { playerHitEnemy.Send(); } } } else { var v = hit.transform.GetComponentInParent <EnemyProgression>(); if (v == null) { v = hit.transform.GetComponent <EnemyProgression>(); } if (v != null) { for (int i = 0; i < repetitions; i++) { v.HitMagic(dmgInt); } } else { hit.transform.SendMessageUpwards("Hit", dmgInt, SendMessageOptions.DontRequireReceiver); } } } } } BlinkTowards(blinkPoint); }
protected override void OnTriggerEnter(Collider other) { int rep = 1; PlayerHitEnemy playerHitEnemy; mutantHitReceiver component6; if (!other.gameObject.CompareTag("Player") && animator.GetCurrentAnimatorStateInfo(2).tagHash != animControl.deathHash && !(currentWeaponScript == null)) { if (other.CompareTag("hanging") || other.CompareTag("corpseProp")) { if (animControl.smashBool) { if (LocalPlayer.Animator.GetFloat("tiredFloat") < 0.35f) { base.Invoke("spawnSmashWeaponBlood", 0.1f); } else { base.Invoke("spawnSmashWeaponBlood", 0.03f); } } else { spawnWeaponBlood(other, false); } Mood.HitRumble(); other.gameObject.SendMessageUpwards("Hit", 0, SendMessageOptions.DontRequireReceiver); FauxMpHit(0); FMODCommon.PlayOneshotNetworked(currentWeaponScript.fleshHitEvent, base.transform, FMODCommon.NetworkRole.Any); } if (!ForestVR.Enabled && GetInvalidAttackAngle(other)) { return; } playerHitEnemy = null; if ((mainTrigger || (ForestVR.Enabled && !mainTrigger)) && repairTool) { RepairTool component = currentWeaponScript.gameObject.GetComponent <RepairTool>(); if (component && component.IsRepairFocused) { currentWeaponScript.gameObject.SendMessage("OnRepairStructure", other.gameObject); if ((bool)component.FocusedRepairCollider) { currentWeaponScript.PlaySurfaceHit(component.FocusedRepairCollider, SfxInfo.SfxTypes.HitWood); } } return; } mutantTargetSwitching component2 = other.transform.GetComponent <mutantTargetSwitching>(); if ((other.CompareTag("enemyCollide") || other.CompareTag("animalCollide") || other.CompareTag("Fish") || other.CompareTag("EnemyBodyPart")) && (mainTrigger || animControl.smashBool || chainSaw)) { bool flag = false; if (component2 && component2.regular) { flag = true; } if (animControl.smashBool) { if (LocalPlayer.Animator.GetFloat("tiredFloat") < 0.35f) { base.Invoke("spawnSmashWeaponBlood", 0.1f); } else { base.Invoke("spawnSmashWeaponBlood", 0.03f); } } else if (!flag) { spawnWeaponBlood(other, false); } } if (other.gameObject.CompareTag("PlayerNet") && (mainTrigger || (!mainTrigger && (animControl.smashBool || chainSaw)))) { if (!ModSettings.FriendlyFire) { return; } BoltEntity component3 = other.GetComponent <BoltEntity>(); BoltEntity component4 = base.GetComponent <BoltEntity>(); if (!object.ReferenceEquals(component3, component4) && lastPlayerHit + 0.4f < Time.time) { other.transform.root.SendMessage("getClientHitDirection", animator.GetInteger("hitDirection"), SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver); lastPlayerHit = Time.time; if (BoltNetwork.isRunning) { ModdedPlayer.instance.DoOnHit(); ModdedPlayer.instance.DoMeleeOnHit(); HitPlayer hitPlayer = HitPlayer.Create(component3, EntityTargets.Everyone); hitPlayer.damage = Mathf.FloorToInt(2f * (WeaponDamage + ModdedPlayer.instance.MeleeDamageBonus) * ModdedPlayer.instance.MeleeAMP * ModdedPlayer.instance.CritDamageBuff); hitPlayer.Send(); } } return; } if (BoltNetwork.isClient) { playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = other.GetComponentInParent <BoltEntity>(); } if (other.gameObject.CompareTag("enemyHead") && !mainTrigger) { other.transform.SendMessageUpwards("HitHead", SendMessageOptions.DontRequireReceiver); if (playerHitEnemy != null) { playerHitEnemy.HitHead = true; } } if (other.gameObject.CompareTag("enemyCollide") && !mainTrigger && !animControl.smashBool && !repairTool) { other.transform.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver); } if (other.gameObject.CompareTag("structure") && !repairTool && (!BoltNetwork.isRunning || BoltNetwork.isServer || !BoltNetwork.isClient || !PlayerPreferences.NoDestructionRemote)) { setup.pmNoise.SendEvent("toWeaponNoise"); Mood.HitRumble(); other.SendMessage("Hit", SendMessageOptions.DontRequireReceiver); float damage = WeaponDamage * 4f + ModdedPlayer.instance.MeleeDamageBonus; damage *= ModdedPlayer.instance.CritDamageBuff * ModdedPlayer.instance.MeleeAMP; if (tht.atEnemy) { damage *= 0.125f; } other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, damage), SendMessageOptions.DontRequireReceiver); } if (BoltNetwork.isClient && (other.CompareTag("jumpObject") || other.CompareTag("UnderfootWood")) && !repairTool) { float damage = WeaponDamage + ModdedPlayer.instance.MeleeDamageBonus; damage *= ModdedPlayer.instance.CritDamageBuff * ModdedPlayer.instance.MeleeAMP; FauxMpHit(Mathf.CeilToInt(damage * 4f)); } switch (other.gameObject.tag) { case "jumpObject": case "UnderfootWood": case "SLTier1": case "SLTier2": case "SLTier3": case "UnderfootRock": case "Target": case "Untagged": case "Block": if (!repairTool) { if (BoltNetwork.isRunning && !BoltNetwork.isServer && BoltNetwork.isClient && PlayerPreferences.NoDestructionRemote) { break; } other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, WeaponDamage * 4f), SendMessageOptions.DontRequireReceiver); setup.pmNoise.SendEvent("toWeaponNoise"); } break; } PlaySurfaceHit(other, SfxInfo.SfxTypes.None); if (spear && other.gameObject.CompareTag("Fish") && (MyFish == null || !MyFish.gameObject.activeSelf) && (!mainTrigger || ForestVR.Enabled)) { base.transform.parent.SendMessage("GotBloody", SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(fleshHitEvent, base.transform, FMODCommon.NetworkRole.Any); spearedFish.Add(other.gameObject); other.transform.parent = base.transform; other.transform.position = SpearTip.position; other.transform.rotation = SpearTip.rotation; MyFish = other.transform.GetComponent <Fish>(); if (MyFish && MyFish.typeCaveFish) { other.transform.position = SpearTip2.position; other.transform.rotation = SpearTip2.rotation; } other.SendMessage("DieSpear", SendMessageOptions.DontRequireReceiver); } if (other.gameObject.CompareTag("hanging") || other.gameObject.CompareTag("corpseProp") || (other.gameObject.CompareTag("BreakableWood") && !mainTrigger)) { Rigidbody component5 = other.GetComponent <Rigidbody>(); float d = pushForce; if (other.gameObject.CompareTag("BreakableWood")) { d = 4500f; } if ((bool)component5) { component5.AddForceAtPosition(playerTr.forward * d * 0.75f * (0.016666f / Time.fixedDeltaTime), base.transform.position, ForceMode.Force); } if (!(bool)other.gameObject.GetComponent <WeaponHitSfxInfo>() && (other.gameObject.CompareTag("hanging") || other.gameObject.CompareTag("corpseProp"))) { FMODCommon.PlayOneshotNetworked(currentWeaponScript.fleshHitEvent, weaponAudio.transform, FMODCommon.NetworkRole.Any); } } if (spear && !mainTrigger && (other.gameObject.CompareTag("Water") || other.gameObject.CompareTag("Ocean"))) { if (!LocalPlayer.ScriptSetup.targetInfo.inYacht) { PlayGroundHit(waterHitEvent); base.StartCoroutine(spawnSpearSplash(other)); } setup.pmNoise.SendEvent("toWeaponNoise"); } if (!spear && !mainTrigger && (other.gameObject.CompareTag("Water") || other.gameObject.CompareTag("Ocean")) && !LocalPlayer.ScriptSetup.targetInfo.inYacht) { PlayGroundHit(waterHitEvent); } if (other.gameObject.CompareTag("Shell") && !mainTrigger) { other.gameObject.SendMessage("getAttackerType", 4, SendMessageOptions.DontRequireReceiver); other.gameObject.SendMessage("getAttacker", Player, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); other.transform.SendMessageUpwards("Hit", 1, SendMessageOptions.DontRequireReceiver); PlayEvent(currentWeaponScript.shellHitEvent, weaponAudio); } if (other.gameObject.CompareTag("PlaneHull") && !mainTrigger) { PlayEvent(currentWeaponScript.planeHitEvent, weaponAudio); } if (other.gameObject.CompareTag("Tent") && !mainTrigger) { PlayEvent(currentWeaponScript.tentHitEvent, weaponAudio); } component6 = other.GetComponent <mutantHitReceiver>(); if ((other.gameObject.CompareTag("enemyCollide") || other.gameObject.CompareTag("animalCollide")) && mainTrigger && !enemyDelay && !animControl.smashBool) { ModdedPlayer.instance.DoOnHit(); ModdedPlayer.instance.DoMeleeOnHit(); if (ModdedPlayer.instance.MeleeArmorReduction > 0 && other.gameObject.CompareTag("enemyCollide")) { if (BoltNetwork.isClient) { EnemyProgression.ReduceArmor(playerHitEnemy.Target, ModdedPlayer.instance.MeleeArmorReduction); } else { other.gameObject.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.MeleeArmorReduction, SendMessageOptions.DontRequireReceiver); } } if (BoltNetwork.isClient && other.gameObject.CompareTag("enemyCollide")) { CoopMutantClientHitPrediction componentInChildren = other.transform.root.gameObject.GetComponentInChildren <CoopMutantClientHitPrediction>(); if ((bool)componentInChildren) { componentInChildren.getClientHitDirection(animator.GetInteger("hitDirection")); componentInChildren.StartPrediction(); } } if ((bool)currentWeaponScript) { currentWeaponScript.transform.parent.SendMessage("GotBloody", SendMessageOptions.DontRequireReceiver); } Vector3 vector = other.transform.root.GetChild(0).InverseTransformPoint(playerTr.position); float num = Mathf.Atan2(vector.x, vector.z) * 57.29578f; other.gameObject.SendMessage("getAttackerType", 4, SendMessageOptions.DontRequireReceiver); other.gameObject.SendMessage("getAttacker", Player, SendMessageOptions.DontRequireReceiver); if (playerHitEnemy != null) { playerHitEnemy.getAttackerType = 4; } animator.SetFloatReflected("connectFloat", 1f); base.Invoke("resetConnectFloat", 0.3f); if (num < -140f || num > 140f) { if ((bool)component6) { component6.takeDamage(1); } else { other.transform.SendMessageUpwards("takeDamage", 1, SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.takeDamage = 1; } } else { if ((bool)component6) { component6.takeDamage(0); } else { other.transform.SendMessageUpwards("takeDamage", 0, SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.takeDamage = 0; } } if (spear || shell || chainSaw) { other.transform.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver); if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = 3; } } else if (axe || rock || stick) { int integer = animator.GetInteger("hitDirection"); if (axe) { if ((bool)component6) { component6.getAttackDirection(integer); component6.getStealthAttack(); } else { other.transform.SendMessageUpwards("getAttackDirection", integer, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("getStealthAttack", SendMessageOptions.DontRequireReceiver); } } else if (stick) { if ((bool)component6) { component6.getAttackDirection(integer); } else { other.transform.SendMessageUpwards("getAttackDirection", integer, SendMessageOptions.DontRequireReceiver); } } else if ((bool)component6) { component6.getAttackDirection(0); component6.getStealthAttack(); } else { other.transform.SendMessageUpwards("getAttackDirection", 0, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("getStealthAttack", SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { if (axe) { playerHitEnemy.getAttackDirection = integer; } else if (stick) { playerHitEnemy.getAttackDirection = integer; } else { playerHitEnemy.getAttackDirection = 0; } playerHitEnemy.getStealthAttack = true; } } else { int integer2 = animator.GetInteger("hitDirection"); if ((bool)component6) { component6.getAttackDirection(integer2); } else { other.transform.SendMessageUpwards("getAttackDirection", integer2, SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = integer2; } } if ((fireStick && Random.value > 0.8f) || AlwaysIgnite || Effects.BlackFlame.IsOn) { if ((bool)component6) { component6.Burn(); } else { other.transform.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.Burn = true; } } float num2 = WeaponDamage + ModdedPlayer.instance.MeleeDamageBonus; float crit = ModdedPlayer.instance.CritDamageBuff; num2 *= crit * ModdedPlayer.instance.MeleeAMP; if (component2 && chainSaw && (component2.typeMaleCreepy || component2.typeFemaleCreepy || component2.typeFatCreepy)) { num2 /= 2f; } if (ModdedPlayer.instance.IsHammerStun && PlayerInventoryMod.EquippedModel == BaseItem.WeaponModelType.Hammer) { if ((bool)component6) { if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { other.GetComponentInParent <EnemyProgression>().Slow(40, ModdedPlayer.instance.HammerStunAmount, ModdedPlayer.instance.HammerStunDuration); } else if (playerHitEnemy != null) { Network.NetworkManager.SendLine("AC" + playerHitEnemy.Target.networkId.PackedValue + ";" + ModdedPlayer.instance.HammerStunAmount + ";" + ModdedPlayer.instance.HammerStunDuration + ";40;", Network.NetworkManager.Target.OnlyServer); } } } if (Effects.BlackFlame.IsOn) { if ((bool)component6) { if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { other.GetComponentInParent <EnemyProgression>().FireDebuff(40, Effects.BlackFlame.FireDamageBonus, 5); } else if (playerHitEnemy != null) { Network.NetworkManager.SendLine("AH" + playerHitEnemy.Target.networkId.PackedValue + ";" + Effects.BlackFlame.FireDamageBonus + ";" + 5 + ";1", Network.NetworkManager.Target.OnlyServer); } } } DamageMath.DamageClamp(num2, out int d, out int a); if (hitReactions.kingHitBool || fsmHeavyAttackBool.Value) { num2 *= ModdedPlayer.instance.HeavyAttackMult; if ((bool)component6) { if (fsmHeavyAttackBool.Value && axe && !smallAxe) { component6.sendHitFallDown(num2 * 3f); if (playerHitEnemy != null) { playerHitEnemy.Hit = (int)d; playerHitEnemy.hitFallDown = true; rep = a; } } else { component6.getCombo(3); for (int i = 0; i < a; i++) { component6.hitRelay(d * 3); } } } else { int animalHitDirection = animalHealth.GetAnimalHitDirection(num); other.transform.SendMessageUpwards("getCombo", 3, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver); for (int i = 0; i < a; i++) { other.transform.SendMessageUpwards("Hit", d * 3, SendMessageOptions.DontRequireReceiver); } //ModdedPlayer.instance.DoAreaDamage(other.transform.root, (int)num2 * 3); if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = animalHitDirection; } } if (playerHitEnemy != null) { playerHitEnemy.Hit = d * 3; playerHitEnemy.getCombo = 3; rep = a; } Mood.HitRumble(); FMODCommon.PlayOneshotNetworked(currentWeaponScript.fleshHitEvent, weaponAudio.transform, FMODCommon.NetworkRole.Any); } else { if ((bool)component6) { component6.hitRelay((int)num2); } else { int animalHitDirection2 = animalHealth.GetAnimalHitDirection(num); other.transform.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection2, SendMessageOptions.DontRequireReceiver); for (int i = 0; i < a; i++) { other.transform.SendMessageUpwards("Hit", d, SendMessageOptions.DontRequireReceiver); } //ModdedPlayer.instance.DoAreaDamage(other.transform.root, (int)num2); if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = animalHitDirection2; } } Mood.HitRumble(); if (playerHitEnemy != null) { playerHitEnemy.Hit = d; rep = a; } FMODCommon.PlayOneshotNetworked(currentWeaponScript.fleshHitEvent, weaponAudio.transform, FMODCommon.NetworkRole.Any); } setup.pmNoise.SendEvent("toWeaponNoise"); hitReactions.enableWeaponHitState(); animControl.hitCombo(); if (!axe && !rock) { goto IL_1171; } if (animator.GetBool("smallAxe")) { goto IL_1171; } goto IL_1181; } goto IL_122e; } return; IL_1941: if (chainSaw) { base.StartCoroutine(chainSawClampRotation(0.5f)); } animEvents.cuttingTree = true; animEvents.Invoke("resetCuttingTree", 0.5f); if (stick || fireStick) { other.SendMessage("HitStick", SendMessageOptions.DontRequireReceiver); setup.pmNoise.SendEvent("toWeaponNoise"); animator.SetFloatReflected("weaponHit", 1f); PlayEvent(treeHitEvent, null); if (BoltNetwork.isRunning && base.entity.isOwner) { FmodOneShot fmodOneShot = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable); fmodOneShot.Position = base.transform.position; fmodOneShot.EventPath = CoopAudioEventDb.FindId(treeHitEvent); fmodOneShot.Send(); } } else if (!Delay) { Delay = true; base.Invoke("ResetDelay", 0.2f); SapDice = Random.Range(0, 5); setup.pmNoise.SendEvent("toWeaponNoise"); if (!noTreeCut) { if (SapDice == 1) { PlayerInv.GotSap(null); } if (other.GetType() == typeof(CapsuleCollider)) { base.StartCoroutine(spawnWoodChips()); } else { base.StartCoroutine(spawnWoodChips()); } other.SendMessage("Hit", treeDamage, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); } PlayEvent(treeHitEvent, null); if (BoltNetwork.isRunning && base.entity.isOwner) { FmodOneShot fmodOneShot2 = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable); fmodOneShot2.Position = base.transform.position; fmodOneShot2.EventPath = CoopAudioEventDb.FindId(treeHitEvent); fmodOneShot2.Send(); } } goto IL_1b46; IL_1181: if ((bool)component6) { component6.getCombo(3); } else { other.transform.SendMessageUpwards("getCombo", 3, SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.getCombo = 3; } goto IL_122e; IL_122e: if ((other.CompareTag("suitCase") || other.CompareTag("metalProp")) && animControl.smashBool) { other.transform.SendMessage("Hit", smashDamage, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); if (playerHitEnemy != null) { playerHitEnemy.Hit = (int)smashDamage; } if (BoltNetwork.isRunning && other.CompareTag("suitCase")) { OpenSuitcase openSuitcase = OpenSuitcase.Create(GlobalTargets.Others); openSuitcase.Position = base.GetComponent <Collider>().transform.position; openSuitcase.Damage = (int)smashDamage; openSuitcase.Send(); } if (smashSoundEnabled) { smashSoundEnabled = false; base.Invoke("EnableSmashSound", 0.3f); PlayEvent(smashHitEvent, null); if (BoltNetwork.isRunning) { FmodOneShot fmodOneShot3 = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable); fmodOneShot3.EventPath = CoopAudioEventDb.FindId(smashHitEvent); fmodOneShot3.Position = base.transform.position; fmodOneShot3.Send(); } } setup.pmNoise.SendEvent("toWeaponNoise"); hitReactions.enableWeaponHitState(); if (other.CompareTag("metalProp")) { Rigidbody component7 = other.GetComponent <Rigidbody>(); if ((bool)component7) { component7.AddForceAtPosition((Vector3.down + LocalPlayer.Transform.forward * 0.2f) * pushForce * 2f * (0.016666f / Time.fixedDeltaTime), base.transform.position, ForceMode.Force); } } } if ((other.CompareTag("enemyCollide") || other.CompareTag("lb_bird") || other.CompareTag("animalCollide") || other.CompareTag("Fish") || other.CompareTag("EnemyBodyPart")) && !mainTrigger && !enemyDelay && (animControl.smashBool || chainSaw)) { float num3 = smashDamage + ModdedPlayer.instance.MeleeDamageBonus; if (chainSaw && !mainTrigger) { base.StartCoroutine(chainSawClampRotation(0.25f)); num3 = (smashDamage + ModdedPlayer.instance.MeleeDamageBonus) / 2f; } float crit = ModdedPlayer.instance.CritDamageBuff; num3 *= crit * ModdedPlayer.instance.MeleeAMP; if (PlayerInventoryMod.EquippedModel == BaseItem.WeaponModelType.Hammer) { num3 *= ModdedPlayer.instance.HammerSmashDamageAmp; } DamageMath.DamageClamp(num3, out int dmg, out int a); base.transform.parent.SendMessage("GotBloody", SendMessageOptions.DontRequireReceiver); enemyDelay = true; base.Invoke("resetEnemyDelay", 0.25f); if ((rock || stick || spear || noBodyCut) && !allowBodyCut) { other.transform.SendMessageUpwards("ignoreCutting", SendMessageOptions.DontRequireReceiver); } other.transform.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("hitSuitCase", num3, SendMessageOptions.DontRequireReceiver); other.gameObject.SendMessage("getAttacker", Player, SendMessageOptions.DontRequireReceiver); other.gameObject.SendMessage("getAttackerType", 4, SendMessageOptions.DontRequireReceiver); if (fsmJumpAttackBool.Value && LocalPlayer.FpCharacter.jumpingTimer > 1.2f && !chainSaw) { other.transform.SendMessageUpwards("Explosion", -1, SendMessageOptions.DontRequireReceiver); if (BoltNetwork.isRunning) { playerHitEnemy.explosion = true; } } else if (!other.gameObject.CompareTag("Fish")) { if (other.gameObject.CompareTag("animalCollide")) { Vector3 vector2 = other.transform.root.GetChild(0).InverseTransformPoint(playerTr.position); float targetAngle = Mathf.Atan2(vector2.x, vector2.z) * 57.29578f; int animalHitDirection3 = animalHealth.GetAnimalHitDirection(targetAngle); other.transform.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection3, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("Hit", (int)num3, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = animalHitDirection3; } } else { other.transform.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver); for (int i = 0; i < a; i++) { other.transform.SendMessageUpwards("Hit", dmg, SendMessageOptions.DontRequireReceiver); } Mood.HitRumble(); } } else if (other.gameObject.CompareTag("Fish") && !spear) { other.transform.SendMessage("Hit", num3, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); } if (playerHitEnemy != null) { playerHitEnemy.getAttackerType = 4; playerHitEnemy.Hit = dmg; rep = a; } if (axe) { other.transform.SendMessageUpwards("HitAxe", SendMessageOptions.DontRequireReceiver); if (playerHitEnemy != null) { playerHitEnemy.HitAxe = true; } } if (other.CompareTag("lb_bird") || other.CompareTag("animalCollide")) { FMODCommon.PlayOneshotNetworked(animalHitEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (other.CompareTag("enemyCollide")) { FMODCommon.PlayOneshotNetworked(fleshHitEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (other.CompareTag("EnemyBodyPart")) { FMODCommon.PlayOneshotNetworked(hackBodyEvent, base.transform, FMODCommon.NetworkRole.Any); FauxMpHit((int)smashDamage); } setup.pmNoise.SendEvent("toWeaponNoise"); hitReactions.enableWeaponHitState(); } if (!mainTrigger && (other.CompareTag("BreakableWood") || other.CompareTag("BreakableRock"))) { other.transform.SendMessage("Hit", WeaponDamage, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, WeaponDamage), SendMessageOptions.DontRequireReceiver); FauxMpHit((int)WeaponDamage); } if (other.CompareTag("lb_bird") && !mainTrigger) { base.transform.parent.SendMessage("GotBloody", SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("Hit", WeaponDamage, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); FMODCommon.PlayOneshotNetworked(animalHitEvent, base.transform, FMODCommon.NetworkRole.Any); setup.pmNoise.SendEvent("toWeaponNoise"); hitReactions.enableWeaponHitState(); if (playerHitEnemy != null) { playerHitEnemy.Hit = (int)WeaponDamage; } } if (other.CompareTag("Tree") && !mainTrigger) { goto IL_1941; } if (other.CompareTag("MidTree") && !mainTrigger) { goto IL_1941; } goto IL_1b46; IL_1171: if (fsmHeavyAttackBool.Value) { goto IL_1181; } if (!hitReactions.kingHitBool) { if ((bool)component6) { component6.getCombo(animControl.combo); } else { other.transform.SendMessageUpwards("getCombo", animControl.combo, SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.getCombo = animControl.combo; } } goto IL_122e; IL_1b46: if (other.gameObject.CompareTag("Rope") && ForestVR.Enabled && mainTrigger) { setup.pmNoise.SendEvent("toWeaponNoise"); int num4 = DamageAmount; other.SendMessage("Hit", 5, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); PlayEvent(ropeHitEvent, null); } if ((other.CompareTag("SmallTree") || other.CompareTag("Rope")) && !mainTrigger) { setup.pmNoise.SendEvent("toWeaponNoise"); int integer3 = animator.GetInteger("hitDirection"); other.transform.SendMessage("getAttackDirection", integer3, SendMessageOptions.DontRequireReceiver); int num5 = DamageAmount; if (chainSaw || machete) { num5 *= 5; } other.SendMessage("Hit", num5, SendMessageOptions.DontRequireReceiver); Mood.HitRumble(); if (chainSaw || machete) { other.SendMessage("Hit", num5, SendMessageOptions.DontRequireReceiver); } FauxMpHit(num5); if (chainSaw || machete) { FauxMpHit(num5); } if (!plantSoundBreak) { if (other.CompareTag("SmallTree")) { if (!string.IsNullOrEmpty(plantHitEvent)) { FMODCommon.PlayOneshotNetworked(plantHitEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (other.CompareTag("Rope")) { PlayEvent(ropeHitEvent, null); } plantSoundBreak = true; base.Invoke("disablePlantBreak", 0.3f); } if (other.CompareTag("SmallTree")) { PlayerInv.GotLeaf(); } } if (other.CompareTag("fire") && !mainTrigger && fireStick) { other.SendMessage("startFire"); } if (playerHitEnemy != null && playerHitEnemy.Target && playerHitEnemy.Hit > 0) { //ModdedPlayer.instance.DoAreaDamage(other.transform.root, playerHitEnemy.Hit); if (ForestVR.Enabled && BoltNetwork.isClient) { playerHitEnemy.getCombo = Random.Range(2, 4); } for (int i = 0; i < rep; i++) { playerHitEnemy.Send(); } } }
void OnTriggerEnter(Collider other) { try { if (other.CompareTag("enemyCollide") || other.CompareTag("enemyRoot")) { if (SpellActions.SeekingArrow_ChangeTargetOnHit) { SpellActions.SetSeekingArrowTarget(other.transform); } var crit = ModdedPlayer.Stats.RandomCritDamage; var dmgOutput = dmg * crit; ModdedPlayer.instance.OnHit(); if (GameSetup.IsMpClient) { var entity = other.GetComponentInParent <BoltEntity>(); if (entity != null) { { var hitContext = new COTFEvents.HitOtherParams(dmgOutput, crit != 1, entity, this); COTFEvents.Instance.OnHitSpell.Invoke(hitContext); COTFEvents.Instance.OnHitEnemy.Invoke(hitContext); } var phe = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); phe.Target = entity; phe.getAttackerType = DamageMath.SILENTattackerTypeMagic; phe.Hit = DamageMath.GetSendableDamage(dmgOutput); if (crit > 1) { int myID = 3000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float fireDmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3; fireDmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; fireDmg *= ModdedPlayer.Stats.fireDamage + 1; using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(entity.networkId.PackedValue); w.Write(fireDmg); w.Write(15); w.Write(myID); w.Close(); } AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } phe.Burn = true; } phe.Send(); } } else //is singleplayer or host { if (EnemyManager.enemyByTransform.ContainsKey(other.transform.root)) { var progression = EnemyManager.enemyByTransform[other.transform.root]; { var hitContext = new COTFEvents.HitOtherParams(dmgOutput, crit != 1, progression, this); COTFEvents.Instance.OnHitSpell.Invoke(hitContext); COTFEvents.Instance.OnHitEnemy.Invoke(hitContext); } progression.HitMagic(dmgOutput); if (crit > 1) { if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit) { //int myID = 3000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float fireDmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3; fireDmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; fireDmg *= ModdedPlayer.Stats.fireDamage + 1; progression.FireDebuff(3000, fireDmg, 14); } progression.HealthScript.Burn(); } } else { Debug.LogWarning("Enemy not found"); } } if (UnityEngine.Random.value < ModdedPlayer.Stats.projectilePierceChance - pierceCount) { pierceCount++; } else { dieTimestamp = 0; } } } catch (Exception exc) { Debug.LogWarning(exc.ToString()); } }
private bool COTFHit(Collider other) { //----------------HIT DAMAGE float outputdmg = 0; if (animControl.smashBool) { outputdmg = smashDamage; } else { outputdmg = weaponDamage; } outputdmg += ModdedPlayer.Stats.meleeFlatDmg + SpellActions.GetParryCounterStrikeDmg(); outputdmg *= ModdedPlayer.Stats.RandomCritDamage * ModdedPlayer.Stats.MeleeDamageMult; if (hitReactions.kingHitBool || fsmHeavyAttackBool.Value) { outputdmg *= ModdedPlayer.Stats.heavyAttackDmg * 3; } if (animControl.smashBool) { outputdmg *= ModdedPlayer.Stats.smashDamage; } if (ModdedPlayer.Stats.perk_danceOfFiregod && Effects.BlackFlame.IsOn) { outputdmg *= 1 + LocalPlayer.Rigidbody.velocity.magnitude; } if (outputdmg < 0) { outputdmg = -outputdmg; } //----------------HIT DAMAGE if (other.CompareTag("enemyCollide") || other.CompareTag("enemyRoot")) { ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Melee(other.transform); if (GameSetup.IsMpClient) { var entity = other.GetComponentInParent <BoltEntity>(); if (entity != null) { var phe = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); phe.Target = entity; phe.getAttackerType = 4 + DamageMath.CONVERTEDFLOATattackerType; phe.Hit = DamageMath.GetSendableDamage(outputdmg); phe.HitAxe = axe; phe.hitFallDown = fsmHeavyAttackBool.Value && axe; phe.getAttackDirection = animator.GetInteger("hitDirection"); phe.takeDamage = 1; phe.getCombo = 3; phe.Burn = (fireStick && Random.value > 0.8f) || AlwaysIgnite || Effects.BlackFlame.IsOn; phe.explosion = fsmJumpAttackBool.Value && LocalPlayer.FpCharacter.jumpingTimer > 1.2f && !chainSaw; phe.Send(); ulong packed = entity.networkId.PackedValue; if (ModdedPlayer.Stats.TotalMeleeArmorPiercing > 0) { EnemyProgression.ReduceArmor(entity, ModdedPlayer.Stats.TotalMeleeArmorPiercing); } if ((hitReactions.kingHitBool || fsmHeavyAttackBool.Value) && ModdedPlayer.Stats.perk_chargedAtkKnockback) { using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(stream)) { Vector3 dir = other.transform.position - LocalPlayer.Transform.position; dir.y = 0; w.Write(43); w.Write(packed); w.Write(dir.x); w.Write(dir.y); w.Write(dir.z); w.Write(1f); w.Close(); } Network.NetworkManager.SendLine(stream.ToArray(), NetworkManager.Target.OnlyServer); stream.Close(); } } if (Effects.BlackFlame.IsOn) { using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(stream)) { w.Write(27); w.Write(packed); w.Write(Effects.BlackFlame.FireDamageBonus); w.Write(20f); w.Write(1); w.Close(); } Network.NetworkManager.SendLine(stream.ToArray(), NetworkManager.Target.OnlyServer); stream.Close(); } if (BlackFlame.GiveAfterburn && Random.value < 0.1f) { int id = 121 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(34); w.Write(packed); w.Write(id); w.Write(1.15f); w.Write(25f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } } if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit) { int myID = 2000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float fireDmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3; fireDmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; fireDmg *= ModdedPlayer.Stats.fireDamage + 1; fireDmg *= 0.35f; using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(packed); w.Write(fireDmg); w.Write(15); w.Write(myID); w.Close(); } AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } if (ModdedPlayer.Stats.i_HammerStun && PlayerInventoryMod.EquippedModel == BaseItem.WeaponModelType.Hammer) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(22); w.Write(packed); w.Write(ModdedPlayer.Stats.i_HammerStunAmount); w.Write(ModdedPlayer.Stats.i_HammerStunDuration); w.Write(40); w.Close(); } AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), NetworkManager.Target.OnlyServer); answerStream.Close(); } } SpellActions.Bash(packed, outputdmg); AfterHit(); return(true); } } else //is singleplayer or host { if (EnemyManager.enemyByTransform.ContainsKey(other.transform.root)) { var progression = EnemyManager.enemyByTransform[other.transform.root]; progression.HitPhysical(outputdmg); progression.HealthScript.getCombo(3); var hitDirection = animator.GetInteger("hitDirection"); progression.HealthScript.getAttackDirection(hitDirection); progression.setup.hitReceiver.getAttackDirection(hitDirection); progression.setup.hitReceiver.getCombo(3); if (fsmJumpAttackBool.Value && LocalPlayer.FpCharacter.jumpingTimer > 1.2f && !chainSaw) { progression.HealthScript.Explosion(-1f); } if (ModdedPlayer.Stats.TotalMeleeArmorPiercing > 0) { progression.ReduceArmor(ModdedPlayer.Stats.TotalMeleeArmorPiercing); } if ((hitReactions.kingHitBool || fsmHeavyAttackBool.Value) && ModdedPlayer.Stats.perk_chargedAtkKnockback) { Vector3 dir = other.transform.position - LocalPlayer.Transform.position; progression.AddKnockbackByDistance(dir, 1); } if (Effects.BlackFlame.IsOn) { progression.FireDebuff(40, Effects.BlackFlame.FireDamageBonus, 20); if (BlackFlame.GiveAfterburn && Random.value < 0.1f) { progression.DmgTakenDebuff(120, 1.15f, 25); } } if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit) { int myID = 2000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float fireDmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3; fireDmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; fireDmg *= ModdedPlayer.Stats.fireDamage + 1; fireDmg *= 0.35f; progression.FireDebuff(2000, fireDmg, 14); } if (ModdedPlayer.Stats.i_HammerStun && PlayerInventoryMod.EquippedModel == BaseItem.WeaponModelType.Hammer) { progression.Slow(40, ModdedPlayer.Stats.i_HammerStunAmount, ModdedPlayer.Stats.i_HammerStunDuration); } SpellActions.Bash(progression, outputdmg); if ((fireStick && Random.value > 0.8f) || AlwaysIgnite || Effects.BlackFlame.IsOn) { progression.HealthScript.Burn(); } AfterHit(); return(true); } } } else if (other.gameObject.CompareTag("PlayerNet") && (mainTrigger || (!mainTrigger && (animControl.smashBool || chainSaw)))) { if (ModSettings.FriendlyFire) { BoltEntity component3 = other.GetComponent <BoltEntity>(); BoltEntity component4 = base.GetComponent <BoltEntity>(); if (!object.ReferenceEquals(component3, component4) && lastPlayerHit + 0.2f < Time.time) { other.transform.root.SendMessage("getClientHitDirection", animator.GetInteger("hitDirection"), SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver); lastPlayerHit = Time.time; if (BoltNetwork.isRunning) { ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Melee(other.transform); DamageMath.ReduceDamageToSendOverNet(2f * (WeaponDamage + ModdedPlayer.Stats.meleeFlatDmg + SpellActions.GetParryCounterStrikeDmg()) * ModdedPlayer.Stats.MeleeDamageMult * ModdedPlayer.Stats.RandomCritDamage, out int dmg, out int repetitions); HitPlayer hitPlayer = HitPlayer.Create(component3, EntityTargets.Everyone); hitPlayer.damage = dmg; for (int i = 0; i < repetitions; i++) { hitPlayer.Send(); } } } AfterHit(); } return(true); } return(false); }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = transform.GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); return; } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); return; } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); return; } else if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); return; } else if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!(bool)component) { component = target.root.GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } return; } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { if (lastPierced != null) { if (target.root == lastPierced) { Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider); return; } } bool pierce = false; float pierceChance = ModdedPlayer.Stats.projectilePierceChance - pierceCount; if (pierceChance > 0) { if (pierceChance >= 1 || pierceChance < Random.value) { Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider); pierceCount++; lastPierced = target.root; Invoke("ForgetLastPierced", 0.125f); pierce = true; } } if (crossbowBoltType) { } else if (flintLockAmmoType) { } else if (spearType) { } else { if (ModdedPlayer.Stats.i_CrossfireQuiver.value) { if (Time.time - ModdedPlayer.instance._lastCrossfireTime > 10 * ModdedPlayer.Stats.cooldown) { ModdedPlayer.instance._lastCrossfireTime = Time.time; Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5; Vector3 dir = transform.position - pos; dir.Normalize(); SpellActions.CastMagicArrow(pos, dir); } } } arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } bool isbird = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool isfish = target.CompareTag("Fish"); bool isanimal = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); if (!spearType && !flintLockAmmoType && !isfish) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (isbird) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(isanimal, isbird, isfish); if (SpellActions.SeekingArrow_ChangeTargetOnHit) { startposition = transform.position; } if (BoltNetwork.isRunning) { if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { if (pierce) { headDamage = ((XArrowStickToTargetMod)arrowStickToTarget).checkHeadDamage(transform); } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } } else { if (pierce) { headDamage = ((XArrowStickToTargetMod)arrowStickToTarget).checkHeadDamage(transform); } headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if ((bool)arrowStickToTarget && !pierce) { Destroy(parent.gameObject); } } else { if (SpellActions.SeekingArrow_ChangeTargetOnHit) { ModdedPlayer.Stats.spell_seekingArrow.value = true; SpellActions.SeekingArrow_Target.gameObject.SetActive(true); SpellActions.SeekingArrow_Target.parent = target.transform; SpellActions.SeekingArrow_Target.position = new Vector3(target.transform.position.x, transform.position.y - 0.075f, target.transform.position.z); SpellActions.SeekingArrow_TimeStamp = Time.time; startposition = transform.position; SpellActions.SeekingArrow_ChangeTargetOnHit = false; } } if (headDamage && !flintLockAmmoType && ModdedPlayer.Stats.perk_trueAim && ModdedPlayer.Stats.spell_seekingArrow) { //True aim ability float dist = (startposition - transform.position).sqrMagnitude; if (dist >= 3600f) { OutputDmg *= 4; NewHitAi(target, isbird || isanimal, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); BuffDB.AddBuff(28, 104, 1.20f, 5); //crit chance if (ModdedPlayer.Stats.perk_trueAimUpgrade && dist >= 14400f) { OutputDmg *= 10; NewHitAi(target, isbird || isanimal, headDamage); NewHitAi(target, isbird || isanimal, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); } } } NewHitAi(target, isbird || isanimal, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (be == null) { be = target.GetComponent <BoltEntity>(); } if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit) { int myID = 1000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float dmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3; dmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; dmg *= ModdedPlayer.Stats.fireDamage + 1; dmg *= 0.3f; if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { target.GetComponentInParent <EnemyProgression>()?.FireDebuff(myID, dmg, 14); } else { if (be != null) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(be.networkId.PackedValue); w.Write(dmg); w.Write(14.5f); w.Write(1); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } } if (ModdedPlayer.Stats.TotalRangedArmorPiercing > 0 && target.gameObject.CompareTag("enemyCollide")) { if (ModdedPlayer.Stats.perk_thrownSpearExtraArmorReduction && spearType) { if (BoltNetwork.isClient) { if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.Stats.TotalRangedArmorPiercing * 2 + ModdedPlayer.Stats.TotalMeleeArmorPiercing); } } else if (EnemyManager.enemyByTransform.ContainsKey(target.root)) { var prog = EnemyManager.enemyByTransform[target.root]; prog.ReduceArmor(ModdedPlayer.Stats.TotalRangedArmorPiercing * 2 + ModdedPlayer.Stats.TotalMeleeArmorPiercing); } } else { if (BoltNetwork.isClient) { if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.Stats.TotalRangedArmorPiercing); } } else if (EnemyManager.enemyByTransform.ContainsKey(target.root)) { var prog = EnemyManager.enemyByTransform[target.root]; prog.ReduceArmor(ModdedPlayer.Stats.TotalRangedArmorPiercing); } } } if (isfish) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } //check piercing if (pierce) { return; } Live = false; disableLive(); DisableFlight(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (!(bool)be) { be = target.GetComponent <BoltEntity>(); } if (be) { if (ModdedPlayer.Stats.i_ArchangelBow && GreatBow.isEnabled) { float lifePerSecond = (ModdedPlayer.Stats.healthRecoveryPerSecond) * ModdedPlayer.Stats.allRecoveryMult * (ModdedPlayer.Stats.healthPerSecRate) * 2; using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(39); w.Write(be.GetState <IPlayerState>().name); w.Write(lifePerSecond); w.Write(ModdedPlayer.Stats.TotalMaxHealth * 0.2f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } BuffDB.AddBuff(25, 91, lifePerSecond, 10); } else if (ModSettings.FriendlyFire) { float dmgUnclamped = this.OutputDmg; if (ModdedPlayer.Stats.spell_seekingArrow) { float dist = Vector3.Distance(target.position, startposition); dmgUnclamped *= 1 + dist * ModdedPlayer.Stats.spell_seekingArrow_DamagePerDistance; } if (spearType) { if (ModdedPlayer.Stats.perk_thrownSpearhellChance > 0 && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance && OutputDmg > 1) { var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(PhysicBody.position - Camera.main.transform.position)); obj.velocity = PhysicBody.velocity.normalized * 90f * ModdedPlayer.Stats.projectileSpeed; Destroy(obj.gameObject, 18); } } if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.Stats.perk_bulletCritChance) || (spearType && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance)) { headDamage = true; dmgUnclamped *= ModdedPlayer.Stats.headShotDamage; dmgUnclamped *= SpellActions.FocusOnHeadShot(); if (ModdedPlayer.Stats.spell_seekingArrow) { dmgUnclamped *= ModdedPlayer.Stats.spell_seekingArrow_HeadDamage; } } else { dmgUnclamped *= SpellActions.FocusOnBodyShot(); } DamageMath.ReduceDamageToSendOverNet(dmgUnclamped, out int sendDamage, out int reps); HitPlayer HP = HitPlayer.Create(be, EntityTargets.Everyone); HP.damage = sendDamage; for (int i = 0; i < reps; i++) { HP.Send(); } //check piercing float pierceChance = ModdedPlayer.Stats.projectilePierceChance - pierceCount; if (pierceChance > 0) { if (pierceChance >= 1 || pierceChance < Random.value) { Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider); pierceCount++; return; } } disableLive(); DisableFlight(); } } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }
protected override void OnTriggerEnter(Collider other) { try { if (GameSetup.IsMpClient) { if (entity == null && !EnemyManager.clientEnemies.ContainsKey(entity.networkId.PackedValue)) { return; } else if (EnemyManager.clientEnemies[entity.networkId.PackedValue].Outdated) { LastReqTime = Time.time; using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(29); w.Write(entity.networkId.PackedValue); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } currState = animator.GetCurrentAnimatorStateInfo(0); nextState = animator.GetNextAnimatorStateInfo(0); if (currState.tagHash != damagedHash && currState.tagHash != staggerHash && currState.tagHash != hitStaggerHash && currState.tagHash != deathHash && nextState.tagHash != damagedHash && nextState.tagHash != staggerHash && nextState.tagHash != hitStaggerHash && nextState.tagHash != deathHash) { if (other.gameObject.CompareTag("trapTrigger")) { other.gameObject.SendMessage("CutRope", SendMessageOptions.DontRequireReceiver); } if (!netPrefab && LocalPlayer.Animator && LocalPlayer.Animator.GetBool("deathBool")) { return; } if (other.gameObject.CompareTag("playerHitDetect") && mainTrigger) { if (!Scene.SceneTracker.hasAttackedPlayer) { Scene.SceneTracker.hasAttackedPlayer = true; Scene.SceneTracker.Invoke("resetHasAttackedPlayer", Random.Range(120, 240)); } targetStats component = other.transform.root.GetComponent <targetStats>(); if (component && component.targetDown) { return; } Animator componentInParent = other.gameObject.GetComponentInParent <Animator>(); Vector3 position = rootTr.position; position.y += 3.3f; Vector3 direction = other.transform.position - position; if (!Physics.Raycast(position, direction, out hit, direction.magnitude, enemyHitMask, QueryTriggerInteraction.Ignore)) { ModAPI.Console.Write("Starting to get hit"); if (((!creepy_male && !creepy && !creepy_baby && !creepy_fat) || ModdedPlayer.instance.ParryAnything) && events) { ModAPI.Console.Write("events exists"); if (componentInParent) { ModAPI.Console.Write("componentInParent exists"); bool flag = InFront(other.gameObject); ModAPI.Console.Write("in front: " + flag + "\nevents.parryBool: " + events.parryBool + "\nnext tagHash: " + (componentInParent.GetNextAnimatorStateInfo(1).tagHash == blockHash) + "\ncurrent tagHash" + (componentInParent.GetCurrentAnimatorStateInfo(1).tagHash == blockHash) + "\nfirst condition" + (!BoltNetwork.isServer || !netPrefab)); if ((!BoltNetwork.isServer || !netPrefab) && flag && events.parryBool && ((componentInParent.GetNextAnimatorStateInfo(1).tagHash == blockHash || componentInParent.GetCurrentAnimatorStateInfo(1).tagHash == blockHash) || ModdedPlayer.instance.ParryAnything)) { ModAPI.Console.Write("Parrying successful"); int parryDir = events.parryDir; BoltSetReflectedShim.SetIntegerReflected(animator, "parryDirInt", parryDir); if (BoltNetwork.isClient && netPrefab) { BoltSetReflectedShim.SetTriggerReflected(animator, "ClientParryTrigger"); hitPrediction.StartParryPrediction(); parryEnemy parryEnemy = parryEnemy.Create(GlobalTargets.OnlyServer); parryEnemy.Target = transform.root.GetComponent <BoltEntity>(); parryEnemy.Send(); FMODCommon.PlayOneshot(parryEvent, base.transform); } else { BoltSetReflectedShim.SetTriggerReflected(animator, "parryTrigger"); } SpellActions.DoParry(transform.position); events.StartCoroutine("disableAllWeapons"); playerHitReactions componentInParent2 = other.gameObject.GetComponentInParent <playerHitReactions>(); if (componentInParent2 != null) { componentInParent2.enableParryState(); } FMODCommon.PlayOneshotNetworked(parryEvent, base.transform, FMODCommon.NetworkRole.Server); events.parryBool = false; return; } } } if ((bool)events) { events.parryBool = false; } other.transform.root.SendMessage("getHitDirection", rootTr.position, SendMessageOptions.DontRequireReceiver); int num = 0; if (maleSkinny || femaleSkinny) { if (pale) { num = ((!skinned) ? Mathf.FloorToInt(10f * GameSettings.Ai.skinnyDamageRatio) : Mathf.FloorToInt(10f * GameSettings.Ai.skinnyDamageRatio * GameSettings.Ai.skinMaskDamageRatio)); } else { num = Mathf.FloorToInt(13f * GameSettings.Ai.skinnyDamageRatio); if (maleSkinny && props.regularStick.activeSelf && events.leftHandWeapon) { num = Mathf.FloorToInt(num * 1.35f); } } } else if (male && pale) { num = ((!skinned) ? Mathf.FloorToInt(22f * GameSettings.Ai.largePaleDamageRatio) : Mathf.FloorToInt(22f * GameSettings.Ai.largePaleDamageRatio * GameSettings.Ai.skinMaskDamageRatio)); } else if (male && !firemanMain) { num = ((!painted) ? Mathf.FloorToInt(20f * GameSettings.Ai.regularMaleDamageRatio) : Mathf.FloorToInt(20f * GameSettings.Ai.regularMaleDamageRatio * GameSettings.Ai.paintedDamageRatio)); } else if (female) { num = Mathf.FloorToInt(17f * GameSettings.Ai.regularFemaleDamageRatio); } else if (creepy) { num = ((!pale) ? Mathf.FloorToInt(28f * GameSettings.Ai.creepyDamageRatio) : Mathf.FloorToInt(35f * GameSettings.Ai.creepyDamageRatio)); } else if (creepy_male) { num = ((!pale) ? Mathf.FloorToInt(60f * GameSettings.Ai.creepyDamageRatio) : Mathf.FloorToInt(120f * GameSettings.Ai.creepyDamageRatio)); } else if (creepy_baby) { num = Mathf.FloorToInt(26f * GameSettings.Ai.creepyBabyDamageRatio); } else if (firemanMain) { num = Mathf.FloorToInt(12f * GameSettings.Ai.regularMaleDamageRatio); if (events && !enemyAtStructure && !events.noFireAttack) { if (BoltNetwork.isRunning && netPrefab) { other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } else { other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } } } if (!female && male) { if (holdingRegularWeapon() && events.leftHandWeapon) { num += 7; } else if (holdingAdvancedWeapon() && events.leftHandWeapon) { num += 15; } } if (setup && setup.health.poisoned) { num = Mathf.FloorToInt(num / 1.6f); } //My additional code try { if (GameSetup.IsMpClient) { if (other.transform.root == LocalPlayer.Transform.root) { var x = EnemyManager.clientEnemies[entity.networkId.PackedValue]; num = Mathf.RoundToInt(num * x.damagemult); if (x.abilities.Contains(EnemyProgression.Abilities.RainEmpowerement)) { if (TheForest.Utils.Scene.WeatherSystem.Raining) { num *= 5; } } if (x.abilities.Contains(EnemyProgression.Abilities.Poisonous)) { BuffDB.AddBuff(3, 32, Mathf.Sqrt(num / 10) / 7, poisonDuration); } if (x.abilities.Contains(EnemyProgression.Abilities.Basher)) { ModdedPlayer.instance.Stun(stunDuration); } if (ModdedPlayer.instance.thornsDamage > 0) { DamageMath.DamageClamp(ModdedPlayer.instance.thornsDamage, out int dmg, out int reps); PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = entity; playerHitEnemy.Hit = dmg; AsyncHit.SendPlayerHitEnemy(playerHitEnemy, reps, 0.1f); } } } else { if (other.transform.root == LocalPlayer.Transform.root) { if (EnemyProg == null) { EnemyProg = setup.health.gameObject.GetComponent <EnemyProgression>(); } num = Mathf.RoundToInt(num * EnemyProg.DamageAmp * EnemyProg.DebuffDmgMult); BoltEntity bo = other.transform.root.GetComponent <BoltEntity>(); if (bo == null) { bo = other.transform.root.GetComponentInChildren <BoltEntity>(); } //POISON ATTACKS if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Poisonous)) { BuffDB.AddBuff(3, 32, Mathf.Sqrt(num / 10) / 10, poisonDuration); } //STUN ON HIT if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Basher)) { ModdedPlayer.instance.Stun(stunDuration); } if (ModdedPlayer.instance.thornsDamage > 0) { Invoke("HitEnemeyDelayed", 0.1f); } } } } catch (System.Exception ex) { ModAPI.Log.Write(ex.ToString()); } PlayerStats component2 = other.transform.root.GetComponent <PlayerStats>(); if (male || female || creepy_male || creepy_fat || creepy || creepy_baby) { netId component3 = other.transform.GetComponent <netId>(); if (BoltNetwork.isServer && component3) { other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver); return; } if (BoltNetwork.isClient && netPrefab && !(bool)component3) { other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("hitFromEnemy", num, SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver); } else if (BoltNetwork.isServer) { if (!(bool)component3) { other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver); other.transform.root.SendMessage("hitFromEnemy", num, SendMessageOptions.DontRequireReceiver); } } else if (!BoltNetwork.isRunning && component2) { component2.setCurrentAttacker(this); component2.hitFromEnemy(num); } } else if (!netPrefab && component2) { component2.setCurrentAttacker(this); component2.hitFromEnemy(num); } goto IL_092f; } return; } goto IL_092f; } return; IL_092f: if (other.gameObject.CompareTag("enemyCollide") && mainTrigger && bodyCollider && !enemyAtStructure) { setupAttackerType(); if (other.gameObject != bodyCollider) { other.transform.SendMessageUpwards("getAttackDirection", Random.Range(0, 2), SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("getCombo", Random.Range(1, 4), SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("getAttackerType", attackerType, SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("getAttacker", rootTr.gameObject, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("Hit", 6, SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } } if (other.gameObject.CompareTag("BreakableWood") || (other.gameObject.CompareTag("BreakableRock") && mainTrigger)) { other.transform.SendMessage("Hit", 50, SendMessageOptions.DontRequireReceiver); other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, 50f), SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } if (other.gameObject.CompareTag("SmallTree") && !mainTrigger) { other.SendMessage("Hit", 2, SendMessageOptions.DontRequireReceiver); } if (other.gameObject.CompareTag("Fire") && mainTrigger && firemanMain && !events.noFireAttack) { other.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } if (other.gameObject.CompareTag("Tree") && mainTrigger && creepy_male) { other.SendMessage("Explosion", 5f, SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } if (!other.gameObject.CompareTag("structure") && !other.gameObject.CompareTag("SLTier1") && !other.gameObject.CompareTag("SLTier2") && !other.gameObject.CompareTag("SLTier3") && !other.gameObject.CompareTag("jumpObject") && !other.gameObject.CompareTag("UnderfootWood")) { return; } if (!mainTrigger) { return; } getStructureStrength component4 = other.gameObject.GetComponent <getStructureStrength>(); bool flag2 = false; if (component4 == null) { flag2 = true; } enemyAtStructure = true; int num2 = 0; if (!creepy_male && !creepy && !creepy_fat && !creepy_baby) { if (!flag2) { num2 = ((maleSkinny || femaleSkinny) ? ((component4._strength == getStructureStrength.strength.weak) ? Mathf.FloorToInt(8f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((pale || painted || skinned) ? ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(16f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(12f * GameSettings.Ai.regularStructureDamageRatio) : 0))); goto IL_0d63; } return; } num2 = ((!creepy_baby) ? Mathf.FloorToInt(30f * GameSettings.Ai.creepyStructureDamageRatio) : Mathf.FloorToInt(10f * GameSettings.Ai.creepyStructureDamageRatio)); goto IL_0d63; IL_0d63: if (setup && setup.health.poisoned) { num2 /= 2; } other.SendMessage("Hit", num2, SendMessageOptions.DontRequireReceiver); other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, num2), SendMessageOptions.DontRequireReceiver); FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server); } catch (System.Exception ee) { ModAPI.Log.Write(ee.ToString()); } }