void SetWeapon(FPSWeapon target, DaggerfallUnityItem weapon) { // Must be a weapon if (weapon.ItemGroup != ItemGroups.Weapons) { return; } // Setup target target.WeaponType = DaggerfallUnity.Instance.ItemHelper.ConvertItemToAPIWeaponType(weapon); target.MetalType = DaggerfallUnity.Instance.ItemHelper.ConvertItemMaterialToAPIMetalType(weapon); target.DrawWeaponSound = weapon.GetEquipSound(); target.SwingWeaponSound = weapon.GetSwingSound(); // Adjust attributes by weapon type if (target.WeaponType == WeaponTypes.Bow) { target.Reach = 50f; target.Cooldown = 1.0f; } else { target.Reach = 2.5f; target.Cooldown = 0.0f; } // TODO: Adjust FPSWeapon attack speed scale for swing pitch variance }
void SetWeapon(FPSWeapon target, DaggerfallUnityItem weapon) { // Must be a weapon if (weapon.ItemGroup != ItemGroups.Weapons) { return; } // Setup target target.WeaponType = DaggerfallUnity.Instance.ItemHelper.ConvertItemToAPIWeaponType(weapon); target.MetalType = DaggerfallUnity.Instance.ItemHelper.ConvertItemMaterialToAPIMetalType(weapon); target.DrawWeaponSound = weapon.GetEquipSound(); target.SwingWeaponSound = weapon.GetSwingSound(); }
//beginning of outfit load routine. Will use saved outfit lists to equipped outfits to player. void loadCurrentOutfit() { //Debugging message. dfAudioSource.PlayOneShot(418, 1, .3f); Debug.Log("Outfit List Size:" + outfitDictSerialized.Count); //creates a local empty list for the dictionary to output too. ulong[] outfitListulong; //creates blank daggerfall item instance. Used for catching last equipped item below. DaggerfallUnityItem lastEquippedItem = new DaggerfallUnityItem(); //looks for selected dictionary value: if it finds it, populates outfitList for if then. //if can't find dictionary key, it outputs error. if (outfitDictSerialized.TryGetValue(index, out outfitListulong)) { //Debugging message. Debug.Log("Outfit List Size:" + outfitDictSerialized.Count); //for loop to unequipped all armor slots and update armoor values. foreach (DaggerfallUnityItem item in PlayerEntity.ItemEquipTable.EquipTable) { if (item != null) { PlayerEntity.ItemEquipTable.UnequipItem(item); PlayerEntity.UpdateEquippedArmorValues(item, false); //checks if item being unequipped is enchanted, if so, run PlayerEffectManager to properly remove any item enchanments. GameManager.Instance.PlayerEffectManager.DoItemEnchantmentPayloads(DaggerfallWorkshop.Game.MagicAndEffects.EnchantmentPayloadFlags.Unequipped, item, GameManager.Instance.PlayerEntity.Items); } } //uses the serialized item list and the players current inventory to equip saved outfit. PlayerEntity.ItemEquipTable.DeserializeEquipTable(outfitListulong, PlayerEntity.Items); //for loop to update all armor values for items deserialized and equipped above. foreach (DaggerfallUnityItem item in PlayerEntity.ItemEquipTable.EquipTable) { if (item != null) { PlayerEntity.UpdateEquippedArmorValues(item, true); lastEquippedItem = item; //checks if item being equipped is enchanted, if so, run PlayerEffectManager to properly activate any item enchanments. if (item.IsEnchanted) { GameManager.Instance.PlayerEffectManager.DoItemEnchantmentPayloads(DaggerfallWorkshop.Game.MagicAndEffects.EnchantmentPayloadFlags.Equipped, item, GameManager.Instance.PlayerEntity.Items); } } } //plays sound of last equipped item. Tells player the outfit bundled loaded through audio. DaggerfallUI.Instance.PlayOneShot(lastEquippedItem.GetEquipSound()); DaggerfallUI.Instance.DaggerfallHUD.Update(); } else { //error messsage Debug.Log("Coudn't Locate Outfit: Index value not found."); DisplayMessage("Couldn't find outfit bundle."); } //refreshes inventory window, which includes the paper doll. //Put outside if then to ensure UI always updates, even if bug happens. DaggerfallUI.Instance.InventoryWindow.Refresh(); DaggerfallUI.Instance.DaggerfallHUD.ActiveSpells.UpdateIcons(); }