Foina Posted March 28, 2013 Share Posted March 28, 2013 (edited) Hello. As the title says, how do I have my script detect the presence of a *working* Oblivion Gate within a certain distance of the player? The script must ignore those gates that have been shut off already. Loosely browsing the list of functions I've found these (I use OBSE v0020):- GetFirstRef- GetNextRef- IsOblivionGate- GetDistance With them, a construct of this type should do what I need (I think): ref pDoorset pDoor to GetFirstRef 24 1while (pDoor) if (pDoor.IsOblivionGate) && (pDoor.GetDistance Player < 5000) ; Found a working Oblivion Gate ; within 5K units of the player ; (do stuff) ; . ; . ; . break endif set pDoor to GetNextRefloop I'm just new to scripting for Oblivion. Maybe there's a more efficient way?Also, notice the 1 in the call to GetFirstRef. I intend to scan the cell the Player is in, plus the ring of 8 cells surrounding it. Will that be enough to catch any Oblivion Gate within 5000 units? (how big is a cell, btw?) Thanks in advance. Edited March 28, 2013 by Foina Link to comment Share on other sites More sharing options...
QQuix Posted March 28, 2013 Share Posted March 28, 2013 That is pretty much it, but you may need to check other attributes (like enabled/disabled/destroyed) in order to get just the active ones (I am not familiar with the working of Oblivion Gates, so I cant tell what differentiates an active from a hidden one). An exterior cell measures 4096x4096 game units, so the "1" will do. Check Oblivion Units for details. Link to comment Share on other sites More sharing options...
Foina Posted March 29, 2013 Author Share Posted March 29, 2013 (edited) Thanks for the input. Good thing you mentioned those flags. I just finished making tests:A working Oblivion Gate, such as the one appearing in Kvatch is:- Enabled && not-Destroyed After closing said portal, the very same gate appears to be:- Enabled && Destroyed Other gates (still functioning) elsewhere on the map appear to be:- Enabled && not-Destroyed I take it that the discriminant I should care about is the Destroyed flag.I don't suppose I can find a Disabled (that is: not-Enabled) Oblivion Gate -- can I? On second thought, reading about the Enable and Disable functions I gather that a not-Enabled object is present in the world and can be worked with -- it just is not rendered on screen. Does it apply to *any* object? So... it's technically posssible to run into a hidden Oblivion Gate? Anybody can confirm or deny, please? I don't have a savegame from before closing the Kvatch gate anymore. Edited March 29, 2013 by Foina Link to comment Share on other sites More sharing options...
QQuix Posted March 29, 2013 Share Posted March 29, 2013 Disabled references are not rendered and cannot be interacted with in game. It is as if they don't exist at all. Only scripts can deal with them (usually to enable and disable them). From what I could get from the Gate script (OblivionGateRandomScript), an oblivion gate is initially disabled, has a percent chance of being enabled when the player gets near them and is destroyed when the player closes it or when the main quest is finished. Link to comment Share on other sites More sharing options...
KenJackson Posted March 29, 2013 Share Posted March 29, 2013 Thanks for the input. Good thing you mentioned those flags. I take it that the discriminant I should care about is the Destroyed flag.I don't suppose I can find a Disabled (that is: not-Enabled) Oblivion Gate -- can I? You would need to run the GetDisabled check as well, but not on the gate itself. The "random" Oblivion Gates aren't really random. The only "random" part about them is whether or not they're open. They're all already in position. They're just disabled, but not directly. It's done by proxy. Each one has an associated xMarker, which is a static, as an "Enable Parent", These xMarkers are initially disabled. This means that while the gate's Disable flag isn't set, the gate behaves as if it were. When they're first opened, what the gate's scripts actually do is enable the XMarker, This causes all the objects that use it as an "Enable Parent" will either enable or disable if the "Set Enable State to Opposite of Parent" flag is checked. The reason you need to run a GetDisabled check on the xMarker is because, until the xMarker gets enabled, the gate won't be active. Link to comment Share on other sites More sharing options...
Foina Posted March 29, 2013 Author Share Posted March 29, 2013 (edited) Let's see if I understand what you say...Every Oblivion Gate is child to an xMarker entity (some abstract -dummy- object the Player can't interact with, but it's there nonetheless).As far as the Enabled flag goes, a Disabled Parent automatically disables all its Childs (regardless of the Childs' flag). If the parent is Enabled, then each Child's Enabled state will match that of its very own Enabled flag. So... when checking for the Enabled flag I should first get a ref to the Oblivion Gate, then climb up to its parent ref (with GetParentRef, I suppose), which is the Marker, and check its (the Marker's) Enabled flag.Am I correct? Sorry, my questions must be terribly boring to you guys. Have patience, I'm learning the ropes. I'll strangle myself with 'em soon enough :P Edited March 29, 2013 by Foina Link to comment Share on other sites More sharing options...
QQuix Posted March 29, 2013 Share Posted March 29, 2013 Let's see if I understand what you say... Every Oblivion Gate is child to an xMarker entity (some abstract -dummy- object the Player can't interact with, but it's there nonetheless). Yes. The XMarker happens to be also the teleport marker of the Gate, meaning it sets the position and angle the player will be when exiting the Oblivion world. As far as the Enabled flag goes, a Disabled Parent automatically disables all its Childs (regardless of the Childs' flag). If the parent is Enabled, then each Child's Enabled state will match that of its very own Enabled flag.Not quite.It is pretty much straightforward: the child reference will assume the same state as the parent.When a parent reference is enabled, all its children are automatically enabled (in the next frame).When a parent reference is disabled, all its children are automatically disabled. (in the next frame). Unless, of course, the child box “Set Enable State to Opposite of Parent” is checked, which is self-explanatory. So... when checking for the Enabled flag I should first get a ref to the Oblivion Gate, then climb up to its parent ref (with GetParentRef, I suppose), which is the Marker, and check its (the Marker's) Enabled flag.Usually, that is not necessary, GetDisabled will return the correct state of the child.(the exception is that when the parent state changes, the children states will not change until the next frame, which is not a concern of yours, since you are not checking the state until later after the gate changes state) Link to comment Share on other sites More sharing options...
Recommended Posts