jmartin664
New member
Couldn't find where anyone had made the opsive spells damage emerald AI. Here is a custom ImpactAction I made that will damage an emerald AI with the opsive bridge attached. Just select it as the impact action when setting up the spell.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EmeraldAI;
using Opsive.UltimateCharacterController.Items.Actions;
using Opsive.UltimateCharacterController.Items.Actions.Magic.ImpactActions;
public class EmeraldSpellDamage : ImpactAction
{
[Tooltip("The damage amount.")]
[SerializeField] protected float m_Amount = 10;
[Tooltip("The magnitude of the force that is applied to the object.")]
[SerializeField] protected float m_ForceMagnitude;
[Tooltip("The number of frames to add the force to.")]
[SerializeField] protected int m_ForceFrames = 1;
[Tooltip("Should the subsequent Impact Actions be interrupted if the Health component doesn't exist?")]
[SerializeField] protected bool m_InterruptImpactOnNullHealth = true;
private EmeraldAISystem _emeraldAI;
private MagicItem magicItem;
public float Amount { get { return m_Amount; } set { m_Amount = value; } }
public float ForceMagnitude { get { return m_ForceMagnitude; } set { m_ForceMagnitude = value; } }
public int ForceFrames { get { return m_ForceFrames; } set { m_ForceFrames = value; } }
public bool InterruptImpactOnNullHealth { get { return m_InterruptImpactOnNullHealth; } set { m_InterruptImpactOnNullHealth = value; } }
/// <summary>
/// Perform the impact action.
/// </summary>
/// <param name="castID">The ID of the cast.</param>
/// <param name="source">The object that caused the cast.</param>
/// <param name="target">The object that was hit by the cast.</param>
/// <param name="hit">The raycast that caused the impact.</param>
protected override void ImpactInternal(uint castID, GameObject source, GameObject target, RaycastHit hit)
{
_emeraldAI = target.GetComponent<EmeraldAISystem>();
if (_emeraldAI != null )
_emeraldAI.Damage((int)Amount, EmeraldAISystem.TargetType.Player, source.transform);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EmeraldAI;
using Opsive.UltimateCharacterController.Items.Actions;
using Opsive.UltimateCharacterController.Items.Actions.Magic.ImpactActions;
public class EmeraldSpellDamage : ImpactAction
{
[Tooltip("The damage amount.")]
[SerializeField] protected float m_Amount = 10;
[Tooltip("The magnitude of the force that is applied to the object.")]
[SerializeField] protected float m_ForceMagnitude;
[Tooltip("The number of frames to add the force to.")]
[SerializeField] protected int m_ForceFrames = 1;
[Tooltip("Should the subsequent Impact Actions be interrupted if the Health component doesn't exist?")]
[SerializeField] protected bool m_InterruptImpactOnNullHealth = true;
private EmeraldAISystem _emeraldAI;
private MagicItem magicItem;
public float Amount { get { return m_Amount; } set { m_Amount = value; } }
public float ForceMagnitude { get { return m_ForceMagnitude; } set { m_ForceMagnitude = value; } }
public int ForceFrames { get { return m_ForceFrames; } set { m_ForceFrames = value; } }
public bool InterruptImpactOnNullHealth { get { return m_InterruptImpactOnNullHealth; } set { m_InterruptImpactOnNullHealth = value; } }
/// <summary>
/// Perform the impact action.
/// </summary>
/// <param name="castID">The ID of the cast.</param>
/// <param name="source">The object that caused the cast.</param>
/// <param name="target">The object that was hit by the cast.</param>
/// <param name="hit">The raycast that caused the impact.</param>
protected override void ImpactInternal(uint castID, GameObject source, GameObject target, RaycastHit hit)
{
_emeraldAI = target.GetComponent<EmeraldAISystem>();
if (_emeraldAI != null )
_emeraldAI.Damage((int)Amount, EmeraldAISystem.TargetType.Player, source.transform);
}
}