Emerald AI Integration

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);
}

}
 
For those of you who have followed along with my Emerald AI integration, I have been developing a new AI system called LifeLink. I have released the first playable demo for testing some alpha melee combat systems. To follow along with the development, please visit my discord channel:


You can find a link to the playable demo in the playable-demos channel and follow along with development progress in the other channels.
 
For anyone trying to integrate with latest Emerald AI 3.0, the following change is required from the integration instructions:

In the EmeraldAIPlayerDamage.cs file in the DamagaeOpsivePlayer function, change

emeraldAI.ClearTarget();

to

emeraldAIEvents.ClearTarget();
 
The only thing I see in the demos is the damage numbers floating up above the AI's head. I don't see that double red arrow so I have no idea what that is. Did you mean to say that the damage numbers are not showing up because I also am not seeing those in my integration test.
 
Ok, I see. This is an Opsive feature. I'm guessing you want these indicators to also work for Emerald AI. I will have to see if this is possible. It might just be a script that needs to be attached.
 
Last edited:
Looks like the attacker information comes through as null and that's why it doesn't show. I'm trying to see what can be done to fix it.
 
Replace the following:
tpcHealth.Damage(DamageAmount);

With:

tpcHealth.Damage(DamageAmount, target.position, target.forward, 1f, target.gameObject);

in the DamageOpsivePlayer function and it should work now.
 
Am i missing something my ai seems to be able to detect me and also can detect other emerald ai but it doesn't hurt them when attacking.
 
Am i missing something my ai seems to be able to detect me and also can detect other emerald ai but it doesn't hurt them when attacking.
It sounds like you missed something with the Opsive integration, but that shouldn't affect whether the AI can hurt each other. That should work regardless of whether the Opsive integration is correct or not. When you run the AI on AI demo, are they not hurting each other?
 
It sounds like you missed something with the Opsive integration, but that shouldn't affect whether the AI can hurt each other. That should work regardless of whether the Opsive integration is correct or not. When you run the AI on AI demo, are they not hurting each other?
i loaded the ai vs ai and it works fine went back to my scene and it works...... hmm but i am having issues with the emerald ai player damage script.... i keep getting errors no matter how i try to do this ive done this before on a old project.. also magique when is life link coming to unity???
 
I keep forgetting to fix the SendPlayerDamage function with the extra parameter that was added some time ago. Here is an updated document with that fix.
 

Attachments

  • Opsive_EmeraldAI_Integration.pdf
    150.8 KB · Views: 59
Top