private void calculateDamage(GameObject go)
 {
     if (this.allowDamage && this.rigidBody.velocity.magnitude > Mathf.Max(this.speedThreshold * 2f, 15f))
     {
         if (go.CompareTag("PlayerNet") && BoltNetwork.isRunning)
         {
             BoltEntity componentInParent = go.GetComponentInParent <BoltEntity>();
             if (componentInParent)
             {
                 HitPlayer hitPlayer = HitPlayer.Create(componentInParent, EntityTargets.OnlyOwner);
                 if (this.flintLock)
                 {
                     hitPlayer.damage = 45;
                 }
                 else
                 {
                     hitPlayer.damage = 5;
                 }
                 hitPlayer.Send();
             }
         }
         if (go.CompareTag("enemyCollide") || go.CompareTag("enemyRoot") || go.tag == "lb_bird" || go.CompareTag("animalCollide") || go.CompareTag("Fish"))
         {
             if (BoltNetwork.isClient)
             {
                 PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Raise(GlobalTargets.OnlyServer);
                 playerHitEnemy.Target             = go.GetComponentInParent <BoltEntity>();
                 playerHitEnemy.getAttackDirection = 3;
                 playerHitEnemy.getAttackerType    = 4;
                 if (this.flintLock)
                 {
                     playerHitEnemy.Hit = 100;
                 }
                 else
                 {
                     playerHitEnemy.Hit = 1;
                 }
                 playerHitEnemy.Send();
             }
             else if (!go.CompareTag("MidTree") && !go.CompareTag("Tree") && go.layer != 11)
             {
                 go.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
                 go.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
                 int num = 1;
                 if (this.flintLock)
                 {
                     num = 100;
                 }
                 go.gameObject.SendMessageUpwards("Hit", num, SendMessageOptions.DontRequireReceiver);
                 go.SendMessage("Hit", num, SendMessageOptions.DontRequireReceiver);
             }
         }
     }
 }
Beispiel #2
0
 private void LocalPlayerAttacked()
 {
     if (!this || !base.transform || !LocalPlayer.Transform)
     {
         LocalPlayer.Tuts.HideReviveMP();
         LocalPlayer.Inventory.Attacked.RemoveListener(new UnityAction(this.LocalPlayerAttacked));
         return;
     }
     if (Vector3.Distance(base.transform.position, LocalPlayer.Transform.position) < this._maxKillDistance)
     {
         HitPlayer hitPlayer = HitPlayer.Create(GlobalTargets.Others);
         hitPlayer.Target = base.entity;
         hitPlayer.Send();
         LocalPlayer.Inventory.Attacked.RemoveListener(new UnityAction(this.LocalPlayerAttacked));
         this.OnEnable();
         this.GrabExit();
         base.gameObject.SetActive(false);
         LocalPlayer.Sfx.PlayKillRabbit();
         LocalPlayer.Tuts.HideReviveMP();
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
    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);
            }
        }
Beispiel #6
0
 private void LateUpdate()
 {
     if (this.Live && this.PhysicBody)
     {
         float   num    = this.PhysicBody.velocity.magnitude * 1.25f * Time.deltaTime;
         Vector3 vector = base.transform.position + base.transform.forward * -num;
         if (num > 0f && Physics.Raycast(base.transform.position, base.transform.forward, out this.hit, num, this.layers))
         {
             if (this.hit.transform.CompareTag("Tree") || this.hit.transform.CompareTag("Target") || this.hit.transform.gameObject.layer == 20)
             {
                 if (this.spearType)
                 {
                     if (this.bodyCollider)
                     {
                         this.bodyCollider.isTrigger = true;
                     }
                     this.PhysicBody.transform.position = this.hit.point - base.transform.forward * 2.1f;
                 }
                 else
                 {
                     this.PhysicBody.transform.position = this.hit.point - base.transform.forward * 0.35f;
                 }
                 this.PhysicBody.velocity    = Vector3.zero;
                 this.PhysicBody.isKinematic = true;
                 this.MyPickUp.SetActive(true);
                 this.Live = false;
                 FMODCommon.PlayOneshotNetworked(this.hitTreeEvent, base.transform, FMODCommon.NetworkRole.Any);
             }
             else if (this.hit.transform.CompareTag("enemyCollide") || this.hit.transform.tag == "lb_bird" || this.hit.transform.CompareTag("animalCollide") || this.hit.transform.CompareTag("Fish"))
             {
                 int num2;
                 if (this.spearType)
                 {
                     num2 = Mathf.FloorToInt(40f);
                 }
                 else
                 {
                     num2 = Mathf.FloorToInt(2f * (this.PhysicBody.velocity.magnitude / 7f));
                     if (num2 > 22)
                     {
                         num2 = 22;
                     }
                 }
                 if (this.spearType)
                 {
                     this.PhysicBody.velocity    = Vector3.zero;
                     this.PhysicBody.isKinematic = false;
                     this.PhysicBody.useGravity  = true;
                     this.Live = false;
                     this.MyPickUp.SetActive(true);
                 }
                 if (BoltNetwork.isClient)
                 {
                     PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Raise(GlobalTargets.OnlyServer);
                     playerHitEnemy.Target             = this.hit.transform.GetComponentInParent <BoltEntity>();
                     playerHitEnemy.getAttackDirection = 3;
                     playerHitEnemy.getAttackerType    = 4;
                     playerHitEnemy.Hit = num2;
                     playerHitEnemy.Send();
                 }
                 else if (this.hit.transform.CompareTag("enemyRoot"))
                 {
                     this.hit.transform.gameObject.SendMessage("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
                     this.hit.transform.gameObject.SendMessage("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
                     GameObject closestPlayerFromPos = Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position);
                     this.hit.transform.gameObject.SendMessage("getAttacker", closestPlayerFromPos, SendMessageOptions.DontRequireReceiver);
                     this.hit.transform.gameObject.SendMessage("Hit", num2, SendMessageOptions.DontRequireReceiver);
                 }
                 else
                 {
                     this.hit.transform.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
                     this.hit.transform.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
                     GameObject closestPlayerFromPos2 = Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position);
                     this.hit.transform.gameObject.SendMessageUpwards("getAttacker", closestPlayerFromPos2, SendMessageOptions.DontRequireReceiver);
                     this.hit.transform.gameObject.SendMessageUpwards("Hit", num2, SendMessageOptions.DontRequireReceiver);
                 }
                 this.MyPickUp.SetActive(true);
                 this.Live = false;
             }
             else if (this.hit.transform.CompareTag("PlayerNet"))
             {
                 if (BoltNetwork.isRunning)
                 {
                     BoltEntity componentInParent = this.hit.transform.GetComponentInParent <BoltEntity>();
                     if (componentInParent)
                     {
                         HitPlayer.Create(componentInParent, EntityTargets.OnlyOwner).Send();
                     }
                 }
             }
             else if (this.hit.transform.CompareTag("TerrainMain") || this.hit.transform.CompareTag("structure") || this.hit.transform.CompareTag("SLTier1") || this.hit.transform.CompareTag("SLTier2") || this.hit.transform.CompareTag("SLTier3"))
             {
                 if (this.ignoreTerrain && this.hit.transform.CompareTag("TerrainMain"))
                 {
                     this.ignoreTerrain = false;
                     Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), false);
                 }
                 else
                 {
                     if (this.spearType)
                     {
                         if (this.bodyCollider)
                         {
                             this.bodyCollider.isTrigger = true;
                         }
                         this.PhysicBody.transform.position = this.hit.point - base.transform.forward * 2.1f;
                     }
                     else
                     {
                         this.PhysicBody.transform.position = this.hit.point - base.transform.forward * 0.35f;
                     }
                     this.PhysicBody.velocity    = Vector3.zero;
                     this.PhysicBody.isKinematic = true;
                     this.MyPickUp.SetActive(true);
                     if (this.at)
                     {
                         this.at.enabled = false;
                     }
                     this.Live = false;
                     if (this.hit.transform.CompareTag("TerrainMain"))
                     {
                         FMODCommon.PlayOneshotNetworked(this.hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any);
                     }
                     else
                     {
                         FMODCommon.PlayOneshotNetworked(this.hitStructureEvent, base.transform, FMODCommon.NetworkRole.Any);
                     }
                 }
             }
             else if (this.hit.transform.CompareTag("CaveDoor"))
             {
                 this.ignoreTerrain = true;
                 Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true);
             }
             else if (!this.hit.collider.isTrigger && !this.hit.transform.Equals(base.transform.parent) && this.hit.transform.CompareTag("enemyRoot"))
             {
                 this.PhysicBody.velocity /= 4f;
                 this.MyPickUp.SetActive(true);
                 this.Live = false;
             }
             else if (!this.hit.collider.isTrigger && !this.hit.transform.Equals(base.transform.parent))
             {
                 this.PhysicBody.velocity /= 2f;
                 this.MyPickUp.SetActive(true);
                 this.Live = false;
                 if (this.at)
                 {
                     this.at.enabled = false;
                 }
             }
             if (!this.Live)
             {
                 this.parent.BroadcastMessage("OnArrowHit", 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);
            }
        }
Beispiel #8
0
        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);
                }
            }
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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);
            }
        }