/// <summary> /// 9 /// Creates spell. Use Action's index to get the spell by index from Spells.STD /// </summary> /// <param name="triggerObj"></param> /// <param name="thisAction"></param> public static void CastSpell(GameObject triggerObj, DaggerfallAction thisAction) { thisAction.Cooldown -= 45.454546f; // Approximates classic based on observation if (thisAction.Cooldown <= 0) { SpellRecord.SpellRecordData spell; if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(thisAction.Index, out spell)) { // Create effect bundle settings from classic spell EffectBundleSettings bundleSettings; if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.Spell, out bundleSettings)) { if (bundleSettings.TargetType == TargetTypes.CasterOnly) { // Spell is readied on player for free GameManager.Instance.PlayerEffectManager.SetReadySpell(thisAction.Index, true); } else { // Spell is fired at player, at strength of player level, from triggering object DaggerfallMissile missile = GameManager.Instance.PlayerEffectManager.InstantiateSpellMissile(bundleSettings.ElementType); missile.Payload = new EntityEffectBundle(bundleSettings, GameManager.Instance.PlayerEntityBehaviour); Vector3 customAimPosition = thisAction.transform.position; customAimPosition.y += 40 * MeshReader.GlobalScale; missile.CustomAimPosition = customAimPosition; missile.CustomAimDirection = Vector3.Normalize(GameManager.Instance.PlayerObject.transform.position - thisAction.transform.position); } } } //Reset cooldown thisAction.Cooldown = 1000; } }
private void PlayerSpellCasting_OnReleaseFrame() { Vector3 missileDirection = GameManager.Instance.MainCamera.transform.forward; Vector3 missilePosition = transform.position + Vector3.up * 0.35f + missileDirection * 0.85f; // TEMP: Just hurling test missiles with no payload at this time DaggerfallMissile missile = Instantiate(ColdMissilePrefab); missile.UseSpellBillboardAnims(SpellTypes.Cold); missile.ExecuteMobileMissile(missilePosition, missileDirection); lastSpell = readySpell; readySpell = null; }
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; }