Jump to content

Is there a way to trace/log script execution? (BCS scripts)


Taylan

Recommended Posts

I'm trying to debug the issue I've described in the following post:

Since I'm still very unfamiliar with BCS files, it's difficult to figure out which of the dozens (hundreds?) of possible IF blocks might be erroneously triggering (or not triggering) to cause the observed behavior. Well, even if I was familiar with all the actions and triggers, I think it would be difficult to find out where I have to look without having some preexisting knowledge about where the actual combat logic is likely to reside.

Hence the question: is there a way in the Infinity Engine to enable some sort of debugging mode where it traces ALL script execution and writes a massive log of every single decision it takes? Of course, this would generate heaps of data, but I figure it shouldn't be too hard to search such a log for certain actions (like the Beholder's piercing melee attack maybe) to quickly find the whereabouts of the problematic decisions taken by the script.

For those familiar with Unix/Linux kind of programming, I'm talking about a trace log of the sort you would get from debugging tools like strace/ltrace/truss.

Alternatively, let me explain what I'm looking for with an example. Consider the following script snippet written in BAF:

IF
	Allegiance(Myself,NEUTRAL)
	OR(7)
		AttackedBy([GOODCUTOFF.0.0.0.0.SUMMONED],DEFAULT)
		AttackedBy([PC],DEFAULT)
		AttackedBy([FAMILIAR],DEFAULT)
		AttackedBy([ALLY],DEFAULT)
		AttackedBy([CONTROLLED],DEFAULT)
		AttackedBy([CHARMED],DEFAULT)
		SpellCastOnMe([GOODCUTOFF.0.0.0.0.SUMMONED],0)
THEN
	RESPONSE #100
		Enemy()
		Shout(89)
		Continue()
END

Now let's say that "Allegiance(Myself,NEUTRAL)" evaluates to false, therefore it skips this whole block. The trace log would then contain a snippet which somehow encodes the steps that were taken during execution. For example, using an imaginary BAF-like syntax:

BEGIN CONDITIONS
	Allegiance(Myself,NEUTRAL): FALSE
END

Or for a more complicated example, let's say that "Allegiance(Myself,NEUTRAL)" matches, and from the OR(7) the third one i.e. "AttackedBy([FAMILIAR],DEFAULT)" matches, and therefore the actions are executed. The trace log would then contain something encoding the following execution, again using our imaginary BAF-like syntax:

BEGIN CONDITIONS
	Allegiance(Myself,NEUTRAL): TRUE
	OR(7)
		AttackedBy([GOODCUTOFF.0.0.0.0.SUMMONED],DEFAULT): FALSE
		AttackedBy([PC],DEFAULT): FALSE
		AttackedBy([FAMILIAR],DEFAULT): TRUE
BEGIN RESPONSES
	HIT RESPONSE #100
		Enemy()
		Shout(89)
		Continue()
END

I know that BAF scripts are not executed directly but rather compiled to BCS, and that probably means that unless our tracing mechanism is highly sophisticated, it will NOT contain such nice snippets in a BAF-like format but rather something ugly that contains the kind of codes and references you see in raw BCS. Still, it would be an immense debugging help, and one can imagine writing a tool that parses it to turn it into a BAF-like syntax just like we can decompile BCS into BAF.

So yeah, is something like this possible? Some native debug functionality of the engine? Some DLL hack?

The next step would be to develop a whole modding IDE where you can set breakpoints in your scripts and trace the execution live while the game is running. xD

Link to comment

There are several version of stutter debugging tools out there that, while not quite what you're looking for, are in that direction.  They won't give all the information you're looking for, but will tell you which blocks are firing.  Combine that with either TobEx or the EE's CLUAConsole LogMessages() and LogSet() functions, and you can save the info to file.

Stutter related tools

How to gather clues when debugging stuttering

Edited by Sam.
Link to comment
Guest The Imp.
59 minutes ago, Sam. said:

It would seem I've gotten old.

 

Well, actually no. If you go to the last link you posted, and then the next page of that, you'll see certain Imp post a link to the BWP links and set of tools, one of which jastey requested to edit/update and that then turned to be her linked tool.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...