bool SilenceCheck() { if (entityBehaviour.Entity.IsSilenced) { // Output "You are silenced." if the host manager is player // Just to let them know why casting isn't working if (entityBehaviour == GameManager.Instance.PlayerEntityBehaviour) { DaggerfallUI.AddHUDText(TextManager.Instance.GetText(textDatabase, "youAreSilenced"), 1.5f); } readySpell = null; return(true); } return(false); }
private void PlayerSpellCasting_OnReleaseFrame() { // TODO: Split missile generation from player spell casting so monsters can also cast spells // Using player as sole testing platform for now // Must have a ready spell if (readySpell == null) { return; } // Play cast sound from caster audio source if (readySpell.CasterEntityBehaviour) { int castSoundID = GetCastSoundID(readySpell.Settings.ElementType); DaggerfallAudioSource audioSource = readySpell.CasterEntityBehaviour.GetComponent <DaggerfallAudioSource>(); if (castSoundID != -1 && audioSource) { audioSource.PlayOneShot((uint)castSoundID); } } // Assign bundle directly to self if target is caster // Otherwise instatiate missile prefab based on element type if (readySpell.Settings.TargetType == TargetTypes.CasterOnly) { AssignBundle(readySpell); } else { DaggerfallMissile missile = InstantiateMissile(readySpell.Settings.ElementType); if (missile) { missile.Payload = readySpell; } } // Clear ready spell and reset casting lastSpell = readySpell; readySpell = null; instantCast = false; castInProgress = false; }
/// <summary> /// Assigns a new spell to be cast. /// For player entity, this will display "press button to fire spell" message. /// </summary> public void SetReadySpell(EntityEffectBundle spell) { // Spell must appear valid if (spell == null || spell.Settings.Version < minAcceptedSpellVersion) { return; } // Assign spell - caster only spells are cast instantly readySpell = spell; if (readySpell.Settings.TargetType == TargetTypes.CasterOnly) { instantCast = true; } if (isPlayerEntity && !instantCast) { DaggerfallUI.AddHUDText(HardStrings.pressButtonToFireSpell, 0.4f); } }
void ClearReadySpellHistory() { lastSpell = null; readySpell = null; }
public void AssignBundle(EntityEffectBundle sourceBundle) { // Source bundle must have one or more effects if (sourceBundle.Settings.Effects == null || sourceBundle.Settings.Effects.Length == 0) { Debug.LogWarning("AssignBundle() could not assign bundle as source has no effects"); return; } // Create new instanced bundle and copy settings from source bundle InstancedBundle instancedBundle = new InstancedBundle(); instancedBundle.version = sourceBundle.Settings.Version; instancedBundle.bundleType = sourceBundle.Settings.BundleType; instancedBundle.targetType = sourceBundle.Settings.TargetType; instancedBundle.elementType = sourceBundle.Settings.ElementType; instancedBundle.name = sourceBundle.Settings.Name; instancedBundle.iconIndex = sourceBundle.Settings.IconIndex; instancedBundle.liveEffects = new List <IEntityEffect>(); if (sourceBundle.CasterEntityBehaviour) { instancedBundle.caster = sourceBundle.CasterEntityBehaviour; instancedBundle.casterEntityType = sourceBundle.CasterEntityBehaviour.EntityType; instancedBundle.casterLoadID = GetCasterLoadID(sourceBundle.CasterEntityBehaviour); } // Instantiate all effects in this bundle for (int i = 0; i < sourceBundle.Settings.Effects.Length; i++) { // Instantiate effect IEntityEffect effect = GameManager.Instance.EntityEffectBroker.InstantiateEffect(sourceBundle.Settings.Effects[i]); if (effect == null) { Debug.LogWarningFormat("AssignBundle() could not add effect as key '{0}' was not found by broker."); continue; } // Spell absorption - must have a caster entity set if (sourceBundle.CasterEntityBehaviour) { int absorbSpellPoints; if (TryAbsorption(effect, sourceBundle.Settings.TargetType, sourceBundle.CasterEntityBehaviour.Entity, out absorbSpellPoints)) { // Spell passed all checks and was absorbed - return cost output to target entityBehaviour.Entity.IncreaseMagicka(absorbSpellPoints); // Output "Spell was absorbed." DaggerfallUI.AddHUDText(TextManager.Instance.GetText(textDatabase, "spellAbsorbed")); continue; } } // Start effect effect.Start(this, sourceBundle.CasterEntityBehaviour); // Do not proceed if chance failed if (effect.Properties.SupportChance && effect.Properties.ChanceFunction == ChanceFunction.OnCast && !effect.ChanceSuccess) { // Output failure messages if (isPlayerEntity && sourceBundle.Settings.TargetType == TargetTypes.CasterOnly) { // Output "Spell effect failed." for caster only spells DaggerfallUI.AddHUDText(TextManager.Instance.GetText(textDatabase, "spellEffectFailed")); } else if (isPlayerEntity) { // Output "Save versus spell made." for external contact spells DaggerfallUI.AddHUDText(TextManager.Instance.GetText(textDatabase, "saveVersusSpellMade")); } continue; } // Do not add unflagged incumbent effects // But allow for an icon refresh as duration might have changed and we want to update this sooner than next magic round if (effect is IncumbentEffect && !(effect as IncumbentEffect).IsIncumbent) { RaiseOnAssignBundle(); continue; } // Add effect instancedBundle.liveEffects.Add(effect); // At this point effect is ready and gets initial magic round effect.MagicRound(); } // Add bundles with at least one effect if (instancedBundle.liveEffects.Count > 0) { instancedBundles.Add(instancedBundle); RaiseOnAssignBundle(); Debug.LogFormat("Adding bundle {0}", instancedBundle.GetHashCode()); } }
public void AbortReadySpell() { readySpell = null; }