Stendhal Quest Coding: Difference between revisions

From Arianne
Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
added sections
imported>Hendrik Brummermann
introduction
Line 2: Line 2:
{{Navigation for Stendhal Contributors}}
{{Navigation for Stendhal Contributors}}
{{Stendhal Quests}}
{{Stendhal Quests}}

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




Line 12: Line 14:
This page describes how to code a quest. You don't need to know a lot about Java. You should, however, already have [[Configure a development environment (IDE)|setup an IDE]] and be able to compile and start a local Stendhal server.
This page describes how to code a quest. You don't need to know a lot about Java. You should, however, already have [[Configure a development environment (IDE)|setup an IDE]] and be able to compile and start a local Stendhal server.


This tutorial assumes that the new quest only uses NPCs and items that already exist in Stendhal.


== Creating a quest skeleton ==
== Creating a quest skeleton ==

Revision as of 23:53, 18 November 2009


Stendhal Quests

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.


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

Before you start

This page describes how to code a quest. You don't need to know a lot about Java. You should, however, already have setup an IDE and be able to compile and start a local Stendhal server.

This tutorial assumes that the new quest only uses NPCs and items that already exist in Stendhal.

Creating a quest skeleton

This tutorial is based on the quest "Beer For Hayunn". As this quest already exists, you may want to delete the java file locally in order to follow this tutorial.

Quest files are put into the package games.stendhal.server.maps.quests. (If you are new to Java: this refers to the folder stendhal/src/games/stendhal/server/maps/quests).

Please create a new file in that folder called BeerForHayunn.java. (Note: The upper / lower case spelling is important, even on Microsoft Windows):

<source lang="java"> package games.stendhal.server.maps.quests;

import games.stendhal.server.entity.npc.*; import games.stendhal.server.entity.npc.action.*; import games.stendhal.server.entity.npc.condition.*; import games.stendhal.server.entity.player.*; import java.util.*;

public class BeerForHayunn extends AbstractQuest {

public static final String QUEST_SLOT = "beer_hayunn";

@Override public void addToWorld() { super.addToWorld(); }

@Override public String getSlotName() { return QUEST_SLOT; }

@Override public String getName() { return "BeerForHayunn"; } } </source>

Don't worry, if you don't understand a word of this. We will explain and extend this skeleton in the following sections.

In order for the Stendhal server to pick up this file, it has to be registered in the file StendhalQuestSystem.java in the package games.stendhal.server.core.rp by adding two lines at the appropriate places:

<source lang="java"> import games.stendhal.server.maps.quests.BeerForHayunn;

// [...]

loadQuest(new BeerForHayunn()); </source>


Teaching the NPC to talk

  • addReplay

Teaching the NPC to ask the player whether he will do the quest

  • add with states
  • very basic introduction to FSM

Teaching the NPC to remember the player

  • ChatAction
  • ChatCondition

Rewarding the player

  • MultiAction

== Further Reading