Пример #1
0
        public override void Awake()
        {
            Get = this;
            base.Awake();

            mDamageAudioSource = gameObject.CreateChild("DamageAudioSource");

            #region material entries
            //create our lookup tables for damage
            //TODO good god in heaven there has to be some way to automate this
            //TODO also we need a table for 'takes damage against'
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Dirt, 1.0f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Fabric, 1.0f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Flesh, 1.5f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Glass, 2.0f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Liquid, 1.0f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Metal, 0.25f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Stone, 0.25f);
            AddMaterialEntry(WIMaterialType.Dirt, WIMaterialType.Wood, 0.5f);

            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Dirt, 0.01f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Fabric, 0.01f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Flesh, 0.01f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Glass, 0.1f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Liquid, 0.01f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Metal, 0.001f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Stone, 0.001f);
            AddMaterialEntry(WIMaterialType.Fabric, WIMaterialType.Wood, 0.001f);

            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Dirt, 0.25f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Fabric, 0.25f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Flesh, 1.0f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Glass, 1.0f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Liquid, 1.0f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Metal, 0.001f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Stone, 0.001f);
            AddMaterialEntry(WIMaterialType.Flesh, WIMaterialType.Wood, 0.001f);

            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Dirt, 0.1f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Fabric, 0.1f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Flesh, 1.0f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Glass, 1.0f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Liquid, 1.0f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Metal, 0.01f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Stone, 0.01f);
            AddMaterialEntry(WIMaterialType.Glass, WIMaterialType.Wood, 0.125f);

            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Dirt, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Fabric, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Flesh, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Glass, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Liquid, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Metal, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Stone, 0.001f);
            AddMaterialEntry(WIMaterialType.Liquid, WIMaterialType.Wood, 0.001f);

            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Dirt, 2.0f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Fabric, 2.0f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Flesh, 3.0f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Glass, 5.0f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Liquid, 1.0f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Metal, 0.5f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Stone, 1.5f);
            AddMaterialEntry(WIMaterialType.Metal, WIMaterialType.Wood, 2.0f);

            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Dirt, 2.0f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Fabric, 2.0f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Flesh, 5.0f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Glass, 5.0f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Liquid, 1.0f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Metal, 0.5f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Stone, 1.0f);
            AddMaterialEntry(WIMaterialType.Stone, WIMaterialType.Wood, 1.5f);

            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Dirt, 1.0f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Fabric, 1.0f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Flesh, 2.0f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Glass, 2.0f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Liquid, 1.0f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Metal, 0.5f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Stone, 0.25f);
            AddMaterialEntry(WIMaterialType.Wood, WIMaterialType.Wood, 1.0f);
            #endregion

            #region armor entries
            //create our lookup tables for damage
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Dirt, 1.5f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Fabric, 1.0f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Flesh, 1.0f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Glass, 1.0f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Metal, 2.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Stone, 2.0f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Wood, 2.0f);

            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Dirt, 1.0f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Fabric, 1.0f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Flesh, 1.5f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Glass, 2.0f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Metal, 0.25f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Stone, 0.25f);
            AddArmorEntry(WIMaterialType.Dirt, WIMaterialType.Wood, 0.5f);

            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Dirt, 0.01f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Fabric, 0.01f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Flesh, 0.01f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Glass, 0.1f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Liquid, 0.01f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Metal, 0.001f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Stone, 0.001f);
            AddArmorEntry(WIMaterialType.Fabric, WIMaterialType.Wood, 0.001f);

            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Dirt, 0.25f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Fabric, 0.25f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Flesh, 1.0f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Glass, 1.0f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Metal, 0.001f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Stone, 0.001f);
            AddArmorEntry(WIMaterialType.Flesh, WIMaterialType.Wood, 0.001f);

            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Dirt, 0.1f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Fabric, 0.1f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Flesh, 1.0f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Glass, 1.0f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Metal, 0.01f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Stone, 0.01f);
            AddArmorEntry(WIMaterialType.Glass, WIMaterialType.Wood, 0.125f);

            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Dirt, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Fabric, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Flesh, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Glass, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Liquid, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Metal, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Stone, 0.001f);
            AddArmorEntry(WIMaterialType.Liquid, WIMaterialType.Wood, 0.001f);

            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Dirt, 2.0f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Fabric, 2.0f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Flesh, 3.0f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Glass, 5.0f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Metal, 0.5f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Stone, 1.5f);
            AddArmorEntry(WIMaterialType.Metal, WIMaterialType.Wood, 2.0f);

            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Dirt, 2.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Fabric, 2.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Flesh, 5.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Glass, 5.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Metal, 0.5f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Stone, 1.0f);
            AddArmorEntry(WIMaterialType.Stone, WIMaterialType.Wood, 1.5f);

            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Dirt, 1.0f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Fabric, 1.0f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Flesh, 2.0f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Glass, 2.0f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Liquid, 1.0f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Metal, 0.5f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Stone, 0.25f);
            AddArmorEntry(WIMaterialType.Wood, WIMaterialType.Wood, 1.0f);
            #endregion
        }
Пример #2
0
        public void TakeFallDamage(float fallImpact)
        {
            if (WorldClock.AdjustedRealTime < (player.LastSpawnTime + gMinimumTimeBeforeFallDamage))
            {
                Debug.Log("Fall damage attempted before minimum spawn time elapsed, ignoring");
                return;
            }

            if (player.IsHijacked || !player.HasSpawned)
            {
                return;
            }

            float actualDamage;
            float attemptedDamage = fallImpact * Globals.FallDamageImpactMultiplier;
            bool  isDead;
            float impactThreshold    = Mathf.Infinity;
            float deathThreshold     = Mathf.Infinity;
            float breakBoneThreshold = Mathf.Infinity;

            switch (Profile.Get.CurrentGame.Difficulty.FallDamage)
            {
            case FallDamageStyle.None:
                //don't do anything
                return;

            case FallDamageStyle.Forgiving:
                attemptedDamage   *= Globals.DamageFallDamageForgivingMultiplier;
                deathThreshold     = Globals.DamageFallDamageForgivingImpactDeathThreshold;
                impactThreshold    = Globals.DamageFallDamageForgivingImpactThreshold;
                breakBoneThreshold = Globals.DamageFallDamageForgivingBrokenBoneThreshold;
                break;

            case FallDamageStyle.Realistic:
                attemptedDamage   *= Globals.DamageFallDamageRealisticMultiplier;
                deathThreshold     = Globals.DamageFallDamageRealisticImpactDeathThreshold;
                impactThreshold    = Globals.DamageFallDamageRealisticImpactThreshold;
                breakBoneThreshold = Globals.DamageFallDamageRealisticBrokenBoneThreshold;
                break;
            }

            if (attemptedDamage < impactThreshold)
            {
                return;
            }
            else if (attemptedDamage > deathThreshold)
            {
                player.Die("FallDamage");
                return;
            }
            else
            {
                WIMaterialType fallOn = DamageManager.GroundTypeToMaterialType(Player.Local.Surroundings.State.GroundBeneathPlayer);
                TakeDamage(fallOn, Player.Local.Position, attemptedDamage, Vector3.zero, "FallDamage", out actualDamage, out isDead);
                bool breakBone = false;
                if (actualDamage >= breakBoneThreshold)
                {
                    breakBone = true;
                }
                else if (actualDamage >= breakBoneThreshold)                    //TODO move these to globals
                {
                    if (Random.value < 0.1f)
                    {
                        breakBone = true;
                    }
                }

                if (breakBone)
                {
                    Player.Local.Status.AddCondition("BrokenBone");
                }
            }
        }