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); } } } } }
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 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); }
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()); } }
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()); } }
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); } }