Thread: [90% Noob Friendly] Ninjas Quest Library - A server independent quest scripting API.

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 [90% Noob Friendly] Ninjas Quest Library - A server independent quest scripting API. 
    Registered Member

    Join Date
    Oct 2009
    Posts
    149
    Thanks given
    4
    Thanks received
    20
    Rep Power
    97

    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
    Reply With Quote  
     


  2. #2  
    Registered Member

    Join Date
    Oct 2009
    Posts
    149
    Thanks given
    4
    Thanks received
    20
    Rep Power
    97
    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):
    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;
    	}
    
    }
    A pretty simple and easygoing piece of code, yeah?

    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":
    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;
    	}
    
    }
    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:
    	public int getCompletionState() {
    		return 2;
    	}
    Ok now to the hardest, yet still simple part of constructing a quest. Setting & Registering events.

    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)
    Code:
    	public void init() {
    		this.registerEvent(STATE, EVENT);
    	}
    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 many
    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:
    Code:
    	public void init() {
    		this.registerEvent(0, EVENT);
    	}
    Now we must find an appropriate event within the API, at the moment however the only finished event is NpcDialogueEvent.
    Here is what you have to fill in when using this event:
    Code:
    	new NpcDialogueEvent(this, EVENT_NAME, ADVANCE, NPC_ID, DIALOGUE);
    The parts highlighted in green are what you always add for this event, and the parts highlighted in yellow are those of which
    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:
    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 },
    	});
    So now that I've added my two events my init() method looks like this:
    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!!!" },
    		}));
    	}
    Notice that because the first event is set to true for advancing, I can then make events for the next quest state.

    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:
    Code:
    import server.model.players.Client;
    Followed by altering our completion method:
    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!");
    	}
    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.

    And there you go! That is a quest easily constructed using this API.

    PLEASE post your comments, feedback and questions on this post!
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member

    Join Date
    Oct 2009
    Posts
    149
    Thanks given
    4
    Thanks received
    20
    Rep Power
    97
    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.

    Reply With Quote  
     

  5. #4  
    Banned
    Join Date
    Apr 2011
    Posts
    801
    Thanks given
    66
    Thanks received
    84
    Rep Power
    0
    Sounds cool good luck
    Reply With Quote  
     

  6. #5  
    Banned
    Join Date
    Jan 2010
    Posts
    26
    Thanks given
    0
    Thanks received
    3
    Rep Power
    0
    The "syntax highlighting" made me giggle.
    Reply With Quote  
     

  7. #6  
    Registered Member

    Join Date
    Oct 2009
    Posts
    149
    Thanks given
    4
    Thanks received
    20
    Rep Power
    97
    Quote Originally Posted by Project Fallout View Post
    The "syntax highlighting" made me giggle.
    The highlighting represents things that have or will be changed/modified you moron. It isn't syntax highlighting.
    Reply With Quote  
     

  8. #7  
    Banned
    Join Date
    Apr 2011
    Posts
    801
    Thanks given
    66
    Thanks received
    84
    Rep Power
    0
    Wow dude that looks really good I might use it when you are done.
    Reply With Quote  
     

  9. #8  
    Registered Member

    Join Date
    Oct 2009
    Posts
    149
    Thanks given
    4
    Thanks received
    20
    Rep Power
    97
    Quote Originally Posted by Piranhas View Post
    Wow dude that looks really good I might use it when you are done.
    That's the idea
    Reply With Quote  
     

  10. #9  
    Registered Member

    Join Date
    Dec 2009
    Posts
    1,142
    Thanks given
    275
    Thanks received
    169
    Rep Power
    164
    I'd like to see an example of this implemented this on a real quest, such as [Only registered and activated users can see links. ]
    Reply With Quote  
     

  11. #10  
    Registered Member Ryan Rebelle's Avatar
    Join Date
    Nov 2009
    Age
    26
    Posts
    1,149
    Thanks given
    108
    Thanks received
    57
    Rep Power
    41
    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:
    Code:
    /**
     * @author Rebelle
     * @date 7/7/2011
     */
    public class CooksAssistant {
    	/**
    	 * Information displayed via quest interface
    	 */
    	public static final void QUEST_INFO(client client) {
    	}
    	/**
    	 * All rewards from the quest; items, experience, etc.
    	 */
    	public static final void QUEST_REWARD(client client) {
    	}
    	/**
    	 * Class Variables
    	 */
    	public static final int QUEST_ID = 0;
    	public static final String QUEST_NAME = "Cook's Assistant";
    	public static int QUEST_PROGRESS = 0;
    	public static final int[][] QUEST_ITEM_REWARD = {
    		{995, 1}
    	};
    	public static final int[][] QUEST_EXP_REWARD = {
    		{1, 0}
    	};
    }


    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"


    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 68
    Last Post: 08-30-2016, 11:36 PM
  2. Replies: 96
    Last Post: 07-30-2010, 08:46 PM
  3. Replies: 0
    Last Post: 11-14-2009, 06:22 PM
  4. Replies: 7
    Last Post: 08-09-2009, 09:06 AM
  5. Noob Friendly Quest Stage, Other Stuff
    By Mrquarterx in forum Tutorials
    Replies: 22
    Last Post: 08-31-2008, 02:02 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •