Thread: Making Npc's do stuff

Results 1 to 5 of 5
  1. #1 Making Npc's do stuff 
    Registered Member Sixpack's Avatar
    Join Date
    Sep 2010
    Posts
    339
    Thanks given
    81
    Thanks received
    80
    Rep Power
    24
    This is for a 614 server btw

    Ok, so I wanted my santa guy to do some stuff. The santa npc has an id of 1552. I added this file called npc1552.
    Code:
    package dragonkk.rs2rsps.scripts.dialogues;
    
    import dragonkk.rs2rsps.scripts.dialogueScript;
    import dragonkk.rs2rsps.util.Misc;
    
    public class npc1552 extends dialogueScript {
    
    	@Override
    	public void run(short inter, byte child) {
    		   switch(this.stage) {
    		   case 0:
    			   if(inter == 241 && child == 5) {
    					String[] talkDefinitions  = new String[]{"Santa", "Merry Christmas, pal!"};
    					this.sendEntityDialogue(SEND_1_TEXT_CHAT, talkDefinitions, false, (short)-1, SEND_NO_EMOTE);
    					this.stage = 1;
    			   }
    		   break;
    		   case 1:
    			   if(inter == 241 && child == 5) {
    				String[] talkDefinitions  = new String[]{Misc.formatPlayerNameForDisplay(p.getDisplayName()), "A Merry Christmas to you too, Santa."};
    				this.sendEntityDialogue(SEND_1_TEXT_CHAT, talkDefinitions, true, (short)-1, SEND_NO_EMOTE);
    					this.stage = 2;
    			   }
    		   break;
    		   case 2:
    			   if(inter == 241 && child == 5) {
    				String[] talkDefinitions  = new String[]{Misc.formatPlayerNameForDisplay(p.getDisplayName()), "But it isn't even Christmas yet!?"};
    				this.sendEntityDialogue(SEND_1_TEXT_CHAT, talkDefinitions, true, (short)-1, SEND_NO_EMOTE);
    					this.stage = 3;
    			   }
    		   break;
    		   case 3:
    			   if(inter == 241 && child == 5) {
    					String[] talkDefinitions  = new String[]{"Santa", "I say it is!", "And as long as I am standing here you can do", "the Christmas Event!"};
    					this.sendEntityDialogue(SEND_2_TEXT_CHAT, talkDefinitions, false, (short)-1, SEND_NO_EMOTE);
    					this.stage = 4;
    			   }
    		   break;
    		   case 4:
    			   if(inter == 241 && child == 5) {
    					String[] talkDefinitions  = new String[]{"Santa", "Do you want me to teleport you to the event?"};
    					this.sendEntityDialogue(SEND_2_TEXT_CHAT, talkDefinitions, false, (short)-1, SEND_NO_EMOTE);
    					this.stage = 5;
    			   }
    		   break;
    		   case 5:
    			   if(inter == 242 && child == 6) {
    					String[] talkDefinitions  = new String[]{Misc.formatPlayerNameForDisplay(p.getDisplayName()), "Certainly.", "No thank you."};
    					this.sendEntityDialogue(SEND_2_OPTIONS, talkDefinitions, true, (short)-1, SEND_NO_EMOTE);
    					this.stage = 6;
    			   }
    		   break;
    		   default:
    			   this.finish();
    		   break;
    		   }
    	}
    
    	@Override
    	public void start() {
    		String[] talkDefinitions  = new String[]{Misc.formatPlayerNameForDisplay(p.getDisplayName()), "Hi Santa! What are you doing here?"};
    		this.sendEntityDialogue(SEND_1_TEXT_CHAT, talkDefinitions, true, (short)-1, SEND_NO_EMOTE);
    		this.stage = 0;
    	}
    
    }
    I know the dialogue is stupid it was just for testing purposes. With the following code I can make the dialogue start:
    Code:
    	} else if (cmd[0].equals("santadialogue")) {
    		p.getDialogue().startDialogue("npc1552");
    But how can I make the dialogue start when you talk to the santa npc? I looked around in a lot of filed and couldn't find it. Help is really appreaciated.


    Edit: if you know how to open a shop when you talk to an npc is would be very nice if you told me how to do that too, although I guess it is done sort of the same way a s a dialogue (but you need to have made a shop to ofc.)
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Sep 2010
    Posts
    115
    Thanks given
    2
    Thanks received
    0
    Rep Power
    1
    this is great and i know your only using it for testing purposes but do you think you would be able to do this if you clicked on the Santa npc instead of a command for it? ?
    would be good if you could.
    Reply With Quote  
     

  3. #3  
    Registered Member Sixpack's Avatar
    Join Date
    Sep 2010
    Posts
    339
    Thanks given
    81
    Thanks received
    80
    Rep Power
    24
    Quote Originally Posted by Spoon Man View Post
    this is great and i know your only using it for testing purposes but do you think you would be able to do this if you clicked on the Santa npc instead of a command for it? ?
    would be good if you could.
    The clicking the santa is the whole thing that I am trying to make =P
    Reply With Quote  
     

  4. #4  
    Registered Member Sixpack's Avatar
    Join Date
    Sep 2010
    Posts
    339
    Thanks given
    81
    Thanks received
    80
    Rep Power
    24
    I am sorry for bumping my own thread but it has been quite a bit of time and I still don't have an answer =P.

    I know how to add items, fighting npc's (and their stats etc.), objects. But I don't know how to let an npc for instance start a dialogue/or open an interface. It would be great if someone helped!
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jul 2008
    Posts
    430
    Thanks given
    6
    Thanks received
    29
    Rep Power
    12
    use the first click packet for talking to an npc. Could be multiple things idk how dragonkk's framework looks like so i wouldn't know. But you have to have the correct packet and as well as the correct streams.

    To check, just make it printout the npc id when u first click an npc to see if you have the correct packet and streams.


    dude this is your problem as well i believe. According to your code look at the default:. Its finishing the code before it began..? Shouldn't it be the stuff from case 0 to the default then increment by 1 then after the case 6 reset to -1 or something so it finishes.

    Thats what your problem is..
    People acting like they know what they are talking about...
    Quote Originally Posted by Emperium View Post
    at the some of the people trying to do this rofl. This is a very simple thing to do and really didn't need any new defined statements in InventoryOptionHandler... Simply use the imports the herblore class uses... But thank you for the help for the ones that do not understand a single thing when it comes to JavaScript
    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

Similar Threads

  1. Replies: 0
    Last Post: 12-04-2009, 06:40 PM
  2. [help or req] npc's with custom stuff..
    By squal707 in forum Requests
    Replies: 5
    Last Post: 06-27-2008, 09:58 AM
  3. Npc's and stuff about them...(for begginers)
    By Zachyboo in forum Tutorials
    Replies: 19
    Last Post: 05-11-2008, 01:38 PM
  4. Replies: 21
    Last Post: 02-29-2008, 10:17 PM
  5. NPC's saying stuff on command
    By Rich Dude in forum Tutorials
    Replies: 26
    Last Post: 11-18-2007, 07:00 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •