Jump to content


Photo

How to add an entrance to an existing map ?


  • Please log in to reply
4 replies to this topic

#1 Huxaltec

Huxaltec
  • Member
  • 10 posts

Posted 21 May 2011 - 04:43 AM

Hi there !

I've just added a new travel trigger to an existing map (without any trouble), using this tutorial :
http://forums.gibber...?showtopic=6031

My question : At the moment, I'd like to add it a new entrance. But there's no tutorial for this and I'm just learning weidu language, so I'm afraid of getting loads of errors. How to add an entrance to an existing map, in tp2 file ?

(sorry for my poor English :S)

Thank you a lot !!!

#2 Yovaneth

Yovaneth

    The newly-appointed Master Builder of Baldur's Gate

  • Modder
  • 3058 posts

Posted 21 May 2011 - 10:55 AM

This does both; adds a travel area and its corresponding entrance.

-Y-

	COPY_EXISTING ~ar2000.are~ ~override~
	 // We start by reading offsets and numbers
	 READ_SHORT 0x5a "trig_num"
	 READ_LONG 0x5c "trig_off"
	 READ_LONG 0x60 "spawn_off"
	 READ_LONG 0x68 "ent_off"
	 READ_SHORT 0x6c "ent_num"
	 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"
	 // Add vertices for each side of the travel region bounding box (here we're using just four). Work clockwise from top left.
 	INSERT_BYTES ("%vert_off%" + ("%vert_num%" * 0x4) 	) 0x10
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) 	) 514
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0x2) 290
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0x4) 571
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0x6) 290
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0x8) 571
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0xa) 400
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0xc) 514
	 WRITE_SHORT ("%vert_off%" + ("%vert_num%" * 0x4) + 0xe) 400
	 // Now, we add a new entrance. Yippie!
	 INSERT_BYTES ("%ent_off%" + ("%ent_num%" * 0x68) 	) 0x68
	 WRITE_ASCII ("%ent_off%" + ("%ent_num%" * 0x68) 	) ~Exitc-ar01~ // Name of the new entrance in the existing area
	 WRITE_SHORT ("%ent_off%" + ("%ent_num%" * 0x68) + 0x20) 541 		// Location: X
	 WRITE_SHORT ("%ent_off%" + ("%ent_num%" * 0x68) + 0x22) 409 		// Location: Y
	 WRITE_SHORT ("%ent_off%" + ("%ent_num%" * 0x68) + 0x24) 0 		// Direction facing (0 - 15)
	 // First, we insert the new trigger by adding 196 bytes at a specific location in the file, then we patch it <img src='http://www.shsforums.net/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=':)' />
	 INSERT_BYTES ("%trig_off%" + ("%trig_num%" * 0xc4) 	) 0xc4
	 WRITE_ASCII ("%trig_off%" + ("%trig_num%" * 0xc4) 	) ~Travc-ar01~ // Name of the new trigger in the existing area
	 WRITE_SHORT ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x20) 0x02 	// Which trigger type? 02 = travel
	 WRITE_SHORT ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x22) 512 	// Bounding box - top left X
	 WRITE_SHORT ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x24) 286 	// Bounding box - top left Y
	 WRITE_SHORT ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x26) 588 	// Bounding box - bottom right X
	 WRITE_SHORT ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x28) 412 	// Bounding box - bottom right Y
	 WRITE_SHORT ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x2a) 0x04 	// Number of vertices (4)
	 WRITE_LONG ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x2c) "%vert_num%" // First vertex index
	 WRITE_LONG ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x34) 0x2A 	// Cursor index (2Ah = 42 = door)
	 WRITE_ASCII ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x38) ~c-ar01~ 	// Destination area
	 WRITE_ASCII ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x40) ~Exitc-ar03~ // Exit point in the destination area
	 WRITE_LONG ("%trig_off%" + ("%trig_num%" * 0xc4) + 0x60) 0x04 	// Flags (ach! forgot to ask)
	 SAY 	("%trig_off%" + ("%trig_num%" * 0xc4) + 0x64) #-1 	// Trigger Text (nothing)
	 // Code wrapup - need to adjust numbers of vertices and triggers and adjust offsets
	 WRITE_SHORT 0x80 ("%vert_num%" + 0x04) // Four new vertices
	 WRITE_SHORT 0x5a ("%trig_num%" + 0x01) // One new trigger
	 WRITE_SHORT 0x6c ("%ent_num%" + 0x01) // One new entrance
	 // Remember that even if the offset-fields are listed in one certain order, the offsets aren't
	 SET "adj" = 0xc4
	 WRITE_LONG 0x60 ("%spawn_off%" + "%adj%")
	 WRITE_LONG 0x68 ("%ent_off%" + "%adj%")
	 SET "adj" = (0xc4 + 0x68)
	 WRITE_LONG 0x70 ("%cont_off%" + "%adj%")
	 WRITE_LONG 0x78 ("%item_off%" + "%adj%")
	 WRITE_LONG 0x7c ("%vert_off%" + "%adj%")
	 WRITE_LONG 0x84 ("%amb_off%" + "%adj%")
	 WRITE_LONG 0x88 ("%var_off%" + "%adj%")
	 WRITE_LONG 0xa8 ("%door_off%" + "%adj%")
	 WRITE_LONG 0xb8 ("%tiled_off%" + "%adj%")
	 SET "adj" = (0xc4 + 0x68 + 0x10)
	 WRITE_LONG 0xa0 ("%bmp_off%" + "%adj%")
	 WRITE_LONG 0xb0 ("%anim_off%" + "%adj%")
	 WRITE_LONG 0xbc ("%song_off%" + "%adj%")
	 WRITE_LONG 0xc0 ("%rest_off%" + "%adj%")
	 WRITE_LONG 0xc4 ("%note_off%" + "%adj%")
	BUT_ONLY_IF_IT_CHANGES


#3 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 21 May 2011 - 12:18 PM

There's also the fj_are_structure function shipped with WeiDU. Check the readme, the Macros Listing section.

Another usage example.

Retired from modding.


#4 Huxaltec

Huxaltec
  • Member
  • 10 posts

Posted 22 May 2011 - 03:31 PM

Two methods for the price of one :-D !! That's great, both work fine !!!! Thanks guys !

#5 Huxaltec

Huxaltec
  • Member
  • 10 posts

Posted 23 May 2011 - 06:28 AM

Sorry for double post.

I have a problem with the travel between the existing area (AR0411) and my own area (QQGLY1).
The game crashes with the message : "An Assertion failed in ChVidImage.cpp at line 6134. Programmer says : Tile data accessed when not loaded".

baldur.log says :

---------------------Start Logging Session---------------------

CVisibilityMap::AddCharacter : ( 3464, 3115 ) #:8454273 R:14
CVisibilityMap::AddCharacter : ( 3395, 3062 ) #:8519810 R:14
CVisibilityMap::AddCharacter : ( 1016, 1194 ) #:8454273 R:14
CVisibilityMap::AddCharacter : ( 952, 1194 ) #:8519810 R:14


baldur.err :

---------------------Start Logging Session---------------------

ASSERTION FAILED!
File: ChVidImage.cpp
Line: 6134

Exp: FALSE

Msg: Tile data accessed when not loaded
Run Debugger?



I used Macro method to create an entrance and trigger travel in AR0411 (see the code below), and I also made it (with IETME) in QQGLY1. Others AR0411 travel triggers were deactivated by scripts.
COPY_EXISTING ar0411.are override
  LPF fj_are_structure
    INT_VAR
    fj_type         = 2    //travel
    fj_box_left     = 3295
    fj_box_top      = 2974
    fj_box_right    = 3623
    fj_box_bottom   = 3244
    fj_cursor_idx   = 30   // door
    fj_flags        = 516  // party required, NPCs can't pass
    fj_vertex_0     = 3295 + (3076 << 16)
    fj_vertex_1     = 3407 + (2974 << 16)
    fj_vertex_2     = 3623 + (3144 << 16)
    fj_vertex_3     = 3464 + (3244 << 16)
    STR_VAR
    fj_structure_type   = region
    fj_name             = QQTRGLY1 // region name
    fj_destination_area = QQGLY1      // *.ARE
    fj_destination_name = QQGLYEN          // entrance name
  END
  LPF fj_are_structure
    INT_VAR
    fj_loc_x       = 3271
    fj_loc_y       = 2950
    fj_orientation = 6   // NW
    STR_VAR
    fj_structure_type = entrance
    fj_name           = QQ411EN
  END

An idea ?



EDIT : everything is working now, IETME just failed on saving my QQGLY1.are.

Edited by Huxaltec, 23 May 2011 - 06:57 AM.