# fj_add_are_structure --> Calculating Vertex?

## Recommended Posts

Hey guys, I've been using this great ARE-patching script by Nythrun, and showcased by Miloch in here, so thanks to the both of you, but I'm stuck on the Vertex part.

Basically I want to add a hidden trigger area. Not sure how to do it

```LPF fj_add_are_structure
INT_VAR
fj_type    = 1   // 1? not sure which one to select. 2 is Travel, not sure which one is just a trigger box
fj_box_left  = 786
fj_box_top    = 614
fj_box_right  = 845
fj_box_bottom   = 595
fj_cursor_index = 30   // I think I should remove this? Since I want it invisible
fj_vertex_0  = 3415 + (625 << 16)     // How do you calculate Vertex?
fj_vertex_1  = 3450 + (650 << 16)
fj_vertex_2  = 3450 + (700 << 16)
fj_vertex_3  = 3415 + (676 << 16)
STR_VAR
fj_structure_type   = region
fj_name      = DX#ENT01
END```

Also, are there any variables I should be assigning that I'm missing?

EDIT: I probably need to assign it a BCS script. Not sure how

Thanks!

Edited by Daxtreme
##### Link to comment

I use "fj_are_structure", what is the difference to "fj_add_are_structure" or is this a typo?

I used this for a hidden trigger area. (I do not assign a script in the mod, but it should work this way):

```/* area patches: give caravan site detection trigger (AR4100 Archaeological Site) */
COPY_EXISTING ~%ArchaeologicalSite%.are~ ~override~
LPF ~fj_are_structure~
INT_VAR
fj_type         = 0    //trap
fj_box_left    = 3618  //smallest x
fj_box_top     = 2087   //smallest y
fj_box_right   = 3827  //biggest x
fj_box_bottom  = 2240 //biggest y
fj_loc_x       = 3700 //between smallest and biggest x
fj_loc_y       = 2100 //between smallest and biggest y
fj_vertex_0    = 3690 + (2240 << 16)
fj_vertex_1    = 3805 + (2236 << 16)
fj_vertex_2    = 3827 + (2129 << 16)
fj_vertex_3    = 3722 + (2087 << 16)
fj_vertex_4    = 3618 + (2185 << 16)
STR_VAR
fj_structure_type   = region
fj_trap_detect      = 100
fj_trap_active      = 1
fj_trap_status      = 0
fj_name             = c#becara //<- script name of the trigger area
fj_reg_script   = c#becara //<- this would be the assigned script name
END```

##### Link to comment

fj_add_are_structure is the first version of the function. The name was shortened when it was added to WeiDU. OP: you might want to switch to using WeiDU's version. In addition to being supported, there has already been bugs fixed. It also comes with documentation.

Vertex values are calculated by bitshifting the y-coordinate of the point into the high word (y << 16) and adding that to the x-coordinate.

##### Link to comment

Could you point me to a tutorial that explains how to bitshift and calculate the vertex? The tutorial links in here are broken because of new forum platform

Thanks!

Edited by Daxtreme
##### Link to comment

Just take a look at Jastey's code.  A coordinate of (3690, 2240) can be provided as:

`3690 + (2240 << 16)`

##### Link to comment

@Daxtreme What I do to get the coordinates (vertexes) is: open the area in NI, open the graphical view, then just point the cursor to where I want the region to be and note down the x.y coordinates of the vertexes. From those I take the smallest / biggest values etc. As Mike1072 just said, it's just the coordinates in there, so

`fj_vertex_0    = 3690 + (2240 << 16)`

means it's the point [3690.2240].

##### Link to comment

What about vertex_1, vertex_2, etc? how many are needed?

##### Link to comment
1 hour ago, Daxtreme said:

What about vertex_1, vertex_2, etc? how many are needed?

Mathematically at least 3 (or you don't form a 2D polygon/shape).

##### Link to comment

Hey guys,

I did that and it works I think but why does my region look like this? (see attachment)

Here's what my code looks like:

```	COPY_EXISTING ~AR5500.are~ ~override~
PATCH_IF SOURCE_SIZE > 0x28f BEGIN
LPF ~fj_are_structure~
INT_VAR
fj_type         = 0    	//trap
fj_box_left    = 112 	 //smallest x
fj_box_top     = 2280   //smallest y
fj_box_right   = 366 	 //biggest x
fj_box_bottom  = 2477 	//biggest y
fj_loc_x       = 210 	//between smallest and biggest x
fj_loc_y       = 2350 	//between smallest and biggest y
fj_vertex_0    = 112 + (2405 << 16)
fj_vertex_1    = 149 + (2477 << 16)
fj_vertex_2    = 317 + (2280 << 16)
fj_vertex_3    = 366 + (2316 << 16)
STR_VAR
fj_structure_type   = region
fj_trap_detect      = 0
fj_trap_active      = 1
fj_trap_status      = 0
fj_name             = dx#am1			 // script name of the trigger area
fj_reg_script   = dx#am1 			// this would be the assigned script name
END
END
BUT_ONLY```

Chosen points are:

112, 2405

149,2477

317,2280

366,2316

Is there a reason why it looks like an X instead of a rectangle? Thanks!

Edited by Daxtreme
##### Link to comment

The area is traced in the order of the vertices. So pick a vertex and then go clockwise or counterclockwise from it.

##### Link to comment

Thanks a lot, it worked!

##### Link to comment

Hey guys if I add the "trap" region above...

Will the "No Traps or Locks (Weimer)" component of the Tweaks Anthology remove it?

It's not even a trap it's just a trigger region to teleport the player, but I'm not sure how the mod recognizes it.

##### Link to comment
On 7/13/2019 at 5:43 PM, Daxtreme said:

Hey guys if I add the "trap" region above...

Will the "No Traps or Locks﻿ (Weimer)" component of the Tweaks Anthology remove it?

It's not even a trap it's just a trigger region to teleport the player, but I'm not sure how the mod recognizes it.

On 1/13/2019 at 8:38 AM, CamDawg said:

Alright, so I've refined the algorithm here a bit. In the old BG2 Tweaks and Ease of Use, it was brute force: all containers and doors had trapped flags removed and lockpick difficulties set to zero. Floor triggers had a basic check to ensure it wasn't a special event region by checking that it could be detected (values of 1 to 99 inclusive) and then removing the trapped flag.

Tweaks v7 sought to refine this a bit. Containers and doors now only had their traps/locks removed if they had a valid detection/lockpick score, essentially the same 1-99 check that was being applied to floor triggers. The problem was that some containers, such as the ones noted here by @AnonymousHero, have a detection difficulty of zero despite being perfectly valid traps.

So v8 is going to refine the algorithm again. Floor regions, containers, and doors will now check if trap detection is not equal to 100 (instead of 1-99). Scores of 100 are the engine's special undetectable value and the default score for untrapped stuff. Instead of checking on lockpick scores, Tweaks will now directly check if a container or door requires a key, and zero the lockpick score if no key is required. Keep in mind that this change now means you will need to care about keys again instead of just bashing doors, but it should also prevent you from getting into areas and places you shouldn't be.

##### Link to comment

I tested and No Traps or Locks doesn't conflict with adding new "trap" areas like I did in the script above. They still work.

## Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
• Website