Thread: Somebody's time to explain the cache, and models

Results 1 to 4 of 4
  1. #1 Somebody's time to explain the cache, and models 
    Registered Member
    Tamatea's Avatar
    Join Date
    Aug 2010
    Posts
    1,317
    Thanks given
    401
    Thanks received
    357
    Rep Power
    2457
    Hey there, I'm writing this post that somebody would be able to explain too me abit about how too add animations, npc, items ect.. but without replacing them all i've spent some time searching and reading peoples threads, so i do have a basic understanding about how it's done; however i still have some questions in regards. For example,

    If you wanted too add a new item, it's too my understanding (which is basic and quite possibly wrong) you add the gzipped model to too your cache, and add the appropriate ints into your ItemDef class, however i know that obj.dat/idx has something too do with it which i don't quite understand


    So i was hoping that somebody would be able too add me on skype or w.e and take the time too explain abit about this too me; I'm not expecting too be spoonfed on how to add new data, just requesting abit of somebodys time too explain abit about it all too me. Thank you very much
    Spoiler for sig too large:


    Attached image
    Attached image
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Nov 2015
    Posts
    409
    Thanks given
    122
    Thanks received
    41
    Rep Power
    17
    Have you read through galkons repacking method tutorial? it pretty much explains it all
    Reply With Quote  
     

  3. #3  
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,409
    Thanks given
    576
    Thanks received
    580
    Rep Power
    5000
    Things like animations, items, objects, npcs, identikit, graphics, etc, have definitions. These definitions are packed (encoded, whatever you wanna call it) into a single .dat file (in 317s at least) inside the cache. So an example of this (probably forgetting some)

    Animation -> seq.dat
    Items -> obj.dat, obj.idx
    Objects -> loc.dat, loc.idx
    Npcs -> npc.dat, npc.idx
    Identikit -> idk.dat
    Graphics -> spotanim.dat

    the .dat files have the definitions and i BELIEVE the idx files hold the count for said config and I think offsets. Anyways if you're going to add custom items, animations, npc or whatever you usually dont need to modify the packed form, instead you're going to need to pack the model/animation into the correct index

    Index 0: Config files
    Index 1: Models
    Index 2: Animations
    Index 3: Sound effect/Music (cant remember which one)
    Index 4: Maps


    and get the definition, which you refer to as 'ints', and hardcode it in. An example of unpacked definition would be


    Code:
    case 2:
    	objType.name = "Cannonball";
    	objType.xAngle2D = 156;
    	objType.yAngle2D = 1852;
    	objType.xOffset2D = 1;
    	objType.cost = 5;
    	objType.members = true;
    	objType.baseModel = 2413;
    	objType.stackable = ALWAYS;
    	objType.zoom2D = 1400;
    	objType.unnoted = true;
    	break;
    That's an item from rs cache. To get definitions, you can either find some released on this forum or get it yourself. Definitions are just decoded data or w/e from the config file so the definition i just posted here is from obj.dat. Once you pack your model/animation file you just get your definition and add it in the right class so for the one I just posted you would go to what most clients has as "ItemDef" or "ItemDefinition" and in a method that looks like this (probably called forID in your client)

    Code:
    	public static ItemDefinition lookup(int id) {
    		for (int i = 0; i < 10; i++) {
    			if (cache[i].id == id) {
    				return cache[i];
    			}
    		}
    
    		cacheIndex = (cacheIndex + 1) % 10;
    		ItemDefinition definition = cache[cacheIndex];
    		data.setPosition(offsets[id]);
    		definition.id = id;
    		definition.reset();
    		definition.decode(data);
    		if (definition.notedTemplateId != -1) {
    			definition.toNote();
    		}
    
    		if (!membersServer && definition.members) {
    			definition.name = "Members Object";
    			definition.description = "Login to a members' server to use this object.".getBytes();
    			definition.groundActions = null;
    			definition.widgetActions = null;
    			definition.team = 0;
    		}
    		return definition;
    	}
    you add the definitions, so...

    Code:
    	public static ItemDefinition lookup(int id) {
    	 for (int i = 0; i < 10; i++) {
    	  if (cache[i].id == id) {
    	   return cache[i];
    	  }
    	 }
    
    	 cacheIndex = (cacheIndex + 1) % 10;
    	 ItemDefinition definition = cache[cacheIndex];
    	 data.setPosition(offsets[id]);
    	 definition.id = id;
    	 definition.reset();
    	 definition.decode(data);
    	 if (definition.notedTemplateId != -1) {
    	  definition.toNote();
    	 }
    
    	 if (!membersServer && definition.members) {
    	  definition.name = "Members Object";
    	  definition.description = "Login to a members' server to use this object.".getBytes();
    	  definition.groundActions = null;
    	  definition.widgetActions = null;
    	  definition.team = 0;
    	 }
    
    	 switch (definition.id) {
    	  case 2:
    	   definition.name = "Cannonball";
    	   definition.xAngle2D = 156;
    	   definition.yAngle2D = 1852;
    	   definition.xOffset2D = 1;
    	   definition.cost = 5;
    	   definition.members = true;
    	   definition.baseModel = 2413;
    	   definition.stackable = ALWAYS;
    	   definition.zoom2D = 1400;
    	   definition.unnoted = true;
    	   break;
    	 }
    	 return definition;
    	}
    Naming will of course be different in every client so you will have to edit that

    Sorry for awkward wording and I might be wrong on some of this stuff so yeah, if anyone notices something i said wrong please point it out.

    If you still have questions or I didnt answer you the way you wanted lmk


    tl;dr when adding custom (hardcoded) items npcs or whatever you dont usually have to touch the .dat (config) file for it, just pack the model/anim/map files and hardcode the definition in the corresponding class








    rep me plz
    Attached image
    Reply With Quote  
     

  4. #4  
    Registered Member
    Tamatea's Avatar
    Join Date
    Aug 2010
    Posts
    1,317
    Thanks given
    401
    Thanks received
    357
    Rep Power
    2457
    Yeah i have, it doesn't explain the questions i'm insinuating at

    Quote Originally Posted by Hacker View Post


    rep me plz

    repped thank you for explaining
    Spoiler for sig too large:


    Attached image
    Attached image
    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. Replies: 27
    Last Post: 12-02-2009, 10:34 PM
  2. Replies: 5
    Last Post: 09-10-2009, 11:06 PM
  3. how to unpack the cache?
    By Gluon in forum Requests
    Replies: 4
    Last Post: 02-18-2009, 12:04 AM
  4. How to change the titlebox and button
    By Blacklord in forum Help
    Replies: 4
    Last Post: 02-13-2009, 01:37 AM
  5. Best place to save the cache?
    By Unborn in forum RS2 Client
    Replies: 7
    Last Post: 06-25-2008, 11:03 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
  •