Esempio n. 1
0
        public ActorHitInfo(ActorHitInfo original)
        {
            Damage            = original.Damage;
            DamagePierce      = original.DamagePierce;
            DamageType        = original.DamageType;
            DamageEffector    = original.DamageEffector;
            HarmFriendly      = original.HarmFriendly;
            HitLocation       = original.HitLocation;
            HitMaterial       = original.HitMaterial;
            Originator        = original.Originator;
            OriginatorFaction = original.OriginatorFaction;
            HitPuff           = original.HitPuff;
            HitCoords         = original.HitCoords;
            HitFlags          = original.HitFlags;
            ExtraHitFlags     = original.ExtraHitFlags;

            if (original.ExtraData != null)
            {
                ExtraData = new Dictionary <string, object>(original.ExtraData);
            }
            else
            {
                ExtraData = null;
            }
        }
Esempio n. 2
0
        public void TakeDamage(ActorHitInfo data)
        {
            LastDamageDealer = data.Originator;

            float damage = data.Damage + data.DamagePierce;

            if (DamageFactor != null && DamageFactor.Length > data.DamageType)
            {
                damage *= DamageFactor[data.DamageType];
            }

            if (!Invincible)
            {
                Health -= damage;
            }

            if (UsePainState && Health > 0 && !ForceDeadState && !IsDead && damage > PainThreshold)
            {
                //do pain calculation
                bool didTakePain = false;
                if (UseRelativePainCalculation)
                {
                    didTakePain = UnityEngine.Random.Range(PainThreshold, PainChance) < damage;
                }
                else
                {
                    didTakePain = UnityEngine.Random.Range(0f, 1f) < PainChance;
                }

                if (didTakePain)
                {
                    EnterPainState();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Spawns a hit puff based on an ActorHitInfo
        /// </summary>
        public static GameObject SpawnHitPuff(ActorHitInfo hitInfo)
        {
            if (!hitInfo.HitCoords.HasValue) //can't spawn if we don't know where to spawn
            {
                return(null);
            }

            return(SpawnHitPuff(hitInfo.HitPuff, hitInfo.HitCoords.Value, hitInfo.HitMaterial));
        }
Esempio n. 4
0
        public void TakeDamage(ActorHitInfo data)
        {
            LastDamageDealer = data.Originator;

            float damage = data.Damage + data.DamagePierce;

            if (DamageFactors != null && DamageFactors.Length > 0)
            {
                foreach (var dfac in DamageFactors) //no you can't eat here
                {
                    if (dfac.DamageType == data.DamageType)
                    {
                        damage *= dfac.DamageFactor;
                        break;
                    }
                }
            }

            if (!Invincible)
            {
                Health -= damage;
            }

            if (UsePainState && Health > 0 && !ForceDeadState && !IsDead && (damage > PainThreshold || data.HitFlags.HasFlag(BuiltinHitFlags.AlwaysPain)) && !data.HitFlags.HasFlag(BuiltinHitFlags.NoPain))
            {
                //do pain calculation
                bool didTakePain;
                if (data.HitFlags.HasFlag(BuiltinHitFlags.AlwaysPain))
                {
                    didTakePain = true;
                }
                else
                {
                    if (UseRelativePainCalculation)
                    {
                        didTakePain = UnityEngine.Random.Range(PainThreshold, PainChance) < damage;
                    }
                    else
                    {
                        didTakePain = UnityEngine.Random.Range(0f, 1f) < PainChance;
                    }
                }

                if (didTakePain)
                {
                    EnterPainState();
                }
            }
        }