Stendhal Quest Coding - Part 3: Difference between revisions

From Arianne
Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
imported>Hendrik Brummermann
No edit summary
Line 17: Line 17:
== Rewarding the player ==
== Rewarding the player ==


In the last section of this tutorial we taught Hayunn to only accept one beer per player. We did neither care about taking the beer from the player nor did we reward the player. We want to add this functionality now.


We have to do several things at once:
{{TODO|
* take the beer from the player
* MultiAction
* provide some money as refund
}}
* increase the xp and karmy
* and finally remember that the quest was completed

But don't worry, that sounds more complicated than it actually is. There are already actions for all of these task that can be combined using a MultiAction:

<source lang="java">
final List<ChatAction> reward = new LinkedList<ChatAction>();
reward.add(new DropItemAction("beer"));
reward.add(new EquipItemAction("money", 20));
reward.add(new IncreaseXPAction(50));
reward.add(new IncreaseKarmaAction(10));
reward.add(new SetQuestAction(QUEST_SLOT, "done"));
npc.add(
ConversationStates.QUEST_ITEM_BROUGHT,
ConversationPhrases.YES_MESSAGES,
new PlayerHasItemWithHimCondition("beer"),
ConversationStates.ATTENDING,
"*glug glug* Ah! That hit the spot. Let me know if you need anything, ok?",
new MultipleActions(reward));
</source>


== Quest Documentation ==
== Quest Documentation ==
Line 27: Line 48:
* should be done much earlier usually
* should be done much earlier usually
* content should be done earlier (see contributor's guide
* content should be done earlier (see contributor's guide
}}

== Advanced Techniques ==

{{TODO|
* AlwaysTrueCondition
}}
}}



Revision as of 16:23, 24 February 2010


Stendhal Quests


This page is currently reworked. You can find the old content on the talk page

You may want to read the first part and second part of the Stendhal Quest Coding tutorial first.

If you have ideas for new quests or are interested in helping to refine quest ideas, please have a look at the Quest Contributor's Guide or the Stendhal Quest Ideas.


Rewarding the player

In the last section of this tutorial we taught Hayunn to only accept one beer per player. We did neither care about taking the beer from the player nor did we reward the player. We want to add this functionality now.

We have to do several things at once:

  • take the beer from the player
  • provide some money as refund
  • increase the xp and karmy
  • and finally remember that the quest was completed

But don't worry, that sounds more complicated than it actually is. There are already actions for all of these task that can be combined using a MultiAction:

<source lang="java">

   final List<ChatAction> reward = new LinkedList<ChatAction>();
   reward.add(new DropItemAction("beer"));
   reward.add(new EquipItemAction("money", 20));
   reward.add(new IncreaseXPAction(50));
   reward.add(new IncreaseKarmaAction(10));
   reward.add(new SetQuestAction(QUEST_SLOT, "done"));
   npc.add(
        ConversationStates.QUEST_ITEM_BROUGHT,
        ConversationPhrases.YES_MESSAGES,
        new PlayerHasItemWithHimCondition("beer"),
        ConversationStates.ATTENDING,
        "*glug glug* Ah! That hit the spot. Let me know if you need anything, ok?",
        new MultipleActions(reward));

</source>

Quest Documentation

TODO:

  • should be done much earlier usually
  • content should be done earlier (see contributor's guide

Advanced Techniques

TODO:

  • AlwaysTrueCondition

Further Reading

TODO: