Stendhal Quest Coding - Part 3: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Kymara |
imported>Kymara |
||
| Line 136: | Line 136: | ||
== Quest Information Methods == |
== Quest Information Methods == |
||
These are used for the travel logs and other parts of the game which refer to quests - e.g. the achievement for completing all quests in Semos needs the region to be set for quests in Semos city, to be able to find them. |
These are used for the travel logs and other parts of the game which refer to quests - e.g. the achievement for completing all quests in Semos needs the region to be set for quests in Semos city, to be able to find them. These standard methods give meta information about the quest which is accessible to other parts of the Stendhal code. |
||
| ⚫ | |||
{{TODO| fill in description, help and examples on methods below and add missing methods by checking abstract quest}} |
|||
This fills in the quest history in the travel log. It is basically a list of steps in the quest in readable form. It starts with an empty list and then checks the state of the player. The list is added to if the player has completed that step. Finally the list is returned at the end. |
|||
<source lang = "java"> |
|||
@Override |
|||
public List<String> getHistory(final Player player) { |
|||
final List<String> res = new ArrayList<String>(); |
|||
if (!player.hasQuest(QUEST_SLOT)) { |
|||
return res; |
|||
} |
|||
res.add("I have talked to Hayunn."); |
|||
final String questState = player.getQuest(QUEST_SLOT); |
|||
if ("rejected".equals(questState)) { |
|||
res.add("I do not want to make Hayunn drunk."); |
|||
} |
|||
if (player.isQuestInState(QUEST_SLOT, "start", "done")) { |
|||
res.add("I promised to buy him a bear from Margaret in Semos Tavern."); |
|||
} |
|||
if (("start".equals(questState) && player.isEquipped("beer")) || "done".equals(questState)) { |
|||
res.add("I have a bottle of beer."); |
|||
} |
|||
if ("done".equals(questState)) { |
|||
res.add("I gave the beer to Hayunn. He paid me 20 gold coins and I got some experience."); |
|||
} |
|||
return res; |
|||
} |
|||
</source> |
|||
There are a few ways to check the states. Some developers use ChatConditions like we did when setting the NPC conversation. Others use more direct checks on the quest state. If using ChatConditions, these have been written to work with the add method for the NPC. If you just want to use them to get a true/false value directly, , you need to get at the 'fire', for example <code>(new() QuestCompletedCondition(QUEST_SLOT).fire(player, null, null)</code>. |
|||
| ⚫ | |||
=== getRegion === |
=== getRegion === |
||
| Line 160: | Line 190: | ||
</source> |
</source> |
||
Reference functions that gather 'meta' information about the quest use this - for example if an NPC wants to list which NPCs to speak to to start quests in a certain region. |
Reference functions that gather 'meta' information about the quest use this - for example if an NPC wants to list which NPCs to speak to to start quests in a certain region. |
||
| ⚫ | |||
| ⚫ | |||
== Further Reading and Complete Code == |
== Further Reading and Complete Code == |
||