RPG对话引擎/结构 [英] RPG dialogue engine / structure

查看:123
本文介绍了RPG对话引擎/结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直对RPG(角色扮演游戏)中涉及的数据结构感兴趣。特别是,我很好奇对话和基于事件的动作。



例如:如果我在游戏中的 x ,项目 y 和任务 z ,我如何解决NPC需要说的内容?分支对话和响应播放器输入似乎与定义的脚本一样微不足道,用户输入使脚本阅读器跳转到脚本中的特定行,该行具有相应的一组响应行(非常类似于选择您自己的冒险)



但是,如果玩家有某些项目,并且完成某些任务似乎真的毁了这个基于脚本的模型,那么绑定逻辑。



我正在寻找如何处理所有这些对话和逻辑的想法(不一定是编程语言示例),并将其分开,以便添加新的分支内容非常容易,而无需深入研究太多的代码。



这是一个开放的问题。我不相信有一个单一的解决方案,但是有一些想法可以让球滚动。作为更多的设计师而不是程序员,我总是有兴趣分开内容和代码。

解决方案

$ b $例如:如果我在游戏中接近
点x的NPC,使用项目y和
任务z,我该如何计算NPC需要说的
?分配
对话并响应玩家
输入似乎不如有
定义的脚本,用户输入导致
脚本读取器跳到
特定行脚本,
有一个对应的一组响应
行(非常喜欢选择你自己的
冒险)



然而,绑定如果
的玩家有某些项目,并且
完成某些任务似乎是
,那么在逻辑上可以解决这个基于脚本的模型。


根本没有。您只需将条件条件纳入数据。



假设您有对话列表,编号为1到400,或者选择您自己的冒险书籍示例。我假设每个对话可能由NPC所说的文本组成,其后是播放器可用的响应列表。



所以下一步是添加条件在那里,只需将条件附加到每个响应。最简单的方法是使用脚本语言执行此操作,因此,如果播放器可以使用此响应,则返回True,并返回False,否则返回True。



例如(XML格式,但可以是任何东西)

 <对话id ='1'> 
< text>
你能冒出来杀死我10只老鼠吗?
< / text>
< response condition =TruenextDialogue ='2'>
真的!无奈可能比杀死你的恶魔更好。我要带给你一个十元的b $ b个尸体。
< / text>
< response condition =rats_left_in_world()< 10nextDialogue ='3'>弟弟!如果你剩下十只老鼠,我的剑就是你的剑,
但不是这样。
< / response>
< /对话>

在您的脚本语言中,您需要一个rats_left_in_world功能,您可以调用它来检索有价值的价值。



如果你没有脚本语言怎么办?那么你可以让程序员的代码对你的对话中的每一种情况都有个别的条件 - 有点乏味,如果你的对话是前面写的,那么并不困难。然后只需在会话脚本中按名称引用条件。



更高级的方案,仍然不需要脚本语言,可能会为每个条件使用标签,如:

 < response> 
< condition type ='min_level'value = '50'/>
悲伤的乡绅,我的时间对于你的喜好太贵了。给你自己一个
农场的手或稳定的男孩来做你的招标!
< / response>

您可以根据需要添加任何条件,只要可以轻松指定一个或两个值。如果满足所有条件,则响应可用。


I've always been interested in the data structures involved in an RPG (Role-Playing Game). In particular, I'm curious about dialogue and events based actions.

For example: If I approach an NPC at point x in the game, with items y and quests z, how would I work out what the NPC needs to say? Branching dialogue and responding to player input seems as trivial as having a defined script, and user input causes the script reader to jump to a particular line in the script, which has a corresponding set of response lines (much like a choose your own adventure)

However, tying in logic to work out if the player has certain items, and completed certain quests seems to really ruin this script based model.

I'm looking for ideas (not necessarily programming language examples) of how to approach all of this dialogue and logic, and separate it out so that it's very easy to add new branching content, without delving into too much code.

This is really an open question. I don't believe there's a single solution, but it'd be good to get the ball rolling with some ideas. As more of a designer than a programmer, I'm always interested in ways to separate content and code.

解决方案

For example: If I approach an NPC at point x in the game, with items y and quests z, how would I work out what the NPC needs to say? Branching dialogue and responding to player input seems as trivial as having a defined script, and user input causes the script reader to jump to a particular line in the script, which has a corresponding set of response lines (much like a choose your own adventure)

However, tying in logic to work out if the player has certain items, and completed certain quests seems to really ruin this script based model.

Not at all. You simply factor the conditionals into the data.

Let's say you have your list of dialogues, numbered 1 to 400 or whatever like the Choose Your Own Adventure book examples. I assume each dialogue may consist of the text spoken by the NPC, followed by a list of responses available to the player.

So the next step is to add the conditionals in there, by simply attaching conditions to each response. The easiest way is to do this with a scripting language, so you have a short and simple piece of code that returns True if this response is available to the player and False if it is not.

eg. (XML format, but could be anything)

<dialogue id='1'>
  <text>
    Couldst thou venture forth and kill me 10 rats, perchance?
  </text>
  <response condition="True" nextDialogue='2'>
    Verily! Naught could be better than slaying thy verminous foes. Ten ratty
    carcasses shall I bring unto thee.
  </text>
  <response condition="rats_left_in_world() < 10" nextDialogue='3'>
    Nay, brother! Had thou but ten rats remaining, my sword would be thine,
    but tis not to be.
  </response>
</dialogue>

In your scripting language, you'd need a 'rats_left_in_world' function that you can call to retrieve the value in question.

What if you have no scripting language? Well, you could have the programmer code an individual condition for each situation in your dialogue - a bit tedious, not all that difficult if your dialogue is written up-front. Then just refer to a condition by name in the conversation script.

A more advanced scheme, still not requiring a scripting language, might use a tag for each condition, like so:

<response>
  <condition type='min_level' value='50'/>
  Sadly squire, my time is too valuable for the likes of thee. Get thyself a
  farm hand or stable boy to do thy bidding!
</response>

You can add as many conditions in there as you need, as long as they can be easily specified with one or two values. If all conditions are met, the response is available.

这篇关于RPG对话引擎/结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆