private void DamageOrgans(float damage, AttackType attackType, DamageType damageType, bool organDamageSplit, float armorPenetration) { var organDamageRatingValue = SubOrganBodyPartArmour.GetRatingValue(attackType, armorPenetration); if (maxHealth - Damages[(int)damageType] < SubOrganDamageIncreasePoint) { organDamageRatingValue += 1 - ((maxHealth - Damages[(int)damageType]) / SubOrganDamageIncreasePoint); organDamageRatingValue = Math.Min(1, organDamageRatingValue); } var subDamage = damage * organDamageRatingValue; //TODO: remove BodyPart component from organ if (organDamageSplit) { foreach (var organ in OrganList) { var organBodyPart = organ.GetComponent <BodyPart>(); organBodyPart.AffectDamage(subDamage / OrganList.Count, (int)damageType); } } else { var organBodyPart = OrganList.PickRandom().GetComponent <BodyPart>(); //It's not like you can aim for Someone's liver can you organBodyPart.AffectDamage(subDamage, (int)damageType); } }
/// <summary> /// Applies damage to this body part. Damage will be divided among it and sub organs depending on their /// armor values. /// </summary> /// <param name="damagedBy">The player or object that caused the damage. Null if there is none</param> /// <param name="damage">Damage amount</param> /// <param name="attackType">Type of attack that is causing the damage</param> /// <param name="damageType">The type of damage</param> /// <param name="damageSplit">Should the damage be divided amongst the contained body parts or applied to a random body part</param> public void TakeDamage(GameObject damagedBy, float damage, AttackType attackType, DamageType damageType, bool damageSplit = false, bool DamageSubOrgans = true, float armorPenetration = 0) { float damageToLimb = Armor.GetTotalDamage( SelfArmor.GetDamage(damage, attackType, armorPenetration), attackType, ClothingArmors, armorPenetration ); AffectDamage(damageToLimb, (int)damageType); // May be changed to individual damage // May also want it so it can miss sub organs if (DamageSubOrgans && OrganList.Count > 0) { var organDamageRatingValue = SubOrganBodyPartArmour.GetRatingValue(attackType, armorPenetration); if (maxHealth - Damages[(int)damageType] < SubOrganDamageIncreasePoint) { organDamageRatingValue += 1 - ((maxHealth - Damages[(int)damageType]) / SubOrganDamageIncreasePoint); organDamageRatingValue = Math.Min(1, organDamageRatingValue); } var subDamage = damage * organDamageRatingValue; //TODO: remove BodyPart component from organ if (damageSplit) { foreach (var organ in OrganList) { var organBodyPart = organ.GetComponent <BodyPart>(); organBodyPart.TakeDamage(damagedBy, subDamage / OrganList.Count, attackType, damageType, damageSplit); } } else { var organBodyPart = OrganList.PickRandom().GetComponent <BodyPart>(); //It's not like you can aim for Someone's liver can you organBodyPart.TakeDamage(damagedBy, subDamage, attackType, damageType); } } if (damageType == DamageType.Brute) //Check damage type to avoid bugs where you can blow someone's head off with a shoe. { if (attackType == AttackType.Melee || attackType == AttackType.Laser || attackType == AttackType.Energy) { CheckBodyPartIntigrity(damage); } } if (attackType == AttackType.Bomb) { TakeBluntDamage(damage); if (damageToLimb >= DamageThreshold) { DismemberBodyPartWithChance(); } } if (attackType == AttackType.Fire || attackType == AttackType.Laser || attackType == AttackType.Energy) { ApplyTraumaDamage(damage, TraumaticDamageTypes.BURN); } if (CanBeBroken) { CheckIfBroken(); } //If our external limb can be broken. }