Thread: My Improved Dialogue System

Results 1 to 7 of 7
  1. #1 My Improved Dialogue System 
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    660
    Discord
    View profile
    Rep Power
    5000
    Well I might aswell just explain it.

    I rewrote my old one as I wasn't very interested in it and it looked fairly bland.

    So I rewrote it and these are its features (Soon to be I just gotta finish up):
    • XML Loading - Seperate Files
    • MultipleOptions
    • Stores in a HashMap
    • Dialogues are stored in a List
    • Adding Items
    • Teleporting
    • Deleting Items
    • Graphics
    • Emotes
    • Continous
    • Show Interface
    • Many more...


    And now to the files:
    First we have the DialogueManager, I have yet to finish this as at the moment I basically use it just for the loading of the dialogues

    Code:
    package com.the_acheron.util;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.util.LinkedList;
    import java.util.List;
    
    import com.the_acheron.model.Dialogue;
    import com.the_acheron.util.log.Logger;
    
    public class DialogueManager {
    
        private static List<Dialogue> dialogues = new LinkedList<Dialogue>();
    
        public static void openDialogue(int dialogueId) {
    	Dialogue def = dialogues.get(dialogueId);
    	if (def != null) {
    
    	}
        }
    
        public static void load() throws Exception {
    	List<Dialogue> defs = new LinkedList<Dialogue>();
    
    	File directory = new File("./data/dialogues");
    
    	String[] files = directory.list();
    
    	for (String loc : files) {
    	    if (loc.endsWith(".xml")) {
    		Dialogue def = (Dialogue) XStreamUtil.getXStream().fromXML(
    			new FileInputStream("./data/dialogues/" + loc));
    		defs.add(def);
    		System.out.println("Def: "
    			+ def.getActionsLinked().get(20).getActionButtonId());
    	    }
    	}
    	dialogues.addAll(defs);
    	Logger.getInstance().info(
    		"Loaded " + dialogues.size() + " dialogue definitions.");
        }
    
    }
    Ignore the System.out.println message.

    The Dialogue Class:
    This is the main part of the DialogueSystem without this it wouldn't work.
    Code:
    package com.the_acheron.model;
    
    import java.util.HashMap;
    import java.util.Map;
    
    public class Dialogue {
    
        /**
         * Where Object[][] is the todo action and Integer is the id of the action.
         * With a maximum of 10 actions.
         */
        private Map<Integer, DialogueConfiguration> actionsLinked = new HashMap<Integer, DialogueConfiguration>(
    	    10);
    
        private String[] dialogueStrings;
    
        private int chatboxId;
    
        private Integer[] dialogueIntegers;
    
        public void setDialogueStrings(String[] dialogueStrings) {
    	this.dialogueStrings = dialogueStrings;
        }
    
        public String[] getDialogueStrings() {
    	return dialogueStrings;
        }
    
        public void setDialogueIntegers(Integer[] dialogueIntegers) {
    	this.dialogueIntegers = dialogueIntegers;
        }
    
        public Integer[] getDialogueIntegers() {
    	return dialogueIntegers;
        }
    
        public void setChatboxId(int chatboxId) {
    	this.chatboxId = chatboxId;
        }
    
        public int getChatboxId() {
    	return chatboxId;
        }
    
        public void setActionsLinked(
    	    Map<Integer, DialogueConfiguration> actionsLinked) {
    	this.actionsLinked = actionsLinked;
        }
    
        public Map<Integer, DialogueConfiguration> getActionsLinked() {
    	return actionsLinked;
        }
    
    }
    DialogueAction enum, speaks for itself:
    Code:
    package com.the_acheron.model;
    
    public enum DialogueAction {
    
        TELEPORT, CONTINOUS, ADD_ITEM, DELETE_ITEM, CLOSE, SHOW_INTERFACE, EMOTE, GRAPHIC
    
    }
    Finally, DialogueConfiguration class:
    Code:
    package com.the_acheron.model;
    
    
    public class DialogueConfiguration {
    
        private DialogueAction[] actionsToBeCompleted;
    
        private Item[] itemsToAdd;
    
        private Location[] teleportLocation;
    
        private int actionButtonId;
    
        private boolean continousDialogue;
        private int nextDialogueId;
    
        public void setActionsToBeCompleted(DialogueAction[] actionsToBeCompleted) {
    	this.actionsToBeCompleted = actionsToBeCompleted;
        }
    
        public DialogueAction[] getActionsToBeCompleted() {
    	return actionsToBeCompleted;
        }
    
        public void setItemsToAdd(Item[] itemsToAdd) {
    	this.itemsToAdd = itemsToAdd;
        }
    
        public Item[] getItemsToAdd() {
    	return itemsToAdd;
        }
    
        public void setTeleportLocation(Location[] teleportLocation) {
    	this.teleportLocation = teleportLocation;
        }
    
        public Location[] getTeleportLocation() {
    	return teleportLocation;
        }
    
        public void setActionButtonId(int actionButtonId) {
    	this.actionButtonId = actionButtonId;
        }
    
        public int getActionButtonId() {
    	return actionButtonId;
        }
    
        public void setContinousDialogue(boolean continousDialogue) {
    	this.continousDialogue = continousDialogue;
        }
    
        public boolean isContinousDialogue() {
    	return continousDialogue;
        }
    
        public void setNextDialogueId(int nextDialogueId) {
    	this.nextDialogueId = nextDialogueId;
        }
    
        public int getNextDialogueId() {
    	return nextDialogueId;
        }
    
    }
    Any questions?

    Also suggest what to do next...

    Edit:

    An example XML File:
    Code:
    <dialogue>
    	<actionsLinked>
    		<hashMap>
    			<int>20</int>
    			<dialogueConfiguration>
    				<actionsToBeCompleted>
    					<dialogueAction>ADD_ITEM</dialogueAction>
    					<dialogueAction>TELEPORT</dialogueAction>
    					<item>
    						<id>995</id>
    						<amount>100</amount>
    					</item>
    					<location>
    						<x>3222</x>
    						<y>3222</y>
    						<z>0</z>
    					</location>
    				</actionsToBeCompleted>
    				<actionButtonId>20</actionButtonId>
    			</dialogueConfiguration>
    		</hashMap>
    	</actionsLinked>
    </dialogue>
    Reply With Quote  
     

  2. #2  
    Oxygen
    Guest
    Pics?
    Reply With Quote  
     

  3. #3  
    Registered Member
    ViperSniper's Avatar
    Join Date
    Apr 2007
    Age
    27
    Posts
    2,417
    Thanks given
    367
    Thanks received
    82
    Rep Power
    976
    Quote Originally Posted by Oxygen View Post
    Pics?
    you really want pictures of Dialogue?

    On topic:
    Better than my way.
    :indeed:
    Reply With Quote  
     

  4. #4  
    Oxygen
    Guest
    Quote Originally Posted by ViperSniper View Post
    you really want pictures of Dialogue?

    On topic:
    Better than my way.
    Well yeah, he said it's 'improved'. Really depends, is it 'improved' visually or just the method?
    Reply With Quote  
     

  5. #5  
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    660
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Oxygen View Post
    Well yeah, he said it's 'improved'. Really depends, is it 'improved' visually or just the method?
    Its not complete so I can't really send pictures.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jul 2008
    Posts
    286
    Thanks given
    17
    Thanks received
    4
    Rep Power
    2
    It's kinda good.. loading dialogue's from XML is a clean and good way to handle a dialogue system instead of all those other servers with like billions of dialogue voids or cases, and half of them isn't even being used..

    but anyway.. nice.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Teemuzz's Avatar
    Join Date
    Oct 2009
    Posts
    2,710
    Thanks given
    1,132
    Thanks received
    400
    Rep Power
    701
    ncie.
    I'm back.
    ScapeEmulator #592 Convert [Only registered and activated users can see links. ]/[Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •