Mrhandy12 wrote...
...I lack deeper understanding of scipting in general. For now, Im just trying to familiarize myself with the tools and making basic things work. Im going to have a closer look at the delays too as the both of you suggested.
In order to help you understand scripting in NWN. There are a few base concepts that really need to be understood.
First is that every script is attached to an object. If the object ever gets deleted/removed/destroyed from the game, so does the script.
With that in mind when you have code like this.
DelayCommand(0.3, AssignCommand(oPC, ClearAllActions()));
It means that even if the PC left the game, What ever object this code is running on is still going to waste time trying to tell the PC to clear all his actions. Thiis would be a better way to go in many situations, If the delay was needed.
AssignCommand(oPC,DelayCommand(0.3, ClearAllActions() ));
This was the Delayed command is already running on the object that is going to use it. If something happens to the object the delayed command just gets removed along with the object. as opposed to commands running in the background for an object that is no longer there.
it also helps to understand the differance between Commands and Actions.
Both Commands and Actions are Void returning functions. The diffrance is how they are handled by the object they are ran on. Commands are executed by the Object as soon as it gets them. Actions are placed into a the Action Que for the object, in the order recived. The Action Que executes one action at a time and does not execute the next action in the Que untill the current action is finished.
the function ActionDoCommand allows you to take a function that would normally be a command and get excuted rith away and add it to the Action Que to wait its turn to execute.
with the above you can build a frame work like this:
// Assign command for the PC to clear his action que.
AssignCommand (oPC, ClearAllActions());
// AssignCommands of actions to be added into the PC's ActionQue to be done in turn in order.
AssignCommand (oPC, SomeAction);
AssignCommand (oPC, SomeAction);
...
AssignCommand (oPC, SomeAction);
// allow the PC to command himself once again after doing all the actions.
AssignCommand (oPC, ActionDoCommand(SetCommandable(TRUE)));
//Set The PC uncommandable, Locking the actionque from having anything else added to it.
SetCommandable(FALSE,oPC);
....
Modifié par Lightfoot8, 19 juin 2012 - 05:34 .