/// <summary> /// Adds a new body part to this body part, and removes the old part whose place is /// being taken if possible /// </summary> /// <param name="prevImplant">Old body part to be removed</param> /// <param name="newImplant">New body part to be added</param> public virtual void ImplantAdded(Pickupable prevImplant, Pickupable newImplant) { //Check what's being added and add sprites if appropriate if (newImplant) { BodyPart implant = newImplant.GetComponent <BodyPart>(); ContainBodyParts.Add(implant); implant.ContainedIn = this; //Initialisation j**z if (HealthMaster != null) { SetUpBodyPart(implant); } } //Remove sprites if appropriate if (prevImplant) { BodyPart implant = prevImplant.GetComponent <BodyPart>(); implant.HealthMaster = null; HealthMaster.RemoveImplant(implant); implant.RemovedFromBody(HealthMaster); implant.ContainedIn = null; ContainBodyParts.Remove(implant); //bodyPartSprites?.UpdateSpritesOnImplantRemoved(implant); } }
/// <summary> /// Checks if the cut is big enough for the contained organs to escape. /// If the cut isn't big enough or has failed a chance check, apply internal damage + bleeding. /// </summary> private void Disembowel() { BodyPart randomBodyPart = ContainBodyParts.GetRandom(); BodyPart randomCustomBodyPart = OptionalOrgans.GetRandom(); if (currentCutSize >= BodyPartStorageContentsSpillOutOnCutSize) { float chance = UnityEngine.Random.Range(0.0f, 1.0f); if (chance >= spillChanceWhenCutPresent) { randomBodyPart.RemoveFromBodyThis(); if (randomCustomBodyPart != null) { randomCustomBodyPart.RemoveFromBodyThis(); } } else { randomBodyPart.ApplyInternalDamage(); if (randomCustomBodyPart != null) { randomCustomBodyPart.ApplyInternalDamage(); } } } else { randomBodyPart.ApplyInternalDamage(); if (randomCustomBodyPart != null) { randomCustomBodyPart.ApplyInternalDamage(); } } }
/// <summary> /// Checks if the cut is big enough for the contained organs to escape. /// If the cut isn't big enough or has failed a chance check, apply internal damage + bleeding. /// </summary> private void Disembowel() { BodyPart randomBodyPart = ContainBodyParts.GetRandom(); float chance = UnityEngine.Random.Range(0.0f, 1.0f); if (chance >= spillChanceWhenCutPresent) { foreach (var bodyPart in ContainBodyParts) { chance = UnityEngine.Random.Range(0.0f, 1.0f); if (chance >= spillChanceWhenCutPresent) { HealthMaster.DismemberBodyPart(bodyPart); } } } else { randomBodyPart.ApplyInternalDamage(); } if (currentPierceDamageLevel >= TraumaDamageLevel.SMALL && isBleedingExternally == false && IsSurface) { StartCoroutine(ExternalBleedingLogic()); } }
/// <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) { if (ContainBodyParts.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; if (damageSplit) { foreach (var bodyPart in ContainBodyParts) { bodyPart.TakeDamage(damagedBy, subDamage / ContainBodyParts.Count, attackType, damageType, damageSplit); } } else { var OrganToDamage = ContainBodyParts.PickRandom(); //It's not like you can aim for Someone's liver can you OrganToDamage.TakeDamage(damagedBy, subDamage, attackType, 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) { if (ContainBodyParts.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; if (damageSplit) { foreach (var bodyPart in ContainBodyParts) { bodyPart.TakeDamage(damagedBy, subDamage / ContainBodyParts.Count, attackType, damageType, damageSplit); } } else { var OrganToDamage = ContainBodyParts.PickRandom(); //It's not like you can aim for Someone's liver can you OrganToDamage.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) { if (damageToLimb >= DamageThreshold) { DismemberBodyPartWithChance(); } } if (attackType == AttackType.Fire) { TakeBurnDamage(damage); } }