• Advertisement
Sign in to follow this  

Unity Dialog system - requirements

This topic is 874 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

i'm writing a dialog system (first serious attempt) and came to a point where i want to make it more 'unspecific'.

Each dialog currently has options to specify requirements (List of DialogRequirement objects) for it to be a selectable option, which consist

of a target (enum - npc, player, world) and a type (enum -state, logEntry, etc) and a few value fields (int, float, string). When checking the requirements

i select the target based on the enum value and pass the requirement object to it. Targets implement an interface (IDialogRelevant) with bool ValidateRequirement(DialogRequirement) and use the value fields for the check.

The problem i have is that the requirement has these value fields (int intValue, float floatValue ..) that are bad to read and easy to implement wrong in the DialogRelevant entity and also the RequirementType enum too tied to a specific type of game (the requirementType enum currently has things like QuestLog for example).

 

What i would want is it to be extensible , like new requirement (sub)classes which then could (and should) be more specific.

What i thought, but am confused about is generic interfaces, or an abstract generic baseclass.

(But if, how would i 'connect' these to the specific requirement target and pass the required value and what way should i do it, and wouldn't i have to typecheck and cast these before passing them to the specific target as i have to store them in a baseclass type field?)

 

i'm using unity (c#) and already have a visual interface ready to build the dialogs, but want it to be open to the requirement types that the user can implement, like i think giving them a Draw() method would be the way (as there's currently only this one requirement object i just inlined the drawing of it).

 

How would i design it?

 

I hope you can understand what i mean.

Edited by Valoo

Share this post


Link to post
Share on other sites
Advertisement
Try inverting the problem. Instead of each entity in the game checking if it is valid for a given dialog option, implement a DialogOption subclass for each type of option, and have that subclass check the entities for validity.

Share this post


Link to post
Share on other sites

I see, my explanation wasn't that good and it seems missing some information. Each entity that needs dialogs has the dialog component that holds all dialogs for that entity. If the player requests dialogs, the code checks the each root element of the dialogs for its requirements. This means, foreach DialogRoot (and subsequent dialogoptions: if at that point), i pass the dialogrequirements to the entity the req. is targeted at, for it to check them, because i currently have no idea how to kind of externalize them (i hope that word describes it better). In the end, i want to enable the user to create custom requirements specific to his game (and maybe the validation methods, if those are needed?), for example like Requirement_HasItem that i can use in my system without hardcoding them or having a big allround requirement class with all value types as fields and an enum that defines how the values should be handled (what i currently have)

Edited by Valoo

Share this post


Link to post
Share on other sites

If you want a fully extendable requirement, I don't see any other choice but to let a derived class or a user-supplied class handle the exact requirement checking (and likely, you want to provide some of these for common types, like "has item"). The simple reason is that you are never going to be complete. It's trivial to think of crazy extensions like "you can only talk to me if the weight of your items together is a prime number".

 

Storage of required items and checking requirements are two different things, and you can do each independent of the other, if you like.

For example, you could have a derived class inspect the environment for checking the requirements (it would need an API to do so), or it could give an object to the central storage that checks on behalf of the derived class. You could even have completely separate check class hierarchies, which can be extended, that the dialog sub-class "magically" knows about.

Share this post


Link to post
Share on other sites

I'd just pass in a list of strings that can be defined by the game developer.

Strings can be things like "VistedMagicalCity", "AquiredMcGuffin", "KilledByAGrue", "CurrentlyHasKeyItem"

 

If that's not enough flexibility, then just make the "requirement" be a script that must return true.

Share this post


Link to post
Share on other sites

@Alberth

The idea of passing check objects sounds good. I guess that would mean i still keep the base requirement class with the valuetype fields which the specific check object then takes the ones it needs from, kind of like an adapter?

 

@Servant of the Lord

For the strings idea, it seems to me that this means logging all game events in this string format. And that means checking the inventory for example for an item would become a search for "PickedUpItemX" or the surrounding system has to know which specific events to log as a certain keyword which i feel could be a too strong requirement for the system. And to your script idea it sounds to me like you mean it in a similar way to these check objects, no? (if i understood these correctly)

Share this post


Link to post
Share on other sites

For the strings idea, it seems to me that this means logging all game events in this string format. And that means checking the inventory for example for an item would become a search for "PickedUpItemX" or the surrounding system has to know which specific events to log as a certain keyword which i feel could be a too strong requirement for the system. And to your script idea it sounds to me like you mean it in a similar way to these check objects, no? (if i understood these correctly)

 

For the string idea, I meant that the quest makers (or whomever) create invisible textual "keys" that unlock branches of the dialog. These invisible keys can be given to the player by scripted situations in the game world. It is simple and straightforward.

 

For example, not every item is going to be used for quests. Depending on your game, I'd guess that less than 1% of all your items will be quest items. So instead of making your dialog system know about the existence of items, just make the items be able to contribute textual keys to the dialog system.

 

For a quest item called "Super dragon crystal", have a field in the item editor where you can add "HAS_SUPER_DRAGON_CRYSTAL". Any item where that "quest item" field is left blank, doesn't bother contributing to the dialog system.

 

If a quest requires the player to have visited the Lonely Eagle Tavern, make the "onEnter" script for that map call SetQuestKey("VISITED_LONELY_EAGLE_TAVERN");

 

If this isn't flexible enough for you, then (instead of the other suggestion) just take the leap to make the dialog system be aware of your scripting environment, and make your Dialog Requirement just be a script that returns true or false if that requirement is met.

Share this post


Link to post
Share on other sites

Unfortunately, no matter what the dialogue system's situational check is going to be uber specific to your game. Not all games feature the same mechanics or quest styles, so each game really needs to make their own checks.

Currently, the way I have mine mapped out in design, is by using a Tree based structure, with each node allowed to accept conditional arguments. This conditional argument on it's own has absolutely no functionality. It only accepts bools. Now Lua has a very nice feature of allowing a variable amount of arguments to be passed through, which makes the process real easy for me, but you can do the same with C# without it looking as clean

 

That means we can build very generic function arguments. Here's what my arguments look like:

Dialogue.checkGlobal(DataTable, enum operation, items . . .) DataTable would be my global game data table. ENUM operation tells if I am ANDing or ORing all this data. AND requires all to be true. Or immediately returns true if one is true.

Dialogue.checkParty(PartyTable, enum operations, characters...). This checks to see if certain characters are in your party. Returns true if yes.

Dialogue.checkQuestStage(QuestTable, int stage);

ect.

 

There are also a few nodes whom soul purpose is to gather information for randomization.

 

A party of 8 exists. Four entered a dungeon, Leo, Neshar, Omally, and Drivilla. But at the time of a trigger, only three are within speaking range. We check to see if each one of the branches are allowed to be ran based on those three. Build an array. Then randomly select a branch to traverse. End result, characters when they enter dungeons.

 

The tool is built using Javascript and HTML, and it outputs two files. JSON for reloading. LUA for the game.

 

The dialogue system may also need to be able to trigger events in the game. In my case, it does. In the middle of a dialogue, a cleric or a thief may be able to give out hints. And the game needs to highlight those, or write to a journal.

Edited by Tangletail

Share this post


Link to post
Share on other sites

I know that it has to be specific to the game, and i hoped to build a system that becomes specialized at the point where the user created his game specific requirements (and/or implemented the associated (generic?)interfaces for the entities).

I currently also have a kind of trigger system, not as sophisticated, but involved entities (npc, player, world context) can be notified when a dialog option is selected. AND'ing and OR'ing of the requirements is also already in there. It's just the way the requirement is structured that currently botheres me. But i will see what i can do with all the suggestions i got.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Manuel Berger
      Hello fellow devs!
      Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
      My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

      In Pseudo-Code:
      angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
      index = (int) (angle / (PI / 5));
      PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

      Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

      What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

      I can't get my head around it. Any suggestions? Is the whole approach doomed?

      Thank you in advance for any input!
       
    • By devbyskc
      Hi Everyone,
      Like most here, I'm a newbie but have been dabbling with game development for a few years. I am currently working full-time overseas and learning the craft in my spare time. It's been a long but highly rewarding adventure. Much of my time has been spent working through tutorials. In all of them, as well as my own attempts at development, I used the audio files supplied by the tutorial author, or obtained from one of the numerous sites online. I am working solo, and will be for a while, so I don't want to get too wrapped up with any one skill set. Regarding audio, the files I've found and used are good for what I was doing at the time. However I would now like to try my hand at customizing the audio more. My game engine of choice is Unity and it has an audio mixer built in that I have experimented with following their tutorials. I have obtained a great book called Game Audio Development with Unity 5.x that I am working through. Half way through the book it introduces using FMOD to supplement the Unity Audio Mixer. Later in the book, the author introduces Reaper (a very popular DAW) as an external program to compose and mix music to be integrated with Unity. I did some research on DAWs and quickly became overwhelmed. Much of what I found was geared toward professional sound engineers and sound designers. I am in no way trying or even thinking about getting to that level. All I want to be able to do is take a music file, and tweak it some to get the sound I want for my game. I've played with Audacity as well, but it didn't seem to fit the bill. So that is why I am looking at a better quality DAW. Since being solo, I am also under a budget contraint. So of all the DAW software out there, I am considering Reaper or Presonus Studio One due to their pricing. My question is, is investing the time to learn about using a DAW to tweak a sound file worth it? Are there any solo developers currently using a DAW as part of their overall workflow? If so, which one? I've also come across Fabric which is a Unity plug-in that enhances the built-in audio mixer. Would that be a better alternative?
      I know this is long, and maybe I haven't communicated well in trying to be brief. But any advice from the gurus/vets would be greatly appreciated. I've leaned so much and had a lot of fun in the process. BTW, I am also a senior citizen (I cut my programming teeth back using punch cards and Structured Basic when it first came out). If anyone needs more clarification of what I am trying to accomplish please let me know.  Thanks in advance for any assistance/advice.
    • By Yosef BenSadon
      Hi , I was considering this start up http://adshir.com/, for investment and i would like a little bit of feedback on what the developers community think about the technology.
      So far what they have is a demo that runs in real time on a Tablet at over 60FPS, it runs locally on the  integrated GPU of the i7 . They have a 20 000 triangles  dinosaur that looks impressive,  better than anything i saw on a mobile device, with reflections and shadows looking very close to what they would look in the real world. They achieved this thanks to a  new algorithm of a rendering technique called Path tracing/Ray tracing, that  is very demanding and so far it is done mostly for static images.
      From what i checked around there is no real option for real time ray tracing (60 FPS on consumer devices). There was imagination technologies that were supposed to release a chip that supports real time ray tracing, but i did not found they had a product in the market or even if the technology is finished as their last demo  i found was with a PC.  The other one is OTOY with their brigade engine that is still not released and if i understand well is more a cloud solution than in hardware solution .
      Would there  be a sizable  interest in the developers community in having such a product as a plug-in for existing game engines?  How important  is Ray tracing to the  future of high end real time graphics?
    • By bryandalo
      Good day,

      I just wanted to share our casual game that is available for android.

      Description: Fight your way from the ravenous plant monster for survival through flips. The rules are simple, drag and release your phone screen. Improve your skills and show it to your friends with the games quirky ranks. Select an array of characters using the orb you acquire throughout the game.

      Download: https://play.google.com/store/apps/details?id=com.HellmodeGames.FlipEscape&hl=en
       
      Trailer: 
       
    • By khawk
      Watch the latest from Unity.
       
  • Advertisement