Stendhal Quest Coding: Difference between revisions

From Arianne
Jump to navigation Jump to search
imported>Hendrik Brummermann
skeletton
imported>Hendrik Brummermann
skeletton
(No difference)

Revision as of 23:49, 18 November 2009


Stendhal Quests


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


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.


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>