Haven-res.jar hit-box fix. Fixed after multiple attempts.

Forum for alternative clients, mods & discussions on the same.

Moderator: Phades

Haven-res.jar hit-box fix. Fixed after multiple attempts.

Postby Xcom » Thu May 16, 2013 4:19 pm

Here is a link to get the edited neg files. There is also a zip with short walls, cheese racks and cupboards.

Download haven-jar.res with edited neg files:
http://www.sendspace.com/file/gy1y6v

Download short walls, cheeseracks, cubs with edited neg files:
http://www.sendspace.com/file/02bkgm

To use it simply replace the haven-res.jar with the one in the ender directory.

To get the the short walls, cheeseracks, cubs. Simply extract them into the costum_res folder.



Edit: Boshaw's salem-layer-util can now fix the hit-boxes. Look at page 3 post nr 29 for more details.

Being inspired by MvGulik's player res collection I thought of making a nice haven-res.jar hit-box editor to fix all the hit-boxes in that collection.

I tried tinkering with Bowsha's Haven LayerUtil with very little success. Being a total noob in coding I gave up and picked up this task several times. I also contacted MvGulik for assistance. But as he had very little java coding experience and my nooblet coding we didn't manage to get much done.

I am posting this and hoping someone out there with the skills and knowhow can help bring this up to speed and help find a solution for the problem.

The hit-box editing was done by me and drenyy during the lag around December. We ran around for a week bumping into objects checking what objects had the correct hit-box data and what didn't. After a week or so we made a nice collection of hit-box edits that would complement the already existing hit-box data that is in the haven-res.jar. With these edits we managed to make a very nice filter for getting the correct hit-boxes of all objects in the game. Using this you can make a very nice pathfinder but the issue is the current system is very messy and looks horrible.

If someone can help with the coding of the haven-res.jar editor. What would be needed would similar be a editor to the Bowsha Haven LayerUtil but instead of extracting and such it would simply go in and do some edits to the hit-boxes.

This is the edits we made in code form. It looks horrible and its overall to slow. The help needed would be simply to make a filter where it would check what object it would need editing and based on its name would do the edits so this would not be needed to get done when the game were running.

Code: Select all
   ArrayList<Rectangle> getAllNegs(){
      long time = System.currentTimeMillis();
      
      int meOffcet = -2;
      int meSize = 4;
      
      if(boatBol){
         meOffcet = -14;
         meSize = 26;
      }
      
      Gob player = getPlayerGob();
      ArrayList<Rectangle> negRec = new ArrayList<Rectangle>();
      synchronized(m_hPanel.ui.mainview.glob.oc){
         for(Gob g : m_hPanel.ui.mainview.glob.oc){
            if(m_memGobs.contains(g) ) continue;
            //m_memGobs.add(g);
            String name = g.resname();
               //g == target
            
            if( g == player ) continue;
            if( g.getc().equals(player.getc() ) ) continue;
            if( name.contains("/tiles/") ) continue;
            if( name.contains("/plants/") ) continue;
            if( name.contains("/items/") ) continue;
            if( name.equals("gfx/terobjs/trees/log") ) continue;
            if( name.equals("gfx/terobjs/blood") ) continue;
            if( name.equals("gfx/terobjs/herbs/chantrelle") ) continue;
            if( (name.equals("gfx/terobjs/hearth-play") && g.getattr(KinInfo.class) == null) ) continue;
            if( (name.contains("/gates/") && g.GetBlob(0) == 2) ) continue;
            
            Coord offcet = new Coord();
            Coord size = new Coord();
            
            if(!editFilter(g, offcet, size) ){
               Resource.Neg neg = g.getneg();
               if(neg == null){System.out.println("Error neg"); continue;}
               
               offcet = neg.bc;
               size = neg.bs;
            }
            
            if(size.x != 0){
               Rectangle rect = new Rectangle(g.getc().x + offcet.x + meOffcet,
                                       g.getc().y + offcet.y + meOffcet,
                                       size.x + meSize,
                                       size.y + meSize);
               negRec.add(rect);
            }
         }
      }
      
      System.out.println("Neg compleate. " + (System.currentTimeMillis() - time) );
      return negRec;
   }
   
   boolean editFilter(Gob g, Coord offcet, Coord size){
      String name = g.resname();
      if( name.contains("/terobjs/") ){
         if( name.contains("/ridges/") ){
            if( name.contains("/grass/") ){ // 5
               if( name.equals("gfx/terobjs/ridges/grass/ss") ){
                  size.x = 14;
                  size.y = 7;
                  offcet.x = -10;
                  offcet.y = -4;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/grass/e") ){
                  size.x = 5;
                  size.y = 21;
                  offcet.x = -2;
                  offcet.y = -11;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/grass/e2s") ){
                  size.x = 23;
                  size.y = 22;
                  offcet.x = 0;
                  offcet.y = -21;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/grass/es") ){
                  size.x = 7;
                  size.y = 16;
                  offcet.x = -5;
                  offcet.y = -6;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/grass/ee") ){
                  size.x = 7;
                  size.y = 14;
                  offcet.x = -4;
                  offcet.y = -10;
                  return true;
               }
            }
            if( name.contains("/mountain/") ){ // 6
               if( name.equals("gfx/terobjs/ridges/mountain/we") ){
                  size.x = 22;
                  size.y = 11;
                  offcet.x = -11;
                  offcet.y = 0;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/mountain/ws") ){
                  size.x = 22;
                  size.y = 11;
                  offcet.x = -11;
                  offcet.y = -11;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/mountain/ne") ){
                  size.x = 11;
                  size.y = 22;
                  offcet.x = -11;
                  offcet.y = -11;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/mountain/ns") ){
                  size.x = 11;
                  size.y = 22;
                  offcet.x = 0;
                  offcet.y = -11;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/mountain/ss") ){
                  size.x = 10;
                  size.y = 11;
                  offcet.x = -10;
                  offcet.y = 0;
                  return true;
               }
               if( name.equals("gfx/terobjs/ridges/mountain/ee") ){
                  size.x = 11;
                  size.y = 10;
                  offcet.x = 0;
                  offcet.y = -10;
                  return true;
               }
            }
         }
         if( name.contains("/furniture/") ){ // 5
            if( name.equals("gfx/terobjs/furniture/coffer") ){
               size.x = 10;
               size.y = 8;
               offcet.x = -5;
               offcet.y = -4;
               return true;
            }
            if( name.equals("gfx/terobjs/furniture/leanto") ){
               size.x = 21;
               size.y = 10;
               offcet.x = -9;
               offcet.y = -5;
               return true;
            }
            if( name.equals("gfx/terobjs/furniture/wardrobe") ){
               size.x = 20;
               size.y = 9;
               offcet.x = -8;
               offcet.y = -3;
               return true;
            }
            if( name.equals("gfx/terobjs/furniture/bed-sturdy") ){
               size.x = 18;
               size.y = 13;
               offcet.x = -8;
               offcet.y = -5;
               return true;
            }
            if( name.equals("gfx/terobjs/furniture/cclosed") || name.equals("gfx/terobjs/furniture/copen" ) ){
               size.x = 7;
               size.y = 4;
               offcet.x = -3;
               offcet.y = -3;
               return true;
            }
         }
         // 7
         if( name.equals("gfx/terobjs/vclaim") ){
            size.x = 27;
            size.y = 8;
            offcet.x = -12;
            offcet.y = -4;
            return true;
         }
         if( name.equals("gfx/terobjs/htable") ){
            size.x = 7;
            size.y = 12;
            offcet.x = -2;
            offcet.y = -5;
            return true;
         }
         if( name.equals("gfx/terobjs/crate") ){
            size.x = 14;
            size.y = 7;
            offcet.x = -6;
            offcet.y = -3;
            return true;
         }
         if( name.equals("gfx/terobjs/trough") ){
            size.x = 21;
            size.y = 10;
            offcet.x = -7;
            offcet.y = -4;
            return true;
         }
         if( name.equals("gfx/terobjs/dframe2") ){
            size.x = 4;
            size.y = 18;
            offcet.x = -3;
            offcet.y = -8;
            return true;
         }
         if( name.equals("gfx/terobjs/mining/ladder") ){
            size.x = 9;
            size.y = 2;
            offcet.x = -4;
            offcet.y = -1;
            return true;
         }
         if( name.equals("gfx/terobjs/lbox") ){
            size.x = 10;
            size.y = 15;
            offcet.x = -6;
            offcet.y = -7;
            return true;
         }
      }
      if( name.contains("/arch/") ){ // 9
         if( name.contains("/gates/") ){
            if( name.contains("-ns") ){
               size.x = 10;
               size.y = 21;
               offcet.x = -5;
               offcet.y = -11;
               return true;
            }
            if( name.contains("-we") ){
               size.x = 21;
               size.y = 10;
               offcet.x = -11;
               offcet.y = -5;
               return true;
            }
         }
         if( name.equals("gfx/arch/sign") ){
            size.x = 10;
            size.y = 10;
            offcet.x = -5;
            offcet.y = -5;
            return true;
         }
         if( name.equals("gfx/arch/stairs-inn") ){
            size.x = 12;
            size.y = 23;
            offcet.x = -7;
            offcet.y = -11;
            return true;
         }
         if( name.equals("gfx/arch/door-inn") ){
            size.x = 19;
            size.y = 5;
            offcet.x = -11;
            offcet.y = -2;
            return true;
         }
      }
      if( name.contains("/kritter/") ){ // 10
         if( name.equals("gfx/kritter/plow/s") ){
            size.x = 6;
            size.y = 6;
            offcet.x = -3;
            offcet.y = -3;
            return true;
         }
         if( name.equals("gfx/kritter/cow/s") ){
            size.x = 11;
            size.y = 11;
            offcet.x = -4;
            offcet.y = -4;
            return true;
         }
         if( name.equals("gfx/kritter/cart/s") ){
            size.x = 10;
            size.y = 10;
            offcet.x = -5;
            offcet.y = -5;
            return true;
         }
         if( name.equals("gfx/kritter/rat/s") ){
            for(String secondName : g.resnames() )
               if( secondName.equals("gfx/kritter/dragonfly/dragonfly") )
                  return false;
            size.x = 1;
            size.y = 1;
            offcet.x = 0;
            offcet.y = 0;
            return true;
         }
         if( name.equals("gfx/kritter/deer/s") ){
            size.x = 11;
            size.y = 11;
            offcet.x = -4;
            offcet.y = -4;
            return true;
         }
         if( name.equals("gfx/kritter/bear/s") ){
            size.x = 16;
            size.y = 16;
            offcet.x = -8;
            offcet.y = -8;
            return true;
         }
         if( name.equals("gfx/kritter/fox/s") ){
            size.x = 7;
            size.y = 7;
            offcet.x = -3;
            offcet.y = -3;
            return true;
         }
         if( name.equals("gfx/kritter/troll/s") ){
            size.x = 16;
            size.y = 16;
            offcet.x = -8;
            offcet.y = -8;
            return true;
         }
      }
      if( name.equals("gfx/borka/s") ){ // 4
         for(String secondName : g.resnames() ){
            if( secondName.contains("gfx/borka/body") )
               return false;
         }
         size.x = 1;
         size.y = 1;
         offcet.x = 0;
         offcet.y = 0;
         return true;
      }
      
      return false; // edit size 46
   }
Last edited by Xcom on Sun Jul 07, 2013 11:04 pm, edited 6 times in total.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby boshaw » Fri May 17, 2013 11:04 am

Hi,

I've put together a small script to do this within salem-layer-util. Here's what you need to do to run it:

1) download the files @ https://github.com/boshaw/salem-layer-util
2) where ever you downloaded it to, go to it and use "run-abcl.{bat,sh}"
3) once abcl loads up all the way to the point where you see "CL-USER>" type:
Code: Select all
(slu:run :mode :hnh-fix-neg :args '("path-to-base-res-folder" "path-to-filter-file"))

'path-to-base-res-folder' should simply be the path (relative or absolute) to the base folder of all the resource files (you'll need to extract the haven-res.jar into a normal folder)
'path-to-filter-file' should be the path to a file containing the right filter information

the filter file format should be as followed:
Code: Select all
resource/file/name
off=###,###
sz=###,###
resource/file/name2
off=###,###
sz=###,###
.
.
.


'resource/file/name' should be the name of the resource file (ie: gfx/tiles/dirt/dirt (don't put ".res" at the end))
off= and sz= options are optional and can be switched in order, their arguments should be two 16-bit integers separated by a comma

The result will be a replacement of the old files with the new edited files based on the filter given.

If you run into a problem just tell me.
User avatar
boshaw
 
Posts: 1538
Joined: Tue Jun 01, 2010 10:22 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby Xcom » Fri May 17, 2013 7:21 pm

Thank you so much for the help boshaw. I followed your instructions but I ran into a bit of a small problem with the filter. The neg files would have to be manually edited one by one. There might be a quicker solution but it would require me to explain it over a form of chat like skype for example. If you had some time it would be a big help if I could explain the problem and get some advice on how to resolve this.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby boshaw » Fri May 17, 2013 7:26 pm

Xcom wrote:I followed your instructions but I ran into a bit of a small problem with the filter. The neg files would have to be manually edited one by one.


what exactly was the issue?
User avatar
boshaw
 
Posts: 1538
Joined: Tue Jun 01, 2010 10:22 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby Xcom » Fri May 17, 2013 8:01 pm

Might be best to explain from start.

The neg files contains the semi correct hit-box data. The data is stored in bc and bs in the form of a non-isometric form. When the game loads the neg files into the memory it converts the bc and bs into a isometric form. Cupboards for example are converted to bc (-5, -5) and bs (10, 10), but in the non-isometric form they have some unreadable data form looking like this bc (0, -11) and bs (0, 11). The larger issue with these non-isometric forms are that they are near to impossible to edit and fix as they use different rounding inside the clients calculation compare to the server and therefor end up outputting wrong hit-box data in many objects like village idols, troughs, herbalist tables and many of the ridges plus more. Even after attempting to fix the sizes in the non-isometric form I discovered it was both close to impossible to understand and edit that type of formant and because of odd rounding differing in server and client resulting in some glitches and offsets.

Because there are to many objects in total to edit by hand the filter would simply have to do the same calculation done when the game is running to convert the data from non-isometric inside each neg file to its converted isometric form. The calculations are done in Resourse.java and MapView.java. Would simply have to go through all the res files one by one and if it found a neg layer it would read the data and edit it to its isometric form using the same calculations done in MapView.java under the function m2s:

Code: Select all
    public static Coord m2s(Coord c) {
   return(new Coord((c.x * 2) - (c.y * 2), c.x + c.y));
    }


Here is another tricky issue. Alot of the neg files needs direct editing as well. If the filter can edit all the files the 50 odd or so files could be manually edited but if it was possible to auto edit by inputting the resnames and checking if they needed direct edit it would be a plus.

Edit: Summery of all that. If it was possible to edit the neg files automatically using the formula used by m2s it would be a world of help. Sorta make the filter to go through the haven-res.jar and auto correct the neg values from non-isometric to isometric.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby boshaw » Fri May 17, 2013 8:13 pm

Xcom wrote:Might be best to explain from start.

The neg files contains the semi correct hit-box data. The data is stored in bc and bs in the form of a non-isometric form. When the game loads the neg files into the memory it converts the bc and bs into a isometric form. Cupboards for example are converted to bc (-5, -5) and bs (10, 10), but in the non-isometric form they have some unreadable data form looking like this bc (0, -11) and bs (0, 11). The larger issue with these non-isometric forms are that they are near to impossible to edit and fix as they use different rounding inside the clients calculation compare to the server and therefor end up outputting wrong hit-box data in many objects like village idols, troughs, herbalist tables and many of the ridges plus more. Even after attempting to fix the sizes in the non-isometric form I discovered it was both close to impossible to understand and edit that type of formant and because of odd rounding differing in server and client resulting in some glitches and offsets.

Because there are to many objects in total to edit by hand the filter would simply have to do the same calculation done when the game is running to convert the data from non-isometric inside each neg file to its converted isometric form. The calculations are done in Resourse.java and MapView.java. Would simply have to go through all the res files one by one and if it found a neg layer it would read the data and edit it to its isometric form using the same calculations done in MapView.java under the function m2s:

Code: Select all
    public static Coord m2s(Coord c) {
   return(new Coord((c.x * 2) - (c.y * 2), c.x + c.y));
    }


Here is another tricky issue. Alot of the neg files needs direct editing as well. If the filter can edit all the files the 50 odd or so files could be manually edited but if it was possible to auto edit by inputting the resnames and checking if they needed direct edit it would be a plus.

Edit: Summery of all that. If it was possible to edit the neg files automatically using the formula used by m2s it would be a world of help. Sorta make the filter to go through the haven-res.jar and auto correct the neg values from non-isometric to isometric.



Okay so, let me make sure i'm getting this right.

You want it to convert all coordinates given in the filter using m2s as it inserts them into their positions right? Also do you want it to scan for all resource files other than those in the filter and do the m2s fix or just the ones in the filter?
User avatar
boshaw
 
Posts: 1538
Joined: Tue Jun 01, 2010 10:22 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby Xcom » Fri May 17, 2013 8:28 pm

boshaw wrote:Okay so, let me make sure i'm getting this right.

You want it to convert all coordinates given in the filter using m2s as it inserts them into their positions right? Also do you want it to scan for all resource files other than those in the filter and do the m2s fix or just the ones in the filter?


Basically edit all res files that are inside the "gfx/terobjs/..." that have a neg layer inside them from non-isometric to isometric using the m2s function.

Just as an example. "cauldron.res" is a res inside the haven-res.jar inside the "gfx/terobjs/" and have a neg layer in it. The filter would simply go in and edit its neg data using the m2s and change the data inside the neg file from

Code: Select all
#Coord bc
0
-10
#Coord bs
0
10


to

Code: Select all
#Coord bc
-5
-5
#Coord bs
10
10


and in some rare instances like for example herbalist table or v-idol to make a different inputted data then the m2s output. That would be the manually edited data on the incorrect hit-box objects.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby boshaw » Mon May 20, 2013 8:54 am

Xcom wrote:
boshaw wrote:Okay so, let me make sure i'm getting this right.

You want it to convert all coordinates given in the filter using m2s as it inserts them into their positions right? Also do you want it to scan for all resource files other than those in the filter and do the m2s fix or just the ones in the filter?


Basically edit all res files that are inside the "gfx/terobjs/..." that have a neg layer inside them from non-isometric to isometric using the m2s function.

Just as an example. "cauldron.res" is a res inside the haven-res.jar inside the "gfx/terobjs/" and have a neg layer in it. The filter would simply go in and edit its neg data using the m2s and change the data inside the neg file from

Code: Select all
#Coord bc
0
-10
#Coord bs
0
10


to

Code: Select all
#Coord bc
-5
-5
#Coord bs
10
10


and in some rare instances like for example herbalist table or v-idol to make a different inputted data then the m2s output. That would be the manually edited data on the incorrect hit-box objects.


Sorry for the delay, i've been a bit busy these last few days.

I updated the program to match how you wanted it to run with m2s'ing all negs + the ability to input new data to neg if needed.

You can redownload it here: https://github.com/boshaw/salem-layer-util (https://github.com/boshaw/salem-layer-u ... master.zip)

All you need to do is:
1. download the zip/clone the repo
2. use "run-abcl.{bat,sh}" depending on what OS you're on
3. wait for your terminal to say
Code: Select all
CL-USER>

4. type
Code: Select all
(slu:run :mode :hnh-fix-neg :args '("path-to-res-folder" "path-to-filter-file"))


'path-to-base-res-folder' should simply be the path (relative or absolute) to the base folder of all the resource files (you'll need to extract the haven-res.jar into a normal folder)
'path-to-filter-file' should be the path to a file containing the right filter information

the filter file format is the same as detailed in posting.php?mode=quote&f=27&p=399734#pr399593


If there's anything i missed or some bug with it just tell em and i'll fix it.
User avatar
boshaw
 
Posts: 1538
Joined: Tue Jun 01, 2010 10:22 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby Xcom » Tue May 21, 2013 12:03 am

Wow this is really nice. Will look into it right away. Thank you so much for all your help. :)
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Assistance needed to fix hit-box data in haven-res.jar

Postby Xcom » Tue May 21, 2013 12:34 am

Having some difficulties.

I extracted the haven-res.jar into a folder and put it inside the same folder as "salem-layer-util-master\", the extracted layer-util tool. I then typed in "(slu:run :mode :hnh-fix-neg :args '("res/" "filter.txt"))"

As I was unsure of filters file type I just made a txt file and added a few names. Like this:

Code: Select all
gfx/terobjs/ridges/grass/ss
off=-10,-4
sz=14,7
gfx/terobjs/ridges/grass/e
off=-2,-11
sz=5,21
gfx/terobjs/ridges/grass/e2s
off=0,-21
sz=23,22
gfx/terobjs/ridges/grass/es
off=-5,-6
sz=7,16
gfx/terobjs/ridges/grass/ee
off=-4,-10
sz=7,14


A bit unsure of what should have happened but instantly the command prompt came back up and it was done. I later used haven LayerUtil to decode the res files to discover that they were unsuccessful in being edited. :(

Might need a bit of help to get it working.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Next

Return to The Wizards' Tower

Who is online

Users browsing this forum: Google [Bot] and 1 guest