Jump to content

Adding (drawing) new floor triggers via WeiDU


aVENGER_(RR)

Recommended Posts

For example, in case I want to add a new floor trap to a certain area, can I do this by patching its .are file with WeiDU? So far, the only way to do this is editing the .are with IETME or DLTCEP. However, that method overwrites an existing .are file which I'd like to avoid in the future.

Link to comment

Hmm, I think I've found a bit of code from the BG2 Fixpack which deals with the aforementioned issue:

 

// fixes coordinates
 COPY_EXISTING ~AR3000.ARE~ ~override~
READ_SHORT 0x5A "info_num"
READ_LONG  0x5C "info_off"
READ_LONG  0x7c "vert_off"
READ_LONG  0xa4 "door_num"
READ_LONG  0xa8 "door_off"
WHILE ("%info_num%" > 0) BEGIN
  SET "info_num" = ("%info_num%" - 1)
  READ_ASCII ("%info_off%" + 0x7c + (0xC4 * "%info_num%")) "script"
  PATCH_IF ("TP3001A" STRING_COMPARE_CASE "%script%" = 0) BEGIN
	WRITE_SHORT ("%info_off%" + 0x24 + (0xC4 * "%info_num%")) 406  // bounding box
	READ_LONG   ("%info_off%" + 0x2c + (0xC4 * "%info_num%")) "vert_idx"
	WRITE_SHORT ("%vert_off%" +		(("%vert_idx%" + 3) * 0x04)) 1040 // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%" + 3) * 0x04)) 406  // vertex
  END ELSE
  PATCH_IF ("TP3017B" STRING_COMPARE_CASE "%script%" = 0) BEGIN
	READ_LONG   ("%info_off%" + 0x2c + (0xC4 * "%info_num%")) "vert_idx"
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%" + 2) * 0x04)) 1774 // vertex
  END ELSE
  PATCH_IF ("TP3019B" STRING_COMPARE_CASE "%script%" = 0) BEGIN
	WRITE_SHORT ("%info_off%" + 0x24 + (0xC4 * "%info_num%")) 1596 // bounding box
	READ_LONG   ("%info_off%" + 0x2c + (0xC4 * "%info_num%")) "vert_idx"
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%" + 1) * 0x04)) 1569 // vertex
  END ELSE
  PATCH_IF ("TP3020" STRING_COMPARE_CASE "%script%" = 0) BEGIN
	WRITE_SHORT ("%info_off%" + 0x22 + (0xC4 * "%info_num%")) 429  // bounding box
	WRITE_SHORT ("%info_off%" + 0x24 + (0xC4 * "%info_num%")) 1899 // bounding box
	WRITE_SHORT ("%info_off%" + 0x26 + (0xC4 * "%info_num%")) 489  // bounding box
	WRITE_SHORT ("%info_off%" + 0x28 + (0xC4 * "%info_num%")) 2039 // bounding box
	READ_LONG   ("%info_off%" + 0x2c + (0xC4 * "%info_num%")) "vert_idx"
	WRITE_SHORT ("%vert_off%" +		(("%vert_idx%"	) * 0x04)) 429  // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%"	) * 0x04)) 2003 // vertex
	WRITE_SHORT ("%vert_off%" +		(("%vert_idx%" + 1) * 0x04)) 448  // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%" + 1) * 0x04)) 1899 // vertex
	WRITE_SHORT ("%vert_off%" +		(("%vert_idx%" + 2) * 0x04)) 489  // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%" + 2) * 0x04)) 1931 // vertex
	WRITE_SHORT ("%vert_off%" +		(("%vert_idx%" + 3) * 0x04)) 483  // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%vert_idx%" + 3) * 0x04)) 2039 // vertex
  END
END
WHILE ("%door_num%" > 0) BEGIN
  SET "door_num" = ("%door_num%" - 1)
  READ_ASCII ("%door_off%" +		("%door_num%" * 0xc8)) "doorname"
  READ_BYTE  ("%door_off%" + 0x29 + ("%door_num%" * 0xc8)) "usekey"
  PATCH_IF ("%doorname%" STRING_COMPARE_CASE "DOOR02" = 0) BEGIN
	WRITE_SHORT ("%door_off%" + 0x44 + ("%door_num%" * 0xc8)) 508 // bounding box
	READ_LONG   ("%door_off%" + 0x34 + ("%door_num%" * 0xc8)) "cl_vert_idx" // closed vertex index
	WRITE_SHORT ("%vert_off%" +		(("%cl_vert_idx%" + 1) * 0x04)) 445  // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%cl_vert_idx%" + 1) * 0x04)) 1896 // vertex
	WRITE_SHORT ("%vert_off%" +		(("%cl_vert_idx%" + 2) * 0x04)) 508  // vertex
	WRITE_SHORT ("%vert_off%" +		(("%cl_vert_idx%" + 3) * 0x04)) 495  // vertex
	WRITE_SHORT ("%vert_off%" + 0x02 + (("%cl_vert_idx%" + 3) * 0x04)) 2048 // vertex
  END
END
BUT_ONLY_IF_IT_CHANGES

 

As I understand it, this block (among other things) re-draws the trigger box for the entrance to the sixth level of Watcher's Keep (TP3020). So, if someone could clarify the code to me I'd be much obliged. :) Basically, all I want to know it how to designate the map coordinates for the corners of a new trigger box and how to assign that trigger an "on clicked" script (but not necessarily a trap script) and how to change the cursor icon into something else (i.e. an area travel icon - cursor index 34).

Link to comment

I don't know how to do this, but for comparison you can grab a similar coe block from Pro-5's addition of P%DragonTrigger setting a trap in BG1 NPC, and the addtions as well in Sirene's call, i think.

 

Here is Pro5's code in BG1 NPC:

 

  /* Macro adding proximity trigger into FW /ARD013.ARE (for Coran dragon talk) by pro-5 */
 DEFINE_PATCH_MACRO ~DRAGON_TRIGGER~ BEGIN
READ_LONG 0x54 "actor_off"
READ_LONG 0x5c "info_off"
READ_SHORT 0x5a "info_num"
READ_LONG 0x60 "spawn_off"
READ_LONG 0x68 "ent_off"
READ_LONG 0x70 "cont_off"
READ_LONG 0x78 "item_off"
READ_LONG 0x7c "vert_off"
READ_SHORT 0x80 "vert_num"
READ_LONG 0x84 "amb_off"
READ_LONG 0x88 "var_off"
READ_LONG 0xa0 "bmp_off"
READ_LONG 0xa8 "door_off"
READ_LONG 0xb0 "anim_off"
READ_LONG 0xb8 "tiled_off"
READ_LONG 0xbc "song_off"
READ_LONG 0xc0 "rest_off"
READ_LONG 0xc4 "note_off"
SET "Left" = 1
SET "Top" = 1
SET "Right" = 2800
SET "Bottom" = 1600
WRITE_SHORT 0x5a ("%info_num%" + 1)
INSERT_BYTES "%info_off%" 0xC4	// insert new blank info point
  WRITE_ASCII "%info_off%" ~P5#DragonTrigger~	 // name
  WRITE_SHORT ("%info_off%" + 0x22) "%Left%"
  WRITE_SHORT ("%info_off%" + 0x24) "%Top%"
  WRITE_SHORT ("%info_off%" + 0x26) "%Right%"
  WRITE_SHORT ("%info_off%" + 0x28) "%Bottom%"
  WRITE_SHORT ("%info_off%" + 0x2A) 4 // # vertices
  WRITE_LONG ("%info_off%" + 0x2C) "%vert_num%"   // first vertex index
  WRITE_BYTE ("%info_off%" + 0x60) 2  // Flags: Trap Resets=true
 //  WRITE_BYTE ("%info_off%" + 0x60) 10 // Flags: Trap Resets=true, Trap Detectable=true - for testing
 //  WRITE_SHORT ("%info_off%" + 0x68) 1 // Trap det.difficulty - for testing
  WRITE_SHORT ("%info_off%" + 0x6C) 1 // Trap flag - needed
  WRITE_ASCII ("%info_off%" + 0x7C) ~P5ARD013~ #8 // Script name
PATCH_IF NOT ("%actor_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x54 ("%actor_off%" + 0xC4)
END
PATCH_IF NOT ("%spawn_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x60 ("spawn_off" + 0xC4)
END
PATCH_IF NOT ("%ent_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x68 ("ent_off" + 0xC4)
END
PATCH_IF NOT ("%cont_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x70 ("cont_off" + 0xC4)
END
PATCH_IF NOT ("%item_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x78 ("item_off" + 0xC4)
END
PATCH_IF NOT ("%vert_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x7c ("vert_off" + 0xC4)
END
PATCH_IF NOT ("%amb_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x84 ("amb_off" + 0xC4)
END
PATCH_IF NOT ("%var_off%" < "%info_off%") BEGIN
  WRITE_LONG 0x88 ("var_off" + 0xC4)
END
PATCH_IF NOT ("%bmp_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xa0 ("bmp_off" + 0xC4)
END
PATCH_IF NOT ("%door_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xa8 ("door_off" + 0xC4)
END
PATCH_IF NOT ("%anim_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xb0 ("anim_off" + 0xC4)
END
PATCH_IF NOT ("%tiled_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xb8 ("tiled_off" + 0xC4)
END
PATCH_IF NOT ("%song_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xbc ("song_off" + 0xC4)
END
PATCH_IF NOT ("%rest_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xc0 ("rest_off" + 0xC4)
END
PATCH_IF NOT ("%note_off%" < "%info_off%") BEGIN
  WRITE_LONG 0xc4 ("note_off" + 0xC4)
END
// Add 4 new vertices
READ_LONG 0x54 "actor_off"
READ_LONG 0x5c "info_off"
READ_SHORT 0x5a "info_num"
READ_LONG 0x60 "spawn_off"
READ_LONG 0x68 "ent_off"
READ_LONG 0x70 "cont_off"
READ_LONG 0x78 "item_off"
READ_LONG 0x7c "vert_off"
READ_SHORT 0x80 "vert_num"
READ_LONG 0x84 "amb_off"
READ_LONG 0x88 "var_off"
READ_LONG 0xa0 "bmp_off"
READ_LONG 0xa8 "door_off"
READ_LONG 0xb0 "anim_off"
READ_LONG 0xb8 "tiled_off"
READ_LONG 0xbc "song_off"
READ_LONG 0xc0 "rest_off"
READ_LONG 0xc4 "note_off"
WRITE_SHORT 0x80 ("%vert_num%" + 4)
INSERT_BYTES ("%vert_off%" + (0x04 * "%vert_num%")) 0x10
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%")   948	// Vertex1.X
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" + 2) 1588 // Vertex1.Y
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" + 4) 651  // Vertex2.X
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" + 6) 1125 // Vertex2.Y
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" + 8) 2366 // Vertex3.X
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" +10) 351  // Vertex3.Y
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" +12) 2743 // Vertex4.X
	WRITE_SHORT ("%vert_off%" + 0x04 * "%vert_num%" +14) 618  // Vertex4.Y
PATCH_IF NOT ("%actor_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x54 ("%actor_off%" + 0x10)
END
PATCH_IF NOT ("%info_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x5c ("info_off" + 0x10)
END
PATCH_IF NOT ("%spawn_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x60 ("spawn_off" + 0x10)
END
PATCH_IF NOT ("%ent_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x68 ("ent_off" + 0x10)
END
PATCH_IF NOT ("%cont_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x70 ("cont_off" + 0x10)
END
PATCH_IF NOT ("%item_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x78 ("item_off" + 0x10)
END
PATCH_IF NOT ("%amb_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x84 ("amb_off" + 0x10)
END
PATCH_IF NOT ("%var_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0x88 ("var_off" + 0x10)
END
PATCH_IF NOT ("%bmp_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xa0 ("bmp_off" + 0x10)
END
PATCH_IF NOT ("%door_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xa8 ("door_off" + 0x10)
END
PATCH_IF NOT ("%anim_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xb0 ("anim_off" + 0x10)
END
PATCH_IF NOT ("%tiled_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xb8 ("tiled_off" + 0x10)
END
PATCH_IF NOT ("%song_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xbc ("song_off" + 0x10)
END
PATCH_IF NOT ("%rest_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xc0 ("rest_off" + 0x10)
END
PATCH_IF NOT ("%note_off%" < "%vert_off%") BEGIN
  WRITE_LONG 0xc4 ("note_off" + 0x10)
END
 END
Link to comment
I don't know how to do this, but for comparison you can grab a similar coe block from Pro-5's addition of P%DragonTrigger setting a trap in BG1 NPC, and the addtions as well in Sirene's call, i think.

 

Thank you! I was able to adapt Pro5's code to do what I wanted. :)

 

I'll add the appropriate credits and a big "Thanks!" to both of you in the Rogue Rebalancing readme. Cheers!

Link to comment

Cheers, but don't add me - just add pro-5. I am still studying pro-5's code to figure out what he is doing!!! :)

 

The Sirine's Call stuff has even more commenting and special tutorial code, so it is worth looking at, too (he adds new areas and sets a good bit of the map via weidu, I think). Pro-5 is most active at SHS, but visits all boards.

Link to comment
Cheers, but don't add me - just add pro-5. I am still studying pro-5's code to figure out what he is doing!!! :)

 

Hey, you pointed me in the right direction and that counts too! :)

 

BTW, the code works like a charm. It's very handy for on the fly area edits, especially for seamlessly inserting new travel triggers into existing areas. Oh and, I'll definitively check out Sirene's Call when I get to replaying BG1 again. :)

Link to comment

Archived

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

×
×
  • Create New...