Thread: [508] Proper NPC Following {Can be converted to any base}

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 [508] Proper NPC Following {Can be converted to any base} 
    Registered Member
    wizzyt21's Avatar
    Join Date
    Aug 2007
    Posts
    1,167
    Thanks given
    49
    Thanks received
    12
    Rep Power
    156
    Open up to server > entity > npcs > following
    Then open up FollowPlayer class, replace the method with:
    Code:
    	public void followPlayer()
    	{
    		if (getPlayer() == null || getPlayer().verify() == Tools.getTranslated(-19)) return;
    		int j = getPlayer().verify().absX, k = getPlayer().verify().absY, l = getNPC().verify().absX, m = getNPC().verify().absY;
    		int followType = 0;
    		boolean equalX = (j == l), equalY = (k == m), lowerX = (j < l), lowerY = (k < m), higherX = (j > l), higherY = (k > m);
    		if (followType <= 0)
    		{
    			if (equalX) getNPC().verify().moveX = 0;
    			else if (lowerX) getNPC().verify().moveX = getMove(l, j + 1 + getNPC().verify().getSize());
    			else if (higherX) getNPC().verify().moveX = getMove(l, j - 1 + getNPC().verify().getSize());
    			if (equalY && (equalX || lowerX || higherX)) getNPC().verify().moveY = 0;
    			else if (lowerY && (equalX || lowerX || higherX)) getNPC().verify().moveY = getMove(k, m + 1 + getNPC().verify().getSize());
    			else if (higherY && (equalX || lowerX || higherX)) getNPC().verify().moveY = getMove(k, m - 1 + getNPC().verify().getSize());
    			long totalX = Math.round(Math.pow(difference(j, l), 2)), totalY = Math.round(Math.pow(difference(k, m), 2));
    			if (createdFor > -1) if (totalX > 10 || totalY > 10) getNPC().verify().moveX = getNPC().verify().moveY = -1;
    			if (lowerY) getNPC().verify().moveY = -1 + (getNPC().verify().getSize()*2);
    			if (higherY) getNPC().verify().moveY = 1 + (getNPC().verify().getSize()*2);
    			getNPC().verify().checkProperMovement();
    		}
    		getNPC().updateAllNecessary().verifyLast();
    	}
    And then in NPC, go into the verify method, under:
    Code:
    		checkNPCEvents();
    		fireNPCEvents();
    Add this(Remember to update whenever needed):
    Code:
    		getNPCEvents().checkPlayerFollowing(this, 5, -2, 1);
    The getSize method will be posted below..
    Enjoy!
    Reply With Quote  
     

  2. #2  
    C.T
    Guest
    could you make a video?
    Reply With Quote  
     

  3. #3  
    Registered Member
    wizzyt21's Avatar
    Join Date
    Aug 2007
    Posts
    1,167
    Thanks given
    49
    Thanks received
    12
    Rep Power
    156
    The getSize method(Sorry, I haven't yet dumped):
    Code:
    	public int getSize()
    	{
    		switch (npcType)
    		{
    			case 6830 :
    			case 6832 :
    				return 1;
    			default :
    				return 0;
    		}
    	}
    Quote Originally Posted by Obisitesexy View Post
    could you make a video?
    I will after I fix the login glitch to my server..
    Last edited by wizzyt21; 12-23-2008 at 02:16 AM. Reason: Double posting is not allowed!
    YOU JUST GOT KNOCKED THE F*CK UP.
    Reply With Quote  
     

  4. #4  
    C.T
    Guest
    could be very nice if you would upload a video
    Reply With Quote  
     

  5. #5  
    Registered Member
    wizzyt21's Avatar
    Join Date
    Aug 2007
    Posts
    1,167
    Thanks given
    49
    Thanks received
    12
    Rep Power
    156
    Congrats on 1,000!
    YOU JUST GOT KNOCKED THE F*CK UP.
    Reply With Quote  
     

  6. #6  
    C.T
    Guest
    Quote Originally Posted by momosherilly View Post
    Congrats on 1,000!
    lol thanks
    Reply With Quote  
     

  7. #7  
    Member [508] Proper NPC Following {Can be converted to any base} Market Banned


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    35
    Posts
    12,574
    Thanks given
    199
    Thanks received
    7,106
    Rep Power
    5000
    You made that look alot more complicated than it has to be lol.

    Attached imageAttached image
    Reply With Quote  
     

  8. #8  
    JohnK
    Guest
    I'll Post when i finish, but if it works, rep to you
    Reply With Quote  
     

  9. #9  
    Dj T3nSiOnN
    Guest
    Nice it worked but i still have a lil glitch... but i fixed silly 0 to a 1
    Reply With Quote  
     

  10. #10  
    Meth0d
    Guest
    Ah, thank you very much! I was working on this for aggression and Summoning. My own following function was rather uh jumpy. Because it wasn't square-by-square the client wouldn't update the NPC position properly.

    This is perfect though! Thanks again.
    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
  •