public static void DoBlink() { RaycastHit[] hits = Physics.RaycastAll(Camera.main.transform.position, Camera.main.transform.forward, BlinkRange); foreach (RaycastHit hit in hits) { if (BlinkDamage != 0) { if (hit.transform.root.CompareTag("enemyCollide")) { float dmg = BlinkDamage + ModdedPlayer.instance.SpellDamageBonus / 5; dmg *= ModdedPlayer.instance.SpellAMP; int dmgInt = Mathf.RoundToInt(dmg); if (GameSetup.IsMpClient) { BoltEntity enemyEntity = hit.transform.root.GetComponent <BoltEntity>(); if (enemyEntity == null) { enemyEntity = hit.transform.root.GetComponentInChildren <BoltEntity>(); } if (enemyEntity != null) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(enemyEntity); playerHitEnemy.hitFallDown = true; playerHitEnemy.Hit = dmgInt; playerHitEnemy.Send(); } } else { hit.transform.SendMessageUpwards("Hit", dmgInt, SendMessageOptions.DontRequireReceiver); } } } if (hit.transform.root != LocalPlayer.Transform.root && Vector3.Distance(hit.point, LocalPlayer.Transform.position) > 4) { int tries = 0; Vector3 hitPoint = hit.point; while (Physics.Raycast(hitPoint, Vector3.up, 2f) && tries < 5) { hitPoint += -Camera.main.transform.forward; tries++; } if (tries < 5) { BlinkTowards(hitPoint); return; } } } Vector3 checkPos = Camera.main.transform.position + new Vector3(Camera.main.transform.forward.x, 0, Camera.main.transform.forward.z).normalized *BlinkRange; if (Physics.Raycast(checkPos + Vector3.up * 2, Vector3.down, out RaycastHit hit1, 10f)) { BlinkTowards(hit1.point + Vector3.up); return; } BlinkTowards(Camera.main.transform.position + Camera.main.transform.forward * (BlinkRange - 1)); }
private void Update() { if (Time.time > this.valideColliderDelay) { this.ValidateWaterCollider(); this.valideColliderDelay = Time.time + 2f; } if (this.inWater) { if (this.currentWaterCollider) { float num = this.currentWaterCollider.bounds.center.y + this.currentWaterCollider.bounds.extents.y; if (!this.netPrefab && num - this.setup.rootTr.position.y > 0.9f && !this.setup.search.fsmInCave.Value) { if (!this.fsmExitWaterBool.Value) { this.setup.pmCombat.SendEvent("goToExitWater"); } this.fsmExitWaterBool.Value = true; } this.waterHeight = num - this.rootTr.position.y; if (this.waterHeight > 4f) { this.underWater = true; if (Time.time > this.inWaterTimer - 1f && !this.drowned) { if (BoltNetwork.isClient) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = base.GetComponent <BoltEntity>(); playerHitEnemy.Hit = 1000; playerHitEnemy.Send(); } else { this.setup.health.HitReal(1000); } this.drowned = true; } } else { this.underWater = false; this.inWaterTimer = Time.time + 5f; } } else { this.underWater = false; } } else { this.inWaterTimer = Time.time + 5f; this.underWater = false; } }
public static int KillAll() { int numKilled = 0; List <GameObject> list = new List <GameObject>(TheForest.Utils.Scene.MutantControler.activeCannibals); foreach (GameObject current in TheForest.Utils.Scene.MutantControler.activeInstantSpawnedCannibals) { if (!list.Contains(current)) { list.Add(current); } } //list.RemoveAll((GameObject o) => 0 == null); list.RemoveAll((GameObject o) => o != o.activeSelf); if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { list[i].SendMessage("killThisEnemy", SendMessageOptions.DontRequireReceiver); //list[i].SendMessage("Die"); numKilled += 1; } } foreach (Collider hit in Physics.OverlapSphere( LocalPlayer.MainCam.transform.position, KillRadius)) { BoltEntity entity = hit.GetComponent <BoltEntity>(); if (entity != null && entity.isAttached && entity.StateIs <IMutantState>()) { try { var playerHitEnemy = PlayerHitEnemy.Create(Bolt.GlobalTargets.OnlyServer); playerHitEnemy.Target = entity; playerHitEnemy.Burn = true; playerHitEnemy.getStealthAttack = true; playerHitEnemy.Hit = 1000; playerHitEnemy.takeDamage = 1000; playerHitEnemy.HitAxe = true; playerHitEnemy.Send(); numKilled += 1; } catch { } } } return(numKilled); }
private void Hit(int d) { if (this.fishScript) { this.fishScript.Hit(d); } if (BoltNetwork.isClient) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = base.transform.GetComponentInParent <BoltEntity>(); playerHitEnemy.Hit = d; } }
public static void ReduceArmor(BoltEntity target, int amount) { if (GameSetup.IsMultiplayer) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = target; playerHitEnemy.Hit = -amount - 50000; playerHitEnemy.Send(); } else { EnemyManager.hostDictionary[target.networkId.PackedValue].ArmorReduction += amount; } }
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); } } } } }
protected override void OnTriggerEnter(Collider other) { 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(); HitPlayer hitPlayer = HitPlayer.Create(component3, EntityTargets.Everyone); hitPlayer.damage = Mathf.FloorToInt((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(); 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) { if ((bool)component6) { component6.Burn(); } else { other.transform.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver); } if (playerHitEnemy != null) { playerHitEnemy.Burn = true; } } float num2 = WeaponDamage + ModdedPlayer.instance.MeleeDamageBonus; //ModAPI.Console.Write("Num 2 " + num2 + " bonus = " + ModdedPlayer.instance.MeleeDamageBonus); float crit = ModdedPlayer.instance.CritDamageBuff; num2 *= crit * ModdedPlayer.instance.MeleeAMP; if (component2 && chainSaw && (component2.typeMaleCreepy || component2.typeFemaleCreepy || component2.typeFatCreepy)) { num2 /= 2f; } //ModAPI.Console.Write(string.Format("\nOutput melee={0}\n\n" + // "weaponDamage float " + weaponDamage + // "\n{1}base \n {2} bonus\n" + // "{3} melee amp \n {4} crit", num2, WeaponDamage, ModdedPlayer.instance.MeleeDamageBonus, ModdedPlayer.instance.MeleeAMP, crit)); if (hitReactions.kingHitBool || fsmHeavyAttackBool.Value) { if ((bool)component6) { if (fsmHeavyAttackBool.Value && axe && !smallAxe) { component6.sendHitFallDown(num2 * 3f); if (playerHitEnemy != null) { playerHitEnemy.Hit = (int)num2 * 3; playerHitEnemy.hitFallDown = true; } } else { component6.getCombo(3); component6.hitRelay((int)num2 * 3); } } else { int animalHitDirection = animalHealth.GetAnimalHitDirection(num); other.transform.SendMessageUpwards("getCombo", 3, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver); other.transform.SendMessageUpwards("Hit", (int)num2 * 3, SendMessageOptions.DontRequireReceiver); //ModdedPlayer.instance.DoAreaDamage(other.transform.root, (int)num2 * 3); if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = animalHitDirection; } } if (playerHitEnemy != null) { playerHitEnemy.Hit = (int)num2 * 3; playerHitEnemy.getCombo = 3; } 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); other.transform.SendMessageUpwards("Hit", (int)num2, SendMessageOptions.DontRequireReceiver); if (playerHitEnemy != null) { playerHitEnemy.getAttackDirection = animalHitDirection2; } } Mood.HitRumble(); if (playerHitEnemy != null) { playerHitEnemy.Hit = (int)num2; } 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; //ModAPI.Console.Write(string.Format("\nOutput melee={0}\n\n" + // "weaponDamage float " + smashDamage + // "\n{1}base \n {2} bonus\n" + // "{3} melee amp \n {4} crit", num3, smashDamage, ModdedPlayer.instance.MeleeDamageBonus, ModdedPlayer.instance.MeleeAMP, crit)); //ModdedPlayer.instance.DoAreaDamage(other.transform.root, (int)num3); 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); other.transform.SendMessageUpwards("Hit", num3, 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 = (int)num3; } 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) { if (ForestVR.Enabled && BoltNetwork.isClient) { playerHitEnemy.getCombo = Random.Range(2, 4); } playerHitEnemy.Send(); //ModdedPlayer.instance.DoAreaDamage(other.transform.root, playerHitEnemy.Hit); } }
protected override void Update() { if (Time.time > valideColliderDelay) { ValidateWaterCollider(); valideColliderDelay = Time.time + 2f; } if (inWater) { if ((bool)currentWaterCollider) { Vector3 center = currentWaterCollider.bounds.center; float y = center.y; Vector3 extents = currentWaterCollider.bounds.extents; float num = y + extents.y; if (!netPrefab) { float num2 = num; Vector3 position = setup.rootTr.position; if (num2 - position.y > 0.9f && !setup.search.fsmInCave.Value) { if (!fsmExitWaterBool.Value) { setup.pmCombat.SendEvent("goToExitWater"); } fsmExitWaterBool.Value = true; } } float num3 = num; Vector3 position2 = rootTr.position; waterHeight = num3 - position2.y; if (waterHeight > 4f) { underWater = true; if (Time.time > inWaterTimer - 1f && !drowned) { if (BoltNetwork.isClient) { PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer); playerHitEnemy.Target = base.GetComponent <BoltEntity>(); playerHitEnemy.Hit = int.MaxValue - 1; playerHitEnemy.Send(); } else { setup.health.HitReal(setup.health.Health); } drowned = true; } } else { underWater = false; inWaterTimer = Time.time + 5f; } } else { underWater = false; } } else { inWaterTimer = Time.time + 5f; underWater = false; } }
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()); } }
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); }
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); } } } }
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()); } }
private static void OnTick(object sender, EventArgs args) { if (Active && Environment.TickCount - _lastPulse > 250) { _lastPulse = Environment.TickCount; var hits = Physics.SphereCastAll(LocalPlayer.MainCam.transform.position, Radius, new Vector3(1f, 0f, 0f)); if (hits != null && hits.Length > 0) { foreach (var hit in hits) { if (Enabled.RepairBuildings) { var entity = hit.collider.GetComponent <BoltEntity>(); if (entity != null && entity.isAttached && entity.StateIs <IRepairableStructure>()) { Logger.Info("Found repairable structure!"); var structure = entity.GetState <IRepairableStructure>(); if (structure != null) { Logger.Info("Got repairable structure!"); var missingMaterials = structure.CalcTotalRepairMaterial() - structure.RepairMaterial; var missingLogs = structure.CalcMissingRepairLogs() - structure.RepairLogs; if (missingMaterials > 0) { for (var i = 0; i < missingMaterials; i++) { structure.AddRepairMaterial(false); } } if (missingLogs > 0) { for (var i = 0; i < missingLogs; i++) { structure.AddRepairMaterial(true); } } } } } if (Enabled.KillEnemies) { var entity = hit.collider.GetComponent <BoltEntity>(); if (entity != null && entity.isAttached && entity.StateIs <IMutantState>()) { try { var playerHitEnemy = PlayerHitEnemy.Create(Bolt.GlobalTargets.OnlyServer); playerHitEnemy.Target = entity; playerHitEnemy.Burn = true; playerHitEnemy.getStealthAttack = true; playerHitEnemy.Hit = 1000; playerHitEnemy.takeDamage = 1000; playerHitEnemy.HitAxe = true; playerHitEnemy.Send(); } catch (Exception) { // ignored } } } if (Enabled.KillPlayers) { var player = hit.collider.GetComponent <CoopPlayerRemoteSetup>(); if (player != null) { KillAllPlayers.KillSinglePlayer(player); } } } } } }
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 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); }
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); }
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); }