/// <summary> /// notify npc that he is attacked /// </summary> /// <param name="attacker">attacker transform</param> /// <param name="hitType">current hit type</param> /// <param name="damage">attackers damage</param> /// <param name="blocking">ref notify attacker that npc has blocked attack</param> /// <returns>success</returns> public bool attack_hit_notify(IGameCharacter attacker, int hitType, int attackSource, ref bool blocking, bool applyHitReaction = true, Vector3?hitVelocity = null, int[] hitParts = null) { if (!m_Initialized) { Debug.LogError("component not initialized" + " < " + this.ToString() + ">"); return(false); } if (isDead) { return(false); } if (!m_Blocking) { int rnd = Random.Range(0, blockOdds); m_Blocking = rnd == 0; if (m_Blocking) { m_Animator.SetBool(HashIDs.BlockBool /*"pBlock"*/, true); m_BlockTimer = 0.0f; } } _end_attack_combo(); m_InCombat = true; blocking = m_Blocking; m_Character.fullStop(); _startHitReaction(attacker, hitType, applyHitReaction, attackSource); int damageReceived = GameUtils.CalculateDamage(this, attacker, m_Blocking); if (m_Stats.currentHealth <= 0) { m_Player.attack_end_notify(this, m_CurrentAttackType); m_InCombat = false; m_Character.animator.SetBool(/*"pAttack1"*/ HashIDs.Attack1Bool, false); m_Attack_combo_started = false; m_Kooldown = true; m_AttackTimer = 0.0f; attackSweepBody.gameObject.SetActive(false); m_Ragdoll.startRagdoll(hitParts, hitVelocity, hitVelocity * 0.025f); } if (!blocking) { if (m_DamageUI) { m_DamageUI.setText("-" + damageReceived); } } return(true); }