Neverwinter Nights Forum News
Posted Friday, December 12, 2003 - 23:38 CET by chevalier

Here are today's Neverwinter Nights forum highlights. Please take into account that these are only single parts of various threads and should not be taken out of context. Bear in mind also that the posts presented here are copied as-is, and that any bad spelling and grammar does not get corrected on our end.

Georg Zoeller, Designer

Missile Storm: Hey, it's not a bug. Since missile storm now correctly checks SR on the first missile, the game won't fire any subsequent missiles if the first one is resisted, as they all would be resisted.

Mark Brockington, Lead Research Scientist

DelayCommand Bug: The intended behaviour has always been to run the events that were delayed at the same time in the order that they were run.

DelayCommand(0.5f,SpeakString("1"));
DelayCommand(0.5f,SpeakString("2"));
DelayCommand(0.5f,SpeakString("3"));

should be forcing a character to say "1", "2" and "3". Why did we make the optimization? Because there are many more events in Hordes than in Shadows or the NWN Official Campaign. Handling of events came up as a major use of CPU time during profiling, and we rationalized that a lot of your modifications would probably also benefit from the speed increase of delayed events.

Imagine all of the events are stored in a ordered linked list. Now, when it comes time to enter an event, we have to scan the list from the top down until we pass all of the events with the same time (time being stored down to a millisecond as an integer, not as a floating point value). There are many events to be run immediately (such as AssignCommand()s), so these are still handled the same way. The huge delays were coming from events that were delayed by a couple of seconds. They had to hop over ALL of the events that were stored at the front of the queue every time we added them. Thousands of comparisons didn't make the CPU very happy.

So, the optimization was to reverse how we handled *delayed* events. Instead of starting at the head of the sorted list, we turned the queue around and started at the tail. But, we forgot to examine what specifically happened when events had equal time. Because we simply reversed all assumptions about ordering, our CompareWorldTimes() function went from == -1 to == 1. (Note that when times are equal, the result is 0). So, to preserve the intended ordering, the code should have been != -1.

There is a significant risk with making this fix. There is also a significant risk associated with removing the optimization. We will investigate the repercussions of restoring this to the proper ordering for a future patch. In the meantime, wrap your Delays in a function (as Georg mentioned earlier) or, if that is not an option, I would wholeheartedly recommend separating all DelayCommands by at least 2 milliseconds or 0.002f to avoid any rounding issues associated with bringing floating point numbers into the game engine. This will ensure that if we restore the proper ordering in a future patch, we won't break your scripts a second time. However, there is another point that was brought up recently about the DelayCommand(0.0f,foo()) versus foo() which runs immediately ... this is not a bug. Commands that are assigned or delayed are always run subsequent to the end of the currently running script completing successfully. This is the intended behaviour. So if I do this in code:

SpeakString("1");
DelayCommand(0.0f,SpeakString("2"));
SpeakString("3");

Your character will say: "1", "3", and "2". Similarly, if SpeakString("2") is assigned to another character, your object will say "1" and "3" before the other object says "2".


Craig Welburn, Live Team Programmer

Launching The DM Client Directly:

Yes you can do this (This is for WinXP).
- Create a normal shortcut to nwmain.exe.
- Then right click on the shortcut and select properties.
- Click on the Shortcut tab at the top.
- Under "Target" add the command line switch "-dmc" to the end.
- Apply the change.

It should now launch the game as the DM Client.


Tom Ohle, Communications Assistant

The Live Team: Rest assured that the live team is extremely busy We definitely plan on supporting the Neverwinter Nights community in 2004, though we're not quite ready to talk about any details yet. We are planning on holding a chat in the coming week or so, where that may be one of the potential topics of conversation.


Name:
E-mail:
Password (staff only):
Comment: