Jump to content
Sign in to follow this  
eugene

custom region/trigger issue

Recommended Posts

hey everyone,

 

I am polishing my mod and wanted to fire some comments if my npc crosses a line. I looked at dynamic trigger/regions on area files and tried Qwinn's macro from here

 

But for some reason it does not work even though I copy-pasted his example. I tried many things with DLTCEP and NearInfinity but everytime failed, could not even set a global :( i hope i am missing a simple typo or easy mistake because I wasted my whole day on it.

 

can any of you give a link of a working example for custom region or point out what I am doing wrong below?

 

thanks

 

if you think my tp2 is crap, here is the proof :)

 

COPY_EXISTING ~AR2402.ARE~ ~override~
 LAUNCH_PATCH_MACRO ~Q_ARE_InitVars~
 LAUNCH_PATCH_MACRO ~Q_AREAdd_InitVars~
 SET "Q_New_Trigg" = 1 // demogorgon
 SET "Q_New_Vertx" = 4 // 4 vertexes
 LAUNCH_PATCH_MACRO ~Q_AREAdd_Process~

 WRITE_ASCII "Q_NewOffset_Trigg"		   ~EULENA1~ #32  //: Name
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x20	0			   //: trigger/region type
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x22	2874			//: bounding box.left
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x24	1246			//: bounding box.top
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x26	3297			//: bounding box.right
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x28	1406			//: bounding box.bottom
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x2A	4			   //: vertice count
 WRITE_LONG  "Q_NewOffset_Trigg" + 0x2C	"Q_Num_Vertx" - 4 //: first vertice index
 WRITE_LONG  "Q_NewOffset_Trigg" + 0x34	0			   //: cursor
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x68	0			 //: trap detection
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x6A	0			 //: trap removal
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x6C	0			   //: trapped
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x70	3025			//: trap loc X
 WRITE_SHORT "Q_NewOffset_Trigg" + 0x72	1198			//: trap loc Y
 WRITE_ASCII "Q_NewOffset_Trigg" + 0x7c	~EULEAR1~ #32  //: script name
 WRITE_ASCII "Q_NewOffset_Trigg" + 0x38	~~ #8		   //: destination area
 WRITE_ASCII "Q_NewOffset_Trigg" + 0x40	~~ #32		  //: entrance name

 //: add 4 Vertexes

 WRITE_SHORT "Q_NewOffset_Vertx"		2874
 WRITE_SHORT "Q_NewOffset_Vertx" + 2	1340
 WRITE_SHORT "Q_NewOffset_Vertx" + 4	2902
 WRITE_SHORT "Q_NewOffset_Vertx" + 6	1406
 WRITE_SHORT "Q_NewOffset_Vertx" + 8	3297
 WRITE_SHORT "Q_NewOffset_Vertx" + 10   1315
 WRITE_SHORT "Q_NewOffset_Vertx" + 12   3253
 WRITE_SHORT "Q_NewOffset_Vertx" + 14   1246

BUT_ONLY_IF_IT_CHANGES

COMPILE ~Lena/Scripts/EULEAR1.baf~

 

and EULEAR1.baf

 

IF
Entered([0])
THEN
RESPONSE #100
	SetGlobal("EU#LenaDemogorgon1","GLOBAL",1)
END

Share this post


Link to post

IIRC scripts are ignored if the area isn't trapped--set it as trapped with detection and removal difficulties of 100, so it'll be invisible to players, and see if it works.

Share this post


Link to post

I've dealt with a similiar situation in the mod I'm currently working on. However, instead of Entered() I've used the IsOverMe() trigger and it worked very well for me.

 

If you are interested, my WeiDU code to add a new region looks like this:

COPY_EXISTING ~ar2000.are~ ~override~
 LPF fj_are_structure
   INT_VAR
   fj_type           = 0         // proximiy trigger
   fj_box_left       = 3360
   fj_box_top        = 2360
   fj_box_right      = 3370
   fj_box_bottom     = 2370
   fj_cursor_idx     = 0         // default cursor
   fj_flags          = (1 << 1)  // [Trap resets]
   fj_trap_active    = 1         // is trapped
   fj_vertex_0       = 3365 + (2370 << 16)
   fj_vertex_1       = 3360 + (2360 << 16)
   fj_vertex_2       = 3370 + (2360 << 16)
   STR_VAR
   fj_structure_type = region
   fj_name           = A7Q2Trigger1
   fj_reg_script     = A7Q2TRIG
 END

 

And my associated script:

IF
 IsOverMe([PC])
 Global("A7Q2Triggered","GLOBAL",0)
THEN
 RESPONSE #100
   SetGlobal("A7Q2Triggered","GLOBAL",1)
   ActionOverride("A7Q2FES",StartDialogueNoSet([PC]))
END

In theory it should also work with Entered() but I haven't tested it.

 

Share this post


Link to post

@CamDawg, thx, I will try this

 

@argent77, I think you use a different macro for the area region add process, can you give a link to the document or source of it?

Share this post


Link to post

fj_are_structure is a very handy patch function to add any kind of structures to area files. See here for more information. LPF is short for LAUNCH_PATCH_FUNCTION.

Share this post


Link to post

@CamDawg, no, did not need to put them actually.

 

@argent77, I used the weidu also but did not work at first.

 

I thought game saves did not hold any area related data but they do. I was testing with a quicksave in ar2402 in demogorgon chamber already and nothing enabled the trap/region. I just tried a very early save and entered ar2402 for the first time. yay... my region was there. reloaded from the save game again, nope, the trap was not there. conclusion, some info are also written to save game.

 

I learned this today :) I hope someone will use this (probably most of you know this hehe)

 

thanks for help guys

Share this post


Link to post
I've dealt with a similiar situation in the mod I'm currently working on. However, instead of Entered() I've used the IsOverMe() trigger and it worked very well for me.
IsOverMe() isn't an event trigger like Entered() and some of the others (Opened(), etc.).

 

Those only respond when the appropriate event fires, and for ground triggers, that means springing the trap (so it has to be marked as trapped if you use Entered()).

 

IsOverMe() just polls the area every frame (or whatever the evaluation period is) and checks for the specified object being in the right spot. It will work from any trigger region, marked as a trap or not.

Share this post


Link to post
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Sign in to follow this  

×