Exemplo n.º 1
0
 public static bool UseCampEquip(DaggerfallUnityItem item, ItemCollection collection)
 {
     if (CampDeployed)
     {
         DestroyCamp();
     }
     if (GameManager.Instance.PlayerEnterExit.IsPlayerInside && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon)
     {
         DaggerfallUI.MessageBox("You can not set up your tent indoors.");
         return(false);
     }
     else
     {
         item.LowerCondition(1, GameManager.Instance.PlayerEntity, collection);
         if (item.currentCondition > 0)
         {
             CampDmg = item.maxCondition - item.currentCondition;
             collection.RemoveItem(item);
             DeployTent();
             return(true);
         }
         else
         {
             DaggerfallUI.MessageBox("Your camping equipment broke.");
             return(false);
         }
     }
 }
Exemplo n.º 2
0
 private static void PackPopUp_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
 {
     if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.No)
     {
         sender.CloseWindow();
     }
     else
     {
         if (!GameManager.Instance.PlayerEnterExit.IsPlayerInside && GameManager.Instance.AreEnemiesNearby())
         {
             DaggerfallUI.MessageBox("There are enemies nearby.");
         }
         else
         {
             DaggerfallUnityItem CampEquip = ItemBuilder.CreateItem(ItemGroups.UselessItems2, ClimateCalories.templateIndex_CampEquip);
             CampEquip.LowerCondition(CampDmg, GameManager.Instance.PlayerEntity);
             DestroyCamp();
             GameManager.Instance.PlayerEntity.Items.AddItem(CampEquip);
             CampDeployed = false;
             FireLit      = false;
             TentMatrix   = new Matrix4x4();
             sender.CloseWindow();
         }
     }
 }
Exemplo n.º 3
0
        public static void DamageEquipmentCommand()
        {
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            for (int i = 0; i < playerEntity.Items.Count; i++)
            {
                DaggerfallUnityItem item = playerEntity.Items.GetItem(i);
                int percentReduce        = (int)Mathf.Ceil(item.maxCondition * 0.10f);
                item.LowerCondition(percentReduce);
            }
        }
Exemplo n.º 4
0
 protected virtual void ApplyDurabilityLoss(DaggerfallUnityItem item, DaggerfallEntityBehaviour entity)
 {
     if (!GameManager.Instance.EntityEffectBroker.SyntheticTimeIncrease)
     {
         int degradeRate = GameManager.Instance.PlayerEntity.IsResting ? restingMagicItemDegradeRate : normalMagicItemDegradeRate;
         if (GameManager.Instance.EntityEffectBroker.MagicRoundsSinceStartup % degradeRate == 0)
         {
             item.LowerCondition(1, entity.Entity, entity.Entity.Items);
             //UnityEngine.Debug.LogFormat("CastWhenHeld degraded '{0}' by 1 durability point. {1}/{2} remaining.", item.LongName, item.currentCondition, item.maxCondition);
         }
     }
 }
Exemplo n.º 5
0
 private static bool ApplyConditionDamageThroughPhysicalHit(DaggerfallUnityItem item, DaggerfallEntity owner, int damage)
 {
     if (item.ItemGroup == ItemGroups.Armor)
     {
         int amount = item.IsShield ? damage / 2 : damage;
         item.LowerCondition(amount, owner);
         if (owner == GameManager.Instance.PlayerEntity)
         {
             Debug.LogFormat("Damaged {0} by {1} from dmg {3}, cond={2}", item.ItemName, amount, item.currentCondition, damage);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
        /// Applies condition damage to an item based on physical hit damage.
        private static void ApplyConditionDamageThroughWeaponDamage(DaggerfallUnityItem item, DaggerfallEntity owner, int damage, bool bluntWep, bool shtbladeWep, bool missileWep, int wepEqualize) // Possibly add on so that magic damage also damages worn equipment.
        {
            //Debug.LogFormat("Item Group Index is {0}", item.GroupIndex);
            //Debug.LogFormat("Item Template Index is {0}", item.TemplateIndex);

            if (item.ItemGroup == ItemGroups.Armor)             // Target gets their armor/shield condition damaged.
            {
                int amount = item.IsShield ? damage * 2: damage * 4;
                item.LowerCondition(amount, owner);

                /*int percentChange = 100 * amount / item.maxCondition;
                 * if (owner == GameManager.Instance.PlayerEntity){
                 * Debug.LogFormat("Target Had {0} Damaged by {1}, cond={2}", item.LongName, amount, item.currentCondition);
                 *      Debug.LogFormat("Had {0} Damaged by {1}%, of Total Maximum. There Remains {2}% of Max Cond.", item.LongName, percentChange, item.ConditionPercentage);} // Percentage Change */
            }
            else             // Attacker gets their weapon damaged, if they are using one, otherwise this method is not called.
            {
                int amount = (10 * damage) / 50;
                if ((amount == 0) && Dice100.SuccessRoll(40))
                {
                    amount = 1;
                }

                if (missileWep)
                {
                    amount = SpecificWeaponConditionDamage(item, amount, wepEqualize);
                }

                item.LowerCondition(amount, owner);

                /*int percentChange = 100 * amount / item.maxCondition;
                 * if (owner == GameManager.Instance.PlayerEntity){
                 *      Debug.LogFormat("Attacker Damaged {0} by {1}, cond={2}", item.LongName, amount, item.currentCondition);
                 *      Debug.LogFormat("Had {0} Damaged by {1}%, of Total Maximum. There Remains {2}% of Max Cond.", item.LongName, percentChange, item.ConditionPercentage);} // Percentage Change */
            }
        }
Exemplo n.º 7
0
        /// Applies condition damage to an item based on physical hit damage. Specifically for unarmed attacks.
        private static void ApplyConditionDamageThroughUnarmedDamage(DaggerfallUnityItem item, DaggerfallEntity owner, int damage)
        {
            //Debug.LogFormat("Item Group Index is {0}", item.GroupIndex);
            //Debug.LogFormat("Item Template Index is {0}", item.TemplateIndex);

            if (item.ItemGroup == ItemGroups.Armor)             // Target gets their armor/shield condition damaged.
            {
                damage /= 100;
                int amount = item.IsShield ? damage: damage * 2;
                item.LowerCondition(amount, owner);

                /*int percentChange = 100 * amount / item.maxCondition;
                 * if (owner == GameManager.Instance.PlayerEntity){
                 * Debug.LogFormat("Target Had {0} Damaged by {1}, cond={2}", item.LongName, amount, item.currentCondition);
                 *      Debug.LogFormat("Had {0} Damaged by {1}%, of Total Maximum. There Remains {2}% of Max Cond.", item.LongName, percentChange, item.ConditionPercentage);} // Percentage Change */
            }
        }
Exemplo n.º 8
0
        protected virtual void InstantiateSpellBundle(EnchantmentParam param, DaggerfallEntityBehaviour sourceEntity, DaggerfallUnityItem sourceItem, EntityEffectManager casterManager, bool recast = false)
        {
            if (!string.IsNullOrEmpty(param.CustomParam))
            {
                // TODO: Instantiate a custom spell bundle
            }
            else
            {
                // Instantiate a classic spell bundle
                SpellRecord.SpellRecordData spell;
                if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(param.ClassicParam, out spell))
                {
                    UnityEngine.Debug.LogFormat("CastWhenHeld callback found enchantment '{0}'", spell.spellName);

                    // Create effect bundle settings from classic spell
                    EffectBundleSettings bundleSettings;
                    if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.HeldMagicItem, out bundleSettings))
                    {
                        // Assign bundle
                        EntityEffectBundle bundle = new EntityEffectBundle(bundleSettings, sourceEntity);
                        bundle.FromEquippedItem = sourceItem;
                        bundle.AddRuntimeFlags(BundleRuntimeFlags.ItemRecastEnabled);
                        casterManager.AssignBundle(bundle, AssignBundleFlags.BypassSavingThrows);

                        // Play cast sound on equip for player only
                        if (casterManager.IsPlayerEntity)
                        {
                            casterManager.PlayCastSound(sourceEntity, casterManager.GetCastSoundID(bundle.Settings.ElementType), true);
                        }

                        // Classic uses an item last "cast when held" effect spell cost to determine its durability loss on equip
                        // Here, all effects are considered, as it seems more coherent to do so
                        if (!recast)
                        {
                            int amount = FormulaHelper.CalculateCastingCost(spell, false);
                            sourceItem.LowerCondition(amount, sourceEntity.Entity, sourceEntity.Entity.Items);
                            //UnityEngine.Debug.LogFormat("CastWhenHeld degraded '{0}' by {1} durability points on equip. {2}/{3} remaining.", sourceItem.LongName, amount, sourceItem.currentCondition, sourceItem.maxCondition);
                        }
                    }

                    // Store equip time as last reroll time
                    sourceItem.timeEffectsLastRerolled = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
                }
            }
        }
Exemplo n.º 9
0
 private static bool UseTent(DaggerfallUnityItem item, ItemCollection collection)
 {
     if (GameManager.Instance.PlayerEnterExit.IsPlayerInside == true)
     {
         ShowMessageBox("You can not pitch your tent indoors.");
         return(false);
     }
     else if (TentDeployed == false)
     {
         item.LowerCondition(1, GameManager.Instance.PlayerEntity, collection);
         DeployTent();
         return(true);
     }
     else
     {
         ShowMessageBox("You have already pitched your tent.");
         return(false);
     }
 }