D'jinni Wiki

Queue in Scripting

1,297pages on
this wiki
Add New Page
Talk0 Share

General purposeEdit

The notion of queue while scripting for The Witcher is close to be the same as the one used in NeverWinter Nights. The queue works like a First In First Out (FIFO) stack, all actions queued are executed in the order they are queued).


Let's consider this short script :

// Geralt
object SDPLAYER = GetFirstPC();
// Displays 'Hello World' above Geralt's head
AssignCommand(SDPLAYER,SpeakString("Hello World"));
// Make Geralt drink a beer
// Displays 'Cheers !!!' above Geralt's head
AssignCommand(SDPLAYER,SpeakString("Cheers !!!"));

Here the queue will contain the following three actions and the order they will be fired :

1. "Hello World"
2. Drink
3. "Cheers !!!"

This way Geralt will drink before saying "Cheers !!!" which is really a bad idea ^^ thus

object SDPLAYER = GetFirstPC();
AssignCommand(SDPLAYER,SpeakString("Hello World"));
AssignCommand(SDPLAYER,SpeakString("Cheers !!!"));

is better !!

Queuing FunctionsEdit

  • All the functions that starts with Action* are subject to queuing their actions into the queue and see them executed at their turn.
  • Most of the queuing functions have also a non queuing version that immediately executes the action whatever the elements in the queue and discards them.

Example :

  • Most of the function are working this way except some special one.

Example of Classical Queuing functionsEdit

  • ActionPlayAnimation
  • ActionSpeakString
  • ActionCastSpellAtObject
  • Etc.

Special queuing functionsEdit

This set of function will be filled with time.

  • ActionJumpToLocation
// The subject will jump to lLocation instantly (even between areas).
// If lLocation is invalid, nothing will happen.
void ActionJumpToLocation(location lLocation);

This action will be queued as first element on the stack to be fired ! All other actions still exists but will be fired after.

  • ClearAllActions
// Clear all the actions of the caller.
// * No return value, but if an error occurs, the log file will contain
// "ClearAllActions failed.".
// - nClearCombatState: if true, this will immediately clear the combat state
// on a creature, which will stop the combat music and allow them to rest,
// engage in dialog, or other actions that they would normally have to wait for.
void ClearAllActions(int nClearCombatState=FALSE, object oSubject=OBJECT_INVALID);

Clears the queue of a given character. Useful function to clear the queue and force the execution of a given action.

  • It is to be noted that moving Geralt while doing an animation break the current animation, and for the move in most cases, discarding all elements from the queue.

Action assigningEdit

Last but not least, action must be assigned to PC or NPCs to be correctly queued. Function AssignCommand do that job :

// Assign aActionToAssign to oActionSubject.
// * No return value, but if an error occurs, the log file will contain
// "AssignCommand failed."
// (If the object doesn't exist, nothing happens.)
void AssignCommand(object oActionSubject,action aActionToAssign);

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.