Thread: clipped following and clipped diagonal. rep+

Results 1 to 7 of 7
  1. #1 clipped following and clipped diagonal. rep+ 
    Registered Member


    Join Date
    Jul 2007
    Posts
    4,133
    Thanks given
    789
    Thanks received
    2,715
    Rep Power
    5000
    Does anyone know how to fix the clipped playerfolowing and the npc noclipping in diagonal lines?
    Npc following fixed player following left

    EDIT:
    Playerfollow:

    Code:
    public void followPlayer() {
    		if(Server.playerHandler.players[c.followId] == null || Server.playerHandler.players[c.followId].isDead) {
    			c.followId = 0;
    			return;
    		}		
    		if(c.freezeTimer > 0) {
    			return;
    		}
    		int otherX = Server.playerHandler.players[c.followId].getX();
    		int otherY = Server.playerHandler.players[c.followId].getY();
    		boolean canwalk = true;
    		boolean withinDistance = c.goodDistance(otherX, otherY, c.getX(), c.getY(), 2);
    		boolean hallyDistance = c.goodDistance(otherX, otherY, c.getX(), c.getY(), 2);
    		boolean bowDistance = c.goodDistance(otherX, otherY, c.getX(), c.getY(), 4);
    		boolean rangeWeaponDistance = c.goodDistance(otherX, otherY, c.getX(), c.getY(), 2);
    		if(!c.goodDistance(otherX, otherY, c.getX(), c.getY(), 25)) {
    			c.followId = 0;
    			return;
    		}
    		c.faceUpdate(c.followId+32768);
    		
    		if (otherY == c.getY() && otherX == c.getX()) {			
    			switch(Misc.random(3))  {
    				case 0:
    				walkTo(0, getMove(c.getX(), otherX - 1));
    				break;
    				
    				case 1:
    				walkTo(0, getMove(c.getX(), otherX + 1));
    				break;
    				
    				case 2:
    				walkTo(0, getMove(c.getY(), otherY + 1));
    				break;
    				
    				case 3:
    				walkTo(0, getMove(c.getY(), otherY - 1));
    				break;
    			}
    		}
    		if(c.usingBow && bowDistance) {
    			return;
    		}
    		
    		if(c.getCombat().usingHally() && hallyDistance) {
    			return;
    		}
    		
    		if(c.usingRangeWeapon && rangeWeaponDistance) {
    			return;
    		}
    		if(c.isRunning2 && !withinDistance) {
    			if(otherY > c.getY() && otherX == c.getX()) {
    				walkTo(0, getMove(c.getY(), otherY - 1) + getMove(c.getY(), otherY - 1));
    			} else if(otherY < c.getY() && otherX == c.getX()) {
    				walkTo(0, getMove(c.getY(), otherY + 1) + getMove(c.getY(), otherY + 1));
    			} else if(otherX > c.getX() && otherY == c.getY()) {
    				walkTo(getMove(c.getX(), otherX - 1) + getMove(c.getX(), otherX - 1), 0);
    			} else if(otherX < c.getX() && otherY == c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1) + getMove(c.getX(), otherX + 1), 0);
    			} else if(otherX < c.getX() && otherY < c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1) + getMove(c.getX(), otherX + 1), getMove(c.getY(), otherY + 1) + getMove(c.getY(), otherY + 1));
    			} else if(otherX > c.getX() && otherY > c.getY()) {
    				walkTo(getMove(c.getX(), otherX - 1) + getMove(c.getX(), otherX - 1), getMove(c.getY(), otherY - 1) + getMove(c.getY(), otherY - 1));
    			} else if(otherX < c.getX() && otherY > c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1) + getMove(c.getX(), otherX + 1), getMove(c.getY(), otherY - 1) + getMove(c.getY(), otherY - 1));
    			} else if(otherX > c.getX() && otherY < c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1) + getMove(c.getX(), otherX + 1), getMove(c.getY(), otherY - 1) + getMove(c.getY(), otherY - 1));
    			} 		
    		} else {
    			if(otherY > c.getY() && otherX == c.getX()) {
    				walkTo(0, getMove(c.getY(), otherY - 1));
    			} else if(otherY < c.getY() && otherX == c.getX()) {
    				walkTo(0, getMove(c.getY(), otherY + 1));
    			} else if(otherX > c.getX() && otherY == c.getY()) {
    				walkTo(getMove(c.getX(), otherX - 1), 0);
    			} else if(otherX < c.getX() && otherY == c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1), 0);
    			} else if(otherX < c.getX() && otherY < c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1), getMove(c.getY(), otherY + 1));
    			} else if(otherX > c.getX() && otherY > c.getY()) {
    				walkTo(getMove(c.getX(), otherX - 1), getMove(c.getY(), otherY - 1));
    			} else if(otherX < c.getX() && otherY > c.getY()) {
    				walkTo(getMove(c.getX(), otherX + 1), getMove(c.getY(), otherY - 1));
    			} else if(otherX > c.getX() && otherY < c.getY()) {
    				walkTo(getMove(c.getX(), otherX - 1), getMove(c.getY(), otherY + 1));
    			} 
    		}
    	}



    If u help I will rep+

    Thanks,
    Arvid
    Reply With Quote  
     

  2. #2  
    Respected Member


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    12,551
    Thanks given
    176
    Thanks received
    5,727
    Rep Power
    5000
    To make them walk diagonal just make BOTH thier coords -- or ++, as you can see in your code, they only ever go +- or -+

    Reply With Quote  
     

  3. #3  
    Registered Member


    Join Date
    Jul 2007
    Posts
    4,133
    Thanks given
    789
    Thanks received
    2,715
    Rep Power
    5000
    fixed the npc thing

    EDIT:

    Can atleast someone tell me where to add the code I think I might be able to add/ make the code myself
    Reply With Quote  
     

  4. #4  
    Respected Member


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    12,551
    Thanks given
    176
    Thanks received
    5,727
    Rep Power
    5000
    Nevermind i was wrong

    walkTo(getMove(c.getX(), otherX + 1), getMove(c.getY(), otherY + 1));

    Reply With Quote  
     

  5. #5  
    Registered Member


    Join Date
    Jul 2007
    Posts
    4,133
    Thanks given
    789
    Thanks received
    2,715
    Rep Power
    5000
    that ain't the good one?^
    Reply With Quote  
     

  6. #6  
    Respected Member


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    12,551
    Thanks given
    176
    Thanks received
    5,727
    Rep Power
    5000
    That's what i was getting at in my first post, but i didn't see it..

    I've not worked on a following/movement code yet so there's not really much i can help with

    Reply With Quote  
     

  7. #7  
    Registered Member


    Join Date
    Jul 2007
    Posts
    4,133
    Thanks given
    789
    Thanks received
    2,715
    Rep Power
    5000
    EDIT:

    Gotta edit this code so it fits in for player following:

    Code:
    if(WorldMap.isWalkAble(npcs[NPCID].heightLevel, npcs[NPCID].absX, npcs[NPCID].absY, npcs[NPCID].absX, npcs[NPCID].absY+npcs[NPCID].moveY) == false)
    				canwalk = false;
    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

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