FANDOM


The AssignCommand() NWScript command causes the indicated object to execute the indicated command (or function). This execution occurs immediately after the current script finishes, but after any prior assigned commands. The most common reason for assigning a command is because some commands (notably, the "Action" commands) always affect their calling object. Assigning a command can also be useful for scripts that inflict damage, as the creator of the damaging effect is given credit for that damage (including credit for any kills resulting from that damage).

A less common reason for assigning a command is to make use of the fact that the command is delayed until the current script finishes. This can be more efficient that using DelayCommand() with a delay of 0.0, and can be useful for delaying a command until certain cleanup operations are finished — such as actually destroying objects or actually removing item properties, neither of which are done while a script executes (they are merely flagged to be done when the script finishes). This is the only circumstance in which assigning a command to OBJECT_SELF has any useful result.

DefinitionEdit

void AssignCommand (object oActionSubject, action aActionToAssign)

object oActionSubject 
The object that will execute the command.
action aActionToAssign 
The instruction that will be executed by oActionSubject. This must be a command or function that returns void.

If oActionSubject does not exist, this command has no result.

The expression passed as the second parameter will be evaluated by the object to which it is assigned, not by the object doing the assigning. Among other implications, this means that any occurrence of OBJECT_SELF will evaluate to the assigned object and any occurrence of EffectDamage() will be credited to the assigned object. In order to have such an expression refer to / be credited to the assigning object, it must be replaced by a variable set to the value of the expression. That is,

object oMe = OBJECT_SELF;
AssignCommand(oSomething, SomeFunction(oMe));

rather than

AssignCommand(oSomething, SomeFunction(OBJECT_SELF));

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.