Jump to content

Short-circuiting Or trigger.


tomprince

Recommended Posts

I have a question the behavor of Or(n). Do all the triggers in the Or block always get run, or does the evalution stop at the first succesful trigger. And is this behaviour the same in scripts vs. dialogues.

 

The reason I ask is becuase GemRB currently short-circuits in scripts but not in dialogues.

Link to comment

I think it depends on the engine, but I haven't thought about it in a long time.

 

I believe they are all evaluated in BG2, but in Icewind2 (and maybe HoW), Or() bails as soon as a true condition is found (evaluated top-down). The only thing that gives me pause is that maybe BG2 was also first true but evaluated bottom-up, but in lieu of writing a script to actually test, I'm reasonably sure it just checks them all (definitely, short-circuiting top-down in BG2 is just plain wrong and will break a ton of stuff).

 

I have no idea why the behavior would be different in dialogues. It wouldn't make one bit of difference either way, no?

Link to comment
I have no idea why the behavior would be different in dialogues. It wouldn't make one bit of difference either way, no?

 

I don't know. Right now, in gemrb, we have two different code paths that do different things. If the original engine compiles the actions in dialog before running them, and uses the same code path then it shouldn't make a difference. Which is what I'd like to do in GemRB.

Link to comment
I was speaking specifically of the Or() trigger.

 

I'm not sure how far the engine runs with the DLG code before dropping off to a common path.

The question is: does the engine drop out of evaluation an OR subblock in DLG in any engine version, if yes, in which?

The easiest answer is probably with IWD2, where there are triggers with side effects.

(TriggerSetGlobal)

 

Obviously it won't offer complete insight into all engine versions.

Link to comment

Yeah, but those are things you'd never actually do in a dialogue, so just making it work the same as script eval seems the best choice (but like I wrote, I can't think of a single case where it would even matter).

Link to comment

Hey, I actually understand what devSin is saying! What are the odds of that?

 

Ultimately, how much does it matter whether OR() blocks ar evaluated top-to-bottom or bottom-to-top? In dialigue files, the generic "pause dialogue" flags prevent this from being an issue and in script, unless you're heavily into AI BS scripts, as opposed to other BCS scripts, it doesn't matter much. OR(99) blocks take miliseconds to evaluate, so it doesn't matter much.

 

What does a millisecond mean? That's really the question.

Link to comment

That's a definitive answer, thanks Bigg :suspect:

Even though i expected the opposite (short-circuit).

 

Now we just have to find out, if ALL engines work the same way or no.

But, i think the BEST way would be to add a config option.

 

 

I vaguely remember reading that the IWD2 developers (one of them) didn't even understand why modders would want to use this priority targetting thing, and that it is different in IWD2.

 

Another useful bit Sim's guide reminded me: bg1/pst has no Or blocks (so those engines we don't have to be afraid of).

Link to comment

If you want a good testing module for BG "simulated OR()" vs BG2 "OR()" to check in-game, Jastey's BG Ajantis has the most comprehensive implementation. Might be a good place to crib things that are supposed to work similarly on both games.

Link to comment
I vaguely remember reading that the IWD2 developers (one of them) didn't even understand why modders would want to use this priority targetting thing, and that it is different in IWD2.
Uh, I already said that IWD2 breaks after the first true condition (and that BG2 didn't). Pay attention!
Link to comment
I vaguely remember reading that the IWD2 developers (one of them) didn't even understand why modders would want to use this priority targetting thing, and that it is different in IWD2.
Uh, I already said that IWD2 breaks after the first true condition (and that BG2 didn't). Pay attention!

You confuse me greatly.

Link to comment

How so?

 

The OP question: "Do all the triggers in the Or block always get run, or does the evalution stop at the first succesful trigger."

 

The first reply in the thread: "I believe they are all evaluated in BG2" = all triggers are checked; "in Icewind2, Or() bails as soon as a true condition is found (evaluated top-down)" = triggers are checked only up to the first true trigger.

 

I want to say that HoW works like BG2 (the scripts would seem to imply this), but I just don't know, and like you stated, it doesn't matter for BG and PST.

Link to comment
I want to say that HoW works like BG2 (the scripts would seem to imply this), but I just don't know

 

why not just check the code in assembly and put this matter to rest? :suspect: don't you have one of those ultra-cool disassemblers like Taimon?

Link to comment

Archived

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

×
×
  • Create New...