Jump to content

Help wanted: tp2 code to add an area to the worldmap


Constantine

Recommended Posts

I'm trying to write code to insert new map to the worldmap. Here's what I've got from the template by SConrad, but unfortunately it isn't working for me. After the patching, worldmap.wmp became corrupted somehow and won't load in the DLTC :)

COPY_EXISTING ~worldmap.wmp~ ~override~

 READ_LONG 0x30 "area_num"
 READ_LONG 0x34 "area_off"
 READ_LONG 0x38 "link_off"
 READ_LONG 0x3c "link_num"
 READ_LONG 0xc "map_off"
 SET "entry"          = ("%map_off%" + 0xb8)
 SET "outer_check" = 0
 SET "inner_check" = 0
 SET "num_ent"     = 0

 // New offsets
 WRITE_LONG 0x30 ("%area_num%" + 1)
 WRITE_LONG 0x38 ("%link_off%" + 0xf0)

 // Add area to worldmap
 INSERT_BYTES   ("%area_off%" + (0xf0 * "%area_num%")) 0xf0
    WRITE_ASCII ("%area_off%" + (0xf0 * "%area_num%")) ~CE#BR1~ // AR-name
    WRITE_ASCII ("%area_off%" + 0x08 + (0xf0 * "%area_num%")) ~CE#BR1~ // AR-name
    WRITE_ASCII ("%area_off%" + 0x10 + (0xf0 * "%area_num%")) ~CE#BR1~ // AR-name
    WRITE_LONG   ("%area_off%" + 0x34 + (0xf0 * "%area_num%")) 27
    WRITE_LONG   ("%area_off%" + 0x38 + (0xf0 * "%area_num%")) 198 // X coordinate
    WRITE_LONG   ("%area_off%" + 0x3C + (0xf0 * "%area_num%")) 236 // Y coordinate
    WRITE_LONG   ("%area_off%" + 0x30 + (0xf0 * "%area_num%")) 3 // Area flags
    SAY             ("%area_off%" + 0x40 + (0xf0 * "%area_num%")) ~my area~ // Name of the area (Caption)
    SAY             ("%area_off%" + 0x44 + (0xf0 * "%area_num%")) #-1 // Tooltip

    WRITE_LONG ("%area_off%" + 0x68 + (0xf0 * "%area_num%")) ("%link_num%" + 1) // First E link
    WRITE_LONG ("%area_off%" + 0x6c + (0xf0 * "%area_num%")) 1 // Number of links from E

 // Add link to City Gates
//  INSERT_BYTES   ("%link_off%" - 0x01 + (0xd8 * "%link_num%")) 0xd8
 INSERT_BYTES   ("%link_off%"  + (0xd8 * "%link_num%")) 0xd8
    WRITE_LONG   ("%link_off%"            + (0xd8 * "%link_num%")) 11 // City Gates
    WRITE_ASCII ("%link_off%" + 0x04 + (0xd8 * "%link_num%")) ~ExitNE~ // Entrance
WRITE_LONG  ("%link_off%" + 0x24 + ("%link_num%" * 0xd8)) 5           // travel time
    WRITE_LONG   ("%link_off%" + 0x28 + (0xd8 * "%link_num%")) 2 // Unknown

 WRITE_LONG 0x3c ("%link_num%" + 1)

BUT_ONLY_IF_IT_CHANGES

Link to comment

You don't update the value of the link_off variable, you just write the new value to 0x38. Add link_off += 0xf0 before you insert the link and you won't corrupt the file. Edit; that's one problem, but there are others as well.

Edit2: Oh, yeah. Links are numbered from 0, so the index for your link is link_num, rather than link_num + 1.

Link to comment
You don't update the value of the link_off variable, you just write the new value to 0x38. Add link_off += 0xf0 before you insert the link and you won't corrupt the file. Edit; that's one problem, but there are others as well.

Edit2: Oh, yeah. Links are numbered from 0, so the index for your link is link_num, rather than link_num + 1.

It worked! Thanks!!! :)

Link to comment

Archived

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

×
×
  • Create New...