Mike1072 Posted June 24, 2019 Share Posted June 24, 2019 2 hours ago, Prof Errata said: IT WORKS ! YOUPI ! Thank you Mike, now I can send my mod ! Glad to hear. 2 hours ago, Prof Errata said: NB: you are Canadian, so do you live near of the province of Quebec ? Nope; other side of the country. We all learn some French in school, though. Quote Link to comment
subtledoctor Posted June 24, 2019 Share Posted June 24, 2019 If you want to be lazy like me, ALTER_SPELL_HEADER and ALTER _ITEM_HEADER work great for setting the icon. Quote Link to comment
Bartimaeus Posted June 24, 2019 Share Posted June 24, 2019 (edited) 16 hours ago, Mike1072 said: The main issue with writing over the entire text field can be solved like this: WRITE_ASCII 0x76 ~ISCRL1R~ #8 This is likely to work if the file hasn't been changed between when SR is installed and your mod is installed. However, it's good practice to not rely on this, and there is a safer way to code this sort of thing. The icon will not always be stored at offset 0x76. The icon field is part of the extended header section of the file. An item may have one or more extended headers, also known as abilities. They are each 0x38 bytes in length and they may not be located directly after the header. We can find out how many abilities there are and where they start in the file by reading that information from the header, in offsets 0x68 and 0x64. Then we can loop through each ability and change its icon. Here's the full code: ACTION_IF (FILE_EXISTS_IN_GAME ~scrlw801.itm~) THEN BEGIN // SR Wraithform COPY_EXISTING ~scrlw801.itm~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files READ_LONG 0x64 abilities_offset READ_SHORT 0x68 num_abilities FOR (i = 0; i < num_abilities; i += 1) BEGIN // loop through abilities // update icon WRITE_ASCII (abilities_offset + 0x38*i + 0x04) ~ISCRL1R~ #8 END END BUT_ONLY END I've used that sort of setup for spells, but I hadn't considered that items with more than one extended header (or none at all) might also change the location. That #8 for 8 bytes is also very helpful to know. Thanks! Edited June 24, 2019 by Bartimaeus Quote Link to comment
Mike1072 Posted June 24, 2019 Share Posted June 24, 2019 Depending on what kind of item it is, those abilities might be something like ranged version / melee version, or they could be separate magical abilities. So for something like changing an icon, I'd probably add some sort of check during the loop to make sure I was modifying the right one. I wanted to put some code out there that wouldn't rely on arbitrary unsafe offsets outside the file header. If you're modifying a file where you aren't sure of its exact contents, you can't be sure that the data you want will be located at those offsets. (Even if it almost always will be.) Subtledoctor's probably right that there are functions that can do this sort of thing as well, but it helps to know how the underlying data is structured. Knowing how to code it yourself also gives the advantage that you can implement more complicated logic in your patches that you might not be able to do with pre-made functions. Quote Link to comment
Prof Errata Posted July 12, 2019 Author Share Posted July 12, 2019 Dear Mike, I need your help again. Recently my mod have been modified for BG2EE integration, and yet the problem with this SCRLW801.ITM has reappeared…Argh…well, i hope that this problem will be resolved once for all, I put here the beta and the WeiDU log. Thanks by advance. Note if you could correct moreover the possible grammatical inaccuracies of the readme, I would be enchanted. NB: the spell keep its normal icon once memorized. Kaya_v2beta.rar WeiDU.log Quote Link to comment
Mike1072 Posted July 13, 2019 Share Posted July 13, 2019 The code you have is changing the icons for the extended headers (item abilities). If you want to change the inventory icon as well, you need to add this line of code when you patch SCRLW801.ITM: WRITE_ASCII 0x3a ~ISCRL1R~ #8 // update inventory icon I would insert it right after this line: PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files Quote Link to comment
Prof Errata Posted July 13, 2019 Author Share Posted July 13, 2019 Wel it works… Thank you again, Mike, now I can release the definitive version of my mod. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.