Adventure Creator / Dialogue System Integration ?

Extreme AI can be integrated fairly easily with many products in the Unity Asset Store. Discuss your experience or questions here!

Moderator: JeffG

Adventure Creator / Dialogue System Integration ?

Postby Manuel » Wed Mar 25, 2015 12:03 pm

Seems like this type of AI would be awesome for these two assets that are almost a standard in narrative heavy games, it would be nice if the AI could come with some custom actions for easy accesing the data within the workflow that we know, and it would be an out of the box asset that could reach more newcomers.

I'll try to make some custom actions for Adventure Creator, to see how this could work.

BTW seems like the creator of Dialogue System is making a similar AI (without the personality model I guess), just a heads up.

PS. Hopefully one day the asset'll be updated with the source, seems kinda weird not being able to fully manipulate the AI.
Really hoping this thing to grow, it's a really cool approach.
Manuel
 
Posts: 4
Joined: Wed Mar 25, 2015 11:48 am
 

Re: Adventure Creator / Dialogue System Integration ?

Postby JeffG » Sat Mar 28, 2015 6:30 pm

Manuel wrote:Seems like this type of AI would be awesome for these two assets that are almost a standard in narrative heavy games, it would be nice if the AI could come with some custom actions for easy accesing the data within the workflow that we know, and it would be an out of the box asset that could reach more newcomers.


That's a great idea; I'd been toying with releasing the dialogue system I've created for SteamSaga (importing from a modified ChatMapper), but I'll have a look at these first.

Manuel wrote:I'll try to make some custom actions for Adventure Creator, to see how this could work.


Excellent! Let me know what happens.

And thanks for the comments and compliments!

Jeff
JeffG
 
Posts: 23
Joined: Tue Apr 01, 2014 10:49 pm
 

Re: Adventure Creator / Dialogue System Integration ?

Postby Manuel » Sat Apr 04, 2015 10:57 pm

I've done a simple script that saves a ExtremeAI to a Adventure Creator local Variable.

Code: Select all
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using TaiPE_Lib;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

   [System.Serializable]
   public class AIAction : Action
   {
      
      // Declare variables here
      public GameObject AItoAsk;
      public bool isPlayer;
      
      public int parameterID = -1;
      public int variableID;
      public int variableNumber;
      
      public int setParameterID = -1;
      
      public int intValue;

      public VariableLocation location;
      
      public string menuName;
      public string elementName;
      
      public Animator animator;
      public string parameterName;

      
      public AIAction ()
      {
         this.isDisplayed = true;
         category = ActionCategory.ThirdParty;
         title = "ExtremeAI: Ask Parameters";
         description = "Asks ExtremeAI Parameter";
      }
      
      
      override public float Run ()
      {
         int am_I_Intimidating = AItoAsk.GetComponent
            <NPCInterface>().myAIChar.AIReturnResult ("Player","intimidating",false);

         Debug.Log ("value of am_I_intimidating: " + am_I_Intimidating);

         AC.LocalVariables.SetIntegerValue (variableID, am_I_Intimidating);

         if (!isRunning)
         {
            isRunning = true;
            return defaultPauseTime;
         }
         else
         {
            isRunning = false;
            return 0f;
         }
      }
      
      
      #if UNITY_EDITOR

      override public void ShowGUI (List<ActionParameter> parameters)
      {
         AItoAsk = (GameObject) EditorGUILayout.ObjectField
            ("GameObject to affect:", AItoAsk, typeof (GameObject), true);
         if (KickStarter.localVariables)
         {
            ShowVarGUI (KickStarter.localVariables.localVars, parameters, ParameterType.LocalVariable);
         }

         AfterRunningOption ();
      }
      private void ShowVarGUI (List<GVar> vars, List<ActionParameter> parameters, ParameterType parameterType)
      {
         // Create a string List of the field's names (for the PopUp box)
         List<string> labelList = new List<string>();
         
         int i = 0;
         if (parameterID == -1)
         {
            variableNumber = -1;
         }
         
         if (vars.Count > 0)
         {
            foreach (GVar _var in vars)
            {
               labelList.Add (_var.label);
               
               // If a GlobalVar variable has been removed, make sure selected variable is still valid
               if (_var.id == variableID)
               {
                  variableNumber = i;
               }
               
               i ++;
            }
            
            if (variableNumber == -1 && (parameters == null || parameters.Count == 0 || parameterID == -1))
            {
               // Wasn't found (variable was deleted?), so revert to zero
               Debug.LogWarning ("Previously chosen variable no longer exists!");
               variableNumber = 0;
               variableID = 0;
            }
            
            
            parameterID = Action.ChooseParameterGUI ("Variable:", parameters, parameterID, parameterType);
            if (parameterID >= 0)
            {
               //variableNumber = 0;
               variableNumber = Mathf.Min (variableNumber, vars.Count-1);
               variableID = -1;
            }
            else
            {
               variableNumber = EditorGUILayout.Popup ("Variable:", variableNumber, labelList.ToArray());
               variableID = vars [variableNumber].id;
            }

         }
         else
         {
            EditorGUILayout.HelpBox ("No variables exist!", MessageType.Info);
            variableID = -1;
            variableNumber = -1;
         }
      }

      public override string SetLabel ()
      {
         // Return a string used to describe the specific action's job.
         
         string labelAdd = "";
         return labelAdd;
      }

      #endif
      
   }

}


It's kinda working, it needs some tweaking to works with prefabs.
I guess it would be the same to change ExAI parameters just changing the action.

Where are the parameters array ? I'll need it to call it into the action through a pop up (would be easier than by string).

Some tips for improvement:
- It should be a lot more comfortable if instead of typing the character name, to have a new window that lists them and their current personality.
- Include into the package a couple of standard NPC/player scripts (would be nice if they could be linked to the database and you can select the character from a list of created players.

Do you have AC to do some testing ? It's easy to do a support package for it, you only need to add the scripts to the actions folder in AC.
Manuel
 
Posts: 4
Joined: Wed Mar 25, 2015 11:48 am
 

Re: Adventure Creator / Dialogue System Integration ?

Postby JeffG » Tue Apr 07, 2015 12:05 am

Cool! I've never worked with AC myself, but I'm guessing that in your code at runtime AC is going out and getting a return value from the AI engine (and that value can then be used anywhere in AC).

Are you asking if there's an accessible parameters list of all the response/stimulus types (intimidating, kind, affectionate, anger, etc.)? Currently you'd have to create that array yourself (you could use the list in the User Manual), but I'm working on a method that will retrieve all the attribute values at once for a character, or that can return a single attribute value. This is so the developer can see the character's raw scores, rather than just the returned 0-4 value calculated when asking how a character will react. I was going to include this in the next update. Would that help you in this situation? I could also add a method that just returns the names of the response/stimulus types into an array (and a method that does the same for all character names).

Cheers,
Jeff
JeffG
 
Posts: 23
Joined: Tue Apr 01, 2014 10:49 pm
 

Re: Adventure Creator / Dialogue System Integration ?

Postby Manuel » Tue Apr 07, 2015 7:20 pm

JeffG wrote:Cool! I've never worked with AC myself, but I'm guessing that in your code at runtime AC is going out and getting a return value from the AI engine (and that value can then be used anywhere in AC).

Cheers,
Jeff


Yeah, pretty much, I'll be not using EAI for my game, but it seems a cool approach, so I'm just looking at it sparingly.

About arrays, I was just thinking that it's easier to code for than doing "string query-like", also easier to do for the "pop-up menus" in the AC workflow.

I'm not sure what did you say about the method of returning.

What's your method of workflow ? Maybe you have a better way to integrate things.
Manuel
 
Posts: 4
Joined: Wed Mar 25, 2015 11:48 am
 
 

Return to Integrate Extreme AI with other Unity Assets

Who is online

Users browsing this forum: No registered users and 1 guest