Beispiel #1
0
    private IEnumerator HitTree(Vector3 position)
    {
        Quaternion rot = (!this.hitPointUpdated) ? base.transform.root.rotation : this.PhysicBody.transform.rotation;

        yield return(null);

        if (this.bodyCollider)
        {
            this.bodyCollider.isTrigger = true;
        }
        if (this.PhysicBody)
        {
            this.PhysicBody.transform.position = position;
            this.PhysicBody.transform.rotation = rot;
            this.PhysicBody.velocity           = Vector3.zero;
            this.PhysicBody.isKinematic        = true;
            this.PhysicBody.useGravity         = false;
        }
        if (this.MyPickUp)
        {
            this.MyPickUp.SetActive(true);
        }
        FMODCommon.PlayOneshotNetworked(this.hitTreeEvent, base.transform, FMODCommon.NetworkRole.Any);
        this.hitPointUpdated = false;
        yield break;
    }
Beispiel #2
0
 public void loadItemIntoBasket(int type)
 {
     if (this._nextItemIndex > 0)
     {
         this._nextItemIndex--;
         int num = this._items[this._nextItemIndex];
         this._items[this._nextItemIndex]       = -1;
         this._ammoLoaded[this._anim.ammoCount] = num;
         this._anim.rockAmmo[this._anim.ammoCount].SetActive(true);
         if (this._renderSlots[this._nextItemIndex].childCount > 0)
         {
             Transform child = this._renderSlots[this._nextItemIndex].GetChild(0);
             this.TransferItemView(child, this._anim.rockAmmo[this._anim.ammoCount].transform, num);
         }
         if (LocalPlayer.Sfx)
         {
             FMODCommon.PlayOneshotNetworked(LocalPlayer.Sfx.WhooshEvent, base.transform, FMODCommon.NetworkRole.Server);
         }
         if (BoltNetwork.isRunning)
         {
             base.entity.Freeze(false);
             base.state.Items[this._nextItemIndex] = -1;
             base.state.Ammo[this._anim.ammoCount] = num;
         }
         this._anim.ammoCount++;
     }
 }
 private void explodeAllPoints()
 {
     for (int i = 0; i < this.explodePoints.Length; i++)
     {
         UnityEngine.Object.Instantiate <GameObject>(this.ExplosionPrefab, this.explodePoints[i].position, Quaternion.identity);
         FMODCommon.PlayOneshotNetworked("event:/mutants/creepies/Worm/worm_fall_impact", this.explodePoints[i], FMODCommon.NetworkRole.Server);
     }
 }
 public bool OriginalPutDown(bool fake, bool drop, bool equipPrevious, GameObject preSpawned)
 {
     if (this._infiniteLogHack)
     {
         return(true);
     }
     if (!fake)
     {
         if (this._logs <= 0)
         {
             return(false);
         }
         this.RemoveLog(equipPrevious);
     }
     if (drop)
     {
         bool       flag       = this._logs == 1;
         Transform  transform  = this._logsHeld[Mathf.Min(this._logs, 1)].transform;
         Vector3    vector     = transform.position + transform.forward * -2f;
         Quaternion quaternion = LocalPlayer.Transform.rotation;
         quaternion *= Quaternion.AngleAxis(90f, Vector3.up);
         if (LocalPlayer.FpCharacter.PushingSled)
         {
             vector += transform.forward * -1.25f + transform.right * -2f;
         }
         Vector3 origin = vector;
         origin.y += 3f;
         if (Physics.Raycast(origin, Vector3.down, out RaycastHit raycastHit, 5f, this._layerMask))
         {
             vector.y = raycastHit.point.y + 2.2f;
         }
         if (flag)
         {
             vector.y += 1f;
         }
         if (BoltNetwork.isRunning)
         {
             DropItem dropItem = DropItem.Create(GlobalTargets.OnlyServer);
             dropItem.PrefabId   = BoltPrefabs.Log;
             dropItem.Position   = vector;
             dropItem.Rotation   = quaternion;
             dropItem.PreSpawned = ((!preSpawned) ? null : preSpawned.GetComponent <BoltEntity>());
             dropItem.Send();
         }
         else if (preSpawned)
         {
             preSpawned.transform.position = vector;
             preSpawned.transform.rotation = quaternion;
         }
         else
         {
             Instantiate(this._logPrefab, vector, quaternion);
         }
         FMODCommon.PlayOneshotNetworked("event:/player/foley/log_drop_exert", transform, FMODCommon.NetworkRole.Any);
     }
     this.UpdateLogCount();
     return(true);
 }
Beispiel #5
0
 private void PlayerSighted()
 {
     base.CancelInvoke("EnablePlayerSighted");
     if (this.playerSightedEnabled)
     {
         this.playerSightedEnabled  = false;
         this.playerSightedInstance = FMODCommon.PlayOneshotNetworked(this.playerSightedEvent, base.transform, FMODCommon.NetworkRole.Server);
     }
 }
Beispiel #6
0
 private void GotClean()
 {
     if (this.isLit)
     {
         FMODCommon.PlayOneshotNetworked("event:/player/actions/molotov_quench", base.transform, FMODCommon.NetworkRole.Any);
     }
     this.isLit = false;
     base.StartCoroutine("forceFireOff");
     LighterControler.HasLightableItem = true;
 }
Beispiel #7
0
    private IEnumerator BurnRoutine(bool burnShort = false)
    {
        this._isBurning = true;
        this.BurnSFX();
        if (burnShort)
        {
            yield return(YieldPresets.WaitTenSeconds);
        }
        else
        {
            yield return(YieldPresets.WaitFourtySeconds);
        }
        Transform bonePrefab  = BoltNetwork.isRunning ? ItemDatabase.ItemById(this._boneItemId)._pickupPrefabMP : ItemDatabase.ItemById(this._boneItemId)._pickupPrefab;
        Transform skullPrefab = BoltNetwork.isRunning ? ItemDatabase.ItemById(this._skullItemId)._pickupPrefabMP : ItemDatabase.ItemById(this._skullItemId)._pickupPrefab;
        Transform pickup;

        for (int i = 0; i < this._bonesSpawn.Length; i++)
        {
            if (this._bonesSpawn[i])
            {
                pickup          = (BoltNetwork.isRunning ? BoltNetwork.Instantiate(bonePrefab.gameObject).transform : UnityEngine.Object.Instantiate <Transform>(bonePrefab));
                pickup.position = this._bonesSpawn[i].position;
                pickup.rotation = this._bonesSpawn[i].rotation;
            }
        }
        pickup          = (BoltNetwork.isRunning ? BoltNetwork.Instantiate(bonePrefab.gameObject).transform : UnityEngine.Object.Instantiate <Transform>(bonePrefab));
        pickup.position = base.transform.position + Vector3.left;
        pickup.rotation = base.transform.rotation;
        pickup          = (BoltNetwork.isRunning ? BoltNetwork.Instantiate(bonePrefab.gameObject).transform : UnityEngine.Object.Instantiate <Transform>(bonePrefab));
        pickup.position = base.transform.position + Vector3.right;
        pickup.rotation = base.transform.rotation;
        if (this._skullSpawn)
        {
            pickup          = (BoltNetwork.isRunning ? BoltNetwork.Instantiate(skullPrefab.gameObject).transform : UnityEngine.Object.Instantiate <Transform>(skullPrefab));
            pickup.position = this._skullSpawn.position;
            pickup.rotation = this._skullSpawn.rotation;
        }
        FMODCommon.PlayOneshotNetworked("event:/fire/bones_explode", base.transform, FMODCommon.NetworkRole.Any);
        limitSledBlur lsb = base.transform.GetComponentInParent <limitSledBlur>();

        if (lsb && lsb.mh)
        {
            lsb.mh.PickUpBody();
        }
        if (BoltNetwork.isRunning && base.entity.isAttached)
        {
            BoltNetwork.Destroy(base.transform.parent.gameObject);
        }
        else
        {
            UnityEngine.Object.Destroy(base.transform.parent.gameObject);
        }
        yield break;
    }
Beispiel #8
0
    private void ExplosionReal()
    {
        FMODCommon.PlayOneshotNetworked(this.breakEvent, base.transform, FMODCommon.NetworkRole.Server);
        GameObject gameObject = UnityEngine.Object.Instantiate(this.Broken, base.transform.position, base.transform.rotation) as GameObject;

        if (this.entity.IsOwner())
        {
            BoltNetwork.Detach(this.entity, new CoopCreateBreakToken());
        }
        UnityEngine.Object.Destroy(base.gameObject);
    }
Beispiel #9
0
 public void GotClean()
 {
     if (this._state == BurnableCloth.States.Burning)
     {
         this._putOutFuel = this._fuel;
         this.Burnt();
         this._state = BurnableCloth.States.PutOutIdle;
         this._player.IsWeaponBurning = false;
         FMODCommon.PlayOneshotNetworked("event:/player/actions/molotov_quench", base.transform, FMODCommon.NetworkRole.Any);
     }
 }
Beispiel #10
0
 private void DieTrap(int type)
 {
     if (type == 3)
     {
         FMODCommon.PlayOneshotNetworked("event:/player/player_vox/jump_vox", base.transform, FMODCommon.NetworkRole.Server);
         FMODCommon.PlayOneshot("event:/player/foley/body_fall", base.transform.position, FMODCommon.NetworkRole.Server, new object[]
         {
             "fall",
             0.8f
         });
     }
 }
Beispiel #11
0
 private bool PutDownNew(bool fake, bool drop, bool equipPrev, GameObject preSpawned)
 {
     if (additional_logs > 0 && !_infiniteLogHack)
     {
         if (drop)
         {
             additional_logs--;
             Transform  heldLog        = this._logsHeld[Mathf.Min(this._logs, 1)].transform;
             Vector3    logPosition    = heldLog.position + heldLog.forward * -2f;
             Quaternion playerRotation = LocalPlayer.Transform.rotation;
             playerRotation *= Quaternion.AngleAxis(90f, Vector3.up);
             if (LocalPlayer.FpCharacter.PushingSled)
             {
                 logPosition += heldLog.forward * -1.25f + heldLog.right * -2f;
             }
             Vector3 rayOrigin = logPosition;
             rayOrigin.y += 3f;
             if (Physics.Raycast(rayOrigin, Vector3.down, out RaycastHit raycastHit, 5f, this._layerMask))
             {
                 logPosition.y = raycastHit.point.y + 2.2f;
             }
             if (_logs == 1)
             {
                 logPosition.y += 1f;
             }
             if (BoltNetwork.isRunning)
             {
                 DropItem dropItem2 = DropItem.Create(GlobalTargets.OnlyServer);
                 dropItem2.PrefabId   = BoltPrefabs.Log;
                 dropItem2.Position   = logPosition;
                 dropItem2.Rotation   = playerRotation;
                 dropItem2.PreSpawned = ((preSpawned != null) ? null : preSpawned.GetComponent <BoltEntity>());
                 dropItem2.Send();
             }
             else if ((bool)preSpawned)
             {
                 preSpawned.transform.position = logPosition;
                 preSpawned.transform.rotation = playerRotation;
             }
             else
             {
                 UnityEngine.Object.Instantiate <GameObject>(this._logPrefab, logPosition, playerRotation);
             }
             FMODCommon.PlayOneshotNetworked("event:/player/foley/log_drop_exert", heldLog, FMODCommon.NetworkRole.Any);
         }
         return(true);
     }
     else
     {
         return(OriginalPutDown(fake, drop, equipPrev, preSpawned));
     }
 }
Beispiel #12
0
 private void GotCleanDisable()
 {
     if (this._state == BurnableCloth.States.Burning)
     {
         this._putOutFuel = this._fuel;
         this.Burnt();
         this._clothDisolveMat.SetFloat("_BurnAmount", 0f);
         this._state = BurnableCloth.States.PutOutIdle;
         this._player.IsWeaponBurning      = false;
         LighterControler.HasLightableItem = true;
         FMODCommon.PlayOneshotNetworked("event:/player/actions/molotov_quench", base.transform, FMODCommon.NetworkRole.Any);
     }
 }
Beispiel #13
0
 public static void Play(SfxInfo.SfxTypes type, Transform source = null, bool mpSync = true)
 {
     if (Sfx.Instance && type < (SfxInfo.SfxTypes)Sfx.Instance._definitions.Length)
     {
         if (mpSync)
         {
             FMODCommon.PlayOneshotNetworked(Sfx.Instance._definitions[(int)type]._path, source, FMODCommon.NetworkRole.Any);
         }
         else
         {
             FMODCommon.PlayOneshot(Sfx.Instance._definitions[(int)type]._path, source);
         }
     }
 }
Beispiel #14
0
 private void DieTrap(int type)
 {
     if (!this.ai.creepy && !this.ai.creepy_male && !this.ai.creepy_baby && !this.ai.creepy_fat)
     {
         if (type == 0)
         {
             this.animator.SetIntegerReflected("trapTypeInt1", 0);
         }
         if (type == 1)
         {
             this.animator.SetIntegerReflected("trapTypeInt1", 1);
         }
         if (type == 2)
         {
             this.animator.SetIntegerReflected("trapTypeInt1", 2);
         }
         if (type == 3)
         {
             FMODCommon.PlayOneshotNetworked("event:/combat/damage/body_impact", base.transform, FMODCommon.NetworkRole.Server);
             this.Hit(100);
         }
         else
         {
             this.animator.SetBoolReflected("trapBool", true);
             if (type == 2)
             {
                 this.animator.SetBoolReflected("enterTrapBool", true);
                 this.animator.SetBoolReflected("deathBOOL", true);
             }
             else
             {
                 this.animator.SetTriggerReflected("deathTrigger");
             }
             GameStats.EnemyKilled.Invoke();
             if (type == 2)
             {
                 this.setup.pmBrain.SendEvent("toDeathTrapNoose");
             }
             else
             {
                 this.setup.pmBrain.SendEvent("toDeathTrap");
             }
         }
     }
     else if (type == 3)
     {
         this.Hit(65);
     }
 }
Beispiel #15
0
 private void AfterHit()
 {
     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();
         }
     }
     FMODCommon.PlayOneshotNetworked(currentWeaponScript.fleshHitEvent, weaponAudio.transform, FMODCommon.NetworkRole.Any);
 }
Beispiel #16
0
 public void Action_LightFire()
 {
     if (BoltNetwork.isClient)
     {
         Debug.LogError("Action_LightFire: Should never be called on the client!");
         return;
     }
     if (!this.Lit)
     {
         if (this.Fuel < 5f)
         {
             this.Fuel = 10f;
             if (this._scaler)
             {
                 this._scaler.Awake();
                 this._scaler.ResetParticleScale(Mathf.Clamp01(this.Fuel / (this.FuelMax * 0.5f)));
             }
         }
         FMODCommon.PlayOneshotNetworked(this.addFuelEvent, base.transform, FMODCommon.NetworkRole.Any);
         this.On();
     }
 }
Beispiel #17
0
    private IEnumerator HitStructure(Vector3 position, bool noStick = false)
    {
        this.disableLive();
        Quaternion rot = this.PhysicBody.transform.rotation;

        yield return(YieldPresets.WaitForFixedUpdate);

        if (this.PhysicBody)
        {
            this.PhysicBody.transform.position = position;
            this.PhysicBody.transform.rotation = rot;
            if (!noStick)
            {
                this.PhysicBody.velocity    = Vector3.zero;
                this.PhysicBody.isKinematic = true;
                this.PhysicBody.useGravity  = false;
            }
            else
            {
                this.PhysicBody.AddTorque((float)UnityEngine.Random.Range(-1000, 1000), (float)UnityEngine.Random.Range(-1000, 1000), (float)UnityEngine.Random.Range(-1000, 1000));
            }
        }
        if (this.MyPickUp)
        {
            this.MyPickUp.SetActive(true);
        }
        if (this.at)
        {
            if (this.at.col && !noStick)
            {
                this.at.col.isTrigger = true;
            }
            this.at.enabled = false;
        }
        FMODCommon.PlayOneshotNetworked(this.hitStructureEvent, base.transform, FMODCommon.NetworkRole.Any);
        yield break;
    }
Beispiel #18
0
 private void playAttackSound()
 {
     FMODCommon.PlayOneshotNetworked(this.attackEvent, base.transform, FMODCommon.NetworkRole.Server);
 }
Beispiel #19
0
 private void playWingFlap()
 {
     Debug.Log("play wing flap");
     FMODCommon.PlayOneshotNetworked(this.wingFlapEvent, this.soundSourceTr, FMODCommon.NetworkRole.Server);
 }
Beispiel #20
0
 private void startRunning()
 {
     FMODCommon.PlayOneshotNetworked(this.startleEvent, base.transform, FMODCommon.NetworkRole.Server);
 }
        protected override void OnTriggerEnter(Collider other)
        {
            try
            {
                currState = animator.GetCurrentAnimatorStateInfo(0);
                nextState = animator.GetNextAnimatorStateInfo(0);
                if (currState.tagHash != damagedHash && currState.tagHash != staggerHash && currState.tagHash != hitStaggerHash && currState.tagHash != deathHash && nextState.tagHash != damagedHash && nextState.tagHash != staggerHash && nextState.tagHash != hitStaggerHash && nextState.tagHash != deathHash)
                {
                    if (other.gameObject.CompareTag("trapTrigger"))
                    {
                        other.gameObject.SendMessage("CutRope", SendMessageOptions.DontRequireReceiver);
                    }
                    if (!netPrefab && LocalPlayer.Animator && LocalPlayer.Animator.GetBool("deathBool"))
                    {
                        return;
                    }
                    if (other.gameObject.CompareTag("playerHitDetect") && mainTrigger)
                    {
                        if (!Scene.SceneTracker.hasAttackedPlayer)
                        {
                            Scene.SceneTracker.hasAttackedPlayer = true;
                            Scene.SceneTracker.Invoke("resetHasAttackedPlayer", Random.Range(120, 240));
                        }
                        targetStats component = other.transform.root.GetComponent <targetStats>();
                        if (component && component.targetDown)
                        {
                            return;
                        }
                        Animator componentInParent = other.gameObject.GetComponentInParent <Animator>();
                        Vector3  position          = rootTr.position;
                        position.y += 3.3f;
                        Vector3 direction = other.transform.position - position;
                        if (!Physics.Raycast(position, direction, out hit, direction.magnitude, enemyHitMask, QueryTriggerInteraction.Ignore))
                        {
                            if (!creepy_male && !creepy && !creepy_baby && !creepy_fat && events && componentInParent)
                            {
                                bool flag = InFront(other.gameObject);
                                if ((!BoltNetwork.isServer || !netPrefab) && flag && events.parryBool && (componentInParent.GetNextAnimatorStateInfo(1).tagHash == blockHash || componentInParent.GetCurrentAnimatorStateInfo(1).tagHash == blockHash))
                                {
                                    int parryDir = events.parryDir;
                                    BoltSetReflectedShim.SetIntegerReflected(animator, "parryDirInt", parryDir);
                                    if (BoltNetwork.isClient && netPrefab)
                                    {
                                        BoltSetReflectedShim.SetTriggerReflected(animator, "ClientParryTrigger");
                                        hitPrediction.StartParryPrediction();
                                        parryEnemy parryEnemy = parryEnemy.Create(GlobalTargets.OnlyServer);
                                        parryEnemy.Target = transform.root.GetComponent <BoltEntity>();
                                        parryEnemy.Send();
                                        FMODCommon.PlayOneshot(parryEvent, base.transform);
                                    }
                                    else
                                    {
                                        BoltSetReflectedShim.SetTriggerReflected(animator, "parryTrigger");
                                    }
                                    events.StartCoroutine("disableAllWeapons");
                                    playerHitReactions componentInParent2 = other.gameObject.GetComponentInParent <playerHitReactions>();
                                    if (componentInParent2 != null)
                                    {
                                        componentInParent2.enableParryState();
                                    }
                                    FMODCommon.PlayOneshotNetworked(parryEvent, base.transform, FMODCommon.NetworkRole.Server);
                                    events.parryBool = false;
                                    return;
                                }
                            }
                            if ((bool)events)
                            {
                                events.parryBool = false;
                            }
                            other.transform.root.SendMessage("getHitDirection", rootTr.position, SendMessageOptions.DontRequireReceiver);
                            int num = 0;
                            if (maleSkinny || femaleSkinny)
                            {
                                if (pale)
                                {
                                    num = ((!skinned) ? Mathf.FloorToInt(10f * GameSettings.Ai.skinnyDamageRatio) : Mathf.FloorToInt(10f * GameSettings.Ai.skinnyDamageRatio * GameSettings.Ai.skinMaskDamageRatio));
                                }
                                else
                                {
                                    num = Mathf.FloorToInt(13f * GameSettings.Ai.skinnyDamageRatio);
                                    if (maleSkinny && props.regularStick.activeSelf && events.leftHandWeapon)
                                    {
                                        num = Mathf.FloorToInt(num * 1.35f);
                                    }
                                }
                            }
                            else if (male && pale)
                            {
                                num = ((!skinned) ? Mathf.FloorToInt(22f * GameSettings.Ai.largePaleDamageRatio) : Mathf.FloorToInt(22f * GameSettings.Ai.largePaleDamageRatio * GameSettings.Ai.skinMaskDamageRatio));
                            }
                            else if (male && !firemanMain)
                            {
                                num = ((!painted) ? Mathf.FloorToInt(20f * GameSettings.Ai.regularMaleDamageRatio) : Mathf.FloorToInt(20f * GameSettings.Ai.regularMaleDamageRatio * GameSettings.Ai.paintedDamageRatio));
                            }
                            else if (female)
                            {
                                num = Mathf.FloorToInt(17f * GameSettings.Ai.regularFemaleDamageRatio);
                            }
                            else if (creepy)
                            {
                                num = ((!pale) ? Mathf.FloorToInt(28f * GameSettings.Ai.creepyDamageRatio) : Mathf.FloorToInt(35f * GameSettings.Ai.creepyDamageRatio));
                            }
                            else if (creepy_male)
                            {
                                num = ((!pale) ? Mathf.FloorToInt(30f * GameSettings.Ai.creepyDamageRatio) : Mathf.FloorToInt(40f * GameSettings.Ai.creepyDamageRatio));
                            }
                            else if (creepy_baby)
                            {
                                num = Mathf.FloorToInt(26f * GameSettings.Ai.creepyBabyDamageRatio);
                            }
                            else if (firemanMain)
                            {
                                num = Mathf.FloorToInt(12f * GameSettings.Ai.regularMaleDamageRatio);
                                if (events && !enemyAtStructure && !events.noFireAttack)
                                {
                                    if (BoltNetwork.isRunning && netPrefab)
                                    {
                                        other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver);
                                    }
                                    else
                                    {
                                        other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver);
                                    }
                                }
                            }
                            if (!female && male)
                            {
                                if (holdingRegularWeapon() && events.leftHandWeapon)
                                {
                                    num += 7;
                                }
                                else if (holdingAdvancedWeapon() && events.leftHandWeapon)
                                {
                                    num += 15;
                                }
                            }
                            if (setup && setup.health.poisoned)
                            {
                                num = Mathf.FloorToInt(num / 1.6f);
                            }

                            //My additional code
                            try
                            {
                                if (EnemyProg == null)
                                {
                                    EnemyProg = setup.health.gameObject.GetComponent <EnemyProgression>();
                                }
                                num = Mathf.RoundToInt(num * EnemyProg.DamageAmp);
                                BoltEntity bo = other.transform.root.GetComponent <BoltEntity>();
                                if (bo == null)
                                {
                                    bo = other.transform.root.GetComponentInChildren <BoltEntity>();
                                }


                                //POISON ATTACKS
                                if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Poisonous))
                                {
                                    if (BoltNetwork.isRunning)
                                    {
                                        if (BoltNetwork.isServer)
                                        {
                                            if (other.transform.root == LocalPlayer.Transform.root)
                                            {
                                                BuffDB.AddBuff(3, 32, num / 20, poisonDuration);
                                            }
                                            else
                                            {
                                                if (bo != null)
                                                {
                                                    Network.NetworkManager.SendLine("PO" + bo.networkId.PackedValue + ";32;" + num / 20 + ";" + poisonDuration, bo.controller);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        BuffDB.AddBuff(3, 32, num / 20, poisonDuration);
                                    }
                                }

                                //STUN ON HIT
                                if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Basher))
                                {
                                    if (BoltNetwork.isRunning)
                                    {
                                        if (BoltNetwork.isServer)
                                        {
                                            if (other.transform.root == LocalPlayer.Transform.root)
                                            {
                                                ModdedPlayer.instance.Stun(stunDuration);
                                            }
                                            else
                                            {
                                                if (bo != null)
                                                {
                                                    Network.NetworkManager.SendLine("ST" + bo.networkId.PackedValue + ";" + stunDuration + ";", bo.controller);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ModdedPlayer.instance.Stun(stunDuration);
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                ModAPI.Log.Write(ex.ToString());
                            }


                            PlayerStats component2 = other.transform.root.GetComponent <PlayerStats>();
                            if (male || female || creepy_male || creepy_fat || creepy || creepy_baby)
                            {
                                netId component3 = other.transform.GetComponent <netId>();
                                if (BoltNetwork.isServer && component3)
                                {
                                    other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver);
                                    return;
                                }
                                if (BoltNetwork.isClient && netPrefab && !(bool)component3)
                                {
                                    other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver);
                                    other.transform.root.SendMessage("hitFromEnemy", num, SendMessageOptions.DontRequireReceiver);
                                    other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver);
                                }
                                else if (BoltNetwork.isServer)
                                {
                                    if (!(bool)component3)
                                    {
                                        other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver);
                                        other.transform.root.SendMessage("hitFromEnemy", num, SendMessageOptions.DontRequireReceiver);
                                    }
                                }
                                else if (!BoltNetwork.isRunning && component2)
                                {
                                    component2.setCurrentAttacker(this);
                                    component2.hitFromEnemy(num);
                                }
                            }
                            else if (!netPrefab && component2)
                            {
                                component2.setCurrentAttacker(this);
                                component2.hitFromEnemy(num);
                            }



                            goto IL_092f;
                        }
                        return;
                    }
                    goto IL_092f;
                }
                return;

IL_092f:
                if (other.gameObject.CompareTag("enemyCollide") && mainTrigger && bodyCollider && !enemyAtStructure)
                {
                    setupAttackerType();
                    if (other.gameObject != bodyCollider)
                    {
                        other.transform.SendMessageUpwards("getAttackDirection", Random.Range(0, 2), SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessageUpwards("getCombo", Random.Range(1, 4), SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessage("getAttackerType", attackerType, SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessage("getAttacker", rootTr.gameObject, SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessageUpwards("Hit", 6, SendMessageOptions.DontRequireReceiver);
                        FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
                    }
                }
                if (other.gameObject.CompareTag("BreakableWood") || (other.gameObject.CompareTag("BreakableRock") && mainTrigger))
                {
                    other.transform.SendMessage("Hit", 50, SendMessageOptions.DontRequireReceiver);
                    other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, 50f), SendMessageOptions.DontRequireReceiver);
                    FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
                }
                if (other.gameObject.CompareTag("SmallTree") && !mainTrigger)
                {
                    other.SendMessage("Hit", 2, SendMessageOptions.DontRequireReceiver);
                }
                if (other.gameObject.CompareTag("Fire") && mainTrigger && firemanMain && !events.noFireAttack)
                {
                    other.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                }
                if (other.gameObject.CompareTag("Tree") && mainTrigger && creepy_male)
                {
                    other.SendMessage("Explosion", 5f, SendMessageOptions.DontRequireReceiver);
                    FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
                }
                if (!other.gameObject.CompareTag("structure") && !other.gameObject.CompareTag("SLTier1") && !other.gameObject.CompareTag("SLTier2") && !other.gameObject.CompareTag("SLTier3") && !other.gameObject.CompareTag("jumpObject") && !other.gameObject.CompareTag("UnderfootWood"))
                {
                    return;
                }
                if (!mainTrigger)
                {
                    return;
                }
                getStructureStrength component4 = other.gameObject.GetComponent <getStructureStrength>();
                bool flag2 = false;
                if (component4 == null)
                {
                    flag2 = true;
                }
                enemyAtStructure = true;
                int num2 = 0;
                if (!creepy_male && !creepy && !creepy_fat && !creepy_baby)
                {
                    if (!flag2)
                    {
                        num2 = ((maleSkinny || femaleSkinny) ? ((component4._strength == getStructureStrength.strength.weak) ? Mathf.FloorToInt(8f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((pale || painted || skinned) ? ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(16f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(12f * GameSettings.Ai.regularStructureDamageRatio) : 0)));
                        goto IL_0d63;
                    }
                    return;
                }
                num2 = ((!creepy_baby) ? Mathf.FloorToInt(30f * GameSettings.Ai.creepyStructureDamageRatio) : Mathf.FloorToInt(10f * GameSettings.Ai.creepyStructureDamageRatio));
                goto IL_0d63;
IL_0d63:
                if (setup && setup.health.poisoned)
                {
                    num2 /= 2;
                }
                other.SendMessage("Hit", num2, SendMessageOptions.DontRequireReceiver);
                other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, num2), SendMessageOptions.DontRequireReceiver);
                FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
            }
            catch (System.Exception ee)
            {
                ModAPI.Log.Write(ee.ToString());
            }
        }
Beispiel #22
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);
        }
    }
Beispiel #23
0
    private IEnumerator HitAi(Transform target, bool hitDelay = false, bool headDamage = false)
    {
        yield return(null);

        int sendDamage = this.damage;

        if (headDamage)
        {
            sendDamage *= 20;
        }
        if (this.PhysicBody)
        {
            this.PhysicBody.velocity = Vector3.zero;
        }
        if (this.spearType)
        {
            this.PhysicBody.isKinematic = false;
            this.PhysicBody.useGravity  = true;
            this.disableLive();
            if (this.MyPickUp)
            {
                this.MyPickUp.SetActive(true);
            }
        }
        if (target)
        {
            Vector3    vector             = target.transform.root.GetChild(0).InverseTransformPoint(base.transform.position);
            float      targetAngle        = Mathf.Atan2(vector.x, vector.z) * 57.29578f;
            int        animalHitDirection = animalHealth.GetAnimalHitDirection(targetAngle);
            BoltEntity componentInParent  = target.GetComponentInParent <BoltEntity>();
            if (!componentInParent)
            {
                target.GetComponent <BoltEntity>();
            }
            if (BoltNetwork.isClient && componentInParent)
            {
                if (hitDelay)
                {
                    target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver);
                    target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver);
                    BoltEntity     component      = this.parent.GetComponent <BoltEntity>();
                    PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Raise(GlobalTargets.OnlyServer);
                    playerHitEnemy.Target      = componentInParent;
                    playerHitEnemy.Weapon      = component;
                    playerHitEnemy.getAttacker = 10;
                    if (target.gameObject.CompareTag("animalRoot"))
                    {
                        playerHitEnemy.getAttackDirection = animalHitDirection;
                    }
                    else
                    {
                        playerHitEnemy.getAttackDirection = 3;
                    }
                    playerHitEnemy.getAttackerType = 4;
                    playerHitEnemy.Hit             = sendDamage;
                    playerHitEnemy.Send();
                }
                else
                {
                    target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver);
                    target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver);
                    PlayerHitEnemy playerHitEnemy2 = PlayerHitEnemy.Raise(GlobalTargets.OnlyServer);
                    playerHitEnemy2.Target = componentInParent;
                    if (target.gameObject.CompareTag("animalRoot"))
                    {
                        playerHitEnemy2.getAttackDirection = animalHitDirection;
                    }
                    else
                    {
                        playerHitEnemy2.getAttackDirection = 3;
                    }
                    playerHitEnemy2.getAttackerType = 4;
                    playerHitEnemy2.Hit             = sendDamage;
                    playerHitEnemy2.Send();
                }
            }
            else
            {
                target.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
                target.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
                GameObject closestPlayerFromPos = Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position);
                target.gameObject.SendMessageUpwards("getAttacker", closestPlayerFromPos, SendMessageOptions.DontRequireReceiver);
                if (target.gameObject.CompareTag("lb_bird") || target.gameObject.CompareTag("animalRoot") || target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("PlayerNet"))
                {
                    if (target.gameObject.CompareTag("enemyRoot"))
                    {
                        EnemyHealth componentInChildren = target.GetComponentInChildren <EnemyHealth>();
                        if (componentInChildren)
                        {
                            componentInChildren.getAttackDirection(3);
                            componentInChildren.setSkinDamage(2);
                            mutantTargetSwitching componentInChildren2 = target.GetComponentInChildren <mutantTargetSwitching>();
                            if (componentInChildren2)
                            {
                                componentInChildren2.getAttackerType(4);
                                componentInChildren2.getAttacker(closestPlayerFromPos);
                            }
                            componentInChildren.Hit(sendDamage);
                        }
                    }
                    else
                    {
                        if (target.gameObject.CompareTag("animalRoot"))
                        {
                            target.gameObject.SendMessage("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver);
                        }
                        target.gameObject.SendMessage("Hit", sendDamage, SendMessageOptions.DontRequireReceiver);
                        target.gameObject.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver);
                    }
                }
                else
                {
                    if (target.gameObject.CompareTag("animalCollide"))
                    {
                        target.gameObject.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver);
                    }
                    target.gameObject.SendMessageUpwards("Hit", sendDamage, SendMessageOptions.DontRequireReceiver);
                    target.gameObject.SendMessageUpwards("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        if (this.MyPickUp)
        {
            this.MyPickUp.SetActive(true);
        }
        FMODCommon.PlayOneshotNetworked(this.hitAiEvent, base.transform, FMODCommon.NetworkRole.Any);
        yield return(null);

        yield break;
    }
        protected override void OnTriggerEnter(Collider other)
        {
            try
            {
                currState = animator.GetCurrentAnimatorStateInfo(0);
                nextState = animator.GetNextAnimatorStateInfo(0);
                if (currState.tagHash != damagedHash && currState.tagHash != staggerHash && currState.tagHash != hitStaggerHash && currState.tagHash != deathHash && nextState.tagHash != damagedHash && nextState.tagHash != staggerHash && nextState.tagHash != hitStaggerHash && nextState.tagHash != deathHash)
                {
                    if (other.gameObject.CompareTag("trapTrigger"))
                    {
                        other.gameObject.SendMessage("CutRope", SendMessageOptions.DontRequireReceiver);
                    }
                    if (!netPrefab && LocalPlayer.Animator && LocalPlayer.Animator.GetBool("deathBool"))
                    {
                        return;
                    }
                    if (other.gameObject.CompareTag("playerHitDetect") && mainTrigger)
                    {
                        if (!Scene.SceneTracker.hasAttackedPlayer)
                        {
                            Scene.SceneTracker.hasAttackedPlayer = true;
                            Scene.SceneTracker.Invoke("resetHasAttackedPlayer", Random.Range(120, 240));
                        }
                        targetStats component = other.transform.root.GetComponent <targetStats>();
                        if (component && component.targetDown)
                        {
                            return;
                        }
                        Animator componentInParent = other.gameObject.GetComponentInParent <Animator>();
                        Vector3  position          = rootTr.position;
                        position.y += 3.3f;
                        Vector3 direction = other.transform.position - position;
                        if (!Physics.Raycast(position, direction, out hit, direction.magnitude, enemyHitMask, QueryTriggerInteraction.Ignore))
                        {
                            bool doParry = SpellActions.ParryAnythingIsTimed;
                            if (doParry || (!creepy_male && !creepy && !creepy_baby && !creepy_fat && events))
                            {
                                if (componentInParent)
                                {
                                    bool flag = InFront(other.gameObject);
                                    if (doParry || ((!BoltNetwork.isServer || !netPrefab) && flag && events.parryBool && ((componentInParent.GetNextAnimatorStateInfo(1).tagHash == blockHash || componentInParent.GetCurrentAnimatorStateInfo(1).tagHash == blockHash))))
                                    {
                                        SpellActions.DoParry(transform.position);
                                        ModAPI.Console.Write("Parrying successful");

                                        if ((!creepy_male && !creepy && !creepy_baby && !creepy_fat && events))
                                        {
                                            int parryDir = events != null ? events.parryDir : 1;
                                            BoltSetReflectedShim.SetIntegerReflected(animator, "parryDirInt", parryDir);
                                            if (BoltNetwork.isClient && netPrefab)
                                            {
                                                BoltSetReflectedShim.SetTriggerReflected(animator, "ClientParryTrigger");
                                                hitPrediction.StartParryPrediction();
                                                FMODCommon.PlayOneshot(parryEvent, base.transform);
                                                parryEnemy parryEnemy = parryEnemy.Create(GlobalTargets.OnlyServer);
                                                parryEnemy.Target = transform.root.GetComponent <BoltEntity>();
                                                parryEnemy.Send();
                                            }
                                            else
                                            {
                                                BoltSetReflectedShim.SetTriggerReflected(animator, "parryTrigger");
                                            }
                                            events.StartCoroutine("disableAllWeapons");
                                            playerHitReactions componentInParent2 = other.gameObject.GetComponentInParent <playerHitReactions>();
                                            if (componentInParent2 != null)
                                            {
                                                componentInParent2.enableParryState();
                                            }
                                            FMODCommon.PlayOneshotNetworked(parryEvent, base.transform, FMODCommon.NetworkRole.Server);
                                            events.parryBool = false;
                                        }
                                        return;
                                    }
                                }
                            }
                            if ((bool)events)
                            {
                                events.parryBool = false;
                            }
                            other.transform.root.SendMessage("getHitDirection", rootTr.position, SendMessageOptions.DontRequireReceiver);
                            float num = 0;
                            if (maleSkinny || femaleSkinny)
                            {
                                if (pale)
                                {
                                    num = ((!skinned) ? Mathf.Floor(10f * GameSettings.Ai.skinnyDamageRatio) : Mathf.Floor(10f * GameSettings.Ai.skinnyDamageRatio * GameSettings.Ai.skinMaskDamageRatio));
                                }
                                else
                                {
                                    num = Mathf.Floor(13f * GameSettings.Ai.skinnyDamageRatio);
                                    if (maleSkinny && props.regularStick.activeSelf && events.leftHandWeapon)
                                    {
                                        num = Mathf.Floor(num * 1.35f);
                                    }
                                }
                            }
                            else if (male && pale)
                            {
                                num = ((!skinned) ? Mathf.Floor(22f * GameSettings.Ai.largePaleDamageRatio) : Mathf.Floor(22f * GameSettings.Ai.largePaleDamageRatio * GameSettings.Ai.skinMaskDamageRatio));
                            }
                            else if (male && !firemanMain)
                            {
                                num = ((!painted) ? Mathf.Floor(20f * GameSettings.Ai.regularMaleDamageRatio) : Mathf.Floor(20f * GameSettings.Ai.regularMaleDamageRatio * GameSettings.Ai.paintedDamageRatio));
                            }
                            else if (female)
                            {
                                num = Mathf.Floor(17f * GameSettings.Ai.regularFemaleDamageRatio);
                            }
                            else if (creepy)
                            {
                                num = ((!pale) ? Mathf.Floor(28f * GameSettings.Ai.creepyDamageRatio) : Mathf.Floor(35f * GameSettings.Ai.creepyDamageRatio));
                            }
                            else if (creepy_male)
                            {
                                num = ((!pale) ? Mathf.Floor(60f * GameSettings.Ai.creepyDamageRatio) : Mathf.Floor(120f * GameSettings.Ai.creepyDamageRatio));
                            }
                            else if (creepy_baby)
                            {
                                num = Mathf.Floor(26f * GameSettings.Ai.creepyBabyDamageRatio);
                            }
                            else if (firemanMain)
                            {
                                num = Mathf.Floor(12f * GameSettings.Ai.regularMaleDamageRatio);
                                if (events && !enemyAtStructure && !events.noFireAttack)
                                {
                                    if (BoltNetwork.isRunning && netPrefab)
                                    {
                                        other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver);
                                    }
                                    else
                                    {
                                        other.gameObject.SendMessageUpwards("Burn", SendMessageOptions.DontRequireReceiver);
                                    }
                                }
                            }
                            if (!female && male)
                            {
                                if (holdingRegularWeapon() && events.leftHandWeapon)
                                {
                                    num += 7;
                                }
                                else if (holdingAdvancedWeapon() && events.leftHandWeapon)
                                {
                                    num += 15;
                                }
                            }
                            if (setup && setup.health.poisoned)
                            {
                                num = Mathf.Floor(num / 2);
                            }

                            //COTF additional code
                            try
                            {
                                if (GameSetup.IsMpClient)
                                {
                                    if (other.transform.root == LocalPlayer.Transform.root)
                                    {
                                        var x = EnemyManager.clientEnemies[entity.networkId.PackedValue];
                                        num = x.damagemult + num - 20f;
                                        if (x.abilities.Contains(EnemyProgression.Abilities.RainEmpowerment))
                                        {
                                            if (Scene.WeatherSystem.Raining)
                                            {
                                                num *= 5;
                                            }
                                        }
                                        hitDamage = num;
                                        if (x.abilities.Contains(EnemyProgression.Abilities.Poisonous))
                                        {
                                            BuffDB.AddBuff(3, 32, Mathf.Sqrt(num / 10) / 7, poisonDuration);
                                        }
                                        if (x.abilities.Contains(EnemyProgression.Abilities.Basher))
                                        {
                                            ModdedPlayer.instance.Stun(stunDuration);
                                        }
                                        if (ModdedPlayer.Stats.TotalThornsDamage > 0)
                                        {
                                            if (ModdedPlayer.Stats.TotalThornsArmorPiercing > 0)
                                            {
                                                EnemyProgression.ReduceArmor(entity, ModdedPlayer.Stats.TotalThornsArmorPiercing);
                                            }

                                            PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer);
                                            playerHitEnemy.Target = entity;
                                            //this integer make the attack not stagger the enemy
                                            playerHitEnemy.getAttackerType = 2000000;
                                            playerHitEnemy.Hit             = DamageMath.GetSendableDamage(ModdedPlayer.Stats.TotalThornsDamage);
                                            playerHitEnemy.Send();
                                        }
                                    }
                                }
                                else
                                {
                                    if (other.transform.root == LocalPlayer.Transform.root && EnemyManager.enemyByTransform.ContainsKey(this.rootTr))
                                    {
                                        if (EnemyProg == null)
                                        {
                                            EnemyProg = EnemyManager.enemyByTransform[this.rootTr];
                                        }
                                        num = EnemyProg.DamageAmp * EnemyProg.DebuffDmgMult + num - 20f;

                                        hitDamage = num;
                                        CotfUtils.Log($"Damage dealt to player: d{hitDamage}  amp{EnemyProg.DamageAmp}  lv{EnemyProg.level}  php{hitDamage*100 / ModdedPlayer.Stats.TotalMaxHealth}%", true);

                                        //POISON ATTACKS
                                        if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Poisonous))
                                        {
                                            BuffDB.AddBuff(3, 32, Mathf.Sqrt(num / 10) / 10, poisonDuration);
                                        }

                                        //STUN ON HIT
                                        if (EnemyProg.abilities.Contains(EnemyProgression.Abilities.Basher))
                                        {
                                            ModdedPlayer.instance.Stun(stunDuration);
                                        }

                                        if (ModdedPlayer.Stats.TotalThornsDamage > 0)
                                        {
                                            EnemyProg.HitPhysicalSilent(ModdedPlayer.Stats.TotalThornsDamage);
                                            if (ModdedPlayer.Stats.TotalThornsArmorPiercing > 0)
                                            {
                                                EnemyProg.ReduceArmor(ModdedPlayer.Stats.TotalThornsArmorPiercing);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                ModAPI.Log.Write(ex.ToString());
                            }
                            PlayerStats component2 = other.transform.root.GetComponent <PlayerStats>();
                            if (male || female || creepy_male || creepy_fat || creepy || creepy_baby)
                            {
                                netId component3 = other.transform.GetComponent <netId>();
                                if (BoltNetwork.isServer && component3)
                                {
                                    other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver);
                                    return;
                                }
                                if (BoltNetwork.isClient && netPrefab && !(bool)component3)
                                {
                                    other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver);
                                    other.transform.root.SendMessage("hitFromEnemy", Mathf.RoundToInt(num), SendMessageOptions.DontRequireReceiver);
                                    other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver);
                                }
                                else if (BoltNetwork.isServer)
                                {
                                    if (!(bool)component3)
                                    {
                                        other.transform.root.SendMessage("setCurrentAttacker", this, SendMessageOptions.DontRequireReceiver);
                                        other.transform.root.SendMessage("hitFromEnemy", Mathf.RoundToInt(num), SendMessageOptions.DontRequireReceiver);
                                    }
                                }
                                else if (!BoltNetwork.isRunning && component2)
                                {
                                    component2.setCurrentAttacker(this);
                                    component2.hitFromEnemy(Mathf.RoundToInt(num));
                                }
                            }
                            else if (!netPrefab && component2)
                            {
                                component2.setCurrentAttacker(this);
                                component2.hitFromEnemy(Mathf.RoundToInt(num));
                            }

                            goto IL_092f;
                        }
                        return;
                    }
                    goto IL_092f;
                }

                return;

IL_092f:
                if (other.gameObject.CompareTag("enemyCollide") && mainTrigger && bodyCollider && !enemyAtStructure)
                {
                    setupAttackerType();
                    if (other.gameObject != bodyCollider)
                    {
                        other.transform.SendMessageUpwards("getAttackDirection", Random.Range(0, 2), SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessageUpwards("getCombo", Random.Range(1, 4), SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessage("getAttackerType", attackerType, SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessage("getAttacker", rootTr.gameObject, SendMessageOptions.DontRequireReceiver);
                        other.transform.SendMessageUpwards("HitPhysical", Random.Range(30f, 50f) * Mathf.Pow(ModdedPlayer.Stats.explosionDamage, 1.25f), SendMessageOptions.DontRequireReceiver);
                        FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
                    }
                }
                if (other.gameObject.CompareTag("BreakableWood") || (other.gameObject.CompareTag("BreakableRock") && mainTrigger))
                {
                    other.transform.SendMessage("Hit", 50, SendMessageOptions.DontRequireReceiver);
                    other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, 50f), SendMessageOptions.DontRequireReceiver);
                    FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
                }
                if (other.gameObject.CompareTag("SmallTree") && !mainTrigger)
                {
                    other.SendMessage("Hit", 2, SendMessageOptions.DontRequireReceiver);
                }
                if (other.gameObject.CompareTag("Fire") && mainTrigger && firemanMain && !events.noFireAttack)
                {
                    other.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                }
                if (other.gameObject.CompareTag("Tree") && mainTrigger && creepy_male)
                {
                    other.SendMessage("Explosion", 5f, SendMessageOptions.DontRequireReceiver);
                    FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
                }
                if (!other.gameObject.CompareTag("structure") && !other.gameObject.CompareTag("SLTier1") && !other.gameObject.CompareTag("SLTier2") && !other.gameObject.CompareTag("SLTier3") && !other.gameObject.CompareTag("jumpObject") && !other.gameObject.CompareTag("UnderfootWood"))
                {
                    return;
                }
                if (!mainTrigger)
                {
                    return;
                }
                getStructureStrength component4 = other.gameObject.GetComponent <getStructureStrength>();
                bool flag2 = component4 == null;
                enemyAtStructure = true;
                int num2;
                if (!creepy_male && !creepy && !creepy_fat && !creepy_baby)
                {
                    if (!flag2)
                    {
                        num2 = ((maleSkinny || femaleSkinny) ? ((component4._strength == getStructureStrength.strength.weak) ? Mathf.FloorToInt(8f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((pale || painted || skinned) ? ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(16f * GameSettings.Ai.regularStructureDamageRatio) : 0) : ((component4._strength != getStructureStrength.strength.veryStrong) ? Mathf.FloorToInt(12f * GameSettings.Ai.regularStructureDamageRatio) : 0)));
                        goto IL_0d63;
                    }
                    return;
                }
                num2 = ((!creepy_baby) ? Mathf.FloorToInt(30f * GameSettings.Ai.creepyStructureDamageRatio) : Mathf.FloorToInt(10f * GameSettings.Ai.creepyStructureDamageRatio));
                goto IL_0d63;
IL_0d63:
                if (setup && setup.health.poisoned)
                {
                    num2 /= 2;
                }
                other.SendMessage("Hit", num2, SendMessageOptions.DontRequireReceiver);
                other.SendMessage("LocalizedHit", new LocalizedHitData(base.transform.position, num2), SendMessageOptions.DontRequireReceiver);
                FMODCommon.PlayOneshotNetworked(weaponHitEvent, base.transform, FMODCommon.NetworkRole.Server);
            }
            catch (System.Exception ee)
            {
                ModAPI.Log.Write(ee.ToString());
            }
        }
        public 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 #26
0
    public IEnumerator doThrower(GameObject posGo)
    {
        this.ih = this.currentThrowerGo.transform.parent.GetComponentInChildren <MultiThrowerItemHolder>();
        if (BoltNetwork.isRunning)
        {
            this.ih.disableTriggerMP();
        }
        else
        {
            this.currentTriggerGo.SetActive(false);
        }
        LocalPlayer.ScriptSetup.pmControl.enabled = false;
        LocalPlayer.Animator.SetBoolReflected("stickBlock", false);
        LocalPlayer.Animator.SetBoolReflected("blockColdBool", true);
        LocalPlayer.Animator.SetFloatReflected("crouch", 0f);
        LocalPlayer.FpCharacter.enabled      = false;
        LocalPlayer.MainRotator.enabled      = false;
        LocalPlayer.Rigidbody.isKinematic    = true;
        LocalPlayer.Rigidbody.useGravity     = false;
        LocalPlayer.Rigidbody.velocity       = Vector3.zero;
        LocalPlayer.CamRotator.rotationRange = new Vector2(70f, 60f);
        LocalPlayer.CamRotator.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
        LocalPlayer.Create.Grabber.gameObject.SetActive(false);
        LocalPlayer.AnimControl.lockGravity   = true;
        LocalPlayer.AnimControl.onRockThrower = true;
        LocalPlayer.Inventory.HideAllEquiped(false, false);
        Vector3 standPos = posGo.transform.position;

        standPos.y += LocalPlayer.AnimControl.playerCollider.height / 2f;
        LocalPlayer.Transform.position = posGo.transform.position;
        LocalPlayer.Transform.rotation = posGo.transform.rotation;
        LocalPlayer.Animator.SetBoolReflected("setThrowerBool", true);
        LocalPlayer.Animator.SetLayerWeightReflected(1, 0f);
        LocalPlayer.Animator.SetLayerWeightReflected(2, 0f);
        LocalPlayer.Animator.SetLayerWeightReflected(3, 0f);
        LocalPlayer.Animator.SetLayerWeightReflected(4, 0f);
        LocalPlayer.AnimControl.playerHeadCollider.enabled = false;
        base.Invoke("resetThrowerParams", 1f);
        yield return(YieldPresets.WaitPointTwoSeconds);

        this.layer0     = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
        this.nextlayer0 = LocalPlayer.Animator.GetNextAnimatorStateInfo(0);
        bool waitForLoad = false;

        while (!waitForLoad)
        {
            if (this.currentThrowerGo == null || posGo == null)
            {
                this.exitThrower();
                base.StopCoroutine("doThrower");
                yield break;
            }
            if (this.layer0.tagHash == this.throwerHash)
            {
                waitForLoad = true;
            }
            if (this.layer0.tagHash == this.enterThrowerHash)
            {
                waitForLoad = true;
            }
            this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
            yield return(null);
        }
        if (BoltNetwork.isRunning)
        {
            if (this.ih)
            {
                this.ih.sendAnimVars(0, true);
            }
        }
        else if (this.currentThrowerGo)
        {
            this.currentThrowerGo.GetComponent <Animator>().SetBoolReflected("load", true);
        }
        while (this.layer0.tagHash != this.throwerHash)
        {
            if (this.currentThrowerGo == null || posGo == null)
            {
                this.exitThrower();
                base.StopCoroutine("doThrower");
                yield break;
            }
            LocalPlayer.Transform.position = posGo.transform.position;
            LocalPlayer.Transform.rotation = posGo.transform.rotation;
            this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
            yield return(null);
        }
        this.am.throwPos.gameObject.SetActive(true);
        int currAmmo = this.ih._anim.ammoCount;

        currAmmo = 3 - currAmmo;
        for (int x = 0; x < currAmmo; x++)
        {
            this.loadAmmo();
            yield return(YieldPresets.WaitPointOneSeconds);
        }
        while (LocalPlayer.AnimControl.onRockThrower)
        {
            if (this.currentThrowerGo == null || posGo == null)
            {
                this.exitThrower();
                base.StopCoroutine("doThrower");
                yield break;
            }
            this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
            LocalPlayer.Transform.position    = posGo.transform.position;
            LocalPlayer.Transform.rotation    = posGo.transform.rotation;
            LocalPlayer.Rigidbody.isKinematic = true;
            LocalPlayer.Rigidbody.useGravity  = false;
            if (TheForest.Utils.Input.GetButtonDown("Take"))
            {
                this.exitThrower();
                base.StopCoroutine("doThrower");
                yield break;
            }
            if (TheForest.Utils.Input.GetButtonDown("Fire1"))
            {
                if (BoltNetwork.isClient)
                {
                    this.ih.sendLandTarget();
                }
                else
                {
                    this.am.landTarget = this.am.throwPos.GetComponent <rockThrowerAimingReticle>()._currentLandTarget;
                }
                LocalPlayer.Animator.SetBoolReflected("releaseThrowerBool", true);
                FMODCommon.PlayOneshotNetworked("event:/traps/catapult_release", base.transform, FMODCommon.NetworkRole.Any);
                if (BoltNetwork.isRunning)
                {
                    this.ih.sendAnimVars(1, true);
                }
                else
                {
                    this.currentThrowerGo.GetComponent <Animator>().SetBoolReflected("release", true);
                }
                base.StartCoroutine("offsetLeverRotation");
                yield return(YieldPresets.WaitOneSecond);

                this.ih.sendResetAmmoMP();
                LocalPlayer.Animator.SetBoolReflected("releaseThrowerBool", false);
                if (BoltNetwork.isRunning)
                {
                    if (this.ih)
                    {
                        this.ih.sendAnimVars(0, false);
                        this.ih.sendAnimVars(1, false);
                    }
                }
                else if (this.currentThrowerGo)
                {
                    this.currentThrowerGo.GetComponent <Animator>().SetBoolReflected("release", false);
                    this.currentThrowerGo.GetComponent <Animator>().SetBoolReflected("load", false);
                }
                this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
                this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
                while (this.layer0.tagHash != this.throwerHash)
                {
                    if (this.currentThrowerGo == null || posGo == null)
                    {
                        this.exitThrower();
                        base.StopCoroutine("doThrower");
                        yield break;
                    }
                    LocalPlayer.Transform.position = posGo.transform.position;
                    LocalPlayer.Transform.rotation = posGo.transform.rotation;
                    this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
                    yield return(null);
                }
                currAmmo = this.ih._anim.ammoCount;
                currAmmo = 3 - currAmmo;
                for (int x2 = 0; x2 < currAmmo; x2++)
                {
                    this.loadAmmo();
                    yield return(YieldPresets.WaitPointOneSeconds);
                }
            }
            this.layer0 = LocalPlayer.Animator.GetCurrentAnimatorStateInfo(0);
            if (!this.fixLeverRotation && this.layer0.tagHash == this.throwerHash)
            {
                this.currentLever.transform.localEulerAngles = new Vector3(0f, LocalPlayer.AnimControl.headCamY / 2f, 0f);
            }
            yield return(null);
        }
        yield break;
    }
Beispiel #27
0
 private void exitThrower()
 {
     base.StopCoroutine("offsetLeverRotation");
     this.fixLeverRotation = false;
     if (this.currentLever)
     {
         this.currentLever.transform.localEulerAngles = Vector3.zero;
         this.am.throwPos.gameObject.SetActive(false);
         this.currentLever.transform.localRotation = Quaternion.identity;
     }
     if (BoltNetwork.isRunning)
     {
         if (this.ih)
         {
             this.ih.sendAnimVars(0, false);
         }
     }
     else if (this.currentThrowerGo)
     {
         this.currentThrowerGo.GetComponent <Animator>().SetBoolReflected("load", false);
     }
     LocalPlayer.Animator.SetBoolReflected("blockColdBool", false);
     FMODCommon.PlayOneshotNetworked("event:/traps/catapult_unload", base.transform, FMODCommon.NetworkRole.Any);
     if (BoltNetwork.isRunning)
     {
         if (this.ih)
         {
             this.ih.Invoke("enableTriggerMP", 1f);
         }
     }
     else
     {
         base.Invoke("enableTrigger", 1f);
     }
     this.currentThrowerGo = null;
     this.currentLever     = null;
     LocalPlayer.ScriptSetup.pmControl.enabled = true;
     LocalPlayer.ScriptSetup.pmControl.SendEvent("toReset2");
     LocalPlayer.Transform.parent     = null;
     LocalPlayer.Transform.localScale = new Vector3(1f, 1f, 1f);
     LocalPlayer.CamFollowHead.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
     LocalPlayer.Create.Grabber.gameObject.SetActive(true);
     LocalPlayer.CamFollowHead.followAnim           = false;
     LocalPlayer.FpCharacter.enabled                = true;
     LocalPlayer.MainRotator.enabled                = true;
     LocalPlayer.CamRotator.enabled                 = true;
     LocalPlayer.AnimControl.onRope                 = false;
     LocalPlayer.AnimControl.lockGravity            = false;
     LocalPlayer.AnimControl.controller.useGravity  = true;
     LocalPlayer.AnimControl.controller.isKinematic = false;
     LocalPlayer.Inventory.ShowAllEquiped(true);
     LocalPlayer.AnimControl.useRootMotion = false;
     LocalPlayer.AnimControl.onRockThrower = false;
     LocalPlayer.Rigidbody.isKinematic     = false;
     LocalPlayer.Rigidbody.useGravity      = true;
     LocalPlayer.Animator.SetBoolReflected("setThrowerBool", false);
     LocalPlayer.AnimControl.playerHeadCollider.enabled = true;
     LocalPlayer.CamRotator.rotationRange  = new Vector2(LocalPlayer.FpCharacter.minCamRotationRange, 0f);
     LocalPlayer.MainRotator.rotationRange = new Vector2(0f, 999f);
     LocalPlayer.Animator.SetLayerWeightReflected(1, 1f);
     LocalPlayer.Animator.SetLayerWeightReflected(4, 1f);
 }
Beispiel #28
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);
             }
         }
     }
 }
Beispiel #29
0
 private void PlayWeaponOneshot(string path)
 {
     FMODCommon.PlayOneshotNetworked(path, this.setup.weaponRight, FMODCommon.NetworkRole.Server);
 }
        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);
            }
        }