// Update is called once per frame void Update() { bool hardFlashLaunch = Input.GetKeyDown(KeyCode.Q); bool softFlashLaunch = Input.GetKeyDown(KeyCode.E); bool molotov = Input.GetKeyDown(KeyCode.Z); bool smoke = Input.GetKeyDown(KeyCode.X); if (hardFlashLaunch || softFlashLaunch) { // Creating the nade FlashGreanade fg = Instantiate(flashPrefab, cam.position + cam.forward * 1, Quaternion.identity); // Activate the mesh so the grenade is visible fg.gameObject.GetComponent <MeshRenderer>().enabled = true; // Grenade needs to have a Rigidbody component, so we can apply forces to it Rigidbody rb = fg.gameObject.AddComponent <Rigidbody>(); rb.collisionDetectionMode = CollisionDetectionMode.Continuous; // This is to avoid the grenade go through walls // Apply a force to throw the nade float launchForce = (hardFlashLaunch) ? hardLaunchForce : softLaunchForce; // Con un hardLaunch lanzamos la granada con fuerza = 20. Con un softLaunch, la lanzamos con fuerza = 2 fg.GetComponent <Rigidbody>().AddForce(cam.forward * launchForce, ForceMode.Impulse); fg.Launch(); // Activate the nade script (see Launch method in FlashGrenade.cs) // Play sounds asrc.clip = flashRadioSound; asrc.Play(); } else if (molotov) { // Creating the nade Molotov m = Instantiate(molotovPrefab, cam.position + cam.forward * 1, Quaternion.identity); m.gameObject.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = true; // Grenade needs to have a Rigidbody component, so we can apply forces to it Rigidbody rb = m.gameObject.AddComponent <Rigidbody>(); rb.collisionDetectionMode = CollisionDetectionMode.Continuous; // Esto se hace para que la granada no atraviese las paredes // Apply a force to throw the nade rb.AddForce(cam.forward * hardLaunchForce, ForceMode.Impulse); rb.angularVelocity = new Vector3(0, 3, 10); m.Launch(); // Play sounds asrc.clip = molotovRadioSound; asrc.Play(); } else if (smoke) // This one is a little bit different. The throw is performed in the method 'ThrowSmoke()' 0.9sec after the key is pressed instead of inside the 'else if' branch. This is made to play the hand animation before the grenade is throwed { Invoke("ThrowSmoke", 0.9f); handsAnim.Play("My_Grenade_Throw"); asrc.clip = smokeRadioSound; asrc.Play(); } }
private void OnCollisionEnter(Collision collision) { Molotov componentInChildren = base.transform.GetComponentInChildren <Molotov>(); if (componentInChildren) { componentInChildren.doMolotovCollision(collision); } }
// Lanzamiento de la bomba. La deja activada. public override void LanzarBomba() { if (bomba.FueDestruido())//Le permite agregar otra bomba si la anterior ya ha explotado { bomba = new Molotov(); } else if (bomba.EstaActivada) { return; } this.tablero.AgregarEntidadEnCasillero(bomba, posicion.Fila, posicion.Columna); bomba.ActivarBomba(); }
private void doBreakReal() { Molotov componentInChildren = base.transform.GetComponentInChildren <Molotov>(); if (componentInChildren) { componentInChildren.doBreakReal(); Collider component = base.transform.GetComponent <Collider>(); if (component) { component.enabled = false; } } }
// Update is called once per frame void Update() { bool hardFlashLaunch = Input.GetKeyDown(KeyCode.Q); bool softFlashLaunch = Input.GetKeyDown(KeyCode.E); bool molotov = Input.GetKeyDown(KeyCode.Z); bool smoke = Input.GetKeyDown(KeyCode.X); if (hardFlashLaunch || softFlashLaunch) { // Creamos la granada FlashGreanade fg = Instantiate(flashPrefab, cam.position + cam.forward * 1, Quaternion.identity); // La granada tiene que tener un Rigidbody, para que podamos aplicar una fuerza sobre ella Rigidbody rb = fg.gameObject.AddComponent <Rigidbody>(); rb.collisionDetectionMode = CollisionDetectionMode.Continuous; // Esto se hace para que la granada no atraviese las paredes // Aplicamos una fuerza sobre ella para lanzarla, y activamos su mecanismo float launchForce = (hardFlashLaunch) ? hardLaunchForce : softLaunchForce; // Con un hardLaunch lanzamos la granada con fuerza = 20. Con un softLaunch, la lanzamos con fuerza = 2 fg.GetComponent <Rigidbody>().AddForce(cam.forward * launchForce, ForceMode.Impulse); fg.Launch(); asrc.clip = flashRadioSound; asrc.Play(); } else if (molotov) { Molotov m = Instantiate(molotovPrefab, cam.position + cam.forward * 2, Quaternion.identity); Rigidbody rb = m.gameObject.AddComponent <Rigidbody>(); rb.collisionDetectionMode = CollisionDetectionMode.Continuous; // Esto se hace para que la granada no atraviese las paredes rb.AddForce(cam.forward * hardLaunchForce, ForceMode.Impulse); rb.angularVelocity = new Vector3(0, 3, 10); m.Launch(); asrc.clip = molotovRadioSound; asrc.Play(); } else if (smoke) { Invoke("ThrowSmoke", 0.9f); handsAnim.Play("My_Grenade_Throw"); asrc.clip = smokeRadioSound; asrc.Play(); } }
public void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (this.ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = base.transform.GetComponentInParent <Molotov>(); if (componentInParent) { componentInParent.IncendiaryBreak(); } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(this.hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(this.hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(this.hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (this.spearType) { base.StartCoroutine(this.HitTree(this.hit.point - base.transform.forward * 2.1f)); } else if (this.hitPointUpdated) { base.StartCoroutine(this.HitTree(this.hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(this.HitTree(base.transform.position - base.transform.forward * 0.35f)); } this.disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!component) { component = target.root.GetComponent <TreeHealth>(); } if (component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { bool flag = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool flag2 = target.CompareTag("Fish"); bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } if (!this.spearType && !this.flintLockAmmoType && !flag2) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (flag) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(flag3, flag, flag2); if (BoltNetwork.isRunning) { if (this.at && this.at._boltEntity && this.at._boltEntity.isAttached && this.at._boltEntity.isOwner) { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if (arrowStickToTarget) { base.Invoke("destroyMe", 0.1f); } } base.StartCoroutine(this.HitAi(target, flag || flag3, headDamage)); if (flag2) { base.StartCoroutine(this.HitFish(target, this.hit.point - base.transform.forward * 0.35f)); } this.disableLive(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity boltEntity = target.GetComponentInParent <BoltEntity>(); if (!boltEntity) { boltEntity = target.GetComponent <BoltEntity>(); } if (boltEntity) { HitPlayer.Create(boltEntity, EntityTargets.OnlyOwner).Send(); this.disableLive(); } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (this.ignoreTerrain) { this.ignoreTerrain = false; base.StartCoroutine(this.RevokeIgnoreTerrain()); } else { if (this.spearType) { if (this.bodyCollider) { this.bodyCollider.isTrigger = true; } base.StartCoroutine(this.HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position) + Terrain.activeTerrain.transform.position.y; if (base.transform.position.y < num) { position2.y = num + 0.5f; } base.StartCoroutine(this.HitStructure(position2, false)); } this.disableLive(); FMODCommon.PlayOneshotNetworked(this.hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if (target.transform.parent && (target.transform.parent.GetComponent <StickFenceChunkArchitect>() || target.transform.parent.GetComponent <BoneFenceChunkArchitect>())) { return; } if (!isTrigger) { if (this.spearType) { base.StartCoroutine(this.HitStructure(this.hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(this.HitStructure(this.hit.point - base.transform.forward * 0.35f, true)); } this.disableLive(); } } else if (target.CompareTag("CaveDoor")) { this.ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (this.flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!this.Live) { this.destroyThisAmmo(); this.parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = transform.GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!(bool)component) { component = target.root.GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { bool flag = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool flag2 = target.CompareTag("Fish"); bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } if (!spearType && !flintLockAmmoType && !flag2) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (flag) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(flag3, flag, flag2); if (BoltNetwork.isRunning) { if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if ((bool)arrowStickToTarget) { base.Invoke("destroyMe", 0.1f); } } base.StartCoroutine(HitAi(target, flag || flag3, headDamage)); ModdedPlayer.instance.DoAreaDamage(target.root, damage); ModdedPlayer.instance.DoOnHit(); if (ModdedPlayer.instance.RangedArmorReduction > 0 && target.gameObject.CompareTag("enemyCollide")) { if (BoltNetwork.isClient) { BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (be == null) { be = target.GetComponent <BoltEntity>(); } if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.instance.MeleeArmorReduction); } } else { target.transform.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.MeleeArmorReduction, SendMessageOptions.DontRequireReceiver); } } if (flag2) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } disableLive(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity boltEntity = target.GetComponentInParent <BoltEntity>(); if (!(bool)boltEntity) { boltEntity = target.GetComponent <BoltEntity>(); } if (boltEntity && ModSettings.FriendlyFire) { HitPlayer HP = HitPlayer.Create(boltEntity, EntityTargets.Everyone); HP.damage = damage; HP.Send(); disableLive(); } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }
public virtual void DaniarConMolotov(Molotov molotov) { }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (alreadyHit.Contains(target)) { return; } else { alreadyHit.Add(target); } if (UpgradePointsMod.instance != null) { float a = BaseDamage + velocitybonus; a *= UpgradePointsMod.instance.ArrowDmg; if (UpgradePointsMod.instance.specialUpgrades[28].bought) { if (UpgradePointsMod.instance.specialUpgrades[49].bought) { if (UpgradePointsMod.instance.specialUpgrades[50].bought) { if (UpgradePointsMod.instance.specialUpgrades[36].bought) { if (UpgradePointsMod.instance.specialUpgrades[90].bought) { if (UpgradePointsMod.instance.specialUpgrades[91].bought) { if (UpgradePointsMod.instance.specialUpgrades[92].bought) { if (UpgradePointsMod.instance.specialUpgrades[93].bought) { if (UpgradePointsMod.instance.specialUpgrades[94].bought) { if (UpgradePointsMod.instance.specialUpgrades[95].bought) { a *= 35; } else { a *= 32.5f; } } else { a *= 30f; } } else { a *= 27f; } } else { a *= 24f; } } else { a *= 20f; } } else { a *= 16f; } } else { a *= 8f; } } else { a *= 3f; } } else { a *= 2f; } if (spearType) { if (UpgradePointsMod.instance.specialUpgrades[30].bought) { a *= 3.5f; } } if (UpgradePointsMod.instance.specialUpgrades[29].bought) { if (UpgradePointsMod.instance.specialUpgrades[89].bought) { a *= 1 + UpgradePointsMod.instance.FocusFireStacks * 0.4f; } else { a *= 1 + UpgradePointsMod.instance.FocusFireStacks * 0.25f; } } if (UpgradePointsMod.instance.specialUpgrades[7].bought) { if (StealthCheck.IsHidden) { if (UpgradePointsMod.instance.specialUpgrades[8].bought) { if (UpgradePointsMod.instance.specialUpgrades[10].bought) { a *= 15; } else { a *= 5; } } else { a *= 2; } } } a *= BrawlerUpgrade.DamageBonus + 1; if (UpgradePointsMod.instance.specialUpgrades[33].bought) { float dist = Vector3.Distance(startingpos, target.position); dist /= 20; // every 20 meters a = a * (1 + dist); } if (UpgradePointsMod.instance.specialUpgrades[48].bought) { if (target.CompareTag("enemyCollide")) { if (UpgradePointsMod.instance.ComboStrikeBonusDamage(UpgradePointsMod.StrikeType.Ranged, target.root)) { a *= 4; } UpgradePointsMod.instance.AddToComboStrike(UpgradePointsMod.StrikeType.Melee, target.root); } } if (UpgradePointsMod.instance.specialUpgrades[44].bought) { if (CharacterControllerMod.FloatVelocity < 0.1f) { a *= 3; } } } a *= UpgradePointsMod.CritBonus(); damage = Mathf.RoundToInt(a); } if (UpgradePointsMod.instance.specialUpgrades[29].bought) { if (UpgradePointsMod.instance.FocusFireTarget == target.gameObject) { if (UpgradePointsMod.instance.specialUpgrades[88].bought) { UpgradePointsMod.instance.FocusFireStacks = Mathf.Clamp(UpgradePointsMod.instance.FocusFireStacks + 1, 0, 100); } else { UpgradePointsMod.instance.FocusFireStacks = Mathf.Clamp(UpgradePointsMod.instance.FocusFireStacks + 1, 0, 20); } } else { UpgradePointsMod.instance.FocusFireStacks = 0; UpgradePointsMod.instance.FocusFireTarget = target.gameObject; } } if (!ignoreCollisionEvents(targetCollider)) { if (!isTrigger) { Molotov componentInParent = ((Component)base.transform).GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = ((Component)target).GetComponent <TreeHealth>(); if (!(bool)component) { component = ((Component)target.root).GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { UpgradePointsMod.instance.DoAreaDamage(target.transform.root, damage); bool flag = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool flag2 = target.CompareTag("Fish"); bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); arrowStickToTarget arrowStickToTarget = ((Component)target).GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = ((Component)target.root).GetComponentInChildren <arrowStickToTarget>(); } if (!spearType && !flintLockAmmoType && !flag2) { if ((bool)arrowStickToTarget && arrowStickToTarget.enabled) { if (flag) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(flag3, flag, flag2); if (BoltNetwork.isRunning) { if ((bool)at && (bool)at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } base.Invoke("destroyMe", 0.1f); } base.StartCoroutine(HitAi(target, flag || flag3, headDamage)); if (flag2) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } disableLive(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity boltEntity = ((Component)target).GetComponentInParent <BoltEntity>(); if (!(bool)boltEntity) { boltEntity = ((Component)target).GetComponent <BoltEntity>(); } if ((bool)boltEntity) { HitPlayer.Create(boltEntity, EntityTargets.OnlyOwner).Send(); disableLive(); } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)((Component)target.transform.parent).GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)((Component)target.transform.parent).GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), ((Component)Terrain.activeTerrain).GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } } }
public override void DaniarConMolotov(Molotov molotov) { try { DaniarConBomba(molotov); } catch (EntidadYaDestruidaException) { } }
// Todas las bombas lo destruyen (le sacan la unica vida que tiene) // menos a la salida (se redefinen) public override void DaniarConMolotov(Molotov molotov) { if (FueDestruido()) throw new EntidadYaDestruidaException(); this.vida = 0; }
public override void DaniarConMolotov(Molotov molotov) { DaniarConBomba(molotov); }
public override void DaniarConMolotov(Molotov molotov) { //No le hace nada if (FueDestruido()) throw new EntidadYaDestruidaException(); }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = transform.GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); return; } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); return; } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); return; } else if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); return; } else if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!(bool)component) { component = target.root.GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } return; } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { if (lastPierced != null) { if (target.root == lastPierced) { Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider); return; } } bool pierce = false; float pierceChance = ModdedPlayer.Stats.projectilePierceChance - pierceCount; if (pierceChance > 0) { if (pierceChance >= 1 || pierceChance < Random.value) { Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider); pierceCount++; lastPierced = target.root; Invoke("ForgetLastPierced", 0.125f); pierce = true; } } if (crossbowBoltType) { } else if (flintLockAmmoType) { } else if (spearType) { } else { if (ModdedPlayer.Stats.i_CrossfireQuiver.value) { if (Time.time - ModdedPlayer.instance._lastCrossfireTime > 10 * ModdedPlayer.Stats.cooldown) { ModdedPlayer.instance._lastCrossfireTime = Time.time; Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5; Vector3 dir = transform.position - pos; dir.Normalize(); SpellActions.CastMagicArrow(pos, dir); } } } arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } bool isbird = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool isfish = target.CompareTag("Fish"); bool isanimal = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); if (!spearType && !flintLockAmmoType && !isfish) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (isbird) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(isanimal, isbird, isfish); if (SpellActions.SeekingArrow_ChangeTargetOnHit) { startposition = transform.position; } if (BoltNetwork.isRunning) { if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { if (pierce) { headDamage = ((XArrowStickToTargetMod)arrowStickToTarget).checkHeadDamage(transform); } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } } else { if (pierce) { headDamage = ((XArrowStickToTargetMod)arrowStickToTarget).checkHeadDamage(transform); } headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if ((bool)arrowStickToTarget && !pierce) { Destroy(parent.gameObject); } } else { if (SpellActions.SeekingArrow_ChangeTargetOnHit) { ModdedPlayer.Stats.spell_seekingArrow.value = true; SpellActions.SeekingArrow_Target.gameObject.SetActive(true); SpellActions.SeekingArrow_Target.parent = target.transform; SpellActions.SeekingArrow_Target.position = new Vector3(target.transform.position.x, transform.position.y - 0.075f, target.transform.position.z); SpellActions.SeekingArrow_TimeStamp = Time.time; startposition = transform.position; SpellActions.SeekingArrow_ChangeTargetOnHit = false; } } if (headDamage && !flintLockAmmoType && ModdedPlayer.Stats.perk_trueAim && ModdedPlayer.Stats.spell_seekingArrow) { //True aim ability float dist = (startposition - transform.position).sqrMagnitude; if (dist >= 3600f) { OutputDmg *= 4; NewHitAi(target, isbird || isanimal, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); BuffDB.AddBuff(28, 104, 1.20f, 5); //crit chance if (ModdedPlayer.Stats.perk_trueAimUpgrade && dist >= 14400f) { OutputDmg *= 10; NewHitAi(target, isbird || isanimal, headDamage); NewHitAi(target, isbird || isanimal, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); } } } NewHitAi(target, isbird || isanimal, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (be == null) { be = target.GetComponent <BoltEntity>(); } if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit) { int myID = 1000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float dmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3; dmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier; dmg *= ModdedPlayer.Stats.fireDamage + 1; dmg *= 0.3f; if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { target.GetComponentInParent <EnemyProgression>()?.FireDebuff(myID, dmg, 14); } else { if (be != null) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(be.networkId.PackedValue); w.Write(dmg); w.Write(14.5f); w.Write(1); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } } if (ModdedPlayer.Stats.TotalRangedArmorPiercing > 0 && target.gameObject.CompareTag("enemyCollide")) { if (ModdedPlayer.Stats.perk_thrownSpearExtraArmorReduction && spearType) { if (BoltNetwork.isClient) { if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.Stats.TotalRangedArmorPiercing * 2 + ModdedPlayer.Stats.TotalMeleeArmorPiercing); } } else if (EnemyManager.enemyByTransform.ContainsKey(target.root)) { var prog = EnemyManager.enemyByTransform[target.root]; prog.ReduceArmor(ModdedPlayer.Stats.TotalRangedArmorPiercing * 2 + ModdedPlayer.Stats.TotalMeleeArmorPiercing); } } else { if (BoltNetwork.isClient) { if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.Stats.TotalRangedArmorPiercing); } } else if (EnemyManager.enemyByTransform.ContainsKey(target.root)) { var prog = EnemyManager.enemyByTransform[target.root]; prog.ReduceArmor(ModdedPlayer.Stats.TotalRangedArmorPiercing); } } } if (isfish) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } //check piercing if (pierce) { return; } Live = false; disableLive(); DisableFlight(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (!(bool)be) { be = target.GetComponent <BoltEntity>(); } if (be) { if (ModdedPlayer.Stats.i_ArchangelBow && GreatBow.isEnabled) { float lifePerSecond = (ModdedPlayer.Stats.healthRecoveryPerSecond) * ModdedPlayer.Stats.allRecoveryMult * (ModdedPlayer.Stats.healthPerSecRate) * 2; using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(39); w.Write(be.GetState <IPlayerState>().name); w.Write(lifePerSecond); w.Write(ModdedPlayer.Stats.TotalMaxHealth * 0.2f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } BuffDB.AddBuff(25, 91, lifePerSecond, 10); } else if (ModSettings.FriendlyFire) { float dmgUnclamped = this.OutputDmg; if (ModdedPlayer.Stats.spell_seekingArrow) { float dist = Vector3.Distance(target.position, startposition); dmgUnclamped *= 1 + dist * ModdedPlayer.Stats.spell_seekingArrow_DamagePerDistance; } if (spearType) { if (ModdedPlayer.Stats.perk_thrownSpearhellChance > 0 && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance && OutputDmg > 1) { var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(PhysicBody.position - Camera.main.transform.position)); obj.velocity = PhysicBody.velocity.normalized * 90f * ModdedPlayer.Stats.projectileSpeed; Destroy(obj.gameObject, 18); } } if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.Stats.perk_bulletCritChance) || (spearType && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance)) { headDamage = true; dmgUnclamped *= ModdedPlayer.Stats.headShotDamage; dmgUnclamped *= SpellActions.FocusOnHeadShot(); if (ModdedPlayer.Stats.spell_seekingArrow) { dmgUnclamped *= ModdedPlayer.Stats.spell_seekingArrow_HeadDamage; } } else { dmgUnclamped *= SpellActions.FocusOnBodyShot(); } DamageMath.ReduceDamageToSendOverNet(dmgUnclamped, out int sendDamage, out int reps); HitPlayer HP = HitPlayer.Create(be, EntityTargets.Everyone); HP.damage = sendDamage; for (int i = 0; i < reps; i++) { HP.Send(); } //check piercing float pierceChance = ModdedPlayer.Stats.projectilePierceChance - pierceCount; if (pierceChance > 0) { if (pierceChance >= 1 || pierceChance < Random.value) { Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider); pierceCount++; return; } } disableLive(); DisableFlight(); } } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = transform.GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!(bool)component) { component = target.root.GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { if (crossbowBoltType) { } else if (flintLockAmmoType) { } else if (spearType) { } else { if (ModdedPlayer.instance.IsCrossfire) { if (Time.time - ModdedPlayer.instance.LastCrossfireTime > 10) { ModdedPlayer.instance.LastCrossfireTime = Time.time; float damage1 = 55 + ModdedPlayer.instance.SpellDamageBonus * 1.25f; damage1 = damage1 * ModdedPlayer.instance.SpellAMP; Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5; Vector3 dir = transform.position - pos; dir.Normalize(); if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { MagicArrow.Create(pos, dir, damage1, ModReferences.ThisPlayerID, SpellActions.MagicArrowDuration, SpellActions.MagicArrowDoubleSlow, SpellActions.MagicArrowDmgDebuff); if (BoltNetwork.isRunning) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(3); w.Write(7); w.Write(pos.x); w.Write(pos.y); w.Write(pos.z); w.Write(dir.x); w.Write(dir.y); w.Write(dir.z); w.Write(damage1); w.Write(ModReferences.ThisPlayerID); w.Write(SpellActions.MagicArrowDuration); w.Write(SpellActions.MagicArrowDoubleSlow); w.Write(SpellActions.MagicArrowDmgDebuff); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Others); answerStream.Close(); } } } else if (GameSetup.IsMpClient) { MagicArrow.CreateEffect(pos, dir, SpellActions.MagicArrowDmgDebuff, SpellActions.MagicArrowDuration); using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(3); w.Write(7); w.Write(pos.x); w.Write(pos.y); w.Write(pos.z); w.Write(dir.x); w.Write(dir.y); w.Write(dir.z); w.Write(damage1); w.Write(ModReferences.ThisPlayerID); w.Write(SpellActions.MagicArrowDuration); w.Write(SpellActions.MagicArrowDoubleSlow); w.Write(SpellActions.MagicArrowDmgDebuff); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Others); answerStream.Close(); } } } } } bool flag = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool flag2 = target.CompareTag("Fish"); bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } if (!spearType && !flintLockAmmoType && !flag2) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (flag) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(flag3, flag, flag2); if (BoltNetwork.isRunning) { if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if ((bool)arrowStickToTarget) { base.Invoke("destroyMe", 0.1f); } } if (SpellActions.SeekingArrow_ChangeTargetOnHit) { SpellActions.SeekingArrow = true; SpellActions.SeekingArrow_Target.gameObject.SetActive(true); SpellActions.SeekingArrow_Target.transform.parent = target.transform; SpellActions.SeekingArrow_Target.transform.position = new Vector3(target.transform.position.x, transform.position.y - 0.075f, target.transform.position.z); SpellActions.SeekingArrow_TimeStamp = Time.time; startposition = transform.position; SpellActions.SeekingArrow_ChangeTargetOnHit = false; } if (headDamage && !flintLockAmmoType && ModdedPlayer.instance.TrueAim && SpellActions.SeekingArrow) { float dist = (startposition - transform.position).sqrMagnitude; if (dist >= 3600f) { OutputDmg *= 4; NewHitAi(target, flag || flag3, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); if (ModdedPlayer.instance.TrueAimUpgrade && dist >= 14400f) { OutputDmg *= 10; NewHitAi(target, flag || flag3, headDamage); NewHitAi(target, flag || flag3, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); } } } NewHitAi(target, flag || flag3, headDamage); ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg); ModdedPlayer.instance.OnHit(); ModdedPlayer.instance.OnHit_Ranged(target); BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (be == null) { be = target.GetComponent <BoltEntity>(); } if (ModdedPlayer.instance.SpellAmpFireDmg) { int myID = 1000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject); float dmg = 1 + ModdedPlayer.instance.SpellDamageBonus / 3; dmg *= ModdedPlayer.instance.SpellAMP; dmg *= ModdedPlayer.instance.FireAmp + 1; dmg *= 0.3f; if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { target.GetComponentInParent <EnemyProgression>()?.FireDebuff(myID, dmg, 14); } else { if (be != null) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(27); w.Write(be.networkId.PackedValue); w.Write(dmg); w.Write(14.5f); w.Write(1); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } } } if (ModdedPlayer.instance.RangedArmorReduction > 0 && target.gameObject.CompareTag("enemyCollide")) { if (BoltNetwork.isClient) { if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.instance.RangedArmorReduction); } } else { target.transform.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.RangedArmorReduction, SendMessageOptions.DontRequireReceiver); } } if (flag2) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } disableLive(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (!(bool)be) { be = target.GetComponent <BoltEntity>(); } if (be) { if (ModdedPlayer.instance.ArchangelBow && GreatBow.isEnabled) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(39); w.Write(be.GetState <IPlayerState>().name); w.Write((ModdedPlayer.instance.LifeRegen) * ModdedPlayer.instance.HealingMultipier * (1 + ModdedPlayer.instance.HealthRegenPercent)); w.Write(ModdedPlayer.instance.MaxHealth * 0.25f); w.Close(); } AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } else if (ModSettings.FriendlyFire) { float dmgUnclamped = this.OutputDmg; if (SpellActions.SeekingArrow) { float dist = Vector3.Distance(target.position, startposition); dmgUnclamped *= 1 + dist * SpellActions.SeekingArrow_DamagePerDistance; } if (spearType) { if (ModdedPlayer.instance.SpearhellChance > 0 && Random.value <= ModdedPlayer.instance.SpearhellChance && OutputDmg > 1) { var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(Camera.main.transform.forward)); obj.velocity = PhysicBody.velocity * 1.05f; Destroy(obj.gameObject, 30); } } else { if (headDamage) { if (ModdedPlayer.instance.EruptionBow && GreatBow.isEnabled) { //if (GameSetup.IsMultiplayer) //{ BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity); //} } } } if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.instance.BulletCritChance) || (spearType && Random.value <= ModdedPlayer.instance.SpearCritChance)) { headDamage = true; dmgUnclamped *= ModdedPlayer.instance.HeadShotDamage; dmgUnclamped *= SpellActions.FocusOnHeadShot(); if (SpellActions.SeekingArrow) { dmgUnclamped *= SpellActions.SeekingArrow_HeadDamage; } } else { dmgUnclamped *= SpellActions.FocusOnBodyShot(); } if (GreatBow.isEnabled) { dmgUnclamped *= 2.1f; } dmgUnclamped *= ModdedPlayer.instance.RangedAMP * ModdedPlayer.instance.CritDamageBuff; if (ModdedPlayer.instance.ProjectileDamageIncreasedBySize) { dmgUnclamped *= ModdedPlayer.instance.ProjectileSizeRatio; } DamageMath.DamageClamp(dmgUnclamped, out int sendDamage, out Repetitions); HitPlayer HP = HitPlayer.Create(be, EntityTargets.Everyone); HP.damage = sendDamage; for (int i = 0; i < Repetitions; i++) { HP.Send(); } disableLive(); } } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }
public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider) { if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot")) { return; } if (!isTrigger) { Molotov componentInParent = transform.GetComponentInParent <Molotov>(); if ((bool)componentInParent) { componentInParent.IncendiaryBreak(); } } bool headDamage = false; if (target.gameObject.layer == LayerMask.NameToLayer("Water")) { FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any); } else if (target.CompareTag("SmallTree")) { FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("PlaneHull")) { FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any); } if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target")) { if (spearType) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f)); } else if (hitPointUpdated) { base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f)); } else { base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f)); } disableLive(); if (target.CompareTag("Tree") || target.root.CompareTag("Tree")) { TreeHealth component = target.GetComponent <TreeHealth>(); if (!(bool)component) { component = target.root.GetComponent <TreeHealth>(); } if ((bool)component) { component.LodTree.AddTreeCutDownTarget(base.gameObject); } } } else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot")) { if (crossbowBoltType) { } else if (flintLockAmmoType) { } else if (spearType) { } else { if (ModdedPlayer.instance.IsCrossfire) { if (Time.time - ModdedPlayer.instance.LastCrossfireTime > 20) { ModdedPlayer.instance.LastCrossfireTime = Time.time; float damage = 55 + ModdedPlayer.instance.SpellDamageBonus * 1.25f; damage = damage * ModdedPlayer.instance.SpellAMP; Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5; Vector3 dir = transform.position - pos; dir.Normalize(); if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer) { MagicArrow.Create(pos, dir, damage, ModReferences.ThisPlayerPacked, SpellActions.MagicArrowDuration, SpellActions.MagicArrowDoubleSlow, SpellActions.MagicArrowDmgDebuff); if (BoltNetwork.isRunning) { string s = "SC7;" + System.Math.Round(pos.x, 5) + ";" + System.Math.Round(pos.y, 5) + ";" + System.Math.Round(pos.z, 5) + ";" + System.Math.Round(dir.x, 5) + ";" + System.Math.Round(dir.y, 5) + ";" + System.Math.Round(dir.z, 5) + ";"; s += damage + ";" + ModReferences.ThisPlayerPacked + ";" + SpellActions.MagicArrowDuration + ";"; if (SpellActions.MagicArrowDoubleSlow) { s += "t;"; } else { s += "f;"; } if (SpellActions.MagicArrowDmgDebuff) { s += "t;"; } else { s += "f;"; } Network.NetworkManager.SendLine(s, Network.NetworkManager.Target.Others); } } else if (GameSetup.IsMpClient) { MagicArrow.CreateEffect(pos, dir, SpellActions.MagicArrowDmgDebuff, SpellActions.MagicArrowDuration); string s = "SC7;" + System.Math.Round(pos.x, 5) + ";" + System.Math.Round(pos.y, 5) + ";" + System.Math.Round(pos.z, 5) + ";" + System.Math.Round(dir.x, 5) + ";" + System.Math.Round(dir.y, 5) + ";" + System.Math.Round(dir.z, 5) + ";"; s += damage + ";" + ModReferences.ThisPlayerPacked + ";" + SpellActions.MagicArrowDuration + ";"; if (SpellActions.MagicArrowDoubleSlow) { s += "t;"; } else { s += "f;"; } if (SpellActions.MagicArrowDmgDebuff) { s += "t;"; } else { s += "f;"; } Network.NetworkManager.SendLine(s, Network.NetworkManager.Target.Others); } } } } bool flag = target.tag == "lb_bird" || target.CompareTag("lb_bird"); bool flag2 = target.CompareTag("Fish"); bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot"); arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>(); if (!(bool)arrowStickToTarget) { arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>(); } if (!spearType && !flintLockAmmoType && !flag2) { if (arrowStickToTarget && arrowStickToTarget.enabled) { if (flag) { EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null); } arrowStickToTarget.CreatureType(flag3, flag, flag2); if (BoltNetwork.isRunning) { if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner) { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } else { headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform); } } if ((bool)arrowStickToTarget) { base.Invoke("destroyMe", 0.1f); } } for (int i = 0; i < Repetitions; i++) { base.StartCoroutine(HitAi(target, flag || flag3, headDamage)); } ModdedPlayer.instance.DoAreaDamage(target.root, damage); ModdedPlayer.instance.DoOnHit(); ModdedPlayer.instance.DoRangedOnHit(); if (ModdedPlayer.instance.RangedArmorReduction > 0 && target.gameObject.CompareTag("enemyCollide")) { if (BoltNetwork.isClient) { BoltEntity be = target.GetComponentInParent <BoltEntity>(); if (be == null) { be = target.GetComponent <BoltEntity>(); } if (be != null) { EnemyProgression.ReduceArmor(be, ModdedPlayer.instance.MeleeArmorReduction); } } else { target.transform.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.MeleeArmorReduction, SendMessageOptions.DontRequireReceiver); } } if (flag2) { base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f)); } disableLive(); } else if (target.CompareTag("PlayerNet")) { if (BoltNetwork.isRunning) { BoltEntity boltEntity = target.GetComponentInParent <BoltEntity>(); if (!(bool)boltEntity) { boltEntity = target.GetComponent <BoltEntity>(); } if (boltEntity && ModSettings.FriendlyFire) { HitPlayer HP = HitPlayer.Create(boltEntity, EntityTargets.Everyone); HP.damage = damage; HP.Send(); disableLive(); } } } else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves) { if (ignoreTerrain) { ignoreTerrain = false; base.StartCoroutine(RevokeIgnoreTerrain()); } else { if (spearType) { if ((bool)bodyCollider) { bodyCollider.isTrigger = true; } base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false)); } else { Vector3 position2 = base.transform.position - base.transform.forward * -0.8f; float num = Terrain.activeTerrain.SampleHeight(base.transform.position); Vector3 position3 = Terrain.activeTerrain.transform.position; float num2 = num + position3.y; Vector3 position4 = base.transform.position; if (position4.y < num2) { position2.y = num2 + 0.5f; } base.StartCoroutine(HitStructure(position2, false)); } disableLive(); FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any); } } else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood")) { if ((bool)target.transform.parent) { if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>()) { return; } if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>()) { return; } } if (!isTrigger) { if (spearType) { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true)); } else { base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true)); } disableLive(); } } else if (target.CompareTag("CaveDoor")) { ignoreTerrain = true; Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true); } else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock"))) { target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver); } if (!Live) { destroyThisAmmo(); parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver); } }