|
|

This is postponed atm because I started working on a 647 server, spending all my time working on that atm (But once I've achieved far enough I can implement this into that =))
What is Ninjas Quest Library?
Ninjas Quest Library is a library designed to be applicable to ANY server, which handles all the hard things that involve controlling quests.
Of course being this not constructed around any single server base, someone of more expertise would have to do out the implementation
to a specific server base before the newbies can make a quest. But once the implementation has been done, constructing your very own,
completely custom quest becomes easier than designing the quest itself.
What is the goal of Ninjas Quest Library?
The goal of this library is simple, a while ago you used to see lots of creative server owners customizing their servers to be how
THEY wanted them to be. But now, your typical PI server has rock crabs training, then a Slayer tower teleport, then a taverly dungeon
teleport, etc. and its just becoming impossible to find a server with uniqueness nowadays. So the goal of this library is to get server owners
to write their own quests using this simple API and have their servers be customized to a fair point rather than the entire thing just be leeched.
What can Ninjas Quest Library do?
Ninjas Quest Library is designed to handle all of the complex coding behind managing an infinite amount of quests; so that you, a simple user
are able to make their own quests with ease. The library will handle all possible events (to the point of which it is able to) that you may
encounter during a quest, for example: Talking to an npc, using two items together, talking to another npc. Hell if you really wanted
to you could make a dud quest that just stops non-donors from wearing a certain item(It's possible!), this is because the a quest written in
this API is given full access to perform actions when a player does any basic things, like talking to an npc, wearing an item, clicking
on a crate, attacking another player, using another item, etc. The possibilities are extensively ranged.
So, how does Ninjas Quest Library work?
Well, once this library has been implemented into a given server; it will search through a specific folder for compiled quests files,
and then dynamically loads them into the server for using. This also adds the possibility of modifying quests without the need
to restart the server as they could just be reloaded; however, this is not recommended as the given quest state system
would cause quest skips/rollbacks if you were to add or remove events from a quest.
Once quests are loaded, and players are playing on the server. As players perform things such as eating some food, making a potion, cleaning some herbs,
closing a door, etc. if implemented correctly, the Library will automatically browse through all of your loaded quest files to check if the player has
done something relevant to a quest. If the player has in fact done something relevant to the quest the event associated with what the player
did will be executed. Then, if the event is set to increase the players quest progress once it is done; the quest progress for that player
will be incremented so that new events can be completed. This continues until the players quest progress reaches the finishing state of
a specific quest, in which a method inside your quest class is performed called 'onQuestCompletion' for you to do whatever you want
with the player at hand, whether it be to give access to ancients, take away remaining quest items or instantly get level 99 in a skill.
Progress:
Red - Not started, but to be completed in the future
Yellow - Not started, but being considered.
Orange - Completed or in completion, but being reconsidered
YellowGreen - All up and running, but things are sure to be modified with various updates.
Green - All up and running, ready for final release.
QuestHandler:
Dynamically loading quests
Saving quest progress
Loading quest progress
Handling events for quests
Quest Event Related:
Quest states(Progress per player)
Event sorting
Multiple events per quest state
Event handling
More events to be used
Quest API:
Registering events
Completion checking & handling
Manual usage of player actions
Events:
Action Button Event
Item On Item Event
Item Use Event
Npc Dialogue Event
Npc Drop Event
Npc Kill Event
Click Object Event
More to be added

So how do I create a quest with this? DO take note that this is a project, and therefore a WIP. Which mean's this IS NOT finished.
To create a quest with this API(Though it hasn't been released yet) you start off with the following template for a quest file(Java):
A pretty simple and easygoing piece of code, yeah?Code:import org.mcmods.questsystem.Quest; import org.mcmods.questsystem.events.*; public class TemplateQuest extends Quest { // Quest's start at state 0 by default, you may register // as many events for one state as you want. Whether the // quest state will move forward will be dependant on // the individual event. Most often there will be an // initializing boolean as to whether or not the quest // state is incremented after the specific event is completed. // Register quest events public void init() { } // Name of the quest, not neccessarily the // name of this java class. public String getName() { return "Quest Template"; } // Code to be executed on completion of this // quest. public void onCompletion(Object client) { } // Returns at what quest state the quest // is finished. Default 1. public int getCompletionState() { return 1; } }
Well it doesn't get much harder then that, from here on out you just need to change the name of the quest, what quest state it finishes at, add some events to it and do something when its finished.
So let's get started on naming the quest, I've decided to name mine "Something Simple":
And now to change the completion state of our quest, for this example I'm only going to have two NPC dialogue events, so I'll set it to 2:Code:import org.mcmods.questsystem.Quest; import org.mcmods.questsystem.events.*; Notice how I haven't changed the class name. This is because, as I said in the first post, the name of the class is not used as the in-server quest name, So it can be whatever you want. public class TemplateQuest extends Quest { public void init() { } public String getName() { return "Something Simple"; } public void onCompletion(Object client) { } public int getCompletionState() { return 1; } }
Ok now to the hardest, yet still simple part of constructing a quest. Setting & Registering events.Code:public int getCompletionState() { return 2; }
Using the registerEvent method itself is no harder than anything else, there is just more to do.
Here is how the registerEvent method is used: (NOTE all registering must be done inside the init() method)
Now for the event state, this should always begin at 0, and increment by 1 per part of the quest. Remember that you may have as manyCode:public void init() { this.registerEvent(STATE, EVENT); }
events at one quest state as you like, just remember to make sure only 1 will increase the quest progress. For this first event we put 0:
Now we must find an appropriate event within the API, at the moment however the only finished event is NpcDialogueEvent.Code:public void init() { this.registerEvent(0, EVENT); }
Here is what you have to fill in when using this event:
The parts highlighted in green are what you always add for this event, and the parts highlighted in yellow are those of whichCode:new NpcDialogueEvent(this, EVENT_NAME, ADVANCE, NPC_ID, DIALOGUE);
you need to change every time you add a new event, here are explanations:
EVENT_NAME - Events which take this argument do so because they save temporary numbers on the server which are used in the event,
so just give these a name that no other event in the current quest has. Events in separate quests though may have the same name as they are stored separately.
ADVANCE - This will be in all events, this is either true or false. As you may have guessed, if it is set to true it will advance the players progress
in the quest once the entire event has been completed(e.g. Using final quest item on an object) and if it is set to false it will not advance the
players quest progress once the event is completed(e.g. A npc that gives information on what to do).
NPC_ID - This is extremely straightforward, the ID of the npc who says this dialogue.
DIALOGUE - This is the trickiest part to explain in this example, the dialogue event takes a 2-dimensional String. However, this is aimed at
any level of expertise so for this just fill it in like this, which makes it nice and easy to comprehend:
So now that I've added my two events my init() method looks like this:Code:NpcDialogueEvent(everything else, new String[][] { { "For every section of text", "that you want to display" }, { "Place a new one of these", "lines and fill text in", "appropriately" }, { "You may have", "no more than", "five sections", "of writing", "per line" }, { "And make sure that you place the brackets and a comma at the end of each line }, });
Notice that because the first event is set to true for advancing, I can then make events for the next quest state.Code:public void init() { this.registerEvent(0, new NpcDialogueEvent(this, "start_quest", true, 555, new String[][] { { "You just started a quest" }, { "Talk to me again to finish it" }, })); this.registerEvent(1, new NpcDialogueEvent(this, "start_quest", true, 555, new String[][] { { "Congratulations you just finished", "the hardest runescape quest", "ever!!!" }, })); }
And now that you've got everything else for the quest done, you can now altar the completion process to give the player something.
For this example I will give the player 1000 gold and send them a congratulations message using a typical PI server. First we import Client:
Followed by altering our completion method:Code:import server.model.players.Client;
Because the API is not built for a single server, we need to do this so that we can use methods and variables inside the Client class.Code:public void onCompletion(Object client) { Client c = (Client)client; c.getItems().addItem(995, 1000); // Add 1000 coins c.sendMessage("Congratulations! You've completed the Something Simple quest!"); }
And there you go! That is a quest easily constructed using this API.
PLEASE post your comments, feedback and questions on this post!

Event Updates & Changelog!
9/7/2011
- Added support for custom quest directories
- Fixed a minor bug in QuestHandler
- Cleaned up the Quest class, implementing cleaner methods.
- Added support for global events. This means that a global event can be triggered at any quest state. However, a global event may not trigger an increase in quest progress.
- Finished converting all possible event checkers to return true or false, true if they found a match and false if they did not.
- Added support for Quest Engine "Quest" classes. This allows users to use a "Quest" to globally effect things in-game. For example, the Cook's Assistant quest would need a Quest Engine to handle milling and milking cows.
- Added support for reloading quests during runtime, this will allow dynamically update quests without the need for a restart. However, this is designed only for quest testing purposes and should not be used once a quest is released.
Sounds cool good luck
The "syntax highlighting" made me giggle.

Wow dude that looks really good I might use it when you are done.![]()


this looks like a pretty neat idea, and i'm not just saying that because i thought about the same thing within the last 24-or-so-hours
Spoiler for spoiler:
no doubt yours will be more professional though; goodluck![]()
Last edited by Ryan Rebelle; 07-08-2011 at 09:33 AM. Reason: "and i'm not just saying"

| « Would anyone download a Completely revamped PI source? | Physic-X Project and Update Thread » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |