Jump to content

How to change the exact icon of a spell scroll in SR 3.1.03 ?


Recommended Posts

Here the problem: I’m creating currently a little spell shop mod for BG2ToB, and I’ve noticed a little icon error for a precise spell scroll - GhostForm SCRLW801.ITM, Level 8 - in Spell Revisions 3.1.03.

If the spell - SPWI801.SPL - has a correct icon of presentation (identical to SCRL1R.ITM Wraithform spell -> ISCRL1R.BAM)   , it’snot the case for the corresponding scroll - SCRLW801.ITM - that has the icon of Tenser's Transformation - SPWI603A.BAM, Level 6 - ! So I hope that a charitable hand will permit to give me the exact manipulation of code in order to have a correct presentation of this damned scroll. Note I’ve already made a successful modification of SR for this scroll with Near Infinity, but what I wish precisely is a line of code after the installation of SR, like this:

- install SR 3.1.03 first;

- the shop mod installed;

- a command in my tp2 in my mod, like this: IF SCRLW801.ITM is detected, change ONLY its present BAM (SPWI603A.BAM) for the ISCRL1R.BAM without touch to the translations files.

That’s all. Thank you by advance.

 

Link to comment

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
WRITE_BYTE 0x76 "ISCRL1R"
END
END

This should write your icon directly to the file in what I think is the correct spot. (e): Although perhaps this won't work, because the "write_byte" command will only overwrite what you put in (I think), and since "ISCRL1R" is only 7 characters long vs. "SPWI603A", which is 8 characters, I imagine the "A" might be left at the end and effectively make your field "ISCRL1RA". I'm not sure how you define a blank space for that byte. A replace text command might suffer the same issue...except it might destroy the entire file as a bonus? I'm certain there's an easy way to do it, but I'm probably too much of a dummy with weidu to do it.

Edited by Bartimaeus
Link to comment

Dear Bartimaeus, thank you for your help. But well, despite of it the install process doesn’t work at all. I’ve modified the tp2 file of my mod with your code, and after with the add of an A in the "ISCRL1R" line, but well…I think it’s only a little problem of syntax, so I hope that it will be solved without difficulty with yours IE programming skills. NB: my mod is a store that sell all the SR 3.1.03 arcanic spells.

I put here the files, if you can to have a look on these. Thank you by advance.

Sorry if my English isn’t perfect, it’s not my mother tongue.

SETUP-KAYA.DEBUG

WeiDU.log

setup-Kaya.tp2

Link to comment

That's because I'm a dummy and didn't convert between a...variable(?) and...hex-text. Yeah, like I said, I'm not the best with weidu. Also, as mentioned in my edit above, it's probably not even a good idea to pursue my idea anyways due to the length being different. I am sure somebody who actually knows how to cleanly do it will help you - anything I know of is probably going to be a little hacky (and actually I want to know how a person who knows what they're doing would do it for my own future reference).

Edited by Bartimaeus
Link to comment

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

 

Link to comment
	/////////////////////////
	/////////////////////////
	//    mod Kaya pour BG2ToB par Prof Errata     //
	/////////////////////////
	/////////////////////////

BACKUP ~Kaya\backup~
AUTHOR ~Prof Errata~

LANGUAGE ~English~
         ~english~
         ~Kaya/translations/english/dialog.tra~
LANGUAGE ~Francais~
         ~french~
         ~Kaya/translations/french/dialog.tra~

BEGIN @10000

// Creature Stuff

COPY ~Kaya/creature/PEKaya.CRE~ ~override/PEKaya.CRE~       
  SAY NAME1 @10010
  SAY NAME2 @10010

// Stores

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

COPY ~Kaya/store/PEKaya.STO~ ~override/PEKaya.STO~       
  SAY NAME2 @10020

// Dialogues

COMPILE
  ~Kaya/dialogue/PEKaya.d~

// Scripts Extensions

EXTEND_BOTTOM ~ar0702.bcs~ ~Kaya/baf/PEKaya.baf~

AT_INTERACTIVE_EXIT ~VIEW Kaya/ModKaya.txt~

 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...