Thread: Good way for dialogues? or OTT

Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1 Good way for dialogues? or OTT 
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    660
    Discord
    View profile
    Rep Power
    5000
    (OTT Being over the top)

    Contains;

    • Different Dialogue Types
    • Multi Lines
    • Continous Chat
    • Adding Items
    • Action Adding

    Just the basics so far, just wondering if I am over complicating it ?

    Code:
    package com.acheron.model;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.util.LinkedHashMap;
    import java.util.List;
    import java.util.Map;
    
    import com.acheron.util.XStreamUtil;
    import com.acheron.util.log.Logger;
    
    public class Dialogue {
    
        public static class DialogueDefinitions {
    
        public static enum actionType {
            ADD_ITEM,
        }
    
        public static enum dialogueType {
            STANDARD, OPTIONS,
        }
    
        @SuppressWarnings("unchecked")
        public static void load() throws FileNotFoundException {
            final List<DialogueDefinitions> defs = (List<DialogueDefinitions>) XStreamUtil
                .getXStream().fromXML(
                    new FileInputStream("data/dialogues.xml"));
    
            for (DialogueDefinitions def : defs) {
            Dialogue.dialogues.put(def.getDialogueId(), def);
            }
    
            Logger.getInstance().info(
                "Loaded " + Dialogue.dialogues.size() + " dialogues.");
    
        }
    
        private dialogueType type = dialogueType.STANDARD;
        private actionType action = actionType.ADD_ITEM;// For adding
        private Item[] toAdd;// Adding item maybe?
    
        private String[] lines;// Default :)
        private int[] actions; // Actions if OPTIONS Type.
    
        private boolean continous = false; // Continous is false.
    
        private int numberOfLines = 1; // Default as 1 :)
    
        private int dialogueId = 0; // Dialogue Id :)
        private int continousId = 1; // Continous id :)
    
        private int chatboxId = 0; // Chatbox Id
    
        private int[] index;// Lines IDs :)
    
        public actionType getAction() {
            return action;
        }
    
        public int[] getActions() {
            return actions;
        }
    
        public int getChatboxId() {
            return chatboxId;
        }
    
        public int getContinousId() {
            return continousId;
        }
    
        public int getDialogueId() {
            return dialogueId;
        }
    
        public int[] getIndex() {
            return index;
        }
    
        public String[] getLines() {
            return lines;
        }
    
        public int getNumberOfLines() {
            return numberOfLines;
        }
    
        public Item[] getToAdd() {
            return toAdd;
        }
    
        public dialogueType getType() {
            return type;
        }
    
        public boolean isContinous() {
            return continous;
        }
    
        public void setAction(actionType action) {
            this.action = action;
        }
    
        public void setActions(int[] actions) {
            this.actions = actions;
        }
    
        public void setChatboxId(int chatboxId) {
            this.chatboxId = chatboxId;
        }
    
        public void setContinous(boolean continous) {
            this.continous = continous;
        }
    
        public void setContinousId(int continousId) {
            this.continousId = continousId;
        }
    
        public void setDialogueId(int dialogueId) {
            this.dialogueId = dialogueId;
        }
    
        public void setIndex(int[] index) {
            this.index = index;
        }
    
        public void setLines(String[] lines) {
            this.lines = lines;
        }
    
        public void setNumberOfLines(int numberOfLines) {
            this.numberOfLines = numberOfLines;
        }
    
        public void setToAdd(Item[] toAdd) {
            this.toAdd = toAdd;
        }
    
        public void setType(dialogueType type) {
            this.type = type;
        }
    
        }
    
        private static final Map<Integer, DialogueDefinitions> dialogues = new LinkedHashMap<Integer, DialogueDefinitions>();
    
        public static DialogueDefinitions getDialogue(int dialogue) {
        DialogueDefinitions def = dialogues.get(dialogue);
        return def;
        }
    
        private transient Player player;
    
        private transient DialogueDefinitions current;
    
        public DialogueDefinitions getCurrent() {
        return current;
        }
    
        public Player getPlayer() {
        return player;
        }
    
        public void setCurrent(DialogueDefinitions def) {
        current = def;
        }
    
        public void setPlayer(Player player) {
        this.player = player;
        }
    
    }
    XML:
    Code:
    <list>
        <dialogue>
            <dialogueId>0</dialogueId>
            <numberOfLines>4</numberOfLines>
            <continous>false</continous> <!-- If true you must have continousId set :) -->
            <type>STANDARD</type><!-- Standard woo :) -->
            <action>ADD_ITEM</action><!-- Testing :) -->
            <toAdd>
                <item>
                    <id>995</id>
                    <amount>100</amount>
                </item>
            </toAdd>
            <lines>
                <string>Welcome to Acheron!</string> <!-- Must match numberOfLines -->
                <string>playername</string>
                <string>Enjoy your stay!</string>
                <string>Latest Update: Dialogues</string>
            </lines>
            <chatboxId>368</chatboxId> <!-- Four lines - Click here to continue -->
            <index>
                <int>369</int> <!-- Must match numberOfLines -->
                <int>370</int>
                <int>371</int>
                <int>372</int>
            </index>
        </dialogue>
        <!-- 
        <chatboxId>368</chatboxId> Fours Lines click here to continue
        <int>369</int>
        <int>370</int>
        <int>371</int>
        <int>372</int>
        
        <chatboxId>363</chatboxId> Three lines click here to continue
        <int>364</int>
        <int>365</int>
        <int>366</int>    
        
        <chatboxId>359</chatboxId> Two lines click here to continue
        <int>360</int>
        <int>361</int>
        
        <chatboxId>356</chatboxId> One line click here to continue
        <int>357</int>    
         -->
    </list>
    Code:
    if (buttonId == 358) {
            DialogueHandling dia = new DialogueHandling();
            // Dont want this in switch;
            DialogueDefinitions def = player.getDialogue().getCurrent();
            if (def == null) {
            player.getActionSender().sendRemoveAllWindows();
            return;
            }
            dia.handleDialog(def, player);
            return;
        }
    Code:
    package com.acheron.packethandler.dialogues;
    
    import com.acheron.model.Dialogue;
    import com.acheron.model.Player;
    import com.acheron.model.Dialogue.DialogueDefinitions;
    
    public class DialogueHandling {
    
        public void handleDialog(DialogueDefinitions def, Player player) {
        player.getDialogue().setCurrent(null);// No need to keep reference
        // anymore
        if (def.isContinous()) {
            player.getActionSender().sendDialogue(
                Dialogue.getDialogue(def.getContinousId()));
            return;// Yet to configure.
        }
        // Else close all windows.
        player.getActionSender().sendRemoveAllWindows();
    
        // Maybe reset All Strings to "";
        int[] index = def.getIndex();
        if (index.equals(null)) {
            return;
        }
        for (int i : index) {
            player.getActionSender().sendString("", i);
        }
        }
    
    }
    Ignore what I use for my chatbox things (Thanks to peterbjornx for his interface editor)
    Reply With Quote  
     

  2. #2  
    Registered Member


    Join Date
    Jul 2007
    Posts
    4,133
    Thanks given
    789
    Thanks received
    2,716
    Rep Power
    5000
    nice I might use this as mine are fucked up
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    Seems good to me, gl finishing
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    660
    Discord
    View profile
    Rep Power
    5000
    Thanks and updated it ~
    Reply With Quote  
     

  5. #5  
    DeclarationOfIndependence
    Guest
    Use a binary, XML takes to long to load.
    Reply With Quote  
     

  6. #6  
     

    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 DeclarationOfIndependence View Post
    Use a binary, XML takes to long to load.
    ATM it takes 1 millisecondth of a millisecond lol
    Reply With Quote  
     

  7. #7  
    DeclarationOfIndependence
    Guest
    Quote Originally Posted by Squire Michael View Post
    ATM it takes 1 millisecondth of a millisecond lol
    Item definitions loading with XML in RS2HD takes pretty long to load.
    Reply With Quote  
     

  8. #8  
     

    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 DeclarationOfIndependence View Post
    Item definitions loading with XML in RS2HD takes pretty long to load.
    Already into Binary same with NPC Def's
    Reply With Quote  
     

  9. #9  
    Registered Member Paketa's Avatar
    Join Date
    Oct 2007
    Posts
    2,681
    Thanks given
    17
    Thanks received
    82
    Rep Power
    680
    Wow this is excellent, I was trying to find a good way to handle dialogues too. Oh and doesn't RS2HD have something like this?

    ps have you handled the face expressions or whatever when the npc talks?
    Reply With Quote  
     

  10. #10  
     

    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 Vigan20 View Post
    Wow this is excellent, I was trying to find a good way to handle dialogues too. Oh and doesn't RS2HD have something like this?

    ps have you handled the face expressions or whatever when the npc talks?
    Not yet I am working on faces and RS2HD doesnt have dialogue yet I believe.
    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

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