Thread: Dialogue System(Easy usage)

Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 47
  1. #11  
    Registered Member
    Nando's Avatar
    Join Date
    Feb 2009
    Age
    26
    Posts
    3,518
    Thanks given
    2,437
    Thanks received
    1,107
    Rep Power
    5000
    nice job not using tho


    Reply With Quote  
     

  2. #12  
    :doge:

    Join Date
    Jan 2009
    Posts
    3,759
    Thanks given
    221
    Thanks received
    816
    Rep Power
    2113
    lol a new instance per dialog..
    Reply With Quote  
     

  3. #13  
    Registered Member 'Conner's Avatar
    Join Date
    Aug 2010
    Posts
    578
    Thanks given
    74
    Thanks received
    19
    Rep Power
    22
    Quote Originally Posted by nemesis View Post
    Make a new class to model folder called DialogueQueue
    Code:
    package com.rs2hd.model;
    
    import com.rs2hd.definitionhandling.DefinitionHandler;
    
    public class DialogueQueue {
    	/**
    	*	Whos dialogues are we dealing with?
    	*/
    	private Player player;
    	/**
    	*	The id of dialogue that's currently being displayed
    	*/
    	private int currentId;
    	/**
    	*	Array where all dialogues are stored.
    	*/
    	private Dialogue[] dialogueArray = new Dialogue[100];
    
    	public DialogueQueue(Player player) {
    		this.player = player;
    	}
    	
    	public void add(Dialogue d) {
    		dialogueArray[getId()] = d;
    		display(d);
    	}
    	
    	public void add(Dialogue[] d) {
    		dialogueArray = d;
    		currentId = 0;
    		display(dialogueArray[currentId]);
    	}
    	
    	public Dialogue getNext() {
    		currentId += 1;
    		if(currentId >= dialogueArray.length) {
    			currentId = -1;
    			clear();
    			return null;
    		}
    		display(dialogueArray[currentId]);
    		return dialogueArray[currentId];
    	}
    	
    	public int getId() {
    		for(int i = 0; i < dialogueArray.length;i++) {
    			if(dialogueArray[i] == null) {
    				return i;
    			}
    		}
    		return -1;
    	}
    	public void display(Dialogue d) {
    		if(d.getNpcId() > -1) {
    			String npcName = DefinitionHandler.getNPCDef(d.getNpcId()).getName() == null ? "Unknown" : DefinitionHandler.getNPCDef(d.getNpcId()).getName();
    			player.getActionSender().sendNpcHead(d.getNpcId(), 241, 2);
    			player.getActionSender().sendString(npcName, 241, 3);
    		} else {
    			player.getActionSender().sendString(player.getUsername(), 241, 3);
    			player.getActionSender().sendPlayerHead(241, 2);
    		}
    		player.getActionSender().sendChatboxInterface(241);
    		player.getActionSender().animateInterface(9847, 241, 2);
    		player.getActionSender().sendString(d.getText(), 241, 4);
    	}
    	public void clear() {
    		dialogueArray = null;
    	}
    }
    And a class called Dialogue

    Code:
    package com.rs2hd.model;
    
    public class Dialogue {
    
    	private Player owner;
    	private String text;
    	private int npcId;
    	
    	public Dialogue(Player p, String str, int npcId) {
    		this.owner = p;
    		this.text = str;
    		this.npcId = npcId;
    	}
    	
    	public String getText() {
    		return text;
    	}
    	
    	public int getNpcId() {
    		return npcId;
    	}
    	
    	public Player getOwner() {
    		return owner;
    	}
    }
    Add this to player class:
    Code:
    	/**
    	*	Dialogues
    	*/
    	private transient DialogueQueue dialogueQueue;
    	/**
    	 * Handles player dialogues.
    	 */
    	public DialogueQueue getDialogueQueue() {
    		return dialogueQueue;
    	}
    Declare this where you set constructors:
    Code:
    dialogueQueue = new DialogueQueue(this);
    Add this to where you handle buttons for interfaces/chatboxinterfaces
    Code:
    			case 241:
    				if(button == 5) {
    					player.getActionSender().sendCloseChatboxInterface();
    					player.getDialogueQueue().getNext();
    				}
    				break;
    Have fun.

    Usage:
    Code:
    		player.getDialogueQueue().add(new Dialogue[]{
    		new Dialogue(player, "Hello!",  -1),
    		new Dialogue(player, "Hi!", affectedNpc.getId()),
    		new Dialogue(player, "How's it going?", -1),
    		new Dialogue(player, "I'm fine thank you.",	affectedNpc.getId())});
    or single dialogue:
    Code:
    
    		player.getDialogueQueue().add(new Dialogue(player, "Hello!",  -1));
    I'm confused....a dialogue...queue? Wtf? Can't you just write the text instead of putting it in a queue? Not to mention you are making a new Dialogue Object ARRAY each time someone clicks on an NPC that supports dialogue, which is asking for a crash.

    And why did you make some variables transient? Lolol I don't see any serialization going on
    [Only registered and activated users can see links. ]

    Quote Originally Posted by 'QuestCrew View Post
    Whats a lobby server?
    Reply With Quote  
     

  4. #14  
    Registered Member
    Serenity's Avatar
    Join Date
    Oct 2008
    Age
    32
    Posts
    2,327
    Thanks given
    43
    Thanks received
    43
    Rep Power
    389
    Quote Originally Posted by 'Conner View Post
    I'm confused....a dialogue...queue? Wtf? Can't you just write the text instead of putting it in a queue? Not to mention you are making a new Dialogue Object ARRAY each time someone clicks on an NPC that supports dialogue, which is asking for a crash.

    And why did you make some variables transient? Lolol I don't see any serialization going on
    you fucking moron you heard somehting someone else says and you got to repeat it?
    you think your a hotshot cause you think you can be a pro programmer in 3 months? and why is it asking for a crash!? i doenst so know what you talk about before making this nonesence aquisation. and a queue is much better then your "putting text on". want me to keep on raggin on you? then continu your course of action, cause every post you make has something about it that aint right of somesort.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  5. Thankful users:


  6. #15  
    Registered Member Sir BeatDown's Avatar
    Join Date
    Nov 2009
    Age
    27
    Posts
    403
    Thanks given
    25
    Thanks received
    5
    Rep Power
    67
    Quote Originally Posted by nemesis View Post
    This can be easily converted ,plus I highly recommend to switch from the if statement shit to this, since when you start making quests, this will come in handy.
    I dont use if statements.

    I use prestored integer arrays in the player class, and use a method to just append dialog onto the player, instead of:

    Code:
    if (questId == 1) {
        if (dStage == 0) {
            if (hasItem(995, 1000)) {
                npcOneLine(p, "You have at least 1k.")
            } else {
                npcTwoLine(p, "You have less than 1k?", "You are poor!");
            }
        }
    }

    Mine is like this:

    Code:
            Engine.dialog.appendNDialog1(p, 0, 9850, "Weclome to RuneScape!", n);
            Engine.dialog.appendPDialog1(p, 1, 9832, "Ok, have a good day.");
            Engine.dialog.appendNDialog1(p, 2, 9850, "Goodbye!", n);


    Quote Originally Posted by GloryScape View Post
    Then code it yourself fucker
    Reply With Quote  
     

  7. #16  
    Registered Member
    Serenity's Avatar
    Join Date
    Oct 2008
    Age
    32
    Posts
    2,327
    Thanks given
    43
    Thanks received
    43
    Rep Power
    389
    Quote Originally Posted by pivotgamer84 View Post
    I dont use if statements.

    I use prestored integer arrays in the player class, and use a method to just append dialog onto the player, instead of:

    Code:
    if (questId == 1) {
        if (dStage == 0) {
            if (hasItem(995, 1000)) {
                npcOneLine(p, "You have at least 1k.")
            } else {
                npcTwoLine(p, "You have less than 1k?", "You are poor!");
            }
        }
    }

    Mine is like this:

    Code:
            Engine.dialog.appendNDialog1(p, 0, 9850, "Weclome to RuneScape!", n);
            Engine.dialog.appendPDialog1(p, 1, 9832, "Ok, have a good day.");
            Engine.dialog.appendNDialog1(p, 2, 9850, "Goodbye!", n);
    then a queue/ dequeu list is better.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  8. #17  
    Registered Member

    Join Date
    Feb 2007
    Posts
    1,005
    Thanks given
    2
    Thanks received
    17
    Rep Power
    93
    Quote Originally Posted by 'Conner View Post
    I'm confused....a dialogue...queue? Wtf? Can't you just write the text instead of putting it in a queue? Not to mention you are making a new Dialogue Object ARRAY each time someone clicks on an NPC that supports dialogue, which is asking for a crash.

    And why did you make some variables transient? Lolol I don't see any serialization going on
    Asking for crash? What the fuck are you talking about, there's no way this could crash if it's used correctly.

    Write text instead of putting it in to queue? Jesus you're a fucking dumbass.

    It's transient so the RS2HD saving system don't save the dialogues into player file, like I sayed on previous posts.

    You're pointing out same things as Encour' did, which makes me think...That you don't have any idea what you're talking about.
    -Removed

    Advertising is not allowed.
    Reply With Quote  
     

  9. Thankful user:


  10. #18  
    Registered Member Sir BeatDown's Avatar
    Join Date
    Nov 2009
    Age
    27
    Posts
    403
    Thanks given
    25
    Thanks received
    5
    Rep Power
    67
    Quote Originally Posted by Serenity View Post
    then a queue/ dequeu list is better.
    I know a list is better, but I wanted to keep it simple. I dont care for speed or power, just simplicity.


    Quote Originally Posted by GloryScape View Post
    Then code it yourself fucker
    Reply With Quote  
     

  11. #19  
    Registered Member youer3455's Avatar
    Join Date
    Jun 2009
    Posts
    559
    Thanks given
    11
    Thanks received
    2
    Rep Power
    15
    Nice I'll look at this.
    Reply With Quote  
     

  12. #20  
    Registered Member
    Join Date
    Aug 2007
    Posts
    453
    Thanks given
    82
    Thanks received
    27
    Rep Power
    53
    Quote Originally Posted by 'Conner View Post
    I'm confused....a dialogue...queue? Wtf? Can't you just write the text instead of putting it in a queue? Not to mention you are making a new Dialogue Object ARRAY each time someone clicks on an NPC that supports dialogue, which is asking for a crash.

    And why did you make some variables transient? Lolol I don't see any serialization going on
    I fucking lol'd.

    Reply With Quote  
     

Page 2 of 5 FirstFirst 1234 ... 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. NPC Dialogue the Easy Way
    By Full Metalst in forum Tutorials
    Replies: 12
    Last Post: 11-10-2010, 01:56 PM
  2. Dialogue System
    By Profesor Oak in forum Snippets
    Replies: 2
    Last Post: 03-11-2010, 02:49 AM
  3. Adding a Easy-To-Use Dialogue (NPC/Player) System
    By LesterKnome in forum Tutorials
    Replies: 7
    Last Post: 08-05-2009, 09:12 PM
  4. Best Dialogue System{3x better than yours}
    By wizzyt21 in forum Tutorials
    Replies: 14
    Last Post: 11-28-2008, 12:41 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
  •