public void TakeDamage(int damageAmount, Transform attacker, bool attackerInOverdrive = false) { if (!isInvulnerable) { int finalDamageAmount; if (attackerInOverdrive) { finalDamageAmount = damageAmount * 2; } else { finalDamageAmount = damageAmount; } ScoreHandler attackerScore = null; //update myAttacker to reflect this agent's current attacker; this will then be available to the Retreat State so this agent can run away from the attacker if (attacker.CompareTag("Player") || attacker.CompareTag("Enemy")) { myAttacker = attacker; attackerScore = attacker.GetComponent <ScoreHandler>(); } if (isUsingShield && shields > 0) { shields -= finalDamageAmount; if (shields <= 0) { //DetonateElectricalCharge(); } } else { currentHP -= finalDamageAmount; if (attackerScore != null) { attackerScore.AddToScore(finalDamageAmount); } //Debug.Log(gameObject.name + " took " + damageAmount + " damage, now has hp: " + currentHP); if (gameObject.CompareTag("Enemy")) { ShouldUseShield(true); } SetMyValueAsATarget(); if (currentHP <= 0) { if (attackerScore != null) { attackerScore.IncreaseKillstreak(); } if (!gameObject.CompareTag("Non-playables")) { Die(); } else { AOScript.audio.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); AOScript.audio.release(); Destroy(gameObject); } } } } else { //Debug.Log(gameObject.name + " is INVULNERABLE!!!"); } }