Thread: REQ - Information on clipping.

Results 1 to 7 of 7
  1. #1 REQ - Information on clipping. 
    Registered Member

    Join Date
    Nov 2014
    Posts
    337
    Thanks given
    47
    Thanks received
    12
    Rep Power
    187
    Hello there community, I'm having some issue's understanding how my clipping for NPCS is not working, Can this be a object loading issue like what objects are in game as in 317, 508, ect.. or is it only have to do with the HandleClipping method for PI Servers?
    Reply With Quote  
     

  2. #2  
    Registered MrClassic
    MrClassic's Avatar
    Join Date
    Oct 2008
    Age
    15
    Posts
    2,063
    Thanks given
    24,154
    Thanks received
    551
    Rep Power
    5000
    post your handleClipping method and where you call this method
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Nov 2014
    Posts
    337
    Thanks given
    47
    Thanks received
    12
    Rep Power
    187
    I call the handleClipping(i) in three different areas within npcHandler.

    This is the method:
    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.
    	}
    Where it's being called is under process method:
    Code:
    if (npcs[i].walkingHome && npcs[i].absX == npcs[i].makeX
    							&& npcs[i].absY == npcs[i].makeY) {
    						npcs[i].walkingHome = false;
    					} else if (npcs[i].walkingHome) {
    						npcs[i].getNextNPCMovement(i);
    						npcs[i].getNextWalkingDirection();
    						handleClipping(i); // <------------------HERE
    						npcs[i].updateRequired = true;
    					}
    					if (npcs[i].walkingType >= 2) {
    						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;
    								}
    							}
    							
    							
    							npcs[i].getNextNPCMovement(i);
    							npcs[i].getNextWalkingDirection();
    							handleClipping(i); // <------------------HERE
    							npcs[i].updateRequired = true;
    						}
    					}
    				}
    Under followPlayer method:
    Code:
    public void followPlayer(int i, int playerId) {
    		if (PlayerHandler.players[playerId] == null) {
    			return;
    		}
    		if (PlayerHandler.players[playerId].respawnTimer > 0) {
    			npcs[i].facePlayer(0);
    			npcs[i].randomWalk = true;
    			npcs[i].underAttack = false;
    			return;
    		}
    
    		if (!followPlayer(i)) {
    			npcs[i].facePlayer(playerId);
    			return;
    		}
    
    		int playerX = PlayerHandler.players[playerId].absX;
    		int playerY = PlayerHandler.players[playerId].absY;
    		npcs[i].randomWalk = false;
    		if (goodDistance(npcs[i].getX(), npcs[i].getY(), playerX, playerY,
    				distanceRequired(i)))
    			return;
    		if ((npcs[i].spawnedBy > 0)
    				|| ((npcs[i].absX < npcs[i].makeX + Config.NPC_FOLLOW_DISTANCE)
    						&& (npcs[i].absX > npcs[i].makeX
    								- Config.NPC_FOLLOW_DISTANCE)
    						&& (npcs[i].absY < npcs[i].makeY
    								+ Config.NPC_FOLLOW_DISTANCE) && (npcs[i].absY > npcs[i].makeY
    						- Config.NPC_FOLLOW_DISTANCE))) {
    			if (npcs[i].heightLevel == PlayerHandler.players[playerId].heightLevel) {
    				if (PlayerHandler.players[playerId] != null && npcs[i] != null) {
    					if (playerY < npcs[i].absY) {
    						npcs[i].moveX = GetMove(npcs[i].absX, playerX);
    						npcs[i].moveY = GetMove(npcs[i].absY, playerY);
    					} else if (playerY > npcs[i].absY) {
    						npcs[i].moveX = GetMove(npcs[i].absX, playerX);
    						npcs[i].moveY = GetMove(npcs[i].absY, playerY);
    					} else if (playerX < npcs[i].absX) {
    						npcs[i].moveX = GetMove(npcs[i].absX, playerX);
    						npcs[i].moveY = GetMove(npcs[i].absY, playerY);
    					} else if (playerX > npcs[i].absX) {
    						npcs[i].moveX = GetMove(npcs[i].absX, playerX);
    						npcs[i].moveY = GetMove(npcs[i].absY, playerY);
    					} else if (playerX == npcs[i].absX
    							|| playerY == npcs[i].absY) {
    						int o = Misc.random(3);
    						switch (o) {
    						case 0:
    							npcs[i].moveX = GetMove(npcs[i].absX, playerX);
    							npcs[i].moveY = GetMove(npcs[i].absY, playerY + 1);
    							break;
    
    						case 1:
    							npcs[i].moveX = GetMove(npcs[i].absX, playerX);
    							npcs[i].moveY = GetMove(npcs[i].absY, playerY - 1);
    							break;
    
    						case 2:
    							npcs[i].moveX = GetMove(npcs[i].absX, playerX + 1);
    							npcs[i].moveY = GetMove(npcs[i].absY, playerY);
    							break;
    
    						case 3:
    							npcs[i].moveX = GetMove(npcs[i].absX, playerX - 1);
    							npcs[i].moveY = GetMove(npcs[i].absY, playerY);
    							break;
    						}
    					}
    					
    					
    					npcs[i].getNextNPCMovement(i);
    					npcs[i].getNextWalkingDirection();
    					handleClipping(i); // <------------------HERE
    					
    					npcs[i].facePlayer(playerId);
    					npcs[i].updateRequired = true;
    				}
    			}
    		} else {
    			npcs[i].facePlayer(0);
    			npcs[i].randomWalk = true;
    			npcs[i].underAttack = false;
    		}
    	}
    Reply With Quote  
     

  4. #4  
    Registered MrClassic
    MrClassic's Avatar
    Join Date
    Oct 2008
    Age
    15
    Posts
    2,063
    Thanks given
    24,154
    Thanks received
    551
    Rep Power
    5000
    hmm... Maybe update your loc.dat and loc.idx server-sided? I don't know what you've changed before this bug occurred
    Reply With Quote  
     

  5. #5  
    Registered Member

    Join Date
    Nov 2014
    Posts
    337
    Thanks given
    47
    Thanks received
    12
    Rep Power
    187
    Quote Originally Posted by MrClassic View Post
    hmm... Maybe update your loc.dat and loc.idx server-sided? I don't know what you've changed before this bug occurred
    This is how it was when I first grabbed it from this site, and for the loc.dat and loc.idx these are the objects being replaced i assume? I will need to get the current ones I have which are 508/525?

    And aint this suppose to be through cache?
    Reply With Quote  
     

  6. #6  
    Registered MrClassic
    MrClassic's Avatar
    Join Date
    Oct 2008
    Age
    15
    Posts
    2,063
    Thanks given
    24,154
    Thanks received
    551
    Rep Power
    5000
    You really want your clipping to be done server-sided. So you have to losd it through cache data. Is your player clipping fine? If yes, then it’s not your loc files.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Nov 2014
    Posts
    337
    Thanks given
    47
    Thanks received
    12
    Rep Power
    187
    Quote Originally Posted by MrClassic View Post
    You really want your clipping to be done server-sided. So you have to losd it through cache data. Is your player clipping fine? If yes, then it’s not your loc files.
    By player clipping you mean as in one player following another?
    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. Req help on this clip
    By Romania Clan in forum Requests
    Replies: 0
    Last Post: 02-19-2012, 09:34 AM
  2. [req] help on one error [req]
    By Discardedx2 in forum Help
    Replies: 2
    Last Post: 02-21-2009, 02:52 AM
  3. [req] ancients on login
    By thexfallen in forum Tutorials
    Replies: 3
    Last Post: 07-22-2008, 06:11 PM
  4. [REQ]Tut on Colors[/REQ]
    By Mrthunder23 in forum Tutorials
    Replies: 11
    Last Post: 07-17-2008, 04:17 AM
  5. [REQ] Tutorial on how to make shop prices change
    By g m4ul3r in forum Tutorials
    Replies: 2
    Last Post: 03-18-2008, 01:12 AM
Tags for this Thread

View Tag Cloud

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