gpt4 book ai didi

data-structures - RPG对话引擎/结构

转载 作者:行者123 更新时间:2023-12-03 12:07:13 24 4
gpt4 key购买 nike

关闭。这个问题需要更多focused .它目前不接受答案。












想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post .

4年前关闭。




Improve this question




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

例如:如果我在游戏中的 x 点接近一个 NPC,有元素 y 和任务 z,我将如何确定 NPC 需要说什么?分支对话和响应玩家输入似乎与定义脚本一样微不足道,用户输入会导致脚本阅读器跳转到脚本中的特定行,该行具有相应的一组响应行(很像选择你自己的冒险)

然而,如果玩家拥有某些元素并完成某些任务,那么结合逻辑来解决这个问题似乎真的破坏了这个基于脚本的模型。

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

这确实是一个悬而未决的问题。我不相信有一个单一的解决方案,但最好能有一些想法让球滚动。作为一名设计师而不是程序员,我总是对分离内容和代码的方法感兴趣。

最佳答案

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.



一点也不。您只需将条件分解到数据中即可。

假设您有对话列表,编号为 1 到 400,或者诸如“选择自己的冒险”书籍示例之类的内容。我假设每个对话都可能包含 NPC 所说的文本,然后是玩家可用的响应列表。

所以下一步是在那里添加条件,只需将条件附加到每个响应。最简单的方法是使用脚本语言执行此操作,因此您有一段简短的代码,如果该响应对玩家可用,则返回 True,否则返回 False。

例如。 (XML 格式,但可以是任何东西)
<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>

在您的脚本语言中,您需要一个“rats_left_in_world”函数,您可以调用该函数来检索有问题的值。

如果您没有脚本语言怎么办?好吧,你可以让程序员为对话中的每种情况编写一个单独的条件——有点乏味,如果你的对话是预先编写的,那就不是那么困难了。然后只需在对话脚本中按名称引用条件。

一个更高级的方案,仍然不需要脚本语言,可以为每个条件使用一个标签,如下所示:
<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>

您可以根据需要在其中添加任意数量的条件,只要它们可以使用一两个值轻松指定。如果满足所有条件,则响应可用。

关于data-structures - RPG对话引擎/结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1840154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com