Jarno Mikkola Posted July 8, 2009 Posted July 8, 2009 So I was one day happily editing files with WeiDU's .tp2 file, and it raised a question, as the .spl file format has multiple same offsets between the Headers, Extended Headers and Feature Blocks. So how in the Unheaven do I tell the WeiDU to edit the specified value so I am sure no other Headers, Extended Headers or Feature Blocks are changed? Yes, I can do that probably with 'READ_size offset=~var~ and PATCH IF ~var~=plah', but is there a way to do this without the READ function? And is there a way to identify the spells specified Extended Headers offsets? What I am talking about... well for example, the .spl has offset 0x000d which size is 1(char) that is identified as 'Target Number' in Extended Header, and the same offset 0x000d which size is 1(char) that is identified as 'Resistance' in Feature Block. ;) Or do I need to change the 0x00 approach somehow?
Avenger Posted July 8, 2009 Posted July 8, 2009 Well, you calculate where that particular structure starts. There are offsets in the header pointing at the cfb and extended headers. You will also need to recalculate offsetsif you insert or delete data. Patching variable length constructs takes some consideration
Ardanis Posted July 8, 2009 Posted July 8, 2009 I'm a bit confused. Are you asking how to tell weidu to differentiate an Extended Header from a Feature Block? A file is a solid massive of bytes that may have various values, there're no borders and signs 'The following 0x28 bytes describe the Feature Block #23'. It's the engine that is programmed to read information in 0x28 blocks. COPY_EXISTING ~spell.spl~ ~override~ READ_LONG 0x64 ab_off READ_SHORT 0x68 ab_num READ_LONG 0x6a ef_off FOR (i=0;i<ab_num;i+=1) BEGIN READ_SHORT (ab_off+i*0x28 + Jarno_Offset) value PATCH_IF (value=x) BEGIN DO_MORE_READS_AND_WRITES END // PATCH_IF // if you need to edit Feature Blocks aka effect then uncomment the following /* READ_SHORT (ab_off+i*0x28+0x1e) ef_num READ_SHORT (ab_off+i*0x28+0x20) ef_ind FOR (k=0;k<ef_num;k+=1) BEGIN READ_SHORT (ef_off+(k+ef_ind)*0x30 + Jarno_Offset_2) value_2 PATCH_IF (value_2=y) BEGIN DO_MORE_READS_AND_WRITES END // PATCH_IF END // 'k' FOR */ END // 'i' FOR BUT_ONLY_IF_IT_CHANGES // yes, you do need to set it, lest it'll copy the file even if no changes were made
Jarno Mikkola Posted July 14, 2009 Author Posted July 14, 2009 ... THANKS! A LOT!Ah, can I use the same FOR (k)'s and (i)'s if I re-read them each time I COPY something in my mod, or should I use different letters each time I use the FOR command? So this is more of copy-paste vs. copy-paste-alter_this_that_AND... Well, it didn't give any errors at least.
Icendoan Posted July 14, 2009 Posted July 14, 2009 You can use the same variable for every FOR unless you need a constantly growing variable. FOR( i = 0; i <10; i++) : the i = 0 is equivalent to SET i = 0, and since this is in every FOR statement, you can use i each time and it will start from 0 every time. (Assuming that all your FOR loops start from 0, of course.) And as a general note before you copy/paste; make sure it works the first time! This means if you make an error in the first one, it is found before you duplicated the code. Icen
Ardanis Posted July 14, 2009 Posted July 14, 2009 Ah, can I use the same FOR (k)'s and (i)'s if I re-read them each time I COPY something in my mod, or should I use different letters each time I use the FOR command? So this is more of copy-paste vs. copy-paste-alter_this_that_AND...Unless you do a complex 200-liner with many LAUNCH_PATCH_MACRO calls it's safe enough. Problems may arise if you set a loop, then do stuff, then set inner loop, repeat, repeat again, include a couple of macros, etc. - you end up with a bunch of variables. And if you lose a track of them then it's possible to do COPY ... ... FOR (i=0;i<abc;i+=1) BEGIN ... DO_SMART_STUFF ... FOR (i=0;i<xyz;i+=1) BEGIN ... MORE_STUFF END // i<xyz loop END // i<abc loop In this case two loops usethe same name for the counter, so once the inner one kicks in then the outer is screwed up, because 'i' is set back to 0. While working on ADD_AREA_TRIGGER macros that use a complex structure - about 200 lines in total, with several auxiliary macros - I came to realize the value of listing all variables that are set in every block of code (in this case - macros). I assume you only need to edit separate files, without any global ACTION_IFs or the like. If so then yes, using the same i & k will cause no issues. For the copypasting purpose, if you need to edited only ability headers then COPY_EXISTING ~spell.spl~ ~override~ READ_LONG 0x64 ab_off READ_SHORT 0x68 ab_num FOR (i=0;i<ab_num;i+=1) BEGIN ... END BUT_ONLY_IF_IT_CHANGES is enough. To get effects within those headers then use this COPY_EXISTING ~spell.spl~ ~override~ READ_LONG 0x64 ab_off READ_SHORT 0x68 ab_num READ_LONG 0x6a ef_off FOR (i=0;i<ab_num;i+=1) BEGIN READ_SHORT (ab_off+i*0x28+0x1e) ef_num READ_SHORT (ab_off+i*0x28+0x20) ef_ind FOR (k=0;k<ef_num;k+=1) BEGIN ... END END BUT_ONLY_IF_IT_CHANGES
igi Posted July 26, 2009 Posted July 26, 2009 Not an IESDP question, and not actively contributing anything, so we'll pay a visit to the archive forum...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.