Please note that new user registrations disabled at this time.

Scripting - am I finding traps?

This forum is to be used for all discussions pertaining to BioWare's Baldur's Gate II: Shadows of Amn.
Post Reply
User avatar
glenfar
Posts: 261
Joined: Mon Apr 19, 2004 9:58 am
Contact:

Scripting - am I finding traps?

Post by glenfar »

I've setup a script for my thief so that if no enemies are around, he'll automatically search for traps (by calling FindTraps()).

This is working, there's just a slight nuisance though. It seems everytime I call FindTraps(), it first STOPS looking for traps, and then starts looking again. You see this come up over and over again in the message area.

Is there a trigger I can use that'll tell me if I'm already looking for traps?
User avatar
glenfar
Posts: 261
Joined: Mon Apr 19, 2004 9:58 am
Contact:

Post by glenfar »

Guess I'll answer my own question! It's not perfect, but I did manage to get something I'm happy with:

IF
See(NearestEnemyOf(Myself))
THEN
RESPONSE #100
SetGlobal("LOOKING","LOCALS",0)
Continue()
END

IF
ActionListEmpty()
!See(NearestEnemyOf(Myself))
Global("LOOKING","LOCALS",0)
THEN
RESPONSE #100
SetGlobal("LOOKING","LOCALS",1)
FindTraps()
END

IF
HotKey(F)
THEN
RESPONSE #100
SetGlobal("LOOKING","LOCALS",1)
FindTraps()
END

Basically, when I start searching for traps, I set a local flag so I know I've done it. This stops me from repeating the command over and over again ...

Then just made sure the flag is cleared when entering combat (so I'll start searching again automatically when the combat is over). Then since other actions can also stop my search, I also added a hotkey.
User avatar
Ekental
Posts: 614
Joined: Mon Nov 10, 2003 12:14 am
Location: Sigil
Contact:

Post by Ekental »

question for you glenfar... do you by any chance also do general programming... i.e. C++, java, perl? maybe COBAL?
Tact is for people not witty enough to be sarcastic
User avatar
glenfar
Posts: 261
Joined: Mon Apr 19, 2004 9:58 am
Contact:

Post by glenfar »

Originally posted by Ekental
do you by any chance also do general programming


Yes I do - primarily VB, but also C++. One of the things I enjoy about games like the BG series is seeing what I can do with the scripting.
User avatar
glenfar
Posts: 261
Joined: Mon Apr 19, 2004 9:58 am
Contact:

Post by glenfar »

Figured out how to do it properly now - this will make sure you're detecting traps whenever there's no enemies around:

IF
ActionListEmpty()
!See(NearestEnemyOf(Myself))
!ModalState(DETECTTRAPS)
THEN
RESPONSE #100
FindTraps()
END

Although I've actually paired up a Monk with my Thief now - makes a great combo. My Monk is now the one detecting traps, which leaves my thief free to hide in shadows (and therefore is ready to backstab at the start of every combat).
Post Reply