Datus and I were discussing the worker.src speech problem tonight on the phone. This has bothered me ever since he emailed me about it. For the benefit of those who may not have been privy to his emial (which I hope are all of you *grins*) I am posting the bug and the fix here.
The bug:
In the POL 0.95 Distro there's an AI script named worker.src. This script is supposed to respond to various speech events such as [NPCName} + "train" or "hire" and so on. The problem is that it doesn't. I have looked at this before but was unable to determine the problem. Well, as I said I was discussing this with Datus and decided to look again.
I admit I was on a mission with this one. After fixing the pack animal problem this one was sticking in my crop and I just had to get it working.
*smiles wryly*
Yeah it was a matter of pride I guess.
The bug originates in the very beginning of the script. It's in the EnableEvents function call. Here is the code that is in error:
Code: Select all
program CastleGuard()
run_script_to_completion("NPCKeeper", me);
drop_anchor();
EnableEvents(SYSEVENT_SPEECH + SYSEVENT_ENGAGED + SYSEVENT_DISENGAGED + SYSEVENT_DAMAGED);
So I asked myself "What AI script do I know of that handles speech properly?" The answer was tamed.src.
Upon opening tamed.src I first looked at the case statement that parses the speech and found nothing unusual there. So I then looked at the function EnableMainEvents and found this curious item, there is an additional parameter passed along with the EnableEvent function call when enabling speech. There's an integer that's passed along. That integer is the listening range. You will note in the above code snippet from worker.src there is no such parameter passed.
The fix for this is by far easier than that for the pack animal one. Simply change the above code to this:
Code: Select all
program Worker()
run_script_to_completion("NPCKeeper", me);
drop_anchor();
EnableEvents(SYSEVENT_SPEECH, 3);
EnableEvents(SYSEVENT_ENGAGED + SYSEVENT_DISENGAGED + SYSEVENT_DAMAGED);
Note also the change to the name from CastleGuard to Worker. This has no effect on functionality. It's just good programming practice to not be lazy when borrowing script templates for use in other scripts.
I have not taken the time to research the other EnableEvents function calls to see if they are properly formatted. If anyone sees a problem with the other ones please post the fix here.
Once again anyone running POL 0.95 Distro converted to POL 0.97 should take note of this bug.