2

我想使用玩家刚刚在响应中使用的动词。

这很容易用名词([名词]),但在手册中我没有找到动词/动作的东西。

这就是我想要做的:

Instead of attacking someone:
   say "How do you want to [verb] [the noun]?".

玩家可能试图杀死、攻击、破坏等某人,而我想使用他/她使用的确切动词。

另外:在打印响应时,是否有一个可以在 [] 中使用的所有标准项目的列表?

4

1 回答 1

5

解析器实际上并没有“动词”的概念,它仅将命令与具有一些特殊标记(通常是名词)但动词不是其中之一的模式匹配。

另请注意,解析器在将原始命令标记化后会丢弃它:换句话说[the noun],它实际上并不包含玩家使用过的单词,而是该名词的打印名称。因此,如果您有:

The dragon is an animal. Understand "beast" as the dragon.

并且玩家键入 >ATTACK BEAST,然后[the noun]仍然会打印“dragon”。

你有几个选择:

  • 再模糊一点。例如:“你想怎么做?” 这是实践中最常用的选项。

  • 取玩家命令的第一个词并假设它是动词:

say "How do you want to [word number 1 in the player's command] [the noun]?";

不建议这样做,因为不能保证第一个单词实际上是动词。如果玩家命令 >GO NORTH THEN KILL DRAGON 或 >AGAIN 怎么办?游戏会问“你想怎么走龙?” 或“你想如何再次成为龙?”

  • 将攻击动作分成几部分,这样你就可以确定玩家使用的是哪一个。
Hitting is an action applying to one thing.
Understand the command "hit" as something new.
Understand "hit [something]" as hitting.

Instead of hitting:
   say "How do you want to hit [the noun]?"

我也不会这样做,因为有更好的选择......

  • 如果您正确创建“攻击方式”动作,Inform 已经内置了此功能。
Attacking it with is an action applying to two things.
Understand the commands "attack" and "hit" as something new.
Understand "attack [something] with [something]" as attacking it with.
Understand "hit [something] with [something]" as attacking it with.
[and so on]

现在 Inform 会自动询问“你想用什么攻击/击中/杀死龙?” 取决于玩家使用的动词。

这也比最初的“代替”方法要好得多,因为现在玩家可以只用一个词(“>剑”)来回答问题——如果他们用代替规则来回答,解析器就不会理解他们的意思的意思。

于 2019-08-03T17:31:25.507 回答