Jump to content
Sign in to follow this  
qwerty12345

Detect active locks / traps

Recommended Posts

Suppose I want to make a script that would enable a thief automatically disarm any found trap and automatically pick any lock in sight. What's my best bet to do that?

The issue is that I don't see a way to determine the state of the object: locked (yes/no), trap armed (yes/no). The closest thing I could find is OpenState(), but it doesn't seem to work on containers.

Share this post


Link to post

I've made a script like that. It was a bit tedious, because you need to know exactly which traps are detected and trapped beforehand. What I did was to create global variables for each trap and each lock in the trap scripts and used the triggers Detected, Disarmed and Opened in that script. Then when I knew the global variables, I could check what their value was in a normal script.

 

For example, in when you start a new game, there is a chest called "Picture 1" which is trapped with a script called GDARTS. So what you could do is edit gdarts.bcs with Near Infinity like this:

 

...
...
IF
OnCreation()
THEN
RESPONSE #100
 SetGlobal("Picture 1 trap","AR0602",2)
 SetGlobal("Picture 1 lock","AR0602",1)
END
IF
Detected([ANYONE])
AreaCheck("AR0602")
Name("Picture 1",Myself)
!Global("Picture 1 trap","AR0602",1)
THEN
RESPONSE #100
 SetGlobal("Picture 1 trap","AR0602",1)
END
IF
Disarmed([ANYONE])
AreaCheck("AR0602")
Name("Picture 1",Myself)
!Global("Picture 1 trap","AR0602",0)
THEN
RESPONSE #100
 SetGlobal("Picture 1 trap","AR0602",0)
END
IF
Unlocked([ANYONE])
AreaCheck("AR0602")
Name("Picture 1",Myself)
!Global("Picture 1 lock","AR0602",0)
THEN
RESPONSE #100
 SetGlobal("Picture 1 lock","AR0602",0)
END

 

Then you could disarm (or unlock) the trap in a custom script.

// Very close to "Picture 1", start searching
IF
Class(Myself,THIEF_ALL)
Range("Picture 1",10)
!ModalState(DETECTTRAPS)								   // !DETECTTRAPS in the last round?
Global("Picture 1 trap","AR0602",2)						  // Is trapped but not detected
THEN
RESPONSE #100
 DisplayString(Myself,52376)						   // "There is something here.. just let me - Hold! It moves!"
 ClearActions(Myself)
 FindTraps()
END
// "Picture 1" trap detected (detect skill: 50)
IF
Range("Picture 1",10)
Global("Picture 1 trap","AR0602",1)						  // Is detected
Class(Myself,THIEF_ALL)
CheckStatGT(Myself,39,TRAPS)							   // Can disarm
THEN
RESPONSE #100
 ClearActions(Myself)
 RemoveTraps("Picture 1")
 PickLock("Picture 1")
 Continue()
END

Edited by HerrSvensson

Share this post


Link to post

Locks that are not trapped are a little more difficult, but here's what you can do:

  1. Create a Lock script (bsc format) similar to the gdarts example above. Let's call it lock1.bcs
  2. Edit the area files for the area where the lock exists, for example AR0602 to unlock "Chest 6". Then start the script lock1.bcs by adding
    ActionOverride("Chest 6",ChangeAIScript("LOCK1",AREA))

    in AR0602.baf after OnCreation().

Share this post


Link to post
Guest
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  

×
×
  • Create New...