Jump to content

BG1 coding questions


jastey

Recommended Posts

That's the one. It's just way too messy to bother with adding the item entirely via .tp2. Work =/= benifit. :D

We should also probably mention that if you are attempting to replace the item with another item with a shorter name than the original, you need to add another line. This is to "end" the item cleanly and is called a null value. If for example you needed to with the code already discussed:

COPY_EXISTING ~AR6700.are~ ~Override/AR6700.are~ //Replace with your area name.
WRITE_ASCII 0x3c8 ~myitem~
 WRITE_BYTE 0x3c9 0x00 //Sets a null value in the very next byte.
WRITE_ASCII 0x3d2 ~1~

 

I hope we haven't confused you entirely and forced some kind of traumatic episode that's resulted in you swearing off modding forever. :D

Link to comment

Well, no traumatic episode, but I'm getting a bit frustrated, because I have no idea what I'm actually doing when using those hex ascii stuff... (*feeling really stupid*), so many thanks for your help! I'm afraid it will be a long way, still...

 

I tried the following code now:

 COPY ~Modfolder/Items/myitem.ITM~ ~Override~
SAY NAME1 @8
SAY NAME2 @8
SAY UNIDENTIFIED_DESC @9
SAY IDENTIFIED_DESC @9

COMPILE ~Modfolder/Dialogues~

COMPILE ~Modfolder/Scripts~

EXTEND_TOP ~AR3344.bcs~ Modfolder/Scripts/C#AR3344.baf~ 

COPY_EXISTING ~AR3344.are~ ~Override/AR3344.are~ 
WRITE_ASCII 0x3c8 ~myitem~
WRITE_BYTE 0x3c9 0x00 //Sets a null value in the very next byte.
WRITE_SHORT 0x3d2 ~1~

 

Which installed without warning but resulted in no item at all. :D

 

The reason why I'm not using COPY_EXISTING: I'm not familiar with it... And I didn't need it up to now. I thought.

 

 It is possible to add an item via a tp2, it takes a lot of coding though.

@Idobec: This sounds as if you'd probably know how to code that? *hope arises*

Link to comment

On quick glance, I'd say it's because you DON'T need that null value in there. Misc07 and MyItem have the same length, so try it without. I thought you were just using MyItem as an example! (It's sorta the token example name for all advice code. heheh) There's a tutorial kicking around with all the WRITE_xxxxx fully explained, but I don't have time to find it for you. I'm off shift and get to go home. :D

 

Edit: Oh yeah, don't forget to check what it looks like in NI after installing. That can usually give you an idea if anything is wrong. :D

Link to comment

Stupid me! Of course the name of the item is not "myitem". I wanted to keep the code general, I guess for this context that's not a good idea. So here's the actual code:

COPY_EXISTING ~AR3344.are~ ~Override/AR3344.are~

WRITE_ASCII 0x3c8 ~C#NO1~

WRITE_BYTE 0x3c9 0x00 //Sets a null value in the very next byte.

WRITE_SHORT 0x3d2 ~1~

 

So, my item name is shorter than Misc07. Is it correct to put a null value into the next byte then? (I really have no idea)

 

I'm off shift and get to go home
Thanks for your help and patience, I really appreciate it! :D
Link to comment
Yeah, stick a null value in there or else everything after that will be moved forward in the file by one byte.

Er, no. The resref for the item will be wrong is all.

 

So, my item name is shorter than Misc07. Is it correct to put a null value into the next byte then? (I really have no idea)

The byte (or bytes) after your filename ends, yes. Do it without any WRITE_BYTES first and then look at the file in NI to get an idea for what is needed.

Link to comment
btw, the 0 byte should go to 0x3cd not 0x3c9.

*bangs her head with something hard*

Thanks, Avenger! With the correct inserted null, the item is correctly replaced! But by loading a different savegame I discoverd, that if the chest was already emptied by the player before installing the mod, my item is lost, too. :D

 

 

Is it necessary to patch the area?

Why not create a new .are with the extra item?

And just replace the existing area? But then again the compatibility with other mods would be lost, in case an other mod changed the area, too...
Link to comment
And just replace the existing area? But then again the compatibility with other mods would be lost, in case an other mod changed the area, too...
The way you are doing the patch then compatibility will be lost regardless. If another mod changes the area then the item you are overwriting will no longer be at that offset.
Link to comment

You mean the hex numbers won't be the same any more? I didn't know that. Well, replacing an existing item is not the way of my joice anyway, because of the above mentioned problem.

 

But assuming the container is still unchanged by the other mod, would it be possible (and if yes, then how) to read the offset of the item, and then use these numbers for the replacing?

 

Still loking for a way to place an item into a chest via .tp2...

Link to comment

If the area was already loaded, you can't really do it compatibly, except using a script.

Problem is that you can't assign a script to the container either (if the area is already in the saved game). And i think it is the only way to create an item in the container (CreateItem from the container's script).

Link to comment
Problem is that you can't assign a script to the container either (if the area is already in the saved game)

What exactly do you mean by that? I assigned a script via .tp2 to a container and I played a save game where I already visited that area before. (The "CreateItem" scipt from above, and the item was in front of the container.)

 

BTW: Thank you all for your help so far! I learned a lot already. :D

 

Er... meaning I'm ready (and hoping) to learn more... :D

Link to comment
Problem is that you can't assign a script to the container either (if the area is already in the saved game)

What exactly do you mean by that? I assigned a script via .tp2 to a container and I played a save game where I already visited that area before. (The "CreateItem" scipt from above, and the item was in front of the container.)

 

BTW: Thank you all for your help so far! I learned a lot already. :D

 

Er... meaning I'm ready (and hoping) to learn more... :D

Interesting you were able to modify the script. Maybe it wasn't in the savegame anyway. :D

 

Maybe bg2 is different from bg1 in how CreateItem works (or i remember wrong and it isn't createitem).

Link to comment

Hi Avenger,

I started a savegame now where I am in the area and even already opened the container before, and my mod item was there (*phew..*). But, as I said, it lands in front of the chest... Which is only... sort of convenient. :D

 

I guess I'll try the sample package of CBisson for adding a container (with item) into an existing area via .tp2 code next. after I understood it, that is, in, let's say, three years. :D

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...