temnix Posted May 17, 2020 Share Posted May 17, 2020 I would like all stores to buy Earrings (75). How do I do that? Here is the code I have tried. COPY_EXISTING ~STOBLACK.STO~ ~override~ READ_LONG 0x2C purc-cat READ_LONG 0x30 purc-num SET "present" = 0 // this is a check for this item category FOR (index = 0; index < purc-num; index = index + 1) BEGIN READ_BYTE ("%purc-num%" + ("%index%" * 0x0c)) "present" PATCH_IF present = 75 THEN BEGIN SET "present" = 1 END END PATCH_IF ("present" = 0) BEGIN // if not buying them already WRITE_LONG 0x30 purc-num INSERT_BYTES ("%purc-cat%" + ("%purc-num%" * 4)) 0x0c /// assuming it's 0 bytes WRITE_LONG ("%purc-cat%" + ("%purc-num%" * 4)) ~75~ END The offsets for stores are from the file for Black Lily's store, and the offsets are the same in all of them, but the value at 0x2C differs. What does that mean, exactly? Anyway, if anybody knows what to do with non-working code, you're welcome to say so. I have tried increasing purc-num by 1, too, it doesn't help. Quote Link to comment
Magus Posted May 20, 2020 Share Posted May 20, 2020 Purchased items are dword (4 bytes), you have to use READ/WRITE_LONG, and correspondingly, INSERT 4 bytes, not 0xc. And increase purc-num. Quote Link to comment
temnix Posted May 22, 2020 Author Share Posted May 22, 2020 (edited) On 5/20/2020 at 5:34 PM, qwerty1234567 said: Purchased items are dword (4 bytes), you have to use READ/WRITE_LONG, and correspondingly, INSERT 4 bytes, not 0xc. And increase purc-num. Oh, god. I was hoping no one would reply. If what you said is right, this dooms me to develop another idea... Okay, I rewrote some of the code, but in this form it doesn't change anything: READ_LONG 0x2C purc-cat READ_LONG 0x30 purc-num SET "present" = 0 // this is a check for this item category FOR (index = 0; index < purc-num; index = index + 1) BEGIN READ_LONG ("%purc-num%" + ("%index%" * 0x0c)) "present" PATCH_IF present = 75 THEN BEGIN SET "present" = 1 END END PATCH_IF ("present" = 0) BEGIN // if not buying them already INSERT_BYTES ("%purc-cat%" + ("%purc-num%" * 4)) 0x4c WRITE_LONG ("%purc-cat%" + ("%purc-num%" * 4)) ~75~ SET purc-num = purc-num + 1 WRITE_LONG 0x30 purc-num END It's as if "present" gets set to 1, that is, as if the store already buys earrings. It doesn't. If I remove the check, I can get this to add earrings, but there are unused bytes tailing then. Edited May 22, 2020 by temnix Quote Link to comment
Ardanis Posted May 23, 2020 Share Posted May 23, 2020 (edited) Slightly more complex than adding single category - it adds them in batches, - but this func should give you some idea where your code fails (I spent too much time away from IE to figure it off the top of my head): https://github.com/Gibberlings3/ItemRevisions/blob/master/item_rev/lib/store_rev_macros.tpa#L155 And some context for it: https://github.com/Gibberlings3/ItemRevisions/blob/master/item_rev/lib/store_rev_macros.tpa#L17 https://github.com/Gibberlings3/ItemRevisions/blob/master/item_rev/components/store_revisions.tpa#L106 Edited May 23, 2020 by Ardanis 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.