Jump to content

GetDistance Conditions on Empty/Unfilled Optional Quest Aliases [Solution]


Sailing Rebel

Recommended Posts

Posted

I was recently struggling with a quest scene that needed to test the distance between the player and a set of optional actors and ended up testing the limits of the Creation Kit condition system. I thought I'd share the solution in the hope that it saves someone having to re-invent the wheel in future.

 

The circumstances were that I had a quest with two required aliases, the Player and one NPC, and three NPC optional aliases. A scene phase in the quest would have the NPCs follow the player and required any one of the four NPCs to be within a certain distance of the player to move to the next phase. This had me stumped for a couple of weeks because of the fact the GetDistance condition on an unfilled alias returns something less than 1.0 units. So if you test for GetDistance < 200.0 (OR) on all aliases and one is not filled then the scene immediately and incorrectly moves to the next phase disregarding distance entirely. The best I could come up with on a single set of conditions alone was to wait for the required NPC to get close but this could result in the player being surrounded by three NPCs doing nothing until the fourth shows up which is just awkward.

 

The solution was to add four phases to the scene at the point where one of them needed to be close.

 

  1. The start conditions on the first of these phases test for the presence of all three optional NPCs. In my case the NPCs were creatures so I just test GetIsCreature. Then the ending conditions for this phase can safely test GetDistance on all aliases.
  2. The start conditions on the next phase tested for the presence of the first two optional NPCs and the absence of the last. This phase could then safely test GetDistance on just those two and the required NPC.
  3. The start conditions on next tested for the presence of the first optional NPC and the absence of the second but does not need to test the third. It can then safely test the distance on just the first optional and required NPCs.
  4. The fourth phase only needs to test for the absence of the first optional NPC to start, and the GetDistance on the required NPC to end.

 

This set up is just a brute force filter in the scene for the aliases so that GetDistance is never tested on an empty alias. The caveat is that the filled optional aliases must be sequential - that is you must fill 1 & 2, or 1 & 2 & 3, but not 1 & 3. In my case I could enforce this in scripting since the aliases were being filled from there anyway. But it should be possible to set up conditions on the optional aliases so they can only be filled sequentially. Non-sequentially filled aliases is not a disaster with the above conditions as the scene can still progress but one or two of the NPCs may not have distance checks, falling back to testing only the required NPC instead. Testing all possible combinations of filled and empty aliases is not reasonable or scalable as those four phases become eight, and adding one extra optional alias will require sixteen phases! This method only requires one extra phase per optional alias.

 

This may be applicable to other conditions. Just hope it saves someone a bit of head-scratching.

 

[I'm posting this here instead of in the support thread for the mod it was used in [NSFW] so it gets some SEO.]

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...