Thread: NPC attack Player

Results 1 to 3 of 3
  1. #1 NPC attack Player 
    Banned
    Join Date
    Aug 2016
    Age
    27
    Posts
    129
    Thanks given
    33
    Thanks received
    36
    Rep Power
    0
    I'm trying to make the NPC attackl the player after a certain option is chosen in dialogue.
    How ould i go about doing that?

    Code:
       @Override
        public void run(int interfaceId, int componentId) {
    	switch(stage) {
    		case -1:
    			sendOptionsDialogue(SEND_DEFAULT_OPTIONS_TITLE, "Let's fight!", "Nothing.");
    			stage = 0;
    			break;
    		case 0:
    			switch (componentId) {
        		case OPTION_1:
        			sendPlayerDialogue(Mood.NORMAL, "Let's fight!");
        			stage  = 1;
        			break;
        		case OPTION_2:
        			sendPlayerDialogue(Mood.NORMAL, "I want nothing. Goodbye.");
        			stage = -2;
        			break;
        		}
        		break;	
    		case 1:
    			//add Barbarian attack me here
    			end();
    			break;
    	    default:
    	    	end();
    	    	break;
    		}
        }
    Reply With Quote  
     

  2. #2  
    EXALTED

    Join Date
    Nov 2012
    Posts
    393
    Thanks given
    35
    Thanks received
    33
    Rep Power
    5
    Something like this:

    Code:
                  for (NPC npc : World.getNPCs()) {
    	        if (npc.getId() == idhere) {
    		       npc.setTarget(player);
    		}
    	   }
    Probably add a check for tiles or whatever to make sure only that NPC targets the player
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Aug 2016
    Age
    27
    Posts
    129
    Thanks given
    33
    Thanks received
    36
    Rep Power
    0
    Quote Originally Posted by databomb View Post
    Something like this:

    Code:
                  for (NPC npc : World.getNPCs()) {
    	        if (npc.getId() == idhere) {
    		       npc.setTarget(player);
    		}
    	   }
    Probably add a check for tiles or whatever to make sure only that NPC targets the player
    how would i check for tiles
    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: 12
    Last Post: 09-30-2013, 09:23 AM
  2. [PI] fucked up npc attack player
    By rexz0rd in forum Help
    Replies: 1
    Last Post: 05-08-2011, 01:32 AM
  3. [508/Pali?] Fixing npc attacking players...
    By Nikki in forum Snippets
    Replies: 6
    Last Post: 07-14-2010, 05:50 AM
  4. Player making NPCs attack him?
    By Markian in forum Help
    Replies: 6
    Last Post: 05-17-2009, 03:52 AM
  5. Making NPCs attack players..
    By Pancakebuddy in forum Tutorials
    Replies: 4
    Last Post: 06-07-2008, 03:56 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
  •