Jump to content

Secret door detection script help needed


ericp07

Recommended Posts

Elves are supposed to get a 1 in 6 chance to detect secret doors simply by passing near them. I'd like to write a script block to simulate this in BG2. The iesdp reveals the action DetectSecretDoor(O:Object*), which appears to be what I need to use for this, and it should be limited to a short range (let's say a range of 10). I'm at a loss as to how to specify and set the condition of mynpc being close enough to any secret door, and not sure how to represent the 1 in 6 chance, unless it's just to use RandomNum(6,1).

 

How would this be set up in a .baf (as in mynpc.baf)?

Link to comment

Interesting question. This appears possible, but I think you'd need one script block for each secret door. You might be able to put this in the door scripts so it will work for all elves.

 

To only trigger when in range, use the Range() trigger. Using RandomNum() and a variable check to prevent unlimited attempts should handle the probability aspect.

Link to comment

Hmmm, and how do I find the names of the secret doors, so I can reference them?

 

Yeah, this should be implemented for all elves (as well as the rest of the 2nd edition AD&D elf abilities that are missing from BG2). It will probably end up being part of yet another racial package, unless any of the authors of the existing racial mods would like to add my content to theirs.

Link to comment

Or you write a mod to scan them for you.

 

Pseudocode:

for each area
 loop through doors
if door is secret
  store (area name, door)
for each stored (area name, door)
 generate script block specific to door
 append script with block

 

Before doing this, I would find a single hidden door and test my script block on it to ensure it works.

Link to comment

For the door script version, you would still locate all secret doors, but then you'd copy the door script to a new file (e.g. "misdrXXX.bcs" where XXX is a number incremented by 1 for each door you find), assign the new script to the door, and add blocks to the script like:

IF
 Global("misdrXXXp1","AREANAME",0)
 InParty(Player1)
 Range(Player1, 10)
 Race(Player1, ELF)
 !StateCheck(Player1, STATE_INVALID)
 RandomNum(6,1)
THEN
 DetectSecretDoor(Myself)
 SetGlobal("misdrXXXp1","AREANAME",1)
END

IF
 Global("misdrXXXp1","AREANAME",0)
 InParty(Player1)
 Range(Player1, 10)
 Race(Player1, ELF)
 !StateCheck(Player1, STATE_INVALID)
 !RandomNum(6,1)
THEN
 SetGlobal("misdrXXXp1","AREANAME",1)
END

With similar blocks for Player2-6.

Link to comment

I'll have to go with the door script version, as I'm not at a level as a coder to go about it the way you suggested earlier, Mike (writing a mod that gathers the data and APPENDs the needed script block(s)).

 

I saw one or two appropriate doors as I was poking around the .are files in NI, so I'll get there again, and move forward. This is going to be a lot more work than I thought!

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...