将任务添加到我的游戏中

Adding Quests to my game

本文关键字:游戏 我的 任务 添加      更新时间:2023-09-26

我终于决定在我的游戏中添加任务。我希望这些任务彼此独立。也许稍后一个,一个人在访问之前完成了另一个任务。无论如何。

我该怎么做?我想了很多。我是一个PHP/Javascript/Mysqli的人。

你和一个NPC交谈,如果你选择了正确的"答案",他们就会开始任务。你完成任务,你可能必须与其他NPC交谈。这一切都取决于。如何存储对话并显示它们?

谢谢。

编辑

这就是我"做"的。

var people = [];
people[1]=['name'=>'Joe'];
people[1]['questions'][1] = 'Why, hello there';
people[1]['questions'][1]['send'] = 1;
people[1]['questions'][2] = 'My name is Joe, You seem to be new around here';
people[1]['questions'][2]['send'] = 2;
people[1]['questions'][3] = 'Why certainly! How about I send you on a quest to help you.  It will get you aquainted with Corgate';
people[1]['questions'][3]['send'] = makequest(1);
people[1]['answers'][1] = array('Hello, who are you?');
people[1]['answers'][1]['send'] = 2;
people[1]['answers'][2] = array("I'm not new! Good bye!",'Yes I am, Can you help me?');
people[1]['answers'][2]['send'][1] = 3;
people[1]['answers'][2]['send'][2] = endthis();

很草率。是的。基本上,它从问题开始。然后"发送"带有该 ID 的答案。然后,基于所选答案数组之一,然后将其发送到相应的问题。

我基本上会用数据库中的表来做。

如果对话都是线性的,你可以搜索下一个NPC的回应

SELECT NPC.response WHERE NPC.previous = ? AND NPC.player_response = ?

其中?是NPC最后说的话,以及玩家的反应。

如果玩家选择了"错误"的响应,则没有任何内容与查询匹配,NPC将保持沉默。