Author Topic: How to gather clues when debugging stuttering  (Read 3665 times)

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
How to gather clues when debugging stuttering
« on: May 24, 2008, 07:56:40 AM »
The most common cause of stuttering characters (that is, characters who stop walking 'without reason') is a script block which fires multiple times and causes the character to stop his current action (Dialogue() when there's no valid entry state is a common example, but not the only one). With this short tp2 code and instruction uses, I hope to help you research with more ease which script block is actually causing the problem. It only gives you a nudge in the 'right' direction, but not the full solution (and in some cases, stuttering is caused by a conflict animation or something completely different anyway).

This tutorial assumes you know the fundamentals of modding (creating a tp2, viewing/reading game resources and variables, understanding scripts). Also, correctly running this code requires a WeiDU feature that is only available in WeiDU 207 or later. PM me if you need the beta for the purposes of this tutorial. It is possible to do a similar thing with WeiDU 206, but it will be much more cumbersome to use, since you'll get printed a random TLK string rather than the script file and block number.

Steps:
1) open your save game, view the creature file that is affected by the stutter, and write down a list of the script files it has as well as the script for the area you're in.

2) create a tp2 like the following one, edit the stuff I marked in the comments, and install it:
Code: [Select]
BACKUP ~stutter_test/backup~
AUTHOR ~blah~

BEGIN ~Test stuttering~
COPY_EXISTING ~scriptfile1.bcs~ ~override~ // be sure to change the file names to point to the relevant ones
~scriptfile2.bcs~ ~override~
~scriptfileN.bcs~ ~override~
~AreaScript.bcs~ ~override~ // ditto
~Baldur(25?).bcs~ ~override~ // use either baldur.bcs or baldur25.bcs wether you're in SoA or in ToB.
SET x = 0 - 1
DECOMPILE_BCS_TO_BAF
REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN
x += 1
END "\1
ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~))"
COMPILE_BAF_TO_BCS

3) load up your game. You'll see the dialogue window spammed with lines like:
<CHARNAME>: Running block 5 of BALDUR.BCS
<CHARNAME>: Running block 123 of DPLAYER2.BCS
etc.
These lines identify which BCS blocks are running. Wait for a bit (30 seconds are fine), and see which ones fire only once, and which ones are firing endlessly. The latter ones are more likely the cause of your stuttering issues.

4) If you don't get repeating blocks, it's time to get bored and add more scripts to the list. Try adding your party members' scripts to the list in step 3. If that doesn't work, try adding all the scripts for all creatures in the area (someday I could write code to automate this as well) - although by this point you'll get spammed by tons of unrelevant AI blocks firing off.

5) Open up those scripts in your favorite game editor (or decompile them with WeiDU and read their contents in your favorite text editors). Try to identify which of those blocks are affecting your stuttering character, and why are they causing him to stutter (is one firing a Dialogue() which doesn't display? Is he under a constant ActionOverride()? NoAction()? *CastSpell()?).

6) If step 5 didn't help identify your issues, try repeating step 4.

I hope this will be useful to some people, and all comments and criticsm (constructive or not) are very welcome. If possible, try to write your feedback in a public post rather than in a PM, so that it's accessible to more people.


This is the code that will run under WeiDU 206, probably all the way back to WeiDU 185. <CHARNAME> will fire off random item descriptions, dialogue lines, sound effects without associated printed dialog, etc. You'll need to decompile all the script files you listed (wether they fired off or not) and seek the tlk string that gets spammed in the dialogue window.
Code: [Select]
BACKUP ~stutter_test/backup~
AUTHOR ~blah~

BEGIN ~Test stuttering~
COPY_EXISTING ~sw1h01.itm~ ~override~
SET x = 0
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~scriptfile1.bcs~ ~override~ // be sure to change the file names to point to the relevant ones
~scriptfile2.bcs~ ~override~
~scriptfileN.bcs~ ~override~
~AreaScript.bcs~ ~override~ // ditto
~Baldur(25?).bcs~ ~override~ // use either baldur.bcs or baldur25.bcs wether you're in SoA or in ToB.
DECOMPILE_BCS_TO_BAF
REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN
x += 1
END "\1
ActionOverride(Player1,DisplayString(Myself,#%x%))"
COMPILE_BAF_TO_BCS

EDIT: fix suggested by Taimon in the comments at G3.
« Last Edit: May 24, 2008, 09:10:50 PM by the bigg »
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: