Author Topic: Adding offsets?  (Read 3134 times)

Loriel

  • Guest
Adding offsets?
« on: August 29, 2003, 04:27:33 PM »
Is there a way to use weidu to add offsets to a file?  For example, I want to add a trigger point to ar0700.are.  Now if I was simply changing a trigger point, I could use the WRITE_BYTE (or SHORT/LONG/ASCII - whichever applies).  I was wondering if there is a way to completely add a new trigger point using weidu.  I figure after adding it, you could use the WRITE_BLAH to add in all the specific information for that trigger point.

The reason I want to know is, I would hate to overwrite another mod's modified area if I can simply add onto it.

japheth

  • Guest
Adding offsets?
« Reply #1 on: August 29, 2003, 04:33:11 PM »
Yes you can.  You'll have to make use of READ_BYTE/LONG/SHORT though.

Check the WeiDU Readme for some tutorials I wrote.

Loriel

  • Guest
Adding offsets?
« Reply #2 on: August 29, 2003, 09:14:35 PM »
Darn it - just once I'd like to ask a question that ISN'T in the readme! :rolleyes:   Thanks for the great tutorial, by the way.  I guess I should read that readme every morning!

icelus

  • Guest
Adding offsets?
« Reply #3 on: August 29, 2003, 09:15:55 PM »
Quote
I guess I should read that readme every morning!
Are you a masochist, too????  I thought I was the only one   :ph34r:  

Loriel

  • Guest
Adding offsets?
« Reply #4 on: August 30, 2003, 02:57:58 AM »
Quote
Are you a masochist, too????  I thought I was the only one   :ph34r:
I think masochist would be those who have memorized it and quote from it, chapter and verse.  You can call me a masochist-in-training... :rolleyes:  

Loriel

  • Guest
Adding offsets?
« Reply #5 on: August 30, 2003, 05:17:11 AM »
I thought I had the concept - but in practice, this code produces a corrupted ar0700.are.  I was hoping someone with a sharper eye than mine could help with this.

Code: [Select]
COPY_EXISTING ~ar0700.are~ ~override/ar0700.are~

  READ_LONG "0xc4" "mapnotesoffset"
  READ_LONG "0xc8" "#mapnotes"
  
  WRITE_LONG 0xc4 ("%mapnotesoffset%" + 0x34)
  WRITE_LONG 0xc8 ("%#mapnotes%" + 1)
  
  INSERT_BYTES ("%mapnotesoffset%" + "%#mapnotes%" * 0x34) 0x34
  
  WRITE_SHORT ("%mapnotesoffset%" + "%#mapnotes%" * 0x34) 3587  //  X coordinate

Also, in the tutorial, it mentions that you could set the flags for the item.  How would you figure out the offset to do that?  From the examples, I thought this might be possible, but I thought I would ask first:

Code: [Select]
WRITE_SHORT ("%mapnotesoffset%" + "%#mapnotes%" * 0x34 + 2)  //  Y coordinate

BTW - I used PRINT as was suggested, and it seems that the last part (X coordinate) still has a value of 0.  I can't check it with NI since it's a corrupted file, so I don't know what happened.  I think I surged... :P   What was that over there?


EDIT:  I forgot to mention that I'm using the latest MacOS X version 1.26 (in case it makes a difference)
« Last Edit: August 30, 2003, 05:23:15 AM by Loriel »

japheth

  • Guest
Adding offsets?
« Reply #6 on: September 02, 2003, 02:47:48 PM »
You almost have it there Loriel, but not quite. :)

Since mapnotes are the last entry in any .are file, you don't have to worry about updating any other offsets (including the automap offset).

Here's some updated code that works:

Code: [Select]
COPY_EXISTING ~ar0700.are~ ~override/ar0700.are~
READ_LONG "0xc4" "automapoffset" // Read in the automap offset
READ_LONG "0xc8" "#automap" // Read in the # of automaps

INSERT_BYTES "%automapoffset%" 0x34 // Insert our bytes for the automap entry at the automap offset

WRITE_SHORT "%automapoffset%" 1000 // X co-ordinate
WRITE_SHORT ("%automapoffset%" + 0x2) 1000 // Y co-ordinate
SAY ("%automapoffset%" + 0x4) ~This is the automap text.~ // Automap text
WRITE_BYTE ("%automapoffset%" + 0x8) 1  // This is 1 for every automap
WRITE_SHORT ("%automapoffset%" + 0xa) 2 // Automap icon colour

WRITE_LONG 0xc8 ("%#automap%" + 1) // Update the # of automap entries

Adding in say, an actor is a little more complex since you have to update any offset that occurs *after* the actor offset.

So, if you were to add one actor using WeiDU, you would have to update the following offsets by 272 bytes (the length of an actor entry):[ul][li]Info/Travel/Proximity Trigger[/li][li]Spawn Points[/li][li]Entrances[/li][li]Containers[/li][li]Items[/li][li]Ambients[/li][li]Variables[/li][li]Doors[/li][li]Tiled Objects[/li][li]Vertices[/li][li]Animations[/li][li]Explored Bitmap[/li][li]Songs[/li][li]Rest Spawn[/li][li]Automap[/li][/ul]That's the order that they occur in the file as well.  So, for example, if you were to add an animation, then you would only have to update the following offsets (since anything occuring before the animation will be pointing to the correct spot):[ul][li]Explored Bitmap[/li][li]Songs[/li][li]Rest Spawn[/li][li]Automap[/li][/ul]And... that's about it really.


japh
« Last Edit: September 02, 2003, 03:37:19 PM by japheth »

Loriel

  • Guest
Adding offsets?
« Reply #7 on: September 03, 2003, 01:31:08 AM »
Thanks for the tips, I was just going ask why the other offsets weren't updating (i have an info point to do as well).

On a side note, could you clarify the difference between SAY and WRITE_ASCII for me?

japheth

  • Guest
Adding offsets?
« Reply #8 on: September 03, 2003, 06:28:41 PM »
SAY will actually write the given string in between the tildes to the dialog.tlk and update the file to point to the string.

WRITE_ASCII just inserts the given ASCII characters into the file.

Loriel

  • Guest
Adding offsets?
« Reply #9 on: September 04, 2003, 01:38:16 AM »
If SAY writes to the dialog.tlk, why would you want to use WRITE_ASCII?  Every item, cre, sto, etc that I've looked at has references to the dialog.tlk for even the names.  Would it be safe to say that shorter things like names/death variables use WRITE_ASCII, while longer things like automap notes/item descriptions use SAY?  Or are they interchangeable?

EDIT:  Actually, I noticed in a few mods that SAY is used for names, so I'm even more perplexed as to when it's appropriate to use either one.
« Last Edit: September 04, 2003, 01:40:22 AM by Loriel »

Idobek

  • Guest
Adding offsets?
« Reply #10 on: September 04, 2003, 06:20:00 AM »
You use SAY to display the name of the file as it is displayed in game. So to change the name of Ribald's store from "Adventurer's Mart" to "Ribald's Store" I would use:

COPY_EXISTING ~ribald.sto~ ~override/ribald.sto~
SAY NAME2 ~Ribald's Store~

You use WRITE_ASCII to write a resource reference into a file. So if I wanted Ribald to sell Azuredge  instead of a standard battle ase I would use:

COPY_EXISTING ~ribald.sto~ ~override/ribald.sto~
WRITE_ASCII 0x114 ~ax1h10.itm~

Does that clarify things?

japheth

  • Guest
Adding offsets?
« Reply #11 on: September 04, 2003, 11:55:20 AM »
Well, actually it would be:

COPY_EXISTING ~ribald.sto~ ~override/ribald.sto~
WRITE_ASCII 0x114 ~ax1h01~

When you are writing in any type of resource type, you never need the extension.  The fields are usually keyed to a certain resource type anyways.

Loriel

  • Guest
Adding offsets?
« Reply #12 on: September 04, 2003, 12:22:31 PM »
I think I understand now - if it's adding a resource such as items, spells, etc (something with an extension), then use WRITE_ASCII.  If it's something that the game text will display, then use SAY.

EDIT: Just re-read this post and realized that my thoughts are formed in BCS format now (too much scripting!):

Code: [Select]
IF
    HasExtension("Resource")
THEN
    RESPONSE #100
        WRITE_ASCII("Resource")
END
I think I'll go find another hobby now... :rolleyes:

EDIT (again): Another way of looking at it would be if it requires a strref in NI, then you need to use SAY, otherwise WRITE_ASCII works fine.
« Last Edit: September 04, 2003, 12:53:34 PM by Loriel »

Idobek

  • Guest
Adding offsets?
« Reply #13 on: September 04, 2003, 05:12:56 PM »
Quote
When you are writing in any type of resource type, you never need the extension. The fields are usually keyed to a certain resource type anyways.

I did, of course, know this. I was just testing to see if anyone would notice the mistake.  :D  

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: