예제 #1
0
 /// <summary>
 /// Applies Trauma damage to a body part.
 /// </summary>
 public void TakeTraumaDamage(float damage, TraumaticDamageTypes damageType)
 {
     foreach (BodyPart limb in ContainsLimbs)
     {
         if (damageType.HasFlag(TraumaticDamageTypes.BURN))
         {
             limb.ApplyTraumaDamage(damage, TraumaticDamageTypes.BURN);
         }
         if (damageType.HasFlag(TraumaticDamageTypes.SLASH))
         {
             limb.ApplyTraumaDamage(damage);
         }
         if (damageType.HasFlag(TraumaticDamageTypes.PIERCE))
         {
             limb.ApplyTraumaDamage(damage, TraumaticDamageTypes.PIERCE);
         }
     }
 }
예제 #2
0
        /// <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="organDamageSplit">Should the damage be divided amongst the contained organs or applied to a random one</param>
        public void TakeDamage(GameObject damagedBy, float damage, AttackType attackType, DamageType damageType,
                               bool organDamageSplit     = false, bool DamageSubOrgans = true, float armorPenetration = 0,
                               double traumaDamageChance = 100, TraumaticDamageTypes tramuticDamageType = TraumaticDamageTypes.NONE)
        {
            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 && containBodyParts.Count > 0)
            {
                DamageOrgans(damage, attackType, damageType, organDamageSplit, armorPenetration);
            }

            if (damage < damageThreshold)
            {
                return;                                    //Do not apply traumas if the damage is not serious.
            }
            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)
                {
                    if (tramuticDamageType != TraumaticDamageTypes.NONE && DMMath.Prob(traumaDamageChance))
                    {
                        //TODO: move this to an utility, its hard to read! - picks a random enum from the ones already flagged
                        Random random = new Random();
                        TraumaticDamageTypes[] typeToSelectFrom = Enum.GetValues(typeof(TraumaticDamageTypes)).Cast <TraumaticDamageTypes>().Where(x => tramuticDamageType.HasFlag(x)).ToArray();
                        TraumaticDamageTypes   selectedType     = typeToSelectFrom[random.Next(1, typeToSelectFrom.Length)];
                        ApplyTraumaDamage(selectedType);
                    }
                    CheckBodyPartIntegrity();
                }
            }

            if (attackType == AttackType.Bomb)
            {
                TakeBluntDamage();
                DismemberBodyPartWithChance();
            }

            if (damageType == DamageType.Burn || attackType == AttackType.Fire ||
                attackType == AttackType.Laser || attackType == AttackType.Energy)
            {
                ApplyTraumaDamage(TraumaticDamageTypes.BURN);
            }
        }