Thread: NPC clipping causes freeze in barrows

Results 1 to 10 of 10
  1. #1 NPC clipping causes freeze in barrows 
    Hella Hard Homie


    Join Date
    Jan 2011
    Posts
    600
    Thanks given
    185
    Thanks received
    43
    Rep Power
    111
    Okay so I recently added NPC + player clipping and havent really found any issues yet, until now.

    If I go into barrows and click the Sarcophagus the barrows brother spawns, but in the mean time an error comes up in the server cmd (none clientsided).
    Code:
    [24-8-13 21:58]: java.lang.ArrayIndexOutOfBound***ception: -1
    [24-8-13 21:58]: A fatal exception has been thrown!
    [24-8-13 21:58]: 	at server.clip.region.Region.getClip(Region.java:21)
    [24-8-13 21:58]: 	at server.clip.region.Region.getClipping(Region.java:226)
    [24-8-13 21:58]: 	at server.model.npcs.NPCHandler.handleClipping(NPCHandler.java:50)
    [24-8-13 21:58]: 	at server.model.npcs.NPCHandler.followPlayer(NPCHandler.java:2279)
    [24-8-13 21:58]: 	at server.model.npcs.NPCHandler.process(NPCHandler.java:1582)
    [24-8-13 21:58]: 	at server.Server.main(Server.java:144)
    Region.java method on line 21 (line 21 in red)
    Code:
        private int getClip(int x, int y, int height) {
            int regionAbsX = (id >> 8) * 64;
            int regionAbsY = (id & 0xff) * 64;
            if (clips[height] == null) {
                return 0;
            }
            return clips[height][x - regionAbsX][y - regionAbsY];
        }
    Region.java method on line 226 (line 226 in red)
    Code:
        public static int getClipping(int x, int y, int height) {
    		if(height > 3)
    			height = 0;
            int regionX = x >> 3;
            int regionY = y >> 3;
            int regionId = ((regionX / 8) << 8) + (regionY / 8);
            for (Region r : regions) {
                if (r.id() == regionId) {
                    return r.getClip(x, y, height);
                }
            }
            return 0;
        }
    And the handleClipping in NPCHandler.. (line 50 in red)
    Code:
    	public void handleClipping(int i) {
    		NPC npc = 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.
    	}
    The code activated when clicking sarcophagus: (This is dharok only, but it happens on all the brothers)
    Code:
    case 6771:
    			if(server.model.minigames.Barrows.selectCoffin(c, 4)) {
    				return;
    			}
    			if(c.barrowsNpcs[4][1] == 0) {
    				Server.npcHandler.spawnNpc(c, 2026, 3551, 9713, -1, 0, 120, 28, 80, 80, true, true);
    				c.barrowsNpcs[4][1] = 1;
    			} else {
    				c.sendMessage("You have already searched in this sarcophagus.");
    			}
    			break;


    Extra: Im guessing it has something to do with the player standing on the stairs that lead to the coffin, and the brothers spawning on the ground and there is a problem with the player height? Like this: http://puu.sh/49VY9.jpg

    Quote Originally Posted by Winston Churchill
    "Success is the ability to go from one failure to another with no loss of enthusiasm"
    Austin still owes me $43
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jun 2010
    Age
    27
    Posts
    2,528
    Thanks given
    544
    Thanks received
    584
    Rep Power
    411
    Code:
    		if(height > 3 || height < 0)
    			height = 0;
    Replace. Oh, and add it in getClip too.
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member

    Join Date
    Mar 2011
    Posts
    1,226
    Thanks given
    245
    Thanks received
    475
    Rep Power
    294
    It's because height here:

    Code:
        private int getClip(int x, int y, int height) {
            int regionAbsX = (id >> 8) * 64;
            int regionAbsY = (id & 0xff) * 64;
            if (clips[height] == null) {
                return 0;
            }
            return clips[height][x - regionAbsX][y - regionAbsY];
        }
    is -1.

    Code:
    Server.npcHandler.spawnNpc(c, 2026, 3551, 9713, -1, 0, 120, 28, 80, 80, true, true);
    You should teleport your player to height 3? I think it is, not -1, and also spawn the npcs at the same height.
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    Hella Hard Homie


    Join Date
    Jan 2011
    Posts
    600
    Thanks given
    185
    Thanks received
    43
    Rep Power
    111
    Thanks guys. I feel pretty stupid for not noticing that

    Quote Originally Posted by Winston Churchill
    "Success is the ability to go from one failure to another with no loss of enthusiasm"
    Austin still owes me $43
    Reply With Quote  
     

  7. #5  
    Donator


    Join Date
    Jan 2012
    Posts
    1,288
    Thanks given
    491
    Thanks received
    229
    Rep Power
    127
    Quote Originally Posted by Aekramer View Post
    Thanks guys. I feel pretty stupid for not noticing that
    And for not noticing this is in the wrong section
    Reply With Quote  
     

  8. Thankful users:


  9. #6  
    Registered Member
    Join Date
    Jun 2011
    Posts
    407
    Thanks given
    77
    Thanks received
    45
    Rep Power
    8
    You sir are a dumb ass for still not noticing wrong section..
    Reply With Quote  
     

  10. #7  
    Donator

    Keith's Avatar
    Join Date
    Sep 2008
    Age
    29
    Posts
    1,900
    Thanks given
    83
    Thanks received
    162
    Rep Power
    1244
    Quote Originally Posted by OmgItsShane View Post
    You sir are a dumb ass for still not noticing wrong section..
    Mistakes happen, I don't think you're going to lose any sleep over this so fuck off.
    Reply With Quote  
     

  11. Thankful users:


  12. #8  
    Registered Member Aleksandr's Avatar
    Join Date
    Sep 2006
    Age
    33
    Posts
    1,034
    Thanks given
    455
    Thanks received
    134
    Rep Power
    74
    use (height & 3)
    Al
    Attached image

    There is no RL, just AFK
    Reply With Quote  
     

  13. #9  
    Registered Member
    Join Date
    Dec 2012
    Posts
    307
    Thanks given
    63
    Thanks received
    36
    Rep Power
    9
    OMG sick SERVER DOWNLOAD. They should make a section for this kinda stuff. Dood nice server man gj.
    Reply With Quote  
     

  14. #10  
    Hella Hard Homie


    Join Date
    Jan 2011
    Posts
    600
    Thanks given
    185
    Thanks received
    43
    Rep Power
    111
    .. Mod please lock and move/delete

    Quote Originally Posted by Winston Churchill
    "Success is the ability to go from one failure to another with no loss of enthusiasm"
    Austin still owes me $43
    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. Matrix, in what class/method handles npc clipping?
    By Ecofriendly in forum Tutorials
    Replies: 4
    Last Post: 10-29-2012, 12:14 AM
  2. Replies: 2
    Last Post: 10-28-2012, 11:54 PM
  3. Replies: 5
    Last Post: 10-28-2012, 11:43 PM
  4. Matrix, in what class/method handles npc clipping?
    By Ecofriendly in forum Requests
    Replies: 0
    Last Post: 10-28-2012, 11:42 PM
  5. npc clipping in godwars help please
    By Golden Hero in forum Help
    Replies: 0
    Last Post: 08-08-2010, 11:39 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •