Thread: (474 + ) Clipping NPC's

Results 1 to 4 of 4
  1. #1 (474 + ) Clipping NPC's 
    Registered Member
    Join Date
    Jul 2013
    Posts
    68
    Thanks given
    5
    Thanks received
    0
    Rep Power
    59
    My NPC's are clipping through walls I've researched everywhere and can't find anything that helps, please if anyone could help with this i'd appreciate it. Here are some codes below.

    HANDLE CLIPPING:
    Code:
    public void handleClipping(final int i) {
    		final NPC npc = NPCHandler.npcs[i];
    		if(npc.moveX == 1 && npc.moveY == 1) {
    			if((Region.getClipping(npc.absX + 1, npc.absY + 1, npc.heightLevel) & 0x12801e0) != 0)  {
    				npc.moveX = 0; npc.moveY = 0;
    				if((Region.getClipping(npc.absX, npc.absY + 1, npc.heightLevel) & 0x1280120) == 0) {
    					npc.moveY = 1;
    				} else {
    					npc.moveX = 1;
    				}
    			}
    		} else if(npc.moveX == -1 && npc.moveY == -1) {
    			if((Region.getClipping(npc.absX - 1, npc.absY - 1, npc.heightLevel) & 0x128010e) != 0)  {
    				npc.moveX = 0; npc.moveY = 0;
    				if((Region.getClipping(npc.absX, npc.absY - 1, npc.heightLevel) & 0x1280102) == 0) {
    					npc.moveY = -1;
    				} else {
    					npc.moveX = -1;
    				}
    			}
    		} else if(npc.moveX == 1 && npc.moveY == -1) {
    			if((Region.getClipping(npc.absX + 1, npc.absY - 1, npc.heightLevel) & 0x1280183) != 0)  {
    				npc.moveX = 0; npc.moveY = 0;
    				if((Region.getClipping(npc.absX, npc.absY - 1, npc.heightLevel) & 0x1280102) == 0) {
    					npc.moveY = -1;
    				} else {
    					npc.moveX = 1;
    				}
    			}
    		} else if(npc.moveX == -1 && npc.moveY == 1) {
    			if((Region.getClipping(npc.absX - 1, npc.absY + 1, npc.heightLevel) & 0x128013) != 0)  {
    				npc.moveX = 0; npc.moveY = 0;
    				if((Region.getClipping(npc.absX, npc.absY + 1, npc.heightLevel) & 0x1280120) == 0) {
    					npc.moveY = 1;
    				} else {
    					npc.moveX = -1;
    				}
    			}
    		} //Checking Diagonal movement.
    		
    		if (npc.moveY == -1 ) {
    			if ((Region.getClipping(npc.absX, npc.absY - 1, npc.heightLevel) & 0x1280102) != 0) {
    				npc.moveY = 0;
    			}
    		} else if( npc.moveY == 1) {
    			if((Region.getClipping(npc.absX, npc.absY + 1, npc.heightLevel) & 0x1280120) != 0) {
    				npc.moveY = 0;
    			}
    		} //Checking Y movement.
    		if(npc.moveX == 1) {
    			if((Region.getClipping(npc.absX + 1, npc.absY, npc.heightLevel) & 0x1280180) != 0) {
    				npc.moveX = 0;
    			}
    		} else if(npc.moveX == -1) {
    			if((Region.getClipping(npc.absX - 1, npc.absY, npc.heightLevel) & 0x1280108) != 0) {
    				npc.moveX = 0;
    			}
    		} //Checking X movement.
    	}
    RANDOM WALKING
    Code:
    else if (npcs[i].walkingHome) {
    						
    						handleClipping(i);
    						npcs[i].getNextNPCMovement(i);
    						npcs[i].updateRequired = true;
    					}
    					if (npcs[i].walkingType >= 0) {
    						switch(npcs[i].walkingType) {
    						case 5:
    							npcs[i].turnNpc(npcs[i].absX -1, npcs[i].absY);
    							break;
    						case 4:
    							npcs[i].turnNpc(npcs[i].absX +1, npcs[i].absY);
    							break;
    						case 3:
    							npcs[i].turnNpc(npcs[i].absX, npcs[i].absY -1);
    							break;
    						case 2:
    							npcs[i].turnNpc(npcs[i].absX, npcs[i].absY +1);
    							break;
    							default:
    								if (npcs[i].walkingType >= 0) {
    									npcs[i].turnNpc(npcs[i].absX, npcs[i].absY);
    								}
    								break;
    						}
    					}
    					if (npcs[i].walkingType == 1) {
    						if (Misc.random(3) == 1 && !npcs[i].walkingHome) {
    							int MoveX = 0;
    							int MoveY = 0;
    							int Rnd = Misc.random(9);
    							if (Rnd == 1) {
    								MoveX = 1;
    								MoveY = 1;
    							} else if (Rnd == 2) {
    								MoveX = -1;
    							} else if (Rnd == 3) {
    								MoveY = -1;
    							} else if (Rnd == 4) {
    								MoveX = 1;
    							} else if (Rnd == 5) {
    								MoveY = 1;
    							} else if (Rnd == 6) {
    								MoveX = -1;
    								MoveY = -1;
    							} else if (Rnd == 7) {
    								MoveX = -1;
    								MoveY = 1;
    							} else if (Rnd == 8) {
    								MoveX = 1;
    								MoveY = -1;
    							}
    
    							if (MoveX == 1) {
    								if (npcs[i].absX + MoveX < npcs[i].makeX + 1) {
    									npcs[i].moveX = MoveX;
    								} else {
    									npcs[i].moveX = 0;
    								}
    							}
    
    							if (MoveX == -1) {
    								if (npcs[i].absX - MoveX > npcs[i].makeX - 1) {
    									npcs[i].moveX = MoveX;
    								} else {
    									npcs[i].moveX = 0;
    								}
    							}
    
    							if (MoveY == 1) {
    								if (npcs[i].absY + MoveY < npcs[i].makeY + 1) {
    									npcs[i].moveY = MoveY;
    								} else {
    									npcs[i].moveY = 0;
    								}
    							}
    
    							if (MoveY == -1) {
    								if (npcs[i].absY - MoveY > npcs[i].makeY - 1) {
    									npcs[i].moveY = MoveY;
    								} else {
    									npcs[i].moveY = 0;
    								}
    							}
    							
    							handleClipping(i);
    							npcs[i].getNextNPCMovement(i);
    							npcs[i].updateRequired = true;
    						}
    					}
    GET NEXT WALKING DIR:
    Code:
    public int getNextWalkingDirection() {
    		int dir;
    		dir = Misc.direction(absX, absY, (absX + moveX), (absY + moveY));
    		if(dir == -1) return -1;
    		dir >>= 1;
    		absX += moveX;
    		absY += moveY;
    		return dir;
    	}
    GET NEXT NPC MOVEMENT
    Code:
    public void getNextNPCMovement(int i) {
    		if(NPCHandler.npcs[i].freezeTimer == 0) {
    			direction = -1;
    			direction = getNextWalkingDirection();
    		}
    	}
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    Jan 2010
    Age
    25
    Posts
    3,985
    Thanks given
    257
    Thanks received
    470
    Rep Power
    536
    This looks like PI
    Reply With Quote  
     

  3. #3  
    Wut can u say when theres nothin to tell

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    20
    Posts
    1,520
    Thanks given
    633
    Thanks received
    381
    Rep Power
    930
    Make sure all walls do actually exist on the server end, and then check if they're appropiately coded in the path finding




    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2013
    Posts
    68
    Thanks given
    5
    Thanks received
    0
    Rep Power
    59
    Quote Originally Posted by Tyrant View Post
    Make sure all walls do actually exist on the server end, and then check if they're appropiately coded in the path finding
    In what java file is walls checked in?

    Quote Originally Posted by Nighel View Post
    This looks like PI
    Indeed is PI
    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. 474 Clipping & NPC-Sizes
    By Someone in forum Buying
    Replies: 4
    Last Post: 07-11-2014, 07:02 AM
  2. Simple no-clipping npcs fix
    By Squidward in forum Tutorials
    Replies: 101
    Last Post: 06-24-2011, 02:42 PM
  3. [474] Advanced NPC & Player Combat and system!
    By wizzyt21 in forum Tutorials
    Replies: 10
    Last Post: 11-29-2008, 10:01 AM
  4. [474 tut] Npc's shouting above their heads!
    By paramore in forum Tutorials
    Replies: 8
    Last Post: 07-26-2008, 11:53 AM
  5. [474] 'Examine npc' packet
    By veer in forum Tutorials
    Replies: 0
    Last Post: 07-10-2008, 03:13 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
  •