public override void Update() { // Update HUD visibility popupText.Enabled = ShowPopupText; midScreenTextLabel.Enabled = ShowMidScreenText; crosshair.Enabled = ShowCrosshair; vitals.Enabled = ShowVitals; compass.Enabled = ShowCompass; interactionModeIcon.Enabled = ShowInteractionModeIcon; placeMarker.Enabled = ShowLocalQuestPlaces; escortingFaces.EnableBorder = ShowEscortingFaces; questDebugger.Enabled = !(questDebugger.State == HUDQuestDebugger.DisplayState.Nothing); activeSpells.Enabled = ShowActiveSpells; // Large HUD will force certain other HUD elements off as they conflict in space or utility bool largeHUDEnabled = false;//DaggerfallUnity.Settings.LargeHUD; if (largeHUDEnabled) { largeHUD.Enabled = true; vitals.Enabled = false; compass.Enabled = false; interactionModeIcon.Enabled = false; } else { largeHUD.Enabled = false; } // Scale HUD elements largeHUD.Scale = NativePanel.LocalScale * DaggerfallUnity.Settings.LargeHUDScale; compass.Scale = NativePanel.LocalScale; vitals.Scale = NativePanel.LocalScale; crosshair.CrosshairScale = CrosshairScale; interactionModeIcon.Scale = NativePanel.LocalScale; // Align compass to screen panel Rect screenRect = ParentPanel.Rectangle; float compassX = screenRect.width - (compass.Size.x); float compassY = screenRect.height - (compass.Size.y); compass.Position = new Vector2(compassX, compassY); // Update midscreen text timer and remove once complete if (midScreenTextTimer != -1) { midScreenTextTimer += Time.deltaTime; if (midScreenTextTimer > midScreenTextDelay) { midScreenTextTimer = -1; midScreenTextLabel.Text = string.Empty; } } // Update arrow count if player holding an unsheathed bow // TODO: Find a spot for arrow counter when large HUD enabled (remembering player could be in 320x200 retro mode) arrowCountTextLabel.Enabled = false; if (!largeHUDEnabled && ShowArrowCount && !GameManager.Instance.WeaponManager.Sheathed) { EquipSlots slot = DaggerfallUnity.Settings.BowLeftHandWithSwitching ? EquipSlots.LeftHand : EquipSlots.RightHand; DaggerfallUnityItem held = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(slot); if (held != null && held.ItemGroup == ItemGroups.Weapons && (held.TemplateIndex == (int)Weapons.Long_Bow || held.TemplateIndex == (int)Weapons.Short_Bow)) { // Arrow count label position is offset to left of compass and centred relative to compass height // This is done every frame to handle adaptive resolutions Vector2 arrowLabelPos = compass.Position; arrowLabelPos.x -= arrowCountTextLabel.TextWidth; arrowLabelPos.y += compass.Size.y / 2 - arrowCountTextLabel.TextHeight / 2; DaggerfallUnityItem arrows = GameManager.Instance.PlayerEntity.Items.GetItem(ItemGroups.Weapons, (int)Weapons.Arrow); arrowCountTextLabel.Text = (arrows != null) ? arrows.stackCount.ToString() : "0"; arrowCountTextLabel.TextScale = NativePanel.LocalScale.x; arrowCountTextLabel.Position = arrowLabelPos; arrowCountTextLabel.Enabled = true; } } HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers(); // Cycle quest debugger state if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerToggle).IsDownWith(keyModifiers)) { questDebugger.NextState(); } // Toggle HUD rendering if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.HUDToggle).IsDownWith(keyModifiers)) { renderHUD = !renderHUD; } flickerController.NextCycle(); // Don't display persistent HUD elements during initial startup // Prevents HUD elements being shown briefly at wrong size/scale at game start if (!startupComplete && !GameManager.Instance.IsPlayingGame()) { largeHUD.Enabled = false; vitals.Enabled = false; crosshair.Enabled = false; compass.Enabled = false; } else { startupComplete = true; } base.Update(); }
protected bool ItemPassesFilter(DaggerfallUnityItem item) { bool iterationPass = false; bool isRecipe = false; string recipeName = string.Empty; string str = string.Empty; str = GetSearchTags(item); if (String.IsNullOrEmpty(filterString)) { return(true); } if (item.LongName.ToLower().Contains("recipe")) { TextFile.Token[] tokens = ItemHelper.GetItemInfo(item, DaggerfallUnity.TextProvider); MacroHelper.ExpandMacros(ref tokens, item); recipeName = tokens[0].text; isRecipe = true; } foreach (string word in filterString.Split(' ')) { if (word.Trim().Length > 0) { if (word[0] == '-') { string wordLessFirstChar = word.Remove(0, 1); iterationPass = true; if (item.LongName.IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } else if (isRecipe && recipeName.IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } else if (itemGroupNames[(int)item.ItemGroup].IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } else if (str != null && str.IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } } else { iterationPass = false; if (item.LongName.IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } else if (isRecipe && recipeName.IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } else if (itemGroupNames[(int)item.ItemGroup].IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } else if (str != null && str.IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } } if (!iterationPass) { return(false); } } } return(true); }
protected virtual void IngredientsListScroller_OnItemClick(DaggerfallUnityItem item) { AddToCauldron(item); }
private void TakeItemFromRepair(DaggerfallUnityItem item) { TransferItem(item, remoteItems, localItems, usingWagon ? WagonCanHoldAmount(item) : CanCarryAmount(item)); item.RepairData.Collect(); // UpdateRepairTimes(false); }
void Update() { if (!dfUnity.IsReady || !playerEnterExit || !PlayerTorch || playerEntity == null || GameManager.IsGamePaused) { return; } bool enableTorch = false; if (DaggerfallUnity.Settings.PlayerTorchFromItems) { DaggerfallUnityItem lightSource = playerEntity.LightSource; if (lightSource != null) { enableTorch = true; torchLight.range = lightSource.ItemTemplate.capacityOrTarget; // Consume durability / fuel if (Time.realtimeSinceStartup > lastTickTime + tickTimeInterval) { lastTickTime = Time.realtimeSinceStartup; if (lightSource.currentCondition > 0) { lightSource.currentCondition--; } if (lightSource.currentCondition == 0 && DaggerfallUnityItem.CompareItems(playerEntity.LightSource, lightSource)) { DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("lightDies"), false, lightSource); enableTorch = false; playerEntity.LightSource = null; if (!lightSource.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Lantern)) { playerEntity.Items.RemoveItem(lightSource); } } } if (lightSource.currentCondition < 3) { // Give warning signs if running low of fuel intensityMod = 0.6f + (Mathf.Cos(guttering) * 0.2f); guttering += Random.Range(-0.02f, 0.06f); } else { intensityMod = 1; guttering = 0; } } } else { enableTorch = (!playerEnterExit.IsPlayerInside && dfUnity.WorldTime.Now.IsCityLightsOn) || playerEnterExit.IsPlayerInsideDungeon; } if (torchLight) { torchLight.intensity = torchIntensity * DaggerfallUnity.Settings.PlayerTorchLightScale * intensityMod; } PlayerTorch.SetActive(enableTorch); }
Texture2D[] BuyItemBackgroundAnimationHandler(DaggerfallUnityItem item) { return((basketItems.Contains(item) || remoteItems.Contains(item)) ? coinsAnimation.animatedTextures : null); }
private void UpdateRepairTimes(bool commit) { if (windowMode != WindowModes.Repair || DaggerfallUnity.Settings.InstantRepairs) { return; } Debug.Log("UpdateRepairTimes called"); int totalRepairTime = 0, longestRepairTime = 0; DaggerfallUnityItem itemLongestTime = null; Dictionary <DaggerfallUnityItem, int> previousRepairTimes = new Dictionary <DaggerfallUnityItem, int>(); foreach (DaggerfallUnityItem item in remoteItemsFiltered) { bool repairDone = item.RepairData.IsBeingRepaired() ? item.RepairData.IsRepairFinished() : item.currentCondition == item.maxCondition; if (repairDone) { continue; } if (item.RepairData.IsBeingRepaired()) { previousRepairTimes.Add(item, item.RepairData.RepairTime); } int repairTime = FormulaHelper.CalculateItemRepairTime(item.currentCondition, item.maxCondition); if (commit && !item.RepairData.IsBeingRepaired()) { item.RepairData.LeaveForRepair(repairTime); string note = string.Format(TextManager.Instance.GetText(textDatabase, "repairNote"), item.LongName, buildingDiscoveryData.displayName); GameManager.Instance.PlayerEntity.Notebook.AddNote(note); } totalRepairTime += repairTime; if (repairTime > longestRepairTime) { longestRepairTime = repairTime; itemLongestTime = item; } if (commit) { item.RepairData.RepairTime = repairTime; } else { item.RepairData.EstimatedRepairTime = repairTime; } } if (itemLongestTime != null) { int modifiedLongestTime = longestRepairTime + ((totalRepairTime - longestRepairTime) / 2); if (commit) { itemLongestTime.RepairData.RepairTime = modifiedLongestTime; } else { itemLongestTime.RepairData.EstimatedRepairTime = modifiedLongestTime; } } // Don't allow repair times to decrease (when removing other now repaired items) // https://forums.dfworkshop.net/viewtopic.php?f=24&t=2053 foreach (KeyValuePair <DaggerfallUnityItem, int> entry in previousRepairTimes) { if (commit) { entry.Key.RepairData.RepairTime = Mathf.Max(entry.Key.RepairData.RepairTime, entry.Value); } else { entry.Key.RepairData.EstimatedRepairTime = Mathf.Max(entry.Key.RepairData.EstimatedRepairTime, entry.Value); } } }
void Update() { // Automatically update weapons from inventory when PlayerEntity available if (playerEntity != null) { UpdateHands(); } else { playerEntity = GameManager.Instance.PlayerEntity; } // Reset variables if there isn't an attack ongoing if (!IsWeaponAttacking()) { // If an attack with a bow just finished, set cooldown if (ScreenWeapon.WeaponType == WeaponTypes.Bow && isAttacking) { float cooldown = 10 * (100 - playerEntity.Stats.LiveSpeed) + 800; cooldownTime = Time.time + (cooldown / 980); // Approximates classic frame update } isAttacking = false; isDamageFinished = false; isBowSoundFinished = false; } // Do nothing while weapon cooldown. Used for bow. if (Time.time < cooldownTime) { return; } // Do nothing if weapon isn't done equipping if ((usingRightHand && EquipCountdownRightHand != 0) || (!usingRightHand && EquipCountdownLeftHand != 0)) { ShowWeapons(false); return; } // Hide weapons and do nothing if spell is ready or cast animation in progress if (GameManager.Instance.PlayerEffectManager) { if (GameManager.Instance.PlayerEffectManager.HasReadySpell || GameManager.Instance.PlayerSpellCasting.IsPlayingAnim) { ShowWeapons(false); return; } } // Do nothing if player paralyzed if (GameManager.Instance.PlayerEntity.IsParalyzed) { ShowWeapons(false); return; } // Toggle weapon sheath if (!isAttacking && InputManager.Instance.ActionStarted(InputManager.Actions.ReadyWeapon)) { ToggleSheath(); } // Toggle weapon hand if (!isAttacking && InputManager.Instance.ActionComplete(InputManager.Actions.SwitchHand)) { ToggleHand(); } // Do nothing if weapons sheathed if (Sheathed) { ShowWeapons(false); return; } else { ShowWeapons(true); } // Get if bow is equipped bool bowEquipped = (ScreenWeapon && ScreenWeapon.WeaponType == WeaponTypes.Bow); // Handle beginning a new attack if (!isAttacking) { if (!DaggerfallUnity.Settings.ClickToAttack || bowEquipped) { // Reset tracking if user not holding down 'SwingWeapon' button and no attack in progress if (!InputManager.Instance.HasAction(InputManager.Actions.SwingWeapon)) { lastAttackHand = Hand.None; _gesture.Clear(); return; } } else { // Player must click to attack if (InputManager.Instance.ActionStarted(InputManager.Actions.SwingWeapon)) { isClickAttack = true; } else { _gesture.Clear(); return; } } } var attackDirection = MouseDirections.None; if (!isAttacking) { if (bowEquipped) { // Ensure attack button was released before starting the next attack if (lastAttackHand == Hand.None) { attackDirection = MouseDirections.Down; // Force attack without tracking a swing for Bow } } else if (isClickAttack) { attackDirection = (MouseDirections)UnityEngine.Random.Range((int)MouseDirections.Left, (int)MouseDirections.DownRight + 1); isClickAttack = false; } else { attackDirection = TrackMouseAttack(); // Track swing direction for other weapons } } // Start attack if one has been initiated if (attackDirection != MouseDirections.None) { ExecuteAttacks(attackDirection); isAttacking = true; } // Stop here if no attack is happening if (!isAttacking) { return; } if (!isBowSoundFinished && ScreenWeapon.WeaponType == WeaponTypes.Bow && ScreenWeapon.GetCurrentFrame() == 3) { ScreenWeapon.PlaySwingSound(); isBowSoundFinished = true; // Remove arrow ItemCollection playerItems = playerEntity.Items; DaggerfallUnityItem arrow = playerItems.GetItem(ItemGroups.Weapons, (int)Weapons.Arrow); if (arrow != null) { arrow.stackCount--; if (arrow.stackCount <= 0) { playerItems.RemoveItem(arrow); } } } else if (!isDamageFinished && ScreenWeapon.GetCurrentFrame() == ScreenWeapon.GetHitFrame()) { // The attack has reached the hit frame. // Attempt to transfer damage based on last attack hand. // Get attack hand weapon // Transfer damage. bool hitEnemy = false; WeaponDamage(ScreenWeapon, out hitEnemy); // Fatigue loss playerEntity.DecreaseFatigue(swingWeaponFatigueLoss); // Play swing sound if attack didn't hit an enemy. if (!hitEnemy && ScreenWeapon.WeaponType != WeaponTypes.Bow) { ScreenWeapon.PlaySwingSound(); } else { // Tally skills if (ScreenWeapon.WeaponType == WeaponTypes.Melee || ScreenWeapon.WeaponType == WeaponTypes.Werecreature) { playerEntity.TallySkill(DFCareer.Skills.HandToHand, 1); } else if (usingRightHand && (currentRightHandWeapon != null)) { playerEntity.TallySkill(currentRightHandWeapon.GetWeaponSkillID(), 1); } else if (currentLeftHandWeapon != null) { playerEntity.TallySkill(currentLeftHandWeapon.GetWeaponSkillID(), 1); } playerEntity.TallySkill(DFCareer.Skills.CriticalStrike, 1); } isDamageFinished = true; } }
private void WeaponDamage(FPSWeapon weapon, out bool hitEnemy) { hitEnemy = false; if (!mainCamera || !weapon) { return; } // Fire ray along player facing using weapon range RaycastHit hit; Ray ray = new Ray(mainCamera.transform.position, mainCamera.transform.forward); if (Physics.SphereCast(ray, SphereCastRadius, out hit, weapon.Reach - SphereCastRadius)) { // Check if hit has an DaggerfallAction component DaggerfallAction action = hit.transform.gameObject.GetComponent <DaggerfallAction>(); if (action) { action.Receive(player, DaggerfallAction.TriggerTypes.Attack); } // Check if hit has an DaggerfallActionDoor component DaggerfallActionDoor actionDoor = hit.transform.gameObject.GetComponent <DaggerfallActionDoor>(); if (actionDoor) { actionDoor.AttemptBash(); return; } // Check if hit an entity and remove health DaggerfallEntityBehaviour entityBehaviour = hit.transform.GetComponent <DaggerfallEntityBehaviour>(); DaggerfallMobileUnit entityMobileUnit = hit.transform.GetComponentInChildren <DaggerfallMobileUnit>(); if (entityBehaviour) { if (entityBehaviour.EntityType == EntityTypes.EnemyMonster || entityBehaviour.EntityType == EntityTypes.EnemyClass) { EnemyEntity enemyEntity = entityBehaviour.Entity as EnemyEntity; // Calculate damage int damage; if (usingRightHand) { damage = FormulaHelper.CalculateAttackDamage(playerEntity, enemyEntity, (int)(EquipSlots.RightHand), entityMobileUnit.Summary.AnimStateRecord); } else { damage = FormulaHelper.CalculateAttackDamage(playerEntity, enemyEntity, (int)(EquipSlots.LeftHand), entityMobileUnit.Summary.AnimStateRecord); } EnemyMotor enemyMotor = hit.transform.GetComponent <EnemyMotor>(); EnemySounds enemySounds = hit.transform.GetComponent <EnemySounds>(); // Play arrow sound and add arrow to target's inventory if (weapon.WeaponType == WeaponTypes.Bow) { enemySounds.PlayArrowSound(); DaggerfallUnityItem arrow = ItemBuilder.CreateItem(ItemGroups.Weapons, (int)Weapons.Arrow); enemyEntity.Items.AddItem(arrow); } // Play hit sound and trigger blood splash at hit point if (damage > 0) { if (usingRightHand) { enemySounds.PlayHitSound(currentRightHandWeapon); } else { enemySounds.PlayHitSound(currentLeftHandWeapon); } EnemyBlood blood = hit.transform.GetComponent <EnemyBlood>(); if (blood) { blood.ShowBloodSplash(enemyEntity.MobileEnemy.BloodIndex, hit.point); } // Knock back enemy based on damage and enemy weight if (enemyMotor) { if (enemyMotor.KnockBackSpeed <= (5 / (PlayerSpeedChanger.classicToUnitySpeedUnitRatio / 10)) && entityBehaviour.EntityType == EntityTypes.EnemyClass || enemyEntity.MobileEnemy.Weight > 0) { float enemyWeight = enemyEntity.GetWeightInClassicUnits(); float tenTimesDamage = damage * 10; float twoTimesDamage = damage * 2; float knockBackAmount = ((tenTimesDamage - enemyWeight) * 256) / (enemyWeight + tenTimesDamage) * twoTimesDamage; float knockBackSpeed = (tenTimesDamage / enemyWeight) * (twoTimesDamage - (knockBackAmount / 256)); knockBackSpeed /= (PlayerSpeedChanger.classicToUnitySpeedUnitRatio / 10); if (knockBackSpeed < (15 / (PlayerSpeedChanger.classicToUnitySpeedUnitRatio / 10))) { knockBackSpeed = (15 / (PlayerSpeedChanger.classicToUnitySpeedUnitRatio / 10)); } enemyMotor.KnockBackSpeed = knockBackSpeed; enemyMotor.KnockBackDirection = mainCamera.transform.forward; } } } else { if ((weapon.WeaponType != WeaponTypes.Bow && !enemyEntity.MobileEnemy.ParrySounds) || weapon.WeaponType == WeaponTypes.Melee) { weapon.PlaySwingSound(); } else if (enemyEntity.MobileEnemy.ParrySounds) { enemySounds.PlayParrySound(); } } // Remove health enemyEntity.DecreaseHealth(damage); hitEnemy = true; // Make foe attack their aggressor // Currently this is just player, but should be expanded later // for a wider variety of behaviours if (enemyMotor) { // Make enemies in an area aggressive if player attacked a non-hostile one. if (!enemyMotor.IsHostile) { GameManager.Instance.MakeEnemiesHostile(); } enemyMotor.MakeEnemyHostileToPlayer(gameObject); } } } // Check if hit a mobile NPC MobilePersonNPC mobileNpc = hit.transform.GetComponent <MobilePersonNPC>(); if (mobileNpc) { EnemyBlood blood = hit.transform.GetComponent <EnemyBlood>(); if (blood) { blood.ShowBloodSplash(0, hit.point); } mobileNpc.Motor.gameObject.SetActive(false); playerEntity.TallyCrimeGuildRequirements(false, 5); // TODO: LOS check from each townsperson. If seen, register crime and start spawning guards as below. playerEntity.CrimeCommitted = PlayerEntity.Crimes.Murder; playerEntity.SpawnCityGuards(true); } } }
private float GetBonusMultiplier(DaggerfallUnityItem item) { if (item.TemplateIndex == (int)Weapons.Staff) { if (item.NativeMaterialValue == 2) // Silver Staff { return(2.25f); } else if (item.NativeMaterialValue == 4) // Dwarven Staff { return(2.50f); } else if (item.NativeMaterialValue == 6) // Adamantium Staff { return(3.00f); } else // All Other Staves { return(1.75f); } } else if (item.TemplateIndex == (int)Weapons.Dagger) { if (item.NativeMaterialValue == 2) // Silver Dagger { return(1.50f); } else if (item.NativeMaterialValue == 4) // Dwarven Dagger { return(1.75f); } else if (item.NativeMaterialValue == 6) // Adamantium Dagger { return(2.00f); } else // All Other Daggers { return(1.25f); } } else if (item.NativeMaterialValue == 4) // Dwarven Item { return(1.25f); } else if (item.NativeMaterialValue == 2) // Silver Item { return(1.50f); } else if (item.NativeMaterialValue == 6) // Adamantium Item { return(1.75f); } else if (item.TemplateIndex == (int)Jewellery.Wand) { return(2.50f); } else if (item.TemplateIndex == (int)Jewellery.Amulet || TemplateIndex == (int)Jewellery.Torc) { return(1.50f); } else if (item.TemplateIndex == (int)Jewellery.Ring) { return(1.25f); } else if (item.TemplateIndex == (int)MensClothing.Plain_robes || TemplateIndex == (int)WomensClothing.Plain_robes) { return(2.00f); } else if (item.TemplateIndex == (int)MensClothing.Priest_robes || TemplateIndex == (int)WomensClothing.Priestess_robes) { return(1.25f); } return(1f); }
public override int GetRepairPercentage(int luckMod, DaggerfallUnityItem itemToRepair) { return(Random.Range(14 + luckMod, 26 + luckMod)); }
public override void Update() { // Update HUD visibility popupText.Enabled = ShowPopupText; midScreenTextLabel.Enabled = ShowMidScreenText; crosshair.Enabled = ShowCrosshair; if (GameManager.Instance.PlayerEntity.CurrentHealth == GameManager.Instance.PlayerEntity.MaxHealth && GameManager.Instance.PlayerEntity.CurrentMagicka == GameManager.Instance.PlayerEntity.MaxMagicka) { vitals.Enabled = false; } else { vitals.Enabled = ShowVitals; } breathBar.Enabled = ShowBreathBar; compass.Enabled = ShowCompass; interactionModeIcon.Enabled = ShowInteractionModeIcon; placeMarker.Enabled = ShowLocalQuestPlaces; escortingFaces.EnableBorder = ShowEscortingFaces; questDebugger.Enabled = !(questDebugger.State == HUDQuestDebugger.DisplayState.Nothing); activeSpells.Enabled = ShowActiveSpells; // Large HUD will force certain other HUD elements off as they conflict in space or utility bool largeHUDwasEnabled = largeHUD.Enabled; bool largeHUDEnabled = DaggerfallUnity.Settings.LargeHUD; if (largeHUDEnabled) { largeHUD.Enabled = true; vitals.Enabled = false; compass.Enabled = false; interactionModeIcon.Enabled = false; // Automatically scale to fit screen width or use custom scale largeHUD.AutoSize = (DaggerfallUnity.Settings.LargeHUDDocked) ? AutoSizeModes.ScaleToFit : AutoSizeModes.Scale; // Alignment when large HUD is undocked - 0=None/Default (centred), 1=Left, 2=Center, 3=Right if (!DaggerfallUnity.Settings.LargeHUDDocked) { largeHUD.HorizontalAlignment = (HorizontalAlignment)DaggerfallUnity.Settings.LargeHUDUndockedAlignment; if (largeHUD.HorizontalAlignment == HorizontalAlignment.None) { largeHUD.HorizontalAlignment = HorizontalAlignment.Center; } } } else { largeHUD.Enabled = false; } if (largeHUDEnabled != largeHUDwasEnabled) { RaiseOnLargeHUDToggleEvent(); } // Scale large HUD largeHUD.CustomScale = NativePanel.LocalScale; if (!DaggerfallUnity.Settings.LargeHUDDocked) { largeHUD.CustomScale *= DaggerfallUnity.Settings.LargeHUDUndockedScale; } // Scale HUD elements compass.Scale = NativePanel.LocalScale; vitals.Scale = new Vector2(NativePanel.LocalScale.x * DaggerfallUnity.Settings.DisplayHUDScaleAdjust, NativePanel.LocalScale.y * DaggerfallUnity.Settings.DisplayHUDScaleAdjust); breathBar.Scale = new Vector2(NativePanel.LocalScale.x * DaggerfallUnity.Settings.DisplayHUDScaleAdjust, NativePanel.LocalScale.y * DaggerfallUnity.Settings.DisplayHUDScaleAdjust); crosshair.CrosshairScale = CrosshairScale; interactionModeIcon.displayScaleAdjust = DaggerfallUnity.Settings.DisplayHUDScaleAdjust; // Align compass to screen panel Rect screenRect = ParentPanel.Rectangle; float compassX = screenRect.width - (compass.Size.x); float compassY = screenRect.height - (compass.Size.y); compass.Position = new Vector2(compassX, compassY); // Update midscreen text timer and remove once complete if (midScreenTextTimer != -1) { midScreenTextTimer += Time.deltaTime; if (midScreenTextTimer > midScreenTextDelay) { midScreenTextTimer = -1; midScreenTextLabel.Text = string.Empty; } } // Update arrow count if player holding an unsheathed bow // TODO: Find a spot for arrow counter when large HUD enabled (remembering player could be in 320x200 retro mode) arrowCountTextLabel.Enabled = false; if (!largeHUDEnabled && ShowArrowCount && !GameManager.Instance.WeaponManager.Sheathed) { EquipSlots slot = DaggerfallUnity.Settings.BowLeftHandWithSwitching ? EquipSlots.LeftHand : EquipSlots.RightHand; DaggerfallUnityItem held = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(slot); if (held != null && held.ItemGroup == ItemGroups.Weapons && (held.TemplateIndex == (int)Weapons.Long_Bow || held.TemplateIndex == (int)Weapons.Short_Bow)) { // Arrow count label position is offset to left of compass and centred relative to compass height // This is done every frame to handle adaptive resolutions Vector2 arrowLabelPos = compass.Position; arrowLabelPos.x -= arrowCountTextLabel.TextWidth; arrowLabelPos.y += compass.Size.y / 2 - arrowCountTextLabel.TextHeight / 2; DaggerfallUnityItem arrows = GameManager.Instance.PlayerEntity.Items.GetItem(ItemGroups.Weapons, (int)Weapons.Arrow, allowQuestItem: false, priorityToConjured: true); arrowCountTextLabel.Text = (arrows != null) ? arrows.stackCount.ToString() : "0"; arrowCountTextLabel.TextColor = (arrows != null && arrows.IsSummoned) ? conjuredArrowsColor : realArrowsColor; arrowCountTextLabel.TextScale = NativePanel.LocalScale.x; arrowCountTextLabel.Position = arrowLabelPos; arrowCountTextLabel.Enabled = true; } } HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers(); // Cycle quest debugger state if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerToggle).IsDownWith(keyModifiers)) { if (DaggerfallUnity.Settings.EnableQuestDebugger) { questDebugger.NextState(); } } if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.Pause).IsUpWith(keyModifiers)) { DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenPauseOptionsDialog); } // Toggle large HUD rendering if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.LargeHUDToggle).IsDownWith(keyModifiers)) { DaggerfallUnity.Settings.LargeHUD = !DaggerfallUnity.Settings.LargeHUD; } // Toggle HUD rendering if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.HUDToggle).IsDownWith(keyModifiers)) { renderHUD = !renderHUD; } // Toggle Retro Renderer Postprocessing if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.ToggleRetroPP).IsDownWith(keyModifiers)) { RetroRenderer retrorenderer = GameManager.Instance.RetroRenderer; if (retrorenderer) { retrorenderer.TogglePostprocessing(); } } flickerController.NextCycle(); // Don't display persistent HUD elements during initial startup // Prevents HUD elements being shown briefly at wrong size/scale at game start if (!startupComplete && !GameManager.Instance.IsPlayingGame()) { largeHUD.Enabled = false; vitals.Enabled = false; crosshair.Enabled = false; compass.Enabled = false; } else { startupComplete = true; } base.Update(); }
public void StockHouseContainer(PlayerGPS.DiscoveredBuilding buildingData) { stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now); items.Clear(); DFLocation.BuildingTypes buildingType = buildingData.buildingType; uint modelIndex = (uint)TextureRecord; int buildingQuality = buildingData.quality; byte[] privatePropertyList = null; DaggerfallUnityItem item = null; Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; if (buildingType < DFLocation.BuildingTypes.House5) { if (modelIndex >= 2) { if (modelIndex >= 4) { if (modelIndex >= 11) { if (modelIndex >= 15) { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels15AndUp[(int)buildingType]; } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels11to14[(int)buildingType]; } } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels4to10[(int)buildingType]; } } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels2to3[(int)buildingType]; } } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels0to1[(int)buildingType]; } if (privatePropertyList == null) { return; } int randomChoice = Random.Range(0, privatePropertyList.Length); ItemGroups itemGroup = (ItemGroups)privatePropertyList[randomChoice]; int continueChance = 100; bool keepGoing = true; while (keepGoing) { if (itemGroup != ItemGroups.MensClothing && itemGroup != ItemGroups.WomensClothing) { if (itemGroup == ItemGroups.MagicItems) { item = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race); } else if (itemGroup == ItemGroups.Books) { int groupIndex = (buildingQuality + 3) / 5; if (groupIndex == (int)ItemGroups.Books) { items.AddItem(ItemBuilder.CreateRandomBook()); } else { item = new DaggerfallUnityItem(itemGroup, groupIndex); } } else { if (itemGroup == ItemGroups.Weapons) { item = ItemBuilder.CreateRandomWeapon(playerEntity.Level); } else if (itemGroup == ItemGroups.Armor) { item = ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race); } else { System.Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(itemGroup); item = new DaggerfallUnityItem(itemGroup, Random.Range(0, enumArray.Length)); } } } else { item = ItemBuilder.CreateRandomClothing(playerEntity.Gender, playerEntity.Race); } continueChance >>= 1; if (DFRandom.rand() % 100 > continueChance) { keepGoing = false; } items.AddItem(item); } } }
public void StockShopShelf(PlayerGPS.DiscoveredBuilding buildingData) { stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now); items.Clear(); DFLocation.BuildingTypes buildingType = buildingData.buildingType; int shopQuality = buildingData.quality; Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; byte[] itemGroups = { 0 }; switch (buildingType) { case DFLocation.BuildingTypes.Alchemist: itemGroups = DaggerfallLootDataTables.itemGroupsAlchemist; RandomlyAddPotionRecipe(25, items); break; case DFLocation.BuildingTypes.Armorer: itemGroups = DaggerfallLootDataTables.itemGroupsArmorer; break; case DFLocation.BuildingTypes.Bookseller: itemGroups = DaggerfallLootDataTables.itemGroupsBookseller; break; case DFLocation.BuildingTypes.ClothingStore: itemGroups = DaggerfallLootDataTables.itemGroupsClothingStore; break; case DFLocation.BuildingTypes.GemStore: itemGroups = DaggerfallLootDataTables.itemGroupsGemStore; break; case DFLocation.BuildingTypes.GeneralStore: itemGroups = DaggerfallLootDataTables.itemGroupsGeneralStore; items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Horse)); items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Small_cart)); break; case DFLocation.BuildingTypes.PawnShop: itemGroups = DaggerfallLootDataTables.itemGroupsPawnShop; break; case DFLocation.BuildingTypes.WeaponSmith: itemGroups = DaggerfallLootDataTables.itemGroupsWeaponSmith; break; } for (int i = 0; i < itemGroups.Length; i += 2) { ItemGroups itemGroup = (ItemGroups)itemGroups[i]; int chanceMod = itemGroups[i + 1]; if (itemGroup == ItemGroups.MensClothing && playerEntity.Gender == Game.Entity.Genders.Female) { itemGroup = ItemGroups.WomensClothing; } if (itemGroup == ItemGroups.WomensClothing && playerEntity.Gender == Game.Entity.Genders.Male) { itemGroup = ItemGroups.MensClothing; } if (itemGroup != ItemGroups.Furniture && itemGroup != ItemGroups.UselessItems1) { if (itemGroup == ItemGroups.Books) { int qualityMod = (shopQuality + 3) / 5; if (qualityMod >= 4) { --qualityMod; } qualityMod++; for (int j = 0; j <= qualityMod; ++j) { items.AddItem(ItemBuilder.CreateRandomBook()); } } else { System.Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(itemGroup); for (int j = 0; j < enumArray.Length; ++j) { DaggerfallConnect.FallExe.ItemTemplate itemTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(itemGroup, j); if (itemTemplate.rarity <= shopQuality) { int stockChance = chanceMod * 5 * (21 - itemTemplate.rarity) / 100; if (Dice100.SuccessRoll(stockChance)) { DaggerfallUnityItem item = null; if (itemGroup == ItemGroups.Weapons) { item = ItemBuilder.CreateWeapon(j + Weapons.Dagger, ItemBuilder.RandomMaterial(playerEntity.Level)); } else if (itemGroup == ItemGroups.Armor) { item = ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, j + Armor.Cuirass, ItemBuilder.RandomArmorMaterial(playerEntity.Level)); } else if (itemGroup == ItemGroups.MensClothing) { item = ItemBuilder.CreateMensClothing(j + MensClothing.Straps, playerEntity.Race); item.dyeColor = ItemBuilder.RandomClothingDye(); } else if (itemGroup == ItemGroups.WomensClothing) { item = ItemBuilder.CreateWomensClothing(j + WomensClothing.Brassier, playerEntity.Race); item.dyeColor = ItemBuilder.RandomClothingDye(); } else { item = new DaggerfallUnityItem(itemGroup, j); if (DaggerfallUnity.Settings.PlayerTorchFromItems && item.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Oil)) { item.stackCount = Random.Range(5, 20 + 1); // Shops stock 5-20 bottles } } items.AddItem(item); } } } } } } }
private void EnchantButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { const int notEnoughGold = 1650; const int notEnoughEnchantmentPower = 1651; const int itemEnchanted = 1652; const int itemMustBeSelected = 1653; DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick); // Must have an item selected or display "An item must be selected to be enchanted." if (selectedItem == null) { DaggerfallUI.MessageBox(itemMustBeSelected); return; } // Must have enchantments to apply or display "You have not prepared enchantments for this item." if (powersList.EnchantmentCount == 0 && sideEffectsList.EnchantmentCount == 0) { DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "noEnchantments")); return; } // Get costs int totalEnchantmentCost = GetTotalEnchantmentCost(); int totalGoldCost = GetTotalGoldCost(); int itemEnchantmentPower = FormulaHelper.GetItemEnchantmentPower(selectedItem); // Check for available gold and display "You do not have the gold to properly pay the enchanter." if not enough int playerGold = GameManager.Instance.PlayerEntity.GetGoldAmount(); if (playerGold < totalGoldCost) { DaggerfallUI.MessageBox(notEnoughGold); return; } // Check for enchantment power and display "You cannot enchant this item beyond its limit." if not enough if (itemEnchantmentPower < totalEnchantmentCost) { DaggerfallUI.MessageBox(notEnoughEnchantmentPower); return; } // Deduct gold from player and display "The item has been enchanted." GameManager.Instance.PlayerEntity.DeductGoldAmount(totalGoldCost); DaggerfallUI.MessageBox(itemEnchanted); // Only enchant one item from stack if (selectedItem.IsAStack()) { selectedItem = GameManager.Instance.PlayerEntity.Items.SplitStack(selectedItem, 1); } // Transfer enchantment settings onto item List <EnchantmentSettings> combinedEnchantments = new List <EnchantmentSettings>(); combinedEnchantments.AddRange(powersList.GetEnchantments()); combinedEnchantments.AddRange(sideEffectsList.GetEnchantments()); selectedItem.SetEnchantments(combinedEnchantments.ToArray(), GameManager.Instance.PlayerEntity); selectedItem.RenameItem(itemNameLabel.Text); // Play enchantment sound effect DaggerfallUI.Instance.PlayOneShot(SoundClips.MakeItem); // Clear selected item and enchantments selectedItem = null; powersList.ClearEnchantments(); sideEffectsList.ClearEnchantments(); Refresh(); }
public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0) { base.EnchantmentPayloadCallback(context, param, sourceEntity, targetEntity, sourceItem, sourceDamage); // Must be Used payload if (context != EnchantmentPayloadFlags.Used) { return(null); } // Must have nearby non-allied enemies List <PlayerGPS.NearbyObject> nearby = GameManager.Instance.PlayerGPS.GetNearbyObjects(PlayerGPS.NearbyObjectFlags.Enemy, enemyRange) .Where(x => ((EnemyEntity)x.gameObject.GetComponent <DaggerfallEntityBehaviour>().Entity).Team != MobileTeams.PlayerAlly).ToList(); MobileTypes nearestType; if (nearby.Count == 0) { ShowSummonFailMessage(); return(null); } else { // Use nearest enemy for cloning PlayerGPS.NearbyObject nearest = nearby[0]; foreach (PlayerGPS.NearbyObject nearbyObject in nearby.Skip(1)) { if (nearbyObject.distance < nearest.distance) { nearest = nearbyObject; } } EnemyEntity enemy = (EnemyEntity)nearest.gameObject.GetComponent <DaggerfallEntityBehaviour>().Entity; if (enemy.Team == MobileTeams.PlayerAlly) { ShowSummonFailMessage(); return(null); } nearestType = (MobileTypes)enemy.MobileEnemy.ID; } // Spawn clone GameObjectHelper.CreateFoeSpawner(foeType: nearestType, spawnCount: 1, alliedToPlayer: true); // Durability loss for this effect return(new PayloadCallbackResults() { durabilityLoss = 100, }); }
private void ConfirmTrade_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { bool receivedLetterOfCredit = false; if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { // Proceed with trade. int tradePrice = GetTradePrice(); switch (windowMode) { case WindowModes.Sell: case WindowModes.SellMagic: float goldWeight = tradePrice * DaggerfallBankManager.goldUnitWeightInKg; if (PlayerEntity.CarriedWeight + goldWeight <= PlayerEntity.MaxEncumbrance) { PlayerEntity.GoldPieces += tradePrice; } else { DaggerfallUnityItem loc = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Letter_of_credit); loc.value = tradePrice; GameManager.Instance.PlayerEntity.Items.AddItem(loc, Items.ItemCollection.AddPosition.Front); receivedLetterOfCredit = true; } RaiseOnTradeHandler(remoteItems.GetNumItems(), tradePrice); remoteItems.Clear(); break; case WindowModes.Buy: PlayerEntity.DeductGoldAmount(tradePrice); RaiseOnTradeHandler(basketItems.GetNumItems(), tradePrice); PlayerEntity.Items.TransferAll(basketItems); break; case WindowModes.Repair: PlayerEntity.DeductGoldAmount(tradePrice); if (DaggerfallUnity.Settings.InstantRepairs) { foreach (DaggerfallUnityItem item in remoteItemsFiltered) { item.currentCondition = item.maxCondition; } } else { UpdateRepairTimes(true); } RaiseOnTradeHandler(remoteItems.GetNumItems(), tradePrice); break; case WindowModes.Identify: PlayerEntity.DeductGoldAmount(tradePrice); for (int i = 0; i < remoteItems.Count; i++) { DaggerfallUnityItem item = remoteItems.GetItem(i); item.IdentifyItem(); } RaiseOnTradeHandler(remoteItems.GetNumItems(), tradePrice); break; } if (receivedLetterOfCredit) { DaggerfallUI.Instance.PlayOneShot(SoundClips.ParchmentScratching); } else { DaggerfallUI.Instance.PlayOneShot(SoundClips.GoldPieces); } PlayerEntity.TallySkill(DFCareer.Skills.Mercantile, 1); Refresh(); } CloseWindow(); if (receivedLetterOfCredit) { DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "letterOfCredit")); } }
public override void SetResource(string line) { base.SetResource(line); string declMatchStr = @"(Item|item) (?<symbol>[a-zA-Z0-9_.-]+) (?<artifact>artifact) (?<itemName>[a-zA-Z0-9_.-]+)|(Item|item) (?<symbol>[a-zA-Z0-9_.-]+) (?<itemName>[a-zA-Z0-9_.-]+)"; string optionsMatchStr = @"range (?<rangeLow>\d+) to (?<rangeHigh>\d+)|" + @"item class (?<itemClass>\d+) subclass (?<itemSubClass>\d+)"; // Try to match source line with pattern string itemName = string.Empty; int itemClass = -1; int itemSubClass = -1; bool isGold = false; int rangeLow = -1; int rangeHigh = -1; Match match = Regex.Match(line, declMatchStr); if (match.Success) { // Store symbol for quest system Symbol = new Symbol(match.Groups["symbol"].Value); // Item or artifact name itemName = match.Groups["itemName"].Value; // Artifact status if (!string.IsNullOrEmpty(match.Groups["artifact"].Value)) { artifact = true; } // Set gold - this is not in the lookup table if (itemName == "gold") { isGold = true; } // Split options from declaration string optionsLine = line.Substring(match.Length); // Match all options MatchCollection options = Regex.Matches(optionsLine, optionsMatchStr); foreach (Match option in options) { // Range low value Group rangeLowGroup = option.Groups["rangeLow"]; if (rangeLowGroup.Success) { rangeLow = Parser.ParseInt(rangeLowGroup.Value); } // Range high value Group rangeHighGroup = option.Groups["rangeHigh"]; if (rangeHighGroup.Success) { rangeHigh = Parser.ParseInt(rangeHighGroup.Value); } // Item class value Group itemClassGroup = option.Groups["itemClass"]; if (itemClassGroup.Success) { itemClass = Parser.ParseInt(itemClassGroup.Value); } // Item subclass value Group itemSubClassGroup = option.Groups["itemSubClass"]; if (itemClassGroup.Success) { itemSubClass = Parser.ParseInt(itemSubClassGroup.Value); } } // Create item if (!string.IsNullOrEmpty(itemName) && !isGold) { item = CreateItem(itemName); // Create by name of item in lookup table } else if (itemClass != -1 && !isGold) { item = CreateItem(itemClass, itemSubClass); // Create item by class and subclass (a.k.a ItemGroup and GroupIndex) } else if (isGold) { item = CreateGold(rangeLow, rangeHigh); // Create gold pieces of amount by level or range values } else { throw new Exception(string.Format("Could not create Item from line {0}", line)); } // add conversation topics from anyInfo command tag AddConversationTopics(); } }
private void UpdateCostAndGold() { bool modeActionEnabled = false; cost = 0; if (windowMode == WindowModes.Buy && basketItems != null) { // Check holidays for half price sales: // - Merchants Festival, suns height 10th for normal shops // - Tales and Tallows hearth fire 3rd for mages guild // - Weapons on Warriors Festival suns dusk 20th uint minutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); int holidayId = FormulaHelper.GetHolidayId(minutes, GameManager.Instance.PlayerGPS.CurrentRegionIndex); for (int i = 0; i < basketItems.Count; i++) { DaggerfallUnityItem item = basketItems.GetItem(i); modeActionEnabled = true; int itemPrice = FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount; if ((holidayId == (int)DFLocation.Holidays.Merchants_Festival && guild == null) || (holidayId == (int)DFLocation.Holidays.Tales_and_Tallow && guild != null && guild.GetFactionId() == (int)FactionFile.FactionIDs.The_Mages_Guild) || (holidayId == (int)DFLocation.Holidays.Warriors_Festival && guild == null && item.ItemGroup == ItemGroups.Weapons)) { itemPrice /= 2; } cost += itemPrice; } } else if (remoteItems != null) { for (int i = 0; i < remoteItems.Count; i++) { DaggerfallUnityItem item = remoteItems.GetItem(i); switch (windowMode) { case WindowModes.Sell: modeActionEnabled = true; cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount; break; case WindowModes.SellMagic: // TODO: Fencing base price higher and guild rep affects it. Implement new formula or can this be used? modeActionEnabled = true; cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality); break; case WindowModes.Repair: if (!item.RepairData.IsBeingRepaired()) { modeActionEnabled = true; cost += FormulaHelper.CalculateItemRepairCost(item.value, buildingDiscoveryData.quality, item.currentCondition, item.maxCondition, guild) * item.stackCount; } break; case WindowModes.Identify: if (!item.IsIdentified) { modeActionEnabled = true; // Identify spell remains free if (!usingIdentifySpell) { cost += FormulaHelper.CalculateItemIdentifyCost(item.value, guild); } } break; } } } costLabel.Text = cost.ToString(); goldLabel.Text = PlayerEntity.GetGoldAmount().ToString(); modeActionButton.Enabled = modeActionEnabled; }
static int Armor(int natTemp) { DaggerfallUnityItem rArm = playerEntity.ItemEquipTable.GetItem(EquipSlots.RightArm); DaggerfallUnityItem lArm = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftArm); DaggerfallUnityItem chest = playerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor); DaggerfallUnityItem legs = playerEntity.ItemEquipTable.GetItem(EquipSlots.LegsArmor); DaggerfallUnityItem head = playerEntity.ItemEquipTable.GetItem(EquipSlots.Head); int temp = 0; int metal = 0; if (chest != null) { switch (chest.NativeMaterialValue & 0xF00) { case (int)ArmorMaterialTypes.Leather: temp += 1; break; case (int)ArmorMaterialTypes.Chain: temp += 1; metal += 1; break; default: temp += 3; metal += 4; break; } } if (legs != null) { switch (legs.NativeMaterialValue & 0xF00) { case (int)ArmorMaterialTypes.Leather: temp += 1; break; case (int)ArmorMaterialTypes.Chain: temp += 1; metal += 1; break; default: temp += 2; metal += 3; break; } } if (lArm != null) { switch (lArm.NativeMaterialValue & 0xF00) { case (int)ArmorMaterialTypes.Leather: temp += 1; break; case (int)ArmorMaterialTypes.Chain: temp += 1; break; default: temp += 1; metal += 1; break; } } if (rArm != null) { switch (rArm.NativeMaterialValue & 0xF00) { case (int)ArmorMaterialTypes.Leather: temp += 1; break; case (int)ArmorMaterialTypes.Chain: temp += 1; break; default: temp += 1; metal += 1; break; } } if (head != null) { switch (head.NativeMaterialValue & 0xF00) { case (int)ArmorMaterialTypes.Leather: temp += 2; break; case (int)ArmorMaterialTypes.Chain: temp += 2; metal += 1; break; default: temp += 1; metal += 1; break; } } int metalTemp = (metal * natTemp) / 20; if (metalTemp > 0 && playerEnterExit.IsPlayerInSunlight && !ArmorCovered()) { temp += metalTemp; if (ClimateCalories.txtCount > ClimateCalories.txtIntervals && metalTemp > 5) { DaggerfallUI.AddHUDText("Your armor is starting to heat up."); } } else if (metalTemp < 0) { temp += (metalTemp + 1) / 2; if (ClimateCalories.txtCount > ClimateCalories.txtIntervals && temp < 0) { DaggerfallUI.AddHUDText("Your armor is getting cold."); } } if (temp > 0) { temp = Mathf.Max(temp - ClimateCalories.wetCount, 0); } return(temp); }
protected override void LocalItemListScroller_OnItemClick(DaggerfallUnityItem item) { // Handle click based on action & mode if (selectedActionMode == ActionModes.Select) { switch (windowMode) { case WindowModes.Sell: case WindowModes.SellMagic: if (remoteItems != null) { // Are we trying to sell the non empty wagon? if (item.ItemGroup == ItemGroups.Transportation && PlayerEntity.WagonItems.Count > 0) { DaggerfallUnityItem usedWagon = PlayerEntity.Items.GetItem(ItemGroups.Transportation, (int)Transportation.Small_cart); if (usedWagon.Equals(item)) { return; } } TransferItem(item, localItems, remoteItems); } break; case WindowModes.Buy: if (usingWagon) // Allows player to get & equip stuff from cart while purchasing. { TransferItem(item, localItems, PlayerEntity.Items, CanCarryAmount(item), equip: !item.IsAStack()); } else // Allows player to equip and unequip while purchasing. { EquipItem(item); } break; case WindowModes.Repair: // Check that item can be repaired, is damaged & transfer if so. if (item.IsEnchanted) { DaggerfallUI.MessageBox(magicItemsCannotBeRepairedTextId); } else if ((item.currentCondition < item.maxCondition) && item.TemplateIndex != (int)Weapons.Arrow) { TransferItem(item, localItems, remoteItems); // UpdateRepairTimes(false); } else { DaggerfallUI.MessageBox(doesNotNeedToBeRepairedTextId); } break; case WindowModes.Identify: // Check if item is unidentified & transfer if (!item.IsIdentified) { TransferItem(item, localItems, remoteItems); } else { DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "doesntNeedIdentify")); } break; } } else if (selectedActionMode == ActionModes.Info) { ShowInfoPopup(item); } }
static int Clothes(int natTemp) { DaggerfallUnityItem chestCloth = playerEntity.ItemEquipTable.GetItem(EquipSlots.ChestClothes); DaggerfallUnityItem feetCloth = playerEntity.ItemEquipTable.GetItem(EquipSlots.Feet); DaggerfallUnityItem legsCloth = playerEntity.ItemEquipTable.GetItem(EquipSlots.LegsClothes); DaggerfallUnityItem cloak1 = playerEntity.ItemEquipTable.GetItem(EquipSlots.Cloak1); DaggerfallUnityItem cloak2 = playerEntity.ItemEquipTable.GetItem(EquipSlots.Cloak2); int chest = 0; int feet = 0; int legs = 0; int cloak = 0; int temp = 0; if (chestCloth != null) { switch (chestCloth.TemplateIndex) { case (int)MensClothing.Straps: case (int)MensClothing.Armbands: case (int)MensClothing.Fancy_Armbands: case (int)MensClothing.Champion_straps: case (int)MensClothing.Sash: case (int)MensClothing.Challenger_Straps: case (int)MensClothing.Eodoric: case (int)MensClothing.Vest: case (int)WomensClothing.Brassier: case (int)WomensClothing.Formal_brassier: case (int)WomensClothing.Eodoric: case (int)WomensClothing.Formal_eodoric: case (int)WomensClothing.Vest: chest = 1; break; case (int)MensClothing.Short_shirt: case (int)MensClothing.Short_shirt_with_belt: case (int)WomensClothing.Short_shirt: case (int)WomensClothing.Short_shirt_belt: chest = 5; break; case (int)MensClothing.Short_tunic: case (int)MensClothing.Toga: case (int)MensClothing.Short_shirt_closed_top: case (int)MensClothing.Short_shirt_closed_top2: case (int)MensClothing.Short_shirt_unchangeable: case (int)MensClothing.Long_shirt: case (int)MensClothing.Long_shirt_with_belt: case (int)MensClothing.Long_shirt_unchangeable: case (int)WomensClothing.Short_shirt_closed: case (int)WomensClothing.Short_shirt_closed_belt: case (int)WomensClothing.Short_shirt_unchangeable: case (int)WomensClothing.Long_shirt: case (int)WomensClothing.Long_shirt_belt: case (int)WomensClothing.Long_shirt_unchangeable: case (int)WomensClothing.Peasant_blouse: case (int)WomensClothing.Strapless_dress: chest = 8; break; case (int)MensClothing.Open_Tunic: case (int)MensClothing.Long_shirt_closed_top: case (int)MensClothing.Long_shirt_closed_top2: case (int)MensClothing.Kimono: case (int)WomensClothing.Evening_gown: case (int)WomensClothing.Casual_dress: case (int)WomensClothing.Long_shirt_closed: case (int)WomensClothing.Open_tunic: chest = 10; break; case (int)MensClothing.Priest_robes: case (int)MensClothing.Anticlere_Surcoat: case (int)MensClothing.Formal_tunic: case (int)MensClothing.Reversible_tunic: case (int)MensClothing.Dwynnen_surcoat: case (int)MensClothing.Plain_robes: case (int)WomensClothing.Priestess_robes: case (int)WomensClothing.Plain_robes: case (int)WomensClothing.Long_shirt_closed_belt: case (int)WomensClothing.Day_gown: chest = 15; break; } } if (feetCloth != null) { switch (feetCloth.TemplateIndex) { case (int)MensClothing.Sandals: case (int)WomensClothing.Sandals: feet = 0; break; case (int)MensClothing.Shoes: case (int)WomensClothing.Shoes: feet = 2; break; case (int)MensClothing.Tall_Boots: case (int)WomensClothing.Tall_boots: feet = 4; break; case (int)MensClothing.Boots: case (int)WomensClothing.Boots: if (feetCloth.CurrentVariant == 0) { feet = 5; } else { feet = 0; } break; default: feet = 5; break; } } if (legsCloth != null) { switch (legsCloth.TemplateIndex) { case (int)MensClothing.Loincloth: case (int)WomensClothing.Loincloth: legs = 1; break; case (int)MensClothing.Khajiit_suit: case (int)WomensClothing.Khajiit_suit: legs = 2; break; case (int)MensClothing.Wrap: case (int)MensClothing.Short_skirt: case (int)WomensClothing.Tights: case (int)WomensClothing.Wrap: legs = 4; break; case (int)MensClothing.Long_Skirt: case (int)WomensClothing.Long_skirt: legs = 8; break; case (int)MensClothing.Casual_pants: case (int)MensClothing.Breeches: case (int)WomensClothing.Casual_pants: legs = 10; break; } } if (cloak1 != null) { int cloak1int = 0; switch (cloak1.CurrentVariant) { case 0: //closed, hood down cloak1int = 4; break; case 1: //closed, hood up cloak1int = 5; break; case 2: //one shoulder, hood up cloak1int = 3; break; case 3: //one shoulder, hood down cloak1int = 2; break; case 4: //open, hood down cloak1int = 1; break; case 5: //open, hood up cloak1int = 2; break; } switch (cloak1.TemplateIndex) { case (int)MensClothing.Casual_cloak: case (int)WomensClothing.Casual_cloak: cloak += cloak1int; break; case (int)MensClothing.Formal_cloak: case (int)WomensClothing.Formal_cloak: cloak += (cloak1int * 3); break; } } if (cloak2 != null) { int cloak2int = 0; switch (cloak2.CurrentVariant) { case 0: //closed, hood down cloak2int = 4; break; case 1: //closed, hood up cloak2int = 5; break; case 2: //one shoulder, hood up cloak2int = 3; break; case 3: //one shoulder, hood down cloak2int = 2; break; case 4: //open, hood down cloak2int = 1; break; case 5: //open, hood up cloak2int = 2; break; } switch (cloak2.TemplateIndex) { case (int)MensClothing.Casual_cloak: case (int)WomensClothing.Casual_cloak: cloak += cloak2int; break; case (int)MensClothing.Formal_cloak: case (int)WomensClothing.Formal_cloak: cloak += (cloak2int * 3); break; } } pureClothTemp = chest + feet + legs + cloak; temp = Mathf.Max(pureClothTemp - ClimateCalories.wetCount, 0); if (natTemp > 30 && playerEnterExit.IsPlayerInSunlight && hood) { temp -= 10; } return(temp); }
// Blits a normal item void BlitItem(DaggerfallUnityItem item) { ImageData source = DaggerfallUnity.Instance.ItemHelper.GetItemImage(item, true, true); DrawTexture(source, item); }
static bool HoodUp() { DaggerfallUnityItem cloak1 = playerEntity.ItemEquipTable.GetItem(EquipSlots.Cloak1); DaggerfallUnityItem cloak2 = playerEntity.ItemEquipTable.GetItem(EquipSlots.Cloak2); DaggerfallUnityItem chestCloth = playerEntity.ItemEquipTable.GetItem(EquipSlots.ChestClothes); bool up = false; if (cloak1 != null) { switch (cloak1.CurrentVariant) { case 0: case 3: case 4: up = false; break; case 1: case 2: case 5: up = true; break; } } if (cloak2 != null && !up) { switch (cloak2.CurrentVariant) { case 0: case 3: case 4: up = false; break; case 1: case 2: case 5: up = true; break; } } if (chestCloth != null && !up) { switch (chestCloth.TemplateIndex) { case (int)MensClothing.Plain_robes: case (int)WomensClothing.Plain_robes: switch (chestCloth.CurrentVariant) { case 0: up = false; break; case 1: up = true; break; } break; } } return(up); }
protected string GetSearchTags(DaggerfallUnityItem item) { var equipSlot = GameManager.Instance.PlayerEntity.ItemEquipTable.GetEquipSlot(item); switch (equipSlot) { case EquipSlots.None: return(string.Empty); case EquipSlots.Amulet0: case EquipSlots.Amulet1: return(Amulet); case EquipSlots.Bracelet0: case EquipSlots.Bracelet1: return(Bracelet); case EquipSlots.Bracer0: case EquipSlots.Bracer1: return(Bracer); case EquipSlots.Ring0: case EquipSlots.Ring1: return(Ring); case EquipSlots.Mark0: case EquipSlots.Mark1: return(Mark); case EquipSlots.Crystal0: case EquipSlots.Crystal1: return(Crystal); case EquipSlots.Head: return(Head); case EquipSlots.RightArm: return(RightArm); case EquipSlots.LeftArm: return(LeftArm); case EquipSlots.Cloak1: case EquipSlots.Cloak2: return(Cloak); case EquipSlots.ChestClothes: return(ChestClothes); case EquipSlots.ChestArmor: return(ChestArmor); case EquipSlots.RightHand: case EquipSlots.Gloves: return(RightHand); case EquipSlots.LeftHand: return(LeftHand); case EquipSlots.LegsArmor: return(LegsArmor); case EquipSlots.LegsClothes: return(LegsClothes); case EquipSlots.Feet: return(Feet); default: return(string.Empty); } }
void UpdateItemsDisplay(bool delayScrollUp) { // Clear list elements ClearItemsList(); if (items == null) { return; } int scrollIndex = 0; if (scroller) { // Update scrollbar int rows = (items.Count + listWidth - 1) / listWidth; itemListScrollBar.TotalUnits = rows; scrollIndex = GetSafeScrollIndex(itemListScrollBar, delayScrollUp); // Update scroller buttons UpdateListScrollerButtons(scrollIndex, rows); // Convert scroller index to item based scroll index scrollIndex *= listWidth; } // Update images and tooltips for (int i = 0; i < listDisplayTotal; i++) { // Skip if out of bounds if (scrollIndex + i >= items.Count) { continue; } // Get item and image DaggerfallUnityItem item = items[scrollIndex + i]; ImageData image = DaggerfallUnity.Instance.ItemHelper.GetInventoryImage(item); // Set animated image frames to button icon (if any) if (image.animatedTextures != null && image.animatedTextures.Length > 0) { itemIconPanels[i].AnimatedBackgroundTextures = image.animatedTextures; } // Set image to button icon itemIconPanels[i].BackgroundTexture = image.texture; // Use texture size if base image size is zero (i.e. new images that are not present in classic data) if (image.width != 0 && image.height != 0) { itemIconPanels[i].Size = new Vector2(image.width, image.height); } else { itemIconPanels[i].Size = new Vector2(image.texture.width, image.texture.height); } // Set stack count if (item.stackCount > 1) { itemStackLabels[i].Text = item.stackCount.ToString(); } // Handle context specific background colour, animations & label if (backgroundColourHandler != null) { itemButtons[i].BackgroundColor = backgroundColourHandler(item); } if (backgroundAnimationHandler != null) { itemButtons[i].AnimationDelayInSeconds = backgroundAnimationDelay; itemButtons[i].AnimatedBackgroundTextures = backgroundAnimationHandler(item); } if (foregroundAnimationHandler != null) { itemAnimPanels[i].AnimationDelayInSeconds = foregroundAnimationDelay; itemAnimPanels[i].AnimatedBackgroundTextures = foregroundAnimationHandler(item); } if (labelTextHandler != null) { itemMiscLabels[i].Text = labelTextHandler(item); } // Tooltip text itemButtons[i].ToolTipText = (item.ItemGroup == ItemGroups.Books && !item.IsArtifact) ? DaggerfallUnity.Instance.ItemHelper.GetBookTitle(item.message, item.LongName) : item.LongName; } }
string ItemLabelTextHandler(DaggerfallUnityItem item) { return(item.ItemName.ToUpper()); }
bool IsEnchantableIngredient(DaggerfallUnityItem item) { // Gem ingredients like amber/jade/ruby are listed under ingredients return(item.IsIngredient && item.ItemGroup == ItemGroups.Gems); }
protected virtual void CauldronListScroller_OnItemClick(DaggerfallUnityItem item) { RemoveFromCauldron(item); }
public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0) { base.EnchantmentPayloadCallback(context, param, sourceEntity, targetEntity, sourceItem, sourceDamage); // Validate if (context != EnchantmentPayloadFlags.Strikes || targetEntity == null || param == null || sourceDamage == 0) { return(null); } // Get target effect manager EntityEffectManager effectManager = targetEntity.GetComponent <EntityEffectManager>(); if (!effectManager) { return(null); } // Cast when strikes enchantment prepares a new ready spell if (!string.IsNullOrEmpty(param.Value.CustomParam)) { // TODO: Ready a custom spell bundle } else { // Ready a classic spell bundle SpellRecord.SpellRecordData spell; EffectBundleSettings bundleSettings; EntityEffectBundle bundle; if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(param.Value.ClassicParam, out spell)) { if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.Spell, out bundleSettings)) { bundle = new EntityEffectBundle(bundleSettings, sourceEntity); effectManager.AssignBundle(bundle, AssignBundleFlags.ShowNonPlayerFailures); } } } return(new PayloadCallbackResults() { durabilityLoss = durabilityLossOnStrike }); }